gogojudo

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

GogoJudo

Golang library for Judopay

Required env vars

Var Default Description
JUDOPAY_URL https://gw1.judopay-sandbox.com/transactions The Judopay endpoint url
JUDOPAY_ID Your JudoPay ID, found on your pplications setting page
JUDOPAY_TOKEN Your application token (Avilable from your app page)
JUDOPAY_SECRET Your application secret (Available from yout app page)
JUDOPAY_API_VERSION 5.6 The API version to use

Documentation

Overview

Package gogojudo is a Go library for interacting with Judopay

By Peter Holt

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeAscending  = "time-ascending"
	TimeDescending = "time-descending"
)

When listing transactions, here are the sort orders

View Source
var CardIDs = map[int]string{
	0:  "Unknown",
	1:  "Visa",
	2:  "Mastercard",
	3:  "Visa Electron",
	4:  "Switch",
	5:  "Solo",
	6:  "Laser",
	7:  "China Union Pay",
	8:  "Amex",
	9:  "JCB",
	10: "Maestro",
	11: "Visa Debit",
	12: "Mastercard Debit",
	13: "Visa Purchasing",
	14: "Discover",
	15: "Carnet",
	16: "Carte Bancaire",
	17: "Diners Club",
	18: "ELO",
	19: "Farmers cards",
	20: "Soriana",
	21: "Private Label Card",
	22: "Q Card",
	23: "Style",
	24: "True Rewards",
	25: "UATP",
	26: "Bankard",
	27: "Banamex costco",
}

Card ID's

View Source
var ErrorMap = map[int]error{}/* 112 elements not displayed */

Functions

This section is empty.

Types

type CardAddress

type CardAddress struct {
}

type CardPaymentModel

type CardPaymentModel struct {
	// Required card details
	CV2         string `json:"cv2,omitempty"`
	CardNumber  string `json:"cardNumber,omitempty"`
	CardToken   string `json:"cardToken,omitempty"`
	OneUseToken string `json:"oneUseToken,omitempty"`
	ExpiryDate  string `json:"expiryDate,omitempty"`
	StartDate   string `json:"startDate,omitempty"`

	// Reference numbers
	ConsumerReference    string `json:"yourConsumerReference,omitempty"`
	YourPaymentReference string `json:"yourPaymentReference,omitempty"`
	PaymentMetaData      []byte `json:"yourPaymentMetaData,omitempty"`

	// Payment details
	Amount                  float64 `json:"amount,omitempty"`
	Currency                string  `json:"currency,omitempty"`
	InitialRecurringPayment bool    `json:"initialRecurringPayment,omitempty"`
	RecurringPayment        bool    `json:"recurringPayment,omitempty"`
	RecurringPaymentType    string  `json:"recurringPaymentType,omitempty"`

	// Other reference information
	IssueNumber         int    `json:"issueNumber,omitempty"`
	WebPaymentReference string `json:"webPaymentReference.omitempty"`

	// Cardholder information
	CardAddress      string                 `json:"card_address,omitempty"`
	MobileNumber     string                 `json:"mobileNumber,omitempty"`
	EmailAddress     string                 `json:"emailAddress,omitempty"`
	ConsumerLocation map[string]interface{} `json:"consumerLocation,omitempty"`

	// Misc. information
	UserAgent      string                 `json:"userAgent,omitempty"`
	DeviceCategory string                 `json:"deviceCategory,omitempty"`
	AcceptHeaders  string                 `json:"acceptHeaders,omitempty"`
	ClientDetails  map[string]interface{} `json:"clientDetails,omitempty"`

	// Merchant JudoID
	JudoID string `json:"judoId,omitempty"`
}

CardPaymentModel is a base structure that provides everything needed to submit a payment request

type CheckCardResponse

type CheckCardResponse struct{}

type JudoError

type JudoError struct {
	Message  string `json:"message"`
	Code     int    `json:"code"`
	Category int    `json:"category"`

	Details []struct {
		Code      int    `json:"code"`
		FieldName string `json:"fieldName"`
		Message   string `json:"message"`
	} `json:"details"`
}

func (*JudoError) GetError

func (je *JudoError) GetError() error

type JudoPay

type JudoPay struct {
	HttpClient    *http.Client
	APIUrl        *url.URL
	Authorization string
	JudopayID     string
}

func New

func New() *JudoPay

funcction New returns an instacce of the Judopay struct

func (*JudoPay) CheckCard

func (jp *JudoPay) CheckCard(rcp RegisterCardModel) (ret CheckCardResponse, err error)

func (*JudoPay) ListTransactions

func (jp *JudoPay) ListTransactions(pageSize int, offset int, sortOrder string) (ret ListTransactions, err error)

func (*JudoPay) Payments

func (jp *JudoPay) Payments(rcp CardPaymentModel) (ret PaymentReceiptModel, err error)

func (*JudoPay) Refund

func (jp *JudoPay) Refund(rcp RefundModel) (ret PaymentReceiptModel, err error)

func (*JudoPay) RegisterCard

func (jp *JudoPay) RegisterCard(rcp RegisterCardModel) (ret RegisterCardResponse, err error)

func (*JudoPay) SetHeaders

func (jp *JudoPay) SetHeaders(req *http.Request) error

func (*JudoPay) Transaction

func (jp *JudoPay) Transaction(receiptID string) (ret PaymentReceiptModel, err error)

type ListTransactions

