gopay

package module
v0.0.0-...-62f1351 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 9 Imported by: 0

README

Unofficial Go SDK for GoPay Payments REST API

Go Reference

Installation

go get https://github.com/apparently-studio/gopay-go-api

Basic usage

client := gopay.NewClient("my id", "my secret", "my goid", "gateway url")

Create Payment

payment, err := gopay.CreatePayment(&client, gopay.PaymentBody{ /* define your payment */ })
if err != nil {
    log.Println(err)
    return
}

log.Println(payment.GWURL)

Get Payment

payment, err := gopay.GetPayment(&client, int64(id))
if err != nil {
    log.Println(err)
    return
}

log.Println(payment)

Refund Payment

err := gopay.RefundPayment(&client, int64(id), 50000)
if err != nil {
    log.Println(err)
    return
}

log.Println("Refund has been successful.")

Documentation

Index

Constants

View Source
const ALIOR_BANK = BankSwift("ALBPPLPW")
View Source
const AUTHORIZED = PaymentState("AUTHORIZED") //	Payment pre-authorized
View Source
const BANK_ACCOUNT = PaymentInstrument("BANK_ACCOUNT") // Bank account
View Source
const BANK_BPH_SA = BankSwift("BPHKPLPK")
View Source
const BANK_MILLENNIUM = BankSwift("BIGBPLPW")
View Source
const BANK_OCHRONY_SRODOWISKA = BankSwift("EBOSPLPW")
View Source
const BGZ_BANK = BankSwift("GOPZPLPW")
View Source
const BITCOIN = PaymentInstrument("BITCOIN") // Bitcoin wallet
View Source
const BLIK = BankSwift("GBGCPLPK-BLIK")
View Source
const BNP_PARIBAS_POLSKA = BankSwift("PPABPLPK")
View Source
const BPS = BankSwift("POLUPLPR")
View Source
const BZ_WBK = BankSwift("WBKPPLPP")
View Source
const CANCELED = PaymentState("CANCELED") //	Payment declined
View Source
const CESKA_SPORITELNA = BankSwift("GIBACZPX")
View Source
const CITI_HANDLOWY = BankSwift("CITIPLPX")
View Source
const CREATED = PaymentState("CREATED") //	Payment created
View Source
const CREDIT_AGRICOLE = BankSwift("AGRIPLPR")
View Source
const CSOB = BankSwift("CEKOCZPP")
View Source
const CSOB_SK = BankSwift("CEKOSKBX")
View Source
const DAY = RecurrenceCycle("DAY")
View Source
const DELIVERY = ItemType("DELIVERY")
View Source
const DEUTSCHE_BANK_POLSKA_SA = BankSwift("DEUTPLPX")
View Source
const DISCOUNT = ItemType("DISCOUNT")
View Source
const DNB_NORD = BankSwift("DNBANOKK")
View Source
const ERA = BankSwift("CEKOCZPP-ERA")
View Source
const EUROBANK = BankSwift("SOGEPLPW")
View Source
const E_SKOK = BankSwift("NBPLPLPW")
View Source
const FIFTEEN = ItemVatRate(15)
View Source
const FIO_BANKA = BankSwift("FIOBCZPP")
View Source
const GETIN_ONLINE = BankSwift("GBGCPLPK-GIO")
View Source
const GETIN_ONLINE1 = BankSwift("GBGCPLPK")
View Source
const GOOGLE_PAY = PaymentInstrument("GPAY") // Google Pay
View Source
const GOPAY = PaymentInstrument("GOPAY") // GoPay wallet
View Source
const IDEA = BankSwift("IEEAPLPA")
View Source
const IKO = BankSwift("BPKOPLPW-IKO")
View Source
const ING_BANK_SLASKI = BankSwift("INGBPLPW")
View Source
const INTELIGO = BankSwift("BPKOPLPW-INTELIGO")
View Source
const ITEM = ItemType("ITEM")
View Source
const KOMERCNI_BANKA = BankSwift("KOMBCZPP")
View Source
const MASTERPASS = PaymentInstrument("MASTERPASS") // Masterpass
View Source
const MBANK = BankSwift("BREXCZPP")
View Source
const MBANK1 = BankSwift("BREXPLPW")
View Source
const MONTH = RecurrenceCycle("MONTH")
View Source
const MPAYMENT = PaymentInstrument("MPAYMENT") // mPlatba (mobile payment)
View Source
const NOBLE_BANK = BankSwift("GBGCPLPK-NOB")
View Source
const ON_DEMAND = RecurrenceCycle("ON_DEMAND")
View Source
const ORANGE = BankSwift("BREXPLPW-OMB")
View Source
View Source
const PARTIALLY_REFUNDED = PaymentState("PARTIALLY_REFUNDED") //	Payment partially refunded
View Source
const PAYMENT_CARD = PaymentInstrument("PAYMENT_CARD") // Payment card
View Source
const PAYMENT_METHOD_CHOSEN = PaymentState("PAYMENT_METHOD_CHOSEN") //	Payment method confirmed
View Source
const PAYPAL = PaymentInstrument("PAYPAL") // PayPal wallet
View Source
const PAYSAFECARD = PaymentInstrument("PAYSAFECARD") // PaySafeCard coupon
View Source
const PEKAO_SA = BankSwift("PKOPPLPW")
View Source
const PLUS_BANK = BankSwift("IVSEPLPP")
View Source
const POCZTOWY_BANK = BankSwift("POCZPLP4")
View Source
const POLSKI_BANK_PRZEDSIEBIORCZOSCI_SPOLKA_AKCYJNA = BankSwift("PBPBPLPW")
View Source
const POSTOVA_BANKA = BankSwift("POBNSKBA")
View Source
const POWSZECHNA_KASA_OSZCZEDNOSCI_BANK_POLSKI_SA = BankSwift("BPKOPLPW")
View Source
const PREMIUM_SMS = PaymentInstrument("PRSMS") // Premium SMS
View Source
const RAIFFEISENBANK = BankSwift("RZBCCZPP")
View Source
const RAIFFEISEN_BANK_POLSKA_SA = BankSwift("RCBWPLPW")
View Source
const REFUNDED = PaymentState("REFUNDED") //	Payment refunded
View Source
const REQUESTED = RecurrenceState("REQUESTED")
View Source
const SBERBANK_SLOVENSKO = BankSwift("LUBASKBX")
View Source
const SGB = BankSwift("GBWCPLPP")
View Source
const SLOVENSKA_SPORITELNA = BankSwift("GIBASKBX")
View Source
const SPECIAL = BankSwift("OTHERS")
View Source
const STARTED = RecurrenceState("STARTED")
View Source
const STOPPED = RecurrenceState("STOPPED")
View Source
const TATRA_BANKA = BankSwift("TATRSKBX")
View Source
const TEN = ItemVatRate(10)
View Source
const TIMEOUTED = PaymentState("TIMEOUTED") //	The payment has expired
View Source
const TOYOTA_BANK = BankSwift("TOBAPLPW")
View Source
const TWENTYONE = ItemVatRate(21)
View Source
const UNICREDIT_BANK_CZ = BankSwift("BACXCZPP")
View Source
const UNICREDIT_BANK_SK = BankSwift("UNCRSKBX")
View Source
const VOLKSWAGEN_BANK = BankSwift("VOWAPLP1")
View Source
const VSEOBECNA_VEROVA_BANKA_BANKA = BankSwift("SUBASKBX")
View Source
const WEEK = RecurrenceCycle("WEEK")
View Source
const ZERO = ItemVatRate(0)

Variables

View Source
var PaymentSecondaryStates = map[int]string{
	101:  "We are waiting for an online payment.",
	102:  "We are waiting for an offline payment.",
	3001: "Bank payment confirmed by advice",
	3002: "Bank payment confirmed by statement.",
	3003: "Bank payment was not confirmed.",
	5001: "Approved with zero amount.",
	5002: "Rejection of the payment in the authorization center of the customer’s bank due to reaching the limits on the payment card.",
	5003: "Refusal of payment in the authorization center of the customer’s bank due to problems on the part of the payment card issuer.",
	5004: "Rejection of the payment in the authorization center of the customer’s bank due to a problem on the part of the payment card issuer.",
	5005: "Rejection of the payment in the authorization center of the customer’s bank due to a blocked payment card.",
	5006: "Refusal of payment in the authorization center of the customer’s bank due to lack of funds on the payment card.",
	5007: "Rejection of the payment in the authorization center of the customer’s bank due to the expired payment card.",
	5008: "Rejection of payment in the authorization center of the customer’s bank due to rejection of the CVV/CVC code.",
	5009: "Rejection of payment in the customer’s 3D Secure bank system.",
	5015: "Rejection of payment in the customer’s 3D Secure bank system.",
	5017: "Rejection of payment in the customer’s 3D Secure bank system.",
	5018: "Rejection of payment in the customer’s 3D Secure bank system.",
	5019: "Rejection of payment in the customer’s 3D Secure bank system.",
	6502: "Rejection of payment in the customer’s 3D Secure bank system.",
	6504: "Rejection of payment in the customer’s 3D Secure bank system.",
	5010: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5014: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5011: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5036: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5012: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5013: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5016: "Rejection of the payment in the authorization center of the customer’s bank due to problems on the payment card.",
	5020: "Unknown configuration",
	5021: "Rejection of the payment in the authorization center of the customer’s bank due to reaching the set limits on the payment card.",
	5022: "There was a technical problem associated with the customer’s bank authorization center.",
	5023: "Payment was not made.",
	5038: "Payment was not made.",
	5024: "Payment was not made. Payment details were not entered within the time limit on the payment gateway.",
	5025: "Payment was not made. The specific reason for rejection is communicated directly to the customer.",
	5026: "Payment was not made. The sum of the credited amounts exceeded the amount paid.",
	5027: "Payment was not made. The user is not authorized to perform the operation.",
	5028: "Payment was not made. The amount to be paid exceeded the authorized amount.",
	5029: "Payment has not been made yet.",
	5030: "The payment was not made due to a re-entry.",
	5031: "There was a technical problem with the payment on the part of the bank.",
	5033: "SMS could not be delivered.",
	5035: "The payment card is issued in a region where card payments are not supported.",
	5037: "The credit card holder canceled the payment.",
	5039: "The payment was declined at the customer’s bank authorization center due to a blocked credit card.",
	5040: "Duplicate reversal transactions",
	5041: "Duplicate transactions",
	5042: "Bank payment declined.",
	5043: "Payment canceled by user.",
	5044: "SMS has been sent. It has not yet been delivered.",
	5045: "Payment received. Payment will be credited after processing on Bitcoin.",
	5046: "The payment was not paid in full.",
	5047: "Payment was made overdue.",
}

