paymentpage

package module
v0.0.0-...-ce876bb Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 12 Imported by: 0

README

Build Status Test Coverage Maintainability

EcommPay payment page SDK

This is a set of libraries in the Go language to ease integration of your service with the EcommPay Payment Page.

Payment flow

Payment flow

Installation

Simply use go get:

go get github.com/ITECOMMPAY/paymentpage-sdk-go

To update later:

go get -u github.com/ITECOMMPAY/paymentpage-sdk-go

Get URL for payment
import "github.com/ITECOMMPAY/paymentpage-sdk-go"

payment := paymentpage.NewPayment(11, "test_payment_id")
payment.SetParam(paymentpage.ParamPaymentCurrency, "EUR")
payment.SetParam(paymentpage.ParamPaymentAmount, 1000)

gate := paymentpage.NewGate("your project secret")
paymentPageUrl := gate.GetPaymentPageUrl(*payment)

paymentPageUrl here is the signed URL.

Handle callback from Ecommpay

You'll need to autoload this code in order to handle notifications:

import "github.com/ITECOMMPAY/paymentpage-sdk-go"

gate := paymentpage.NewGate("your project secret")
callback, err := gate.HandleCallback(data)

data is the JSON string received from payment system;

err nil or error interface; error returned if signature invalid or callback data can't parse;

callback is the Callback object describing properties received from payment system; callback implements these methods:

  1. callback.GetPaymentStatus() Get payment status.
  2. callback.GetPayment() Get all payment data.
  3. callback.GetPaymentId() Get payment ID in your system.

Documentation

Index

Constants

View Source
const (
	PaymentStatusSuccess           string = "success"
	PaymentStatusDecline           string = "decline"
	PaymentStatusAW3DS             string = "awaiting 3ds result"
	PaymentStatusAWRedirect        string = "awaiting redirect result"
	PaymentStatusAWCustomer        string = "awaiting customer"
	PaymentStatusAWClarification   string = "awaiting clarification"
	PaymentStatusAWCapture         string = "awaiting capture"
	PaymentStatusCancelled         string = "cancelled"
	PaymentStatusRefunded          string = "refunded"
	PaymentStatusPartiallyRefunded string = "partially refunded"
	PaymentStatusProcessing        string = "processing"
	PaymentStatusError             string = "error"
	PaymentStatusReversed          string = "reversed"
)

Constants with possible statuses of payment

View Source
const (
	ParamProjectId            string = "project_id"
	ParamPaymentId            string = "payment_id"
	ParamPaymentAmount        string = "payment_amount"
	ParamPaymentCurrency      string = "payment_currency"
	ParamPaymentDescription   string = "payment_description"
	ParamAccountToken         string = "account_token"
	ParamCardOperationType    string = "card_operation_type"
	ParamBestBefore           string = "best_before"
	ParamCloseOnMissclick     string = "close_on_missclick"
	ParamCssModalWrap         string = "css_modal_wrap"
	ParamCustomerId           string = "customer_id"
	ParamForceAcsNewWindow    string = "force_acs_new_window"
	ParamForcePaymentMethod   string = "force_payment_method"
	ParamLanguageCode         string = "language_code"
	ParamListPaymentBlock     string = "list_payment_block"
	ParamMerchantFailUrl      string = "merchant_fail_url"
	ParamMerchantSuccessUrl   string = "merchant_success_url"
	ParamMode                 string = "mode"
	ParamRecurringRegister    string = "recurring_register"
	ParamCustomerFirstName    string = "customer_first_name"
	ParamCustomerLastName     string = "customer_last_name"
	ParamCustomerPhone        string = "customer_phone"
	ParamCustomerEmail        string = "customer_email"
	ParamCustomerCountry      string = "customer_country"
	ParamCustomerState        string = "customer_state"
	ParamCustomerCity         string = "customer_city"
	ParamCustomerDayOfBirth   string = "customer_day_of_birth"
	ParamCustomerSsn          string = "customer_ssn"
	ParamBillingPostal        string = "billing_postal"
	ParamBillingCountry       string = "billing_country"
	ParamBillingRegion        string = "billing_region"
	ParamBillingCity          string = "billing_city"
	ParamBillingAddress       string = "billing_address"
	ParamRedirect             string = "redirect"
	ParamRedirectFailMode     string = "redirect_fail_mode"
	ParamRedirectFailUrl      string = "redirect_fail_url"
	ParamRedirectOnMobile     string = "redirect_on_mobile"
	ParamRedirectSuccessMode  string = "redirect_success_mode"
	ParamRedirectSuccessUrl   string = "redirect_success_url"
	ParamRedirectTokenizeMode string = "redirect_tokenize_mode"
	ParamRedirectTokenizeUrl  string = "redirect_tokenize_url"
	ParamRegionCode           string = "region_code"
	ParamTargetElement        string = "target_element"
	ParamTerminalId           string = "terminal_id"
	ParamBaseUrl              string = "baseurl"
	ParamPaymentExtraParam    string = "payment_extra_param"

	PaymentTypePurchase  string = "purchase"
	PaymentTypePayout    string = "payout"
	PaymentTypeRecurring string = "recurring"
)

