alipay

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOrderAmountOver = errors.New("订单金额超限")
	ErrVerifySign      = errors.New("异步通知验证签名未通过")
)

Functions

This section is empty.

Types

type Client

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

func Init

func Init(config Config) *Client

Init 客户端初始化

func (*Client) Pay

func (client *Client) Pay(order Order) (payUrl string, err error)

Pay 订单支付请求,返回支付界面链接及可能出现的错误

func (*Client) VerifyForm

func (client *Client) VerifyForm(form url.Values) (orderID string, err error)

VerifyForm 校验form表单并返回对应订单ID(注意: callback为get,notify为post)

type Config

type Config struct {
	KAppID               string // 应用ID
	KPrivateKey          string // 应用私钥
	IsProduction         bool   // 是否是正式环境
	AppPublicCertPath    string // app公钥证书路径
	AliPayRootCertPath   string // alipay根证书路径
	AliPayPublicCertPath string // alipay公钥证书路径
	NotifyURL            string // 异步通知地址
	ReturnURL            string // 支付后回调链接地址
}

Config 初始化配置文件

type Order

type Order struct {
	ID          string      // 订单ID
	Subject     string      // 订单标题
	TotalAmount float32     // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	Code        ProductCode // 销售产品码,与支付宝签约的产品码名称
}

type ProductCode

type ProductCode string
const (
	AppPay       ProductCode = "QUICK_MSECURITY_PAY"    // app支付
	PhoneWebPay  ProductCode = "QUICK_WAP_WAY"          // 手机网站支付
	LaptopWebPay ProductCode = "FAST_INSTANT_TRADE_PAY" // 电脑网站支付
)

Jump to

Keyboard shortcuts

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