Functions

func RefundPayment

func RefundPayment(client *Client, ID int64, amount int) error

Refund Payment https://doc.gopay.com/#payment-refund

Types

type Accounts

type Accounts struct {
	Id       int    `json:"id,omitempty"`       // Account ID
	Balance  int    `json:"balance,omitempty"`  // Balance
	Currency string `json:"currency,omitempty"` // Currency [ISO 4217](http://www.iso.org/iso/home/standards/currency_codes.htm)
}

type AdditionalParam

type AdditionalParam struct {
	Name  string `json:"name,omitempty"`  // Parameter name
	Value string `json:"value,omitempty"` // Value of optional parameter
}

type Address

type Address struct {
	Street     string `json:"street,omitempty"`      // Street
	PostalCode string `json:"postal_code,omitempty"` // PostalCode
	City       string `json:"city,omitempty"`        // City
	Country    string `json:"country,omitempty"`     // Country code ISO 3166-1 alpha-3
}

type BankAccount

type BankAccount struct {
	Iban          string     `json:"iban,omitempty"`           // International bank account number
	Bic           *BankSwift `json:"bic,omitempty"`            // Business identification code (SWIFT)
	Prefix        string     `json:"prefix,omitempty"`         // Bank account prefix
	AccountNumber string     `json:"account_number,omitempty"` // Bank account number
	BankCode      string     `json:"bank_code,omitempty"`      // Bank account code
	AccountName   string     `json:"account_name,omitempty"`   // Bank account name
}

https://doc.gopay.com/#bank-account

type BankSwift

type BankSwift string

type Callback

type Callback struct {
	ReturnURL       string `json:"return_url,omitempty"`       // URL address for return to e-shop (with protocol)
	NotificationUrl string `json:"notification_url,omitempty"` // URL address for sending asynchronous notification in the case of changes in the payment status (with protocol)
}

type Client

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

func NewClient

func NewClient(id string, secret string, goId int, url string) Client

func (*Client) RefreshToken

func (c *Client) RefreshToken() error

type Contact

type Contact struct {
	FirstName   string `json:"first_name,omitempty"`   // First name
	LastName    string `json:"last_name,omitempty"`    // Last name
	Email       string `json:"email,omitempty"`        // Valid e-mail
	PhoneNumber string `json:"phone_number,omitempty"` // Phone number with country code
	City        string `json:"city,omitempty"`         // City
	Street      string `json:"street,omitempty"`       // Street
	PostalCode  string `json:"postal_code,omitempty"`  // Postal code
	CountryCode string `json:"country_code,omitempty"` // Country code ISO 3166-1 alpha-3
}

https://doc.gopay.com/#contact

type EET