type ListTransactions struct {
	ResultCount int               `json:"resultCount"`
	PageSize    int               `json:"pageSize"`
	Offset      int               `json:"offset"`
	Results     []TransactionItem `json:"results"`
	Sort        string            `json:"sort"`
}

type PaymentReceiptModel

type PaymentReceiptModel struct {
	ReceiptID            string    `json:"receiptId"`
	YourPaymentReference string    `json:"yourPaymentReference"`
	Type                 string    `json:"type"`
	CreatedAt            time.Time `json:"createdAt"`
	Result               string    `json:"result"`
	Message              string    `json:"message"`
	JudoID               int       `json:"judoId"`
	MerchantName         string    `json:"merchantName"`
	AppearsOnStatementAs string    `json:"appearsOnStatementAs"`
	OriginalAmount       string    `json:"originalAmount"`
	NetAmount            string    `json:"netAmount"`
	Amount               string    `json:"amount"`
	Currency             string    `json:"currency"`
	CardDetails          struct {
		CardLastfour  string `json:"cardLastfour"`
		EndDate       string `json:"endDate"`
		CardToken     string `json:"cardToken"`
		CardType      int    `json:"cardType"`
		CardScheme    string `json:"cardScheme"`
		CardFunding   string `json:"cardFunding"`
		CardCategory  string `json:"cardCategory"`
		CardQualifier int    `json:"cardQualifier"`
		CardCountry   string `json:"cardCountry"`
		Bank          string `json:"bank"`
	} `json:"cardDetails"`
	Consumer struct {
		ConsumerToken         string `json:"consumerToken"`
		YourConsumerReference string `json:"yourConsumerReference"`
	} `json:"consumer"`
	RiskScore int `json:"riskScore"`
	Risks     struct {
		PostCodeCheck      string `json:"postCodeCheck"`
		MerchantSuggestion string `json:"merchantSuggestion"`
		MerchantStatistics struct {
		} `json:"merchantStatistics"`
	} `json:"risks"`
	AcsURL  string `json:"acsUrl,omitempty"`
	MD      string `json:"md,omitempty"`
	PaReq   string `json:"paReq,omitempty"`
	TermURL string `json:"termUrl,omitempty"`
	// 3D Secure
	PaymentRequires3DSecure struct {
		Result  string `json:"result,omitempty"`
		Message string `json:"message,omitempty"`
		AcsURL  string `json:"acsUrl,omitempty"`
		MD      string `json:"md,omitempty"`
		PaReq   string `json:"paReq,omitempty"`
		TermURL string `json:"termUrl,omitempty"`
	} `json:"paymentRequires3DSecure"`
}

type RefundModel

type RefundModel struct {
	// Payment identification
	ReceiptID            string `json:"receiptId"`
	YourPaymentReference string `json:"yourPaymentReference"`

	// Information relating to the transaction
	PaymentMetaData string                 `json:"yourPaymentMetaData"`
	ClientDetails   map[string]interface{} `json:"clientDetails"`

	// Finantial information
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`

	// Since it needs to be included
	JudoID string `json:"judoId"`
}

type RegisterCardModel

type RegisterCardModel struct {

	// Required Fields
	CV2               string `json:"cv2"`        // CV2 from the credit card, also known as the card verification value (CVV) or security code. The 3 or 4 digit number on the back of a card
	CardNumber        string `json:"cardNumber"` // The unique number printed on a credit card, should be submitted without any whitespace or non-numeric characters
	ConsumerReference string `json:"yourConsumerReference,omitempty"`
	PaymentReference  string `json:"yourPaymentReference,omitempty"`

	// Dates
	ExpiryDate string `json:"expiryDate,omitempty"`
	StartDate  string `json:"startDate,omitempty"`

	IssueNumber int `json:"issue_number,omitempty"`

	// Address
	CardAddress string `json:"card_address,omitempty"`

	// Other Details
	ClientDetails map[string]interface{} `json:"client_details,omitempty"`
	JudoID        string                 `json:"judo_id,omitempty"`
	Currency      string                 `json:"currency,omitempty"`
}

type RegisterCardResponse

type RegisterCardResponse struct {
}

type TransactionItem

type TransactionItem struct {
	ReceiptID            string    `json:"receiptId"`
	OriginalReceiptID    string    `json:"originalReceiptId,omitempty"`
	YourPaymentReference string    `json:"yourPaymentReference"`
	Type                 string    `json:"type"`
	CreatedAt            time.Time `json:"createdAt"`
	Result               string    `json:"result"`
	Message              string    `json:"message"`
	JudoID               int       `json:"judoId"`
	MerchantName         string    `json:"merchantName"`
	AppearsOnStatementAs string    `json:"appearsOnStatementAs"`
	OriginalAmount       string    `json:"originalAmount,omitempty"`
	NetAmount            string    `json:"netAmount"`
	Amount               string    `json:"amount"`
	Currency             string    `json:"currency"`
	CardDetails          struct {
		CardLastfour  string `json:"cardLastfour"`
		EndDate       string `json:"endDate"`
		CardType      int    `json:"cardType"`
		CardQualifier int    `json:"cardQualifier"`
	} `json:"cardDetails"`
	Consumer struct {
		ConsumerToken         string `json:"consumerToken"`
		YourConsumerReference string `json:"yourConsumerReference"`
	} `json:"consumer"`
	YourPaymentMetaData struct {
	} `json:"yourPaymentMetaData"`
	PostCodeCheckResult string `json:"postCodeCheckResult"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL