gopay

package module
v0.0.0-...-411c7b1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 6 Imported by: 0

README

GoPay's Go SDK for Payments REST API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalParam

type AdditionalParam struct {
	//Parameter name
	//Example: invoicenumber
	Name string `json:"name"`

	//Value of optional parameter
	//Example: 2015001003
	Value string `json:"value"`
}

type BankAccount

type BankAccount struct {
	//International bank account number
	IBAN string `json:"iban,omitempty"`

	//Business identification code (SWIFT)
	BIC string `json:"bic,omitempty"`

	//Bank account prefix
	Prefix string `json:"prefix,omitempty"`

	//Bank account number
	AccountNumber string `json:"account_number,omitempty"`

	//Bank account code
	BankCode string `json:"bank_code,omitempty"`

	//Bank account holder name
	AccountName string `json:"account_name,omitempty"`

	//Account token of a saved account for PSD2 payments
	AccountToken string `json:"account_token,omitempty"`
}

type Callback

type Callback struct {
	//URL address for return to e-shop (with protocol)
	//Max length: 512
	ReturnURL string `json:"return_url"`

	//URL address for sending asynchronous notification in the case of changes in the payment status (with protocol)
	//Max length: 512
	NotificationURL string `json:"notification_url,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Login

func Login(clientID, clientSecret string) (*Client, error)

func (*Client) CreatePayment

func (c *Client) CreatePayment(p *Payment) (*PaymentResp, error)

func (*Client) PaymentStatus

func (c *Client) PaymentStatus(id int) (*PaymentStatus, error)

type Contact

type Contact struct {
	//First name
	//Max length: 256
	FirstName string `json:"first_name,omitempty"`

	//Last name
	//Max length: 256
	LastName string `json:"last_name,omitempty"`

	//Valid e-mail
	//Max length: 128
	Email string `json:"email,omitempty"`

	//Phone number with country code
	//Max length: 128
	PhoneNumber string `json:"phone_number,omitempty"`

	//City
	//Max length: 128
	City string `json:"city,omitempty"`

	//Street
	//Max length: 128
	Street string `json:"street,omitempty"`

	//Postal code
	//Max length: 16
	PostalCode string `json:"postal_code,omitempty"`

	//Country code ISO 3166-1 alpha-3
	CountryCode string `json:"country_code,omitempty"`
}

type Currency

type Currency string
const (
	CurrencyCZK Currency = "CZK" //Czech koruna
	CurrencyEUR Currency = "EUR" //Euro
	CurrencyPLN Currency = "PLN" //Polish złoty
	CurrencyUSD Currency = "USD" //United States dollar
	CurrencyGBP Currency = "GBP" //Pound sterling
	CurrencyHUF Currency = "HUF" //Hungarian forint
	CurrencyRON Currency = "RON" //Romanian lei
	CurrencyBGN Currency = "BGN" //Bulgarian lev
	CurrencyHRK Currency = "HRK" //Croatian kuna
)

type Error

type Error struct {
	Scope       ErrorScope //Error range
	Field       string     //Which parameter is affected by the error, unless it is a global error
	Message     string     //Localized message. Localization based on Accept-Language in the header. It is set to en-US by default.
	Description string     //Technical description of the error
	ErrorCode   ErrorCode  //Numeric designation of the error type
	ErrorName   string     //Code designation of the error type
}

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode int
const (
	ErrorCode100 ErrorCode = 100 //System Error
	ErrorCode110 ErrorCode = 110 //Compulsory
	ErrorCode111 ErrorCode = 111 //Wrong format
	ErrorCode112 ErrorCode = 112 //Already exists
	ErrorCode113 ErrorCode = 113 //Cannot be changed
	ErrorCode114 ErrorCode = 114 //Cannot delete
	ErrorCode115 ErrorCode = 115 //Ambiguous
	ErrorCode116 ErrorCode = 116 //Invalid request
	ErrorCode200 ErrorCode = 200 //Unauthorized access
	ErrorCode201 ErrorCode = 201 //The method of assigning rights is not supported
	ErrorCode202 ErrorCode = 202 //Wrong access data
	ErrorCode203 ErrorCode = 203 //PIN access has been disabled
	ErrorCode301 ErrorCode = 301 //Unable to create payment
	ErrorCode302 ErrorCode = 302 //Payment cannot be made
	ErrorCode303 ErrorCode = 303 //Payment in wrong condition
	ErrorCode304 ErrorCode = 304 //Payment not found
	ErrorCode305 ErrorCode = 305 //E-shop has been deactivated
	ErrorCode321 ErrorCode = 321 //The payee cannot accept the payment
	ErrorCode330 ErrorCode = 330 //Payment cannot be refunded
	ErrorCode331 ErrorCode = 331 //Payment cannot be refunded
	ErrorCode332 ErrorCode = 332 //Wrong amount
	ErrorCode333 ErrorCode = 333 //Lack of money in the account
	ErrorCode340 ErrorCode = 340 //Recurring payment failed
	ErrorCode341 ErrorCode = 341 //Recurring payment is not supported
	ErrorCode342 ErrorCode = 342 //Payment recurrence stopped
	ErrorCode343 ErrorCode = 343 //Time limit for recurring payments exceeded
	ErrorCode350 ErrorCode = 350 //Payment hold failed
	ErrorCode351 ErrorCode = 351 //Payment has already been canceled
	ErrorCode352 ErrorCode = 352 //Revocation revocation failed
	ErrorCode353 ErrorCode = 353 //Pre-authorization canceled
	ErrorCode360 ErrorCode = 360 //The sum of the amounts of the order items does not match the payment amount
	ErrorCode394 ErrorCode = 394 //Account not found
)

func (ErrorCode) String

func (e ErrorCode) String() string

type ErrorResp

type ErrorResp struct {
	DateIssued time.Time
	Errors     []Error
}

func (ErrorResp) Error

func (er ErrorResp) Error() string

type ErrorScope

type ErrorScope string
const (
	ErrorScopeF ErrorScope = "F" //The error concerns a specific parameter
	ErrorScopeG ErrorScope = "G" //Global error
)

type Item

type Item struct {
	//Type of row, for registration of sales
	Type Type `json:"type,omitempty"`

	//Product name
	//Max length: 256
	Name string `json:"name,omitempty"`

	//Total price of items in cents
	Amount int `json:"amount,omitempty"`

	//Number of items
	//Min: 1
	Count int `json:"count,omitempty"`

	//VAT rate
	//Min: 0
	//Max: 100
	VatRate int `json:"vat_rate,omitempty"`

	//EAN code of the product
	Ean int `json:"ean,omitempty"`

	//URL address of the product
	//Max length: 512
	ProductURL string `json:"product_url,omitempty"`
}

type Lang

type Lang string
const (
	LangCS Lang = "CS" //Czech
	LangSK Lang = "SK" //Slovak
	LangEN Lang = "EN" //English
	LangDE Lang = "DE" //German
	LangRU Lang = "RU" //Russian
	LangPL Lang = "PL" //Polish
	LangHU Lang = "HU" //Hungarian
	LangRO Lang = "RO" //Romanian
	LangBG Lang = "BG" //Bulgarian
	LangHR Lang = "HR" //Croatian
	LangIT Lang = "IT" //Italian
	LangFR Lang = "FR" //French
	LangES Lang = "ES" //Spanish
)

type Payer

type Payer struct {
	//Array of allowed payment methods
	AllowedPaymentInstruments []PaymentInstrument `json:"allowed_payment_instruments,omitempty"`

	//Preferred payment method
	DefaultPaymentInstrument PaymentInstrument `json:"default_payment_instrument,omitempty"`

	//Array of allowed bank codes
	AllowedSwifts []Swift `json:"allowed_swifts,omitempty"`

	//Preferred bank if default_payment_instrument is set to BANK_ACCOUNT, set by SWIFT code
	DefaultSwift Swift `json:"default_swift,omitempty"`

	//Customer´s data
	Contact Contact `json:"contact,omitempty"`

	//Bank account´s information
	BankAccount BankAccount `json:"bank_account,omitempty"`

	//Payment card´s information
	PaymentCard PaymentCard `json:"payment_card,omitempty"`

	//PIN for identification payment purposes
	VerifyPin string `json:"verify_pin,omitempty"`

	//Token for identification payment purposes
	AllowedCardRoken string `json:"allowed_card_token,omitempty"`

	//Email of used GoPay wallet (only for GOPAY payment method)
	Email string `json:"email,omitempty"`
}

type Payment

type Payment struct {
	//Payment method settings and payer information
	Payer Payer `json:"payer,omitempty"`

	//Payee information
	Target Target `json:"target,omitempty"`

	//Details of the payment items
	Items []Item `json:"items,omitempty"`

	//Payment amount in cents
	Amount int `json:"amount,omitempty"`

	//Payment currency
	Currency Currency `json:"currency,omitempty"`

	//Merchant’s order id, alphanumeric
	OrderNumber string `json:"order_number,omitempty"`

	//Order description, alphanumeric
	OrderDescription string `json:"order_description,omitempty"`

	//Payment gateway language
	Lang Lang `json:"lang,omitempty"`

	//Callback URL for processing of the payment result / Notification URL for processing of change of payment status
	Callback Callback `json:"callback,omitempty"`

	//Additional payment parameters
	//Max items: 4
	AdditionalParams []AdditionalParam `json:"additional_params,omitempty"`

	//true if the payment should be preauthorized
	Preauthorization bool `json:"preauthorization,omitempty"`

	//Contains object describing recurrence, if the payment should be recurrent
	Recurrence *Recurrence `json:"recurrence,omitempty"`
}

type PaymentCard

type PaymentCard struct {
	//Masked payment card´s number
	CardNumber string `json:"card_number,omitempty"`

	//Expiration date
	CardExpiration string `json:"card_expiration,omitempty"`

	//Payment card´s type
	CardBrand string `json:"card_brand,omitempty"`

	//Country code of issuing bank
	CardIssuerCountry string `json:"card_issuer_country,omitempty"`

	//Issuing bank
	CardIssuerBank string `json:"card_issuer_bank,omitempty"`

	//Token for identification payment purposes
	//Example: 6RuTM69kX6UUGZ6p9hyMPrTUVXmMDdkC4BNnQvQcb
	CardToken string `json:"card_token,omitempty"`

	//3D Secure authorization’s result for identification payment purposes
	Result3DS string `json:"3ds_result,omitempty"`
}

type PaymentInstrument

type PaymentInstrument string
const (
	PaymentInstrumentPaymentCard PaymentInstrument = "PAYMENT_CARD" //Payment card
	PaymentInstrumentBankAccount PaymentInstrument = "BANK_ACCOUNT" //Bank account
	PaymentInstrumentGPAY        PaymentInstrument = "GPAY"         //Google Pay
	PaymentInstrumentApplePay    PaymentInstrument = "APPLE_PAY"    //Apple Pay
	PaymentInstrumentGoPay       PaymentInstrument = "GOPAY"        //GoPay wallet
	PaymentInstrumentPayPal      PaymentInstrument = "PAYPAL"       //PayPal wallet
	PaymentInstrumentMPayment    PaymentInstrument = "MPAYMENT"     //mPlatba (mobile payment)
	PaymentInstrumentPRSMS       PaymentInstrument = "PRSMS"        //Premium SMS
	PaymentInstrumentPaySafeCard PaymentInstrument = "PAYSAFECARD"  //PaySafeCard coupon
	PaymentInstrumentBitcoin     PaymentInstrument = "BITCOIN"      //Bitcoin wallet
	PaymentInstrumentClickToPay  PaymentInstrument = "CLICK_TO_PAY" //Click to Pay
)

type PaymentResp

type PaymentResp struct {
	//Payment ID
	ID int `json:"id,omitempty"`

	//Order ID
	OrderNumber string `json:"order_number,omitempty"`

	//Payment status
	State State `json:"state,omitempty"`

	//Amount in cents
	Amount int `json:"amount,omitempty"`

	//Payment currency
	Currency Currency `json:"currency,omitempty"`

	//Information about the payer and payment methods
	Payer Payer `json:"payer,omitempty"`

	//Payee information
	Target Target `json:"target,omitempty"`

	//Additional parameters
	AdditionalParams []AdditionalParam `json:"additional_params,omitempty"`

	//Payment gateway language
	Lang Lang `json:"lang,omitempty"`

	//Descibes recurrence if the payment is recurrent
	Recurrence Recurrence `json:"recurrence,omitempty"`

	//Describes preauthorization if the payment is preauthorized
	Preauthorization Preauthorization `json:"preauthorization,omitempty"`

	//URL for initiation of the payment gate
	//Example: https://gw.sandbox.gopay.com/gw/v3/bCcvmwTKK5hrJx2aGG8ZnFyBJhAvF
	GwURL string `json:"gw_url,omitempty"`
}

type PaymentStatus

type PaymentStatus struct {

	//Order ID
	//Example: OBJ20200825
	OrderNumber string `json:"order_number,omitempty"`
	//Payment status
	//Example: PAID
	State State `json:"state,omitempty"`
	//Payment substate
	//Example: _3001
	SubState Substate
	//Payment amount in cents
	//Example: 139950
	Amount int `json:"amount,omitempty"`
	//Payment currency
	//Example: CZK
	Currency Currency `json:"currency,omitempty"`
	//Payment method used
	//Example: BANK_ACCOUNT
	PaymentInstrument PaymentInstrument `json:"payment_intrument,omitempty"`
	//Information about payer and payment methods
	Payer Payer `json:"payer,omitempty"`
	//Payee information
	Target Target `json:"target,omitempty"`
	//Additional payment parameters
	AdditionalParams []AdditionalParam `json:"additional_params,omitempty"`
	//Payment gateway language
	//Example: CS
	Lang Lang `json:"lang,omitempty"`
	//Recurrence info if the payment is recurrent
	Recurrence *Recurrence `json:"recurrence,omitempty"`
	//Preauthorization info if the payment is preauthorized
	Preauthorization bool `json:"preauthorization,omitempty"`
	EetCode          struct {
		//Fiskální identifikační kód (FIK)
		//Example: 28da0811-e050-46c7-a62c-aa456d1f07ef-ff
		FIK string

		//Bezpečnostní kód poplatníka (BKP)
		//Example: 5d874afc-251f8661-ff0e0b13-c7cd8793-6bf0386a
		BKP string

		//Podpisový kód poplatníka (PKP)
		//Example: Ca8sTbURReQjjgcy/znXBKjPOnZof3AxWK5WySpyMrUXF0o7cz1BP6a.....
		PKP string
	} `json:"eet_code,omitempty"`
	//Payment gateway URL
	//Example: https://gw.sandbox.gopay.com/gw/v3/bCcvmwTKK5hrJx2aGG8ZnFyBJhAvF
	GwURL string `json:"gw_url,omitempty"`
	// contains filtered or unexported fields
}

type Preauthorization

type Preauthorization struct {
	//Whether the pre-authorization was established
	Requested bool `json:"requested,omitempty"`

	//Payment pre-authorization status
	State PreauthorizationState `json:"state,omitempty"`
}

type PreauthorizationState

type PreauthorizationState string
const (
	PreauthorizationStateRequested  PreauthorizationState = "REQUESTED"  //Pre-authorization created
	PreauthorizationStateAuthorized PreauthorizationState = "AUTHORIZED" //Pre-authorized
	PreauthorizationStateCaptured   PreauthorizationState = "CAPTURED"   //Pre-authorion captured
	PreauthorizationStateCanceled   PreauthorizationState = "CANCELED"   //Pre-authorization canceled
)

type Recurrence

type Recurrence struct {
	//Time period of recurring
	//Example: MONTH
	RecurrenceCycle RecurrenceCycle `json:"recurrence_cycle,omitempty"`

	//Recurring period of recurring payment
	//Example: 12
	RecurrencePeriod int `json:"recurrence_period,omitempty"`

	//The period of validity recurring payment
	//Example: 2025-12-31
	RecurrenceDateTo string `json:"recurrence_date_to,omitempty"`

	//Describes state of recurring payment
	//Example: STARTED
	RecurrenceState RecurrenceState `json:"recurrence_state,omitempty"`
}

type RecurrenceCycle

type RecurrenceCycle string
const (
	RecurrenceCycleDAY       RecurrenceCycle = "DAY"       //Daily recurrence period
	RecurrenceCycleWEEK      RecurrenceCycle = "WEEK"      //Weekly recurrence period
	RecurrenceCycleMONTH     RecurrenceCycle = "MONTH"     //Monthly recurrence period
	RecurrenceCycleON_DEMAND RecurrenceCycle = "ON_DEMAND" //Recurring payment on demand
)

type RecurrenceState

type RecurrenceState string
const (
	RecurrenceStateRequested RecurrenceState = "REQUESTED" //Recurring payment created, waiting for authorization of initial payment
	RecurrenceStateStarted   RecurrenceState = "STARTED"   //Payment recurrence active
	RecurrenceStateStopped   RecurrenceState = "STOPPED"   //Payment recurring canceled
)

type State

type State string
const (
	StateCreated             State = "CREATED"               //Payment created
	StatePaid                State = "PAID"                  //Payment has already been paid
	StateCanceled            State = "CANCELED"              //Payment declined
	StatePaymentMethodChosen State = "PAYMENT_METHOD_CHOSEN" //Payment method confirmed
	StateTimeouted           State = "TIMEOUTED"             //The payment has expired
	StateAuthorized          State = "AUTHORIZED"            //Payment pre-authorized
	StateRefunded            State = "REFUNDED"              //Payment refunded
	StatePartiallyRefunded   State = "PARTIALLY_REFUNDED"    //Payment partially refunded
)

type Substate

type Substate string

func (Substate) String

func (s Substate) String() string

type Swift

type Swift string
const (
	SwiftGIBACZPX    Swift = "GIBACZPX"     //Česká Spořitelna
	SwiftKOMBCZPP    Swift = "KOMBCZPP"     //Komerční Banka
	SwiftRZBCCZPP    Swift = "RZBCCZPP"     //Raiffeisenbank
	SwiftFIOBCZPP    Swift = "FIOBCZPP"     //FIO Banka
	SwiftBACXCZPP    Swift = "BACXCZPP"     //UniCredit Bank
	SwiftBREXCZPP    Swift = "BREXCZPP"     //mBank
	SwiftCEKOCZPP    Swift = "CEKOCZPP"     //ČSOB
	SwiftCEKOCZPPERA Swift = "CEKOCZPP-ERA" //Poštovní Spořitelna
	SwiftAGBACZPP    Swift = "AGBACZPP"     //Moneta Money Bank
	SwiftAIRACZPP    Swift = "AIRACZPP"     //AirBank
	SwiftEQBKCZPP    Swift = "EQBKCZPP"     //EQUA Bank
	SwiftINGBCZPP    Swift = "INGBCZPP"     //ING Bank
	SwiftEXPNCZPP    Swift = "EXPNCZPP"     //Expobank
	SwiftOBKLCZ2X    Swift = "OBKLCZ2X"     //OberBank AG
	SwiftVBOECZ2X    Swift = "VBOECZ2X"     //Sberbank CZ
	SwiftSUBACZPP    Swift = "SUBACZPP"     //Všeobecná Úvěrová Banka - pobočka Praha
	SwiftBPPFCZP1    Swift = "BPPFCZP1"     //Hello! Bank
	SwiftTATRSKBX    Swift = "TATRSKBX"     //Tatra Banka
	SwiftSUBASKBX    Swift = "SUBASKBX"     //Všeobecná Úverová Banka
	SwiftUNCRSKBX    Swift = "UNCRSKBX"     //UniCredit Bank SK
	SwiftGIBASKBX    Swift = "GIBASKBX"     //Slovenská Sporiteľňa
	SwiftPOBNSKBA    Swift = "POBNSKBA"     //Poštová Banka
	SwiftOTPVSKBX    Swift = "OTPVSKBX"     //OTP Banka
	SwiftKOMASK2X    Swift = "KOMASK2X"     //Prima Banka
	SwiftCITISKBA    Swift = "CITISKBA"     //Citibank Europe
	SwiftFIOZSKBA    Swift = "FIOZSKBA"     //FIO Banka SK
	SwiftINGBSKBX    Swift = "INGBSKBX"     //ING Wholesale Banking SK
	SwiftBREXSKBX    Swift = "BREXSKBX"     //mBank SK
	SwiftJTBPSKBA    Swift = "JTBPSKBA"     //J&T Banka SK
	SwiftOBKLSKBA    Swift = "OBKLSKBA"     //OberBank AG SK
	SwiftBSLOSK22    Swift = "BSLOSK22"     //Privatbanka
	SwiftBFKKSKBB    Swift = "BFKKSKBB"     //BKS Bank AG SK
	SwiftGBGCPLPK    Swift = "GBGCPLPK"     //Getin Bank
	SwiftNESBPLPW    Swift = "NESBPLPW"     //Nest Bank
	SwiftVOWAPLP9    Swift = "VOWAPLP9"     //Volkswagen Bank
	SwiftCITIPLPX    Swift = "CITIPLPX"     //Citi handlowy
	SwiftWBKPPLPP    Swift = "WBKPPLPP"     //Santander
	SwiftBIGBPLPW    Swift = "BIGBPLPW"     //Millenium Bank
	SwiftEBOSPLPW    Swift = "EBOSPLPW"     //Bank Ochrony Srodowiska
	SwiftPKOPPLPW    Swift = "PKOPPLPW"     //Pekao Bank
	SwiftPPABPLPK    Swift = "PPABPLPK"     //BNP Paribas
	SwiftBPKOPLPW    Swift = "BPKOPLPW"     //OWSZECHNA KASA OSZCZEDNOSCI BANK POLSK
	SwiftAGRIPLPR    Swift = "AGRIPLPR"     //Credit Agricole Banka Polska
	SwiftGBGCPLPKNOB Swift = "GBGCPLPK-NOB" //Noble Bank
	SwiftPOLUPLPR    Swift = "POLUPLPR"     //BPS/Bank Nowy BFG
	SwiftBREXPLPW    Swift = "BREXPLPW"     //mBank PL
	SwiftINGBPLPW    Swift = "INGBPLPW"     //ING Bank PL
	SwiftALBPPLPW    Swift = "ALBPPLPW"     //Alior
	SwiftIEEAPLPA    Swift = "IEEAPLPA"     //IdeaBank
	SwiftPOCZPLP4    Swift = "POCZPLP4"     //Pocztowy24
	SwiftIVSEPLPP    Swift = "IVSEPLPP"     //Plus Bank
	SwiftTOBAPLPW    Swift = "TOBAPLPW"     //Toyota Bank
)

type Target

type Target struct {
	//always ACCOUNT
	Type string `json:"type,omitempty"`

	//Unique identifier of an e-shop in the payment gateway system
	//Example: 8123456789
	Goid int `json:"goid,omitempty"`
}

type Type

type Type string
const (
	TypeITEM     Type = "ITEM"     //Product/service
	TypeDELIVERY Type = "DELIVERY" //Delivery
	TypeDISCOUNT Type = "DISCOUNT" //Discount
)

Jump to

Keyboard shortcuts

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