type EET struct {
	DicPoverujiciho string `json:"dic_poverujiciho,omitempty"` //	DIČ pověřujícího poplatníka	varchar
	CelkTrzba       int64  `json:"celk_trzba,omitempty"`       //	Celková částka tržby	long v centech
	ZaklNepodlDph   int64  `json:"zakl_nepodl_dph,omitempty"`  //	Celková částka plnění osvobozených od DPH	long v centech
	ZaklDan1        int64  `json:"zakl_dan1,omitempty"`        //	Celkový základ daně se základní sazbou DPH	long v centech
	Dan1            int64  `json:"dan1,omitempty"`             //	Celková DPH se základní sazbou	long v centech
	ZaklDan2        int64  `json:"zakl_dan2,omitempty"`        //	Celkový základ daně s první sníženou sazbou DPH	long v centech
	Dan2            int64  `json:"dan2,omitempty"`             //	Celková DPH s první sníženou sazbou	long v centech
	ZaklDan3        int64  `json:"zakl_dan3,omitempty"`        //	Celkový základ daně s druhou sníženou sazbou DPH	long v centech
	Dan3            int64  `json:"dan3,omitempty"`             //	Celková DPH s druhou sníženou sazbou	long v centech
	CestSluz        int64  `json:"cest_sluz,omitempty"`        //	Celková částka v režimu DPH pro cestovní službu	long v centech
	PouzitZboz1     int64  `json:"pouzit_zboz1,omitempty"`     //	Celková částka v režimu DPH pro prodej použitého zboží se základní sazbou	long v centech
	PouzitZboz2     int64  `json:"pouzit_zboz2,omitempty"`     //	Celková částka v režimu DPH pro prodej použitého zboží s první sníženou sazbou	long v centech
	PouzitZboz3     int64  `json:"pouzit_zboz3,omitempty"`     //	Celková částka v režimu DPH pro prodej použitého zboží s druhou sníženou sazbou	long v centech
	UrcenoCerpZuct  int64  `json:"urceno_cerp_zuct,omitempty"` //	Celková částka plateb určená k následnému čerpání nebo zúčtování	long v centech
	CerpZuct        int64  `json:"cerp_zuct,omitempty"`        //	Celková částka plateb, které jsou následným čerpáním nebo zúčtováním platby	long v centech
	Mena            int64  `json:"mena,omitempty"`             //	Měna, ve které jsou údaje předávány
}

TODO: možná anglicky? (GoPay to má taky v čj)

type EETCode

type EETCode struct {
	FIK string `json:"fik,omitempty"` // Fiskální identifikační kód (FIK)
	BKP string `json:"bkp,omitempty"` // Bezpečnostní kód poplatníka (BKP)
	PKP string `json:"pkp,omitempty"` // Podpisový kód poplatníka (PKP)
}

type ItemType

type ItemType string

type ItemVatRate

type ItemVatRate int

type Items

type Items struct {
	Type       ItemType    `json:"type,omitempty"`        // Type of row, for registration of sales
	ProductUrl string      `json:"product_url,omitempty"` // URL address of the product
	Ean        string      `json:"ean,omitempty"`         // [EAN code of the product](https://en.wikipedia.org/wiki/International_Article_Number)
	Count      int64       `json:"count,omitempty"`       // Number of items
	Name       string      `json:"name,omitempty"`        // Product name
	Amount     int64       `json:"amount,omitempty"`      // Total price of items in cents
	VatRate    ItemVatRate `json:"vat_rate,omitempty"`    // VAT rate
}

type Payer

type Payer struct {
	AllowedPaymentInstruments []PaymentInstrument `json:"allowed_payment_instruments,omitempty"` // Array of allowed payment methods
	DefaultPaymentInstrument  PaymentInstrument   `json:"default_payment_instrument,omitempty"`  // Preferred payment method
	DefaultSwift              *BankSwift          `json:"default_swift,omitempty"`               // Preferred bank if default_payment_instrument is set to BANK_ACCOUNT, set by SWIFT code
	AllowedSwifts             []BankSwift         `json:"allowed_swifts,omitempty"`              // Array of allowed bank codes
	BankAccount               *BankAccount        `json:"bank_account,omitempty"`                // Bank account´s information
	PaymentCard               *PaymentCard        `json:"payment_card,omitempty"`                // Payment card´s information
	Contact                   *Contact            `json:"contact,omitempty"`                     // Customer´s data
	VerifyPin                 string              `json:"verify_pin,omitempty"`                  // PIN for identification payment purposes
	AllowedCardToken          string              `json:"allowed_card_token,omitempty"`          // Token for identification payment purposes
}

https://doc.gopay.com/#payer

type Payment

