unitpay

package module
v0.0.0-...-432dad6 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 8 Imported by: 0

README

unitpay-go

Go package for Unitpay

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PublicKey string
View Source
var SecretKey string

Functions

func CheckIp

func CheckIp(ip string) bool

Check ip of request

func HandleRequestWithParams

func HandleRequestWithParams(hr *HandlerRequest) error
Function to handle Unitpay request. Accept unitpay.HandleRequest.

Returns nil error if its ok. Alternatively you can pass http.Request in HandleRequest function

func Init

func Init(secret string, public string)

Init unitpay with secret key, public key and default values.

func SetDefaultBackUrl

func SetDefaultBackUrl(backurl string)

Functions to change some of default values for form

func SetDefaultCurrency

func SetDefaultCurrency(currency string) error

Functions to change some of default values for form

func SetDefaultHideMenu

func SetDefaultHideMenu(defaulthidemenu bool)

Functions to change some of default values for form

func SetDefaultLocale

func SetDefaultLocale(locale string) error

Functions to change some of default values for form

func SetDefaultPayBaseUrl

func SetDefaultPayBaseUrl(defaultpaybaseurl string)

Functions to change some of default values for form

func SetDefaultPaymentMethod

func SetDefaultPaymentMethod(paymentmethod string) error

Functions to change some of default values for form

Types

type DefaultValues

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

Form

Type of default values for form

type HandlerRequest

type HandlerRequest struct {
	Method         string   `json:"method"`
	UnitpayId      int      `json:"unitpayId"`
	ProjectId      int      `json:"projectId"`
	Account        string   `json:"account"`
	PayerSum       int      `json:"payerSum"`
	PayerCurrency  string   `json:"payerCurrency"`
	Profit         int      `json:"profit"`
	Phone          int      `json:"phone"`
	PaymentType    string   `json:"paymentType"`
	OrderSum       int      `json:"orderSum"`
	OrderCurrency  string   `json:"orderCurrency"`
	Operator       string   `json:"operator"`
	Date           string   `json:"date"`
	ErrorMessage   string   `json:"errorMessage"`
	Test           int      `json:"test"`
	DS3            int      `json:"3ds"`
	SubscriptionId int      `json:"subscriptionId"`
	Signature      string   `json:"signature"`
	ParamsSlice    []string `json:"params_slice"`
}

Handler Request

All Request values from UnitpayDocs

func GetParamsFromRequest

func GetParamsFromRequest(r *http.Request) *HandlerRequest
Function to get values from Request

You can access this function from outside of package to operate params manually

func HandleRequest

func HandleRequest(r *http.Request) (*HandlerRequest, error)
Function to handle Unitpay request. Accept http.Request.

Returns Params of request and nil error if its ok. Returns nil Params and error if there are errors. Alternatively you can get params by yourself and handle it with HandleRequestWithParams function

type OptionalParams

type OptionalParams struct {
	Currency      string `json:"currency"`
	Locale        string `json:"locale"`
	BackUrl       string `json:"backUrl"`
	PaymentMethod string `json:"payment_method"`
	Operator      string `json:"operator"`
	HideMenu      string `json:"hide_menu"`
	CustomerEmail string `json:"customer_email"`
	CustomerPhone string `json:"customer_phone"`
	CashItems     string `json:"cash_items"`
}

Other simple payment form Params (non-required). Used in func Form

type Params

type Params struct {
	RequiredParams
	OptionalParams
}

Params options summary

func NewEmptyParams

func NewEmptyParams() *Params

return new params object with empty required params and default optional params

func NewParams

func NewParams(sum int, account string, desc string) *Params

Return new params object with given required params and default optional params

func (*Params) Form

func (params *Params) Form() (URL string, err error)

Function to init simple payment form. Returns url of payment form.

func (*Params) GetSignature

func (params *Params) GetSignature() string

func to get signature of given params

func (*Params) SetAccount

func (params *Params) SetAccount(account string) error

Group of functions to set Form params values

func (*Params) SetBackUrl

func (params *Params) SetBackUrl(backurl string) error

Group of functions to set Form params values

func (*Params) SetCashItems

func (params *Params) SetCashItems(items string) error

func (*Params) SetCurrency

func (params *Params) SetCurrency(currency string) error

Group of functions to set Form params values

func (*Params) SetCustomerEmail

func (params *Params) SetCustomerEmail(email string) error

func (*Params) SetCustomerPhone

func (params *Params) SetCustomerPhone(phone string) error

func (*Params) SetDesc

func (params *Params) SetDesc(desc string)

Group of functions to set Form params values

func (*Params) SetHideMenu

func (params *Params) SetHideMenu(hidemenu bool) error

Group of functions to set Form params values

func (*Params) SetLocale

func (params *Params) SetLocale(locale string) error

Group of functions to set Form params values

func (*Params) SetOperator

func (params *Params) SetOperator(operator string) error

func (*Params) SetPaymentMethod

func (params *Params) SetPaymentMethod(paymentmethod string) error

Group of functions to set Form params values

func (*Params) SetSum

func (params *Params) SetSum(sum int) error

Group of functions to set Form params values

type RequiredParams

type RequiredParams struct {
	Sum       int    `json:"sum"`
	Account   string `json:"account"`
	Desc      string `json:"desc"`
	Signature string `json:"signature"`
}

Simple payment form Required Params Used in func Form

Jump to

Keyboard shortcuts

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