Constants with possible payment params and types of payment

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

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

Structure for processing callbacks

func NewCallback

func NewCallback(signatureHandler SignatureHandler, callbackData string) (*Callback, error)

Constructor for Callback structure

func (*Callback) GetParam

func (c *Callback) GetParam(pathStr string) interface{}

Get callback param by path name

func (*Callback) GetPayment

func (c *Callback) GetPayment() interface{}

Return map with payment data

func (*Callback) GetPaymentId

func (c *Callback) GetPaymentId() interface{}

Return our payment id

func (*Callback) GetPaymentStatus

func (c *Callback) GetPaymentStatus() interface{}

Return payment status

type Gate

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

Structure for communicate with our

func NewGate

func NewGate(secret string) *Gate

Constructor for Gate structure

func (*Gate) GetPaymentPageUrl

func (g *Gate) GetPaymentPageUrl(payment Payment) string

Method build payment URL

func (*Gate) HandleCallback

func (g *Gate) HandleCallback(callbackData string) (*Callback, error)

Method for handling callback

func (*Gate) SetBaseUrl

func (g *Gate) SetBaseUrl(url string) *Gate

Method for set base payment page URL

type Payment

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

Structure for preparing payment params

func NewPayment

func NewPayment(projectId int, paymentId interface{}) *Payment

Constructor for Payment structure

func (*Payment) GetParams

func (p *Payment) GetParams() map[string]interface{}

Method return payment params

func (*Payment) SetParam

func (p *Payment) SetParam(key string, value interface{}) *Payment

Setter for payment params

type PaymentPage

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

Structure for build payment URL

func NewPaymentPage

func NewPaymentPage(signatureHandler SignatureHandler) *PaymentPage

Constructor for PaymentPage structure

func (*PaymentPage) GetUrl

func (p *PaymentPage) GetUrl(payment Payment) string

Method build payment URL

func (*PaymentPage) SetBaseUrl

func (p *PaymentPage) SetBaseUrl(baseUrl string) *PaymentPage

Method for set base payment page URL

type SignatureHandler

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

Structure for make/check signature

func NewSignatureHandler

func NewSignatureHandler(secret string) *SignatureHandler

Constructor for SignatureHandler structure

func (*SignatureHandler) Check

func (s *SignatureHandler) Check(signature string, params map[string]interface{}) bool

Method for check signature

func (*SignatureHandler) SetSort

func (s *SignatureHandler) SetSort(sort bool) *SignatureHandler

Setter for sort flag

func (*SignatureHandler) Sign

func (s *SignatureHandler) Sign(params map[string]interface{}) string

Method for make signature

Jump to

Keyboard shortcuts

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