type Payment struct {
	ID               int64             `json:"id,omitempty"`                // Payment ID
	OrderNumber      string            `json:"order_number,omitempty"`      // Order ID
	State            *PaymentState     `json:"state,omitempty"`             // Payment status
	Amount           int64             `json:"amount,omitempty"`            // Amount in cents
	Currency         string            `json:"currency,omitempty"`          // Payment currency [ISO 4217](http://www.iso.org/iso/home/standards/currency_codes.htm)
	Payer            *Payer            `json:"payer,omitempty"`             // Information about the payer and payment methods
	Target           *Target           `json:"target,omitempty"`            // Payee information
	AdditionalParams []AdditionalParam `json:"additional_params,omitempty"` // Additional parameters
	Lang             string            `json:"string,omitempty"`            // Payment gateway language
	GWURL            string            `json:"gw_url,omitempty"`            // URL for initiation of the payment gate
	Preauthorization bool              `json:"preauthorization,omitempty"`  // true if the payment should be preauthorized
	Recurrence       *Recurrence       `json:"recurrence,omitempty"`        // Contains object describing recurrence, if the payment should be recurrent
}

Payment struct returned from REST API.

func CreatePayment

func CreatePayment(client *Client, body PaymentBody) (*Payment, error)

Create Payment https://doc.gopay.com/#payment-creation

func GetPayment

func GetPayment(client *Client, ID int64) (*Payment, error)

Get Payment https://doc.gopay.com/#payment-status

type PaymentBody

type PaymentBody struct {
	Payer            *Payer            `json:"payer,omitempty"`             // Payment method settings and payer information
	Target           *Target           `json:"target,omitempty"`            // Payee information
	Amount           int64             `json:"amount,omitempty"`            // Payment amount in cents
	Currency         string            `json:"currency,omitempty"`          // Payment currency [ISO 4217](http://www.iso.org/iso/home/standards/currency_codes.htm)
	OrderNumber      string            `json:"order_number,omitempty"`      // Merchant’s order id, alphanumeric
	OrderDescription string            `json:"order_description,omitempty"` // Order description, alphanumeric
	Items            []Items           `json:"items,omitempty"`             // Details of the payment items
	EET              *EET              `json:"eet,omitempty"`               // EET údaje (povinné pro funkci EET)
	Callback         *Callback         `json:"callback,omitempty"`          // Callback URL for processing of the payment result / Notification URL for processing of change of payment status
	AdditionalParams []AdditionalParam `json:"additional_params,omitempty"` // Additional payment parameters
	Lang             string            `json:"lang,omitempty"`              // Payment gateway language
	Preauthorization bool              `json:"preauthorization,omitempty"`  // true if the payment should be preauthorized
	Recurrence       *Recurrence       `json:"recurrence,omitempty"`        // Contains object describing recurrence, if the payment should be recurrent
}

Payment body used when creating Payment..

type PaymentCard

type PaymentCard struct {
	CardNumber        string `json:"card_number,omitempty"`         // Masked payment card´s number
	CardExpiration    string `json:"card_expiration,omitempty"`     // Expiration date
	CardBrand         string `json:"card_brand,omitempty"`          // Payment card´s type
	CardIssuerCountry string `json:"card_issuer_country,omitempty"` // Country code of issuing bank
	CardIssuerBank    string `json:"card_issuer_bank,omitempty"`    // Issuing bank
	CardToken         string `json:"card_token,omitempty"`          // Token for identification payment purposes
	Card3dsResult     string `json:"3ds_result,omitempty"`          // 3D Secure authorization’s result for identification payment purposes
}

https://doc.gopay.com/#payment-card

type PaymentInstrument

type PaymentInstrument string

type PaymentState

type PaymentState string

type Recurrence

type Recurrence struct {
	RecurrenceCycle  RecurrenceCycle `json:"recurrence_cycle,omitempty"`   // Time period of recurring
	RecurrencePeriod int64           `json:"recurrence_period,omitempty"`  // Recurring period of recurring payment
	RecurrenceDateTo string          `json:"recurrence_date_to,omitempty"` // The period of validity recurring payment (yyyy-mm-dd)
	RecurrenceState  RecurrenceState `json:"recurrence_state,omitempty"`   // Describes state of recurring payment
}

type RecurrenceCycle

type RecurrenceCycle string

type RecurrenceState

type RecurrenceState string

type RefreshTokenResponse

type RefreshTokenResponse struct {
	TokenType   string `json:"token_type"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type RequestBody

type RequestBody interface {
	// contains filtered or unexported methods
}

type Target

type Target struct {
	Type string `json:"type,omitempty"` // Always ACCOUNT
	Goid int64  `json:"goid,omitempty"` // Unique identifier of an e-shop in the payment gateway system
}

Jump to

Keyboard shortcuts

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