pay

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

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

2PAY GOLANG SDK

2Pay Online Api

Installation

$ go get github.com/2pay-co/golang-sdk

Usage

Please see examples

demo

package main

import (
	"fmt"
	pay "github.com/2pay-co/golang-sdk"
	"github.com/gogf/gf/v2/os/gtime"
)

func main() {

	t := pay.New("", "")
	param := pay.SecurePay{
		Currency:    "USD",
		Amount:      "10",
		Vendor:      "alipay",
		Reference:   gtime.Datetime(),
		Terminal:    "ONLINE",
		IpnURL:      "https://google.com",
		CallbackURL: "https://google.com",
		Note:        "test order",
		Description: "test order",
		Timeout:     "120",
		GoodsInfo: []pay.GoodsInfo{
			{
				"test goods 1", "1",
			},
			{
				"test goods 2", "1",
			},
		},
	}

	resp, err := t.SecurePay(&param)
	fmt.Println(resp, err)
}

Documentation

Index

Constants

View Source
const (
	BaseUrl      = "https://api.2pay.co"
	SecurePayUrl = "/online/v1/secure-pay"
	RefundPayUrl = "/app-data-search/v1/refund"
	QueryPayUrl  = "/app-data-search/v1/tran-query"
)

Variables

This section is empty.

Functions

func PostJson

func PostJson(url string, args map[string]interface{}) ([]byte, error)

Types

type BaseResponse

type BaseResponse struct {
	Result string `json:"ret_code"`
	RetMsg string `json:"ret_msg"`
}

type GoodsInfo

type GoodsInfo struct {
	GoodsName string `json:"goodsName"`
	Quantity  string `json:"quantity"`
}

type QueryResp

type QueryResp struct {
	BaseResponse
	QueryRet QueryRet `json:"result"`
}

type QueryRet

type QueryRet struct {
	TransactionNo  string  `json:"transactionNo"`
	Reference      string  `json:"reference"`
	Amount         float64 `json:"amount"`
	Status         string  `json:"status"`
	Currency       string  `json:"currency"`
	SettleCurrency string  `json:"settleCurrency"`
}

type SecurePay

type SecurePay struct {
	MerchantNo  string      `json:"merchantNo"`
	VerifySign  string      `json:"verifySign"`
	Currency    string      `json:"currency"`
	Amount      string      `json:"amount"`
	Vendor      string      `json:"vendor"`
	Reference   string      `json:"reference"`
	Terminal    string      `json:"terminal"`
	IpnURL      string      `json:"ipnUrl"`
	CallbackURL string      `json:"callbackUrl"`
	Note        string      `json:"note"`
	Description string      `json:"description"`
	Timeout     string      `json:"timeout"`
	GoodsInfo   []GoodsInfo `json:"goodsInfo"`
	CreditType  string      `json:"creditType"`
	CustomerNo  string      `json:"customerNo"`
}

type SecurePayResponse

type SecurePayResponse struct {
	Result   string       `json:"ret_code"`
	RetMsg   string       `json:"ret_msg"`
	Response SecurePayRet `json:"result,omitempty"`
}

type SecurePayRet

type SecurePayRet struct {
	Amount         string `json:"amount"`
	Currency       string `json:"currency"`
	TransactionNo  string `json:"transactionNo"`
	Reference      string `json:"reference"`
	CashierURL     string `json:"cashierUrl"`
	SettleCurrency string `json:"settleCurrency"`
}

type TwoPay

type TwoPay struct {
	MerchantNo string
	Token      string
}

func New

func New(merchantNo, token string) *TwoPay

func (*TwoPay) Query

func (t *TwoPay) Query(orderNo string) (*QueryResp, error)

func (*TwoPay) Refund

func (t *TwoPay) Refund(orderNo string, amount float64) (*BaseResponse, error)

func (*TwoPay) SecurePay

func (t *TwoPay) SecurePay(param *SecurePay) (*SecurePayResponse, error)

Jump to

Keyboard shortcuts

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