alipay

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 25 Imported by: 0

README

alipay

golang sdk for alipay

GoDoc

Documentation

Overview

Package alipay provides alipay related api. See details on https://docs.open.alipay.com/api_1

Package alipay https://docs.open.alipay.com/204/105465/

Package alipay https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query

Package alipay https://docs.open.alipay.com/api_1/alipay.trade.cancel/

Package alipay https://docs.open.alipay.com/api_1/alipay.trade.create/

Package alipay https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query/

Package alipay https://docs.open.alipay.com/common/105806

Package alipay https://docs.open.alipay.com/270/alipay.trade.page.pay

Package alipay https://docs.open.alipay.com/api_1/alipay.trade.pay/

Package alipay https://docs.open.alipay.com/api_1/alipay.trade.precreate/

Package alipay https://docs.open.alipay.com/api_1/alipay.trade.query

Package alipay https://docs.open.alipay.com/203/107090/

Index

Constants

View Source
const (
	// BillTypeTrade 指商户基于支付宝交易收单的业务账
	BillTypeTrade = "trade"

	// BillTypeSigncustomer 指基于商户支付宝余额收入及支出等资金变动的帐务账单
	BillTypeSigncustomer = "signcustomer"
)
View Source
const (
	CsvBusinessTypeTrade  = "交易"
	CsvBusinessTypeRefund = "退款"
)

CsvBusinessType ...

View Source
const (
	MethodAlipayTradeFastpayRefundQuery             = "alipay.trade.fastpay.refund.query"
	MethodAlipayTradeOrderSettle                    = "alipay.trade.order.settle"
	MethodAlipayTradeClose                          = "alipay.trade.close"
	MethodAlipayTradeCancel                         = "alipay.trade.cancel"
	MethodAlipayTradeRefund                         = "alipay.trade.refund"
	MethodAlipayTradePrecreate                      = "alipay.trade.precreate"
	MethodAlipayTradeCreate                         = "alipay.trade.create"
	MethodAlipayTradePay                            = "alipay.trade.pay"
	MethodAlipayTradeQuery                          = "alipay.trade.query"
	MethodAlipayDataDataserviceBillDownloadurlQuery = "alipay.data.dataservice.bill.downloadurl.query"
	MethodAlipayTradePagePay                        = "alipay.trade.page.pay"
	MethodAlipayTradeAppPay                         = "alipay.trade.app.pay"
	MethodAlipayTradeWapPay                         = "alipay.trade.wap.pay"
)

MethodAlipay ...

View Source
const (
	// WaitBuyerPay 交易创建,等待买家付款
	WaitBuyerPay = "WAIT_BUYER_PAY"

	// TradeClosed 未付款交易超时关闭,或支付完成后全额退款
	TradeClosed = "TRADE_CLOSED"

	// TradeSuccess 交易支付成功
	TradeSuccess = "TRADE_SUCCESS"

	// TradeFinished 交易结束,不可退款
	TradeFinished = "TRADE_FINISHED"
)
View Source
const (
	AlipayGateway = "https://openapi.alipay.com/gateway.do"
)

AlipayGateway ...

View Source
const (
	GatewaySuccess = "10000"
)

Success ...

Variables

View Source
var (
	ErrAsyncVerify = errors.New("支付宝异步验签失败")
)

ErrAsyncVerify ...

Functions

func DayFormat

func DayFormat(t time.Time) string

DayFormat ...

func Float64ifyPrice

func Float64ifyPrice(price string) float64

Float64ifyPrice ...

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

GbkToUtf8 ...

func NewPrivateKey

func NewPrivateKey(privateBytes []byte) (priKey *rsa.PrivateKey, err error)

NewPrivateKey privateKey格式参照ParsePKCS1PrivateKey

func NewPublicKey

func NewPublicKey(pubBytes []byte) (pub *rsa.PublicKey, err error)

NewPublicKey publicKey参照ParsePKIXPublicKey

func NormValues

func NormValues(v url.Values) string

NormValues ...

func RSA2

func RSA2(privateKey *rsa.PrivateKey, in string) (string, error)

RSA2 ...

func StringifyPrice

func StringifyPrice(price float64) string

StringifyPrice ...

func Verify

func Verify(publicKey *rsa.PublicKey, data []byte, sig []byte) error

Verify ...

Types

type Alipay

type Alipay struct {
	*rsa.PrivateKey
	*rsa.PublicKey
	// contains filtered or unexported fields
}

Alipay ...

func New

func New(appID string, pubBytes, privateBytes []byte) (*Alipay, error)

New ...

func (*Alipay) AppID

func (alipay *Alipay) AppID() string

AppID ...

func (*Alipay) AppPay

func (alipay *Alipay) AppPay(param *AppPayParam, notifyURL string) (string, error)

AppPay ...

func (*Alipay) BillDownloadurlQuery

func (alipay *Alipay) BillDownloadurlQuery(param *BillDownloadURLQueryParam) (int, *BillDownloadURLQueryResponse, error)

BillDownloadurlQuery ...

func (*Alipay) BillSigncustomerList added in v1.2.0

func (alipay *Alipay) BillSigncustomerList(bill []byte) ([]*BillSigncustomerEntry, error)

BillSigncustomerList ...

func (*Alipay) BillTradeList

func (alipay *Alipay) BillTradeList(bill []byte) ([]*BillTradeEntry, error)

BillTradeList ...

func (*Alipay) Cancel

func (alipay *Alipay) Cancel(param CancelParam) (int, *CancelResponse, error)

Cancel ...

func (*Alipay) Close

func (alipay *Alipay) Close(param *CloseParam) (int, *CloseResponse, error)

Close ...

func (*Alipay) Create

func (alipay *Alipay) Create(param *CreateParam) (int, *CreateResponse, error)

Create ...

func (*Alipay) DownloadBill

func (alipay *Alipay) DownloadBill(billURL string) ([]byte, error)

DownloadBill ...

func (*Alipay) FastpayRefundQuery

func (alipay *Alipay) FastpayRefundQuery(param *FastpayRefundQueryParam) (int, *FastpayRefundQueryResponse, error)

FastpayRefundQuery ...

func (*Alipay) HTTPClient

func (alipay *Alipay) HTTPClient() *http.Client

HTTPClient ...

func (*Alipay) MakeParam

func (alipay *Alipay) MakeParam(content interface{}, method string, fillList ...Fill) (string, error)

MakeParam ...

func (*Alipay) OnRequest

func (alipay *Alipay) OnRequest(content interface{}, method string, fillList ...Fill) (int, []byte, error)

OnRequest ...

func (*Alipay) OrderSettle

func (alipay *Alipay) OrderSettle(param *OrderSettleParam) (int, *FastpayRefundQueryResponse, error)

OrderSettle ...

func (*Alipay) PagePay

func (alipay *Alipay) PagePay(param *PagePayParam, notifyURL string, returnURL string) (string, error)

PagePay ...

func (*Alipay) ParseAsyncResponse

func (alipay *Alipay) ParseAsyncResponse(values url.Values) (*AsyncResponse, error)

ParseAsyncResponse ...

func (*Alipay) Pay

func (alipay *Alipay) Pay(param *PayParam, notifyURL, appAuthToken string) (int, *PayResponse, error)

Pay ...

func (*Alipay) Precreate

func (alipay *Alipay) Precreate(param *PrecreateParam) (int, *PrecreateResponse, error)

Precreate ...

func (*Alipay) Query

func (alipay *Alipay) Query(param *QueryParam) (int, *QueryResponse, error)

Query ...

func (*Alipay) Refund

func (alipay *Alipay) Refund(param *RefundParam) (int, *RefundResponse, error)

Refund ...

func (*Alipay) WapPay

func (alipay *Alipay) WapPay(param *WapPayParam, notifyURL string, returnURL string) (string, error)

WapPay ...

type AppPayParam

type AppPayParam struct {
	Body               string                 `json:"body,omitempty"`                 // 对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body。
	Subject            string                 `json:"subject"`                        // 商品的标题/交易标题/订单标题/订单关键字等。
	OutTradeNo         string                 `json:"out_trade_no"`                   // 商户网站唯一订单号
	TimeoutExpress     string                 `json:"timeout_express,omitempty"`      // 该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m。 注:若为空,则默认为15d。
	TotalAmount        string                 `json:"total_amount"`                   // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	ProductCode        string                 `json:"product_code"`                   // 销售产品码,商家和支付宝签约的产品码,为固定值QUICK_MSECURITY_PAY
	GoodsType          string                 `json:"goods_type,omitempty"`           // 商品主类型:0—虚拟类商品,1—实物类商品 注:虚拟类商品不支持使用花呗渠道
	PassbackParams     string                 `json:"passback_params,omitempty"`      // 公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝会在异步通知时将该参数原样返回。本参数必须进行UrlEncode之后才可以发送给支付宝
	PromoParams        string                 `json:"promo_params"`                   // 优惠参数 注:仅与支付宝协商后可用
	ExtendParams       string                 `json:"extend_params,omitempty"`        // 业务扩展参数,详见下面的“业务扩展参数说明”
	EnablePayChannels  string                 `json:"enable_pay_channels,omitempty"`  // 可用渠道,用户只能在指定渠道范围内支付 当有多个渠道时用“,”分隔 注:与disable_pay_channels互斥
	DisablePayChannels string                 `json:"disable_pay_channels,omitempty"` // 禁用渠道,用户不可用指定渠道支付 当有多个渠道时用“,”分隔  注:与enable_pay_channels互斥
	StoreID            string                 `json:"store_id,omitempty"`             // 商户门店编号。该参数用于请求参数中以区分各门店,非必传项。
	ExtUserInfo        AppPayParamExtUserInfo `json:"ext_user_info,omitempty"`        // 外部指定买家,详见外部用户ExtUserInfo参数说明
}

AppPayParam ...

type AppPayParamExtUserInfo

type AppPayParamExtUserInfo struct {
	Name          string `json:"name"`            // 姓名
	Mobile        string `json:"mobile"`          // 手机号
	CertType      string `json:"cert_type"`       // 身份证:IDENTITY_CARD、护照:PASSPORT、军官证:OFFICER_CARD、士兵证:SOLDIER_CARD、户口本:HOKOU等。如有其它类型需要支持,请与蚂蚁金服工作人员联系。
	CertNo        string `json:"cert_no"`         // 证件号
	MinAge        string `json:"min_age"`         // 允许的最小买家年龄,买家年龄必须大于等于所传数值 注:  1. need_check_info=T时该参数才有效  2. min_age为整数,必须大于等于0
	FixBuyer      string `json:"fix_buyer"`       // 是否强制校验付款人身份信息 T:强制校验,F:不强制
	NeedCheckInfo string `json:"need_check_info"` // 是否强制校验身份信息 T:强制校验,F:不强制
}

AppPayParamExtUserInfo ...

type AppPayParamExtendParams

type AppPayParamExtendParams struct {
	SysServiceProviderID string `json:"sys_service_provider_id,omitempty"` // 系统商编号,该参数作为系统商返佣数据提取的依据,请填写系统商签约协议的PID
	NeedBuyerRealnamed   string `json:"needBuyerRealnamed,omitempty"`      //是否发起实名校验 T:发起 F:不发起
	TransMemo            string `json:"TRANS_MEMO,omitempty"`              // 账务备注 注:该字段显示在离线账单的账务备注中
	HbFqNum              string `json:"hb_fq_num,omitempty"`               // 花呗分期数(目前仅支持3、6、12) 注:使用该参数需要仔细阅读“花呗分期接入文档”
	HbFqSellerPercent    string `json:"hb_fq_seller_percent,omitempty"`    // 卖家承担收费比例,商家承担手续费传入100,用户承担手续费传入0,仅支持传入100、0两种,其他比例暂不支持  注:使用该参数需要仔细阅读“花呗分期接入文档”
}

AppPayParamExtendParams ...

type AsyncResponse

type AsyncResponse struct {
	NotifyTime        string
	NotifyType        string
	NotifyID          string
	AppID             string
	Charset           string
	Version           string
	SignType          string
	Sign              string
	AuthAppID         string
	TradeNo           string
	OutTradeNo        string
	OutBizNo          string
	BuyerID           string
	BuyerLogonID      string
	SellerID          string
	SellerEmail       string
	TradeStatus       string
	TotalAmount       string
	ReceiptAmount     string
	InvoiceAmount     string
	BuyerPayAmount    string
	PointAmount       string
	RefundFee         string
	Subject           string
	Body              string
	GmtCreate         string
	GmtPayment        string
	GmtRefund         string
	GmtClose          string
	FundBillList      string
	PassbackParams    string
	VoucherDetailList string
}

AsyncResponse ...

type BillDownloadURLQueryParam

type BillDownloadURLQueryParam struct {
	BillType string `json:"bill_type,omitempty"` // 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
	BillDate string `json:"bill_date,omitempty"` // 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
}

BillDownloadURLQueryParam ...

type BillDownloadURLQueryResponse

type BillDownloadURLQueryResponse struct {
	ResponseError
	BillDownloadURL string `json:"bill_download_url"` // 账单下载地址链接,获取连接后30秒后未下载,链接地址失效。
}

BillDownloadURLQueryResponse ...

func (*BillDownloadURLQueryResponse) IsBillNotExist

func (resp *BillDownloadURLQueryResponse) IsBillNotExist() bool

IsBillNotExist ...

type BillSigncustomerEntry added in v1.2.0

type BillSigncustomerEntry struct {
	FundFlowID     string // 账务流水号
	TransactionID  string // 业务流水号
	BusinessID     string // 商户订单号
	ProductName    string // 商品名称
	TimeStart      string // 发生时间
	OtherAccount   string // 对方账号
	IncomeAmount   string // 收入金额(+元)
	ExpensesAmount string // 支出金额(-元)
	Balance        string // 账户余额(元)
	TradingChannel string // 交易渠道
	BusinessType   string // 业务类型
	Remark         string // 备注
}

BillSigncustomerEntry ...

type BillTradeEntry

type BillTradeEntry struct {
	TradeNo             string // 支付宝交易号
	OutTradeNo          string // 商户订单号
	BusinessType        string // 业务类型
	Subject             string // 商品名称
	TimeStart           string // 创建时间
	TimeEnd             string // 完成时间
	ShopNo              string // 门店编号
	ShopName            string // 门店名称
	Operator            string // 操作员
	TerminalNo          string // 终端号
	BuyerEmail          string // 对方账户
	TotalAmount         string // 订单金额(元)
	ReceiptAmount       string // 商家实收(元)
	Coupon              string // 支付宝红包(元)
	Jf                  string // 集分宝(元)
	AlipayOff           string // 支付宝优惠(元)
	SellerOff           string // 商家优惠(元)
	CouponChargeOff     string // 券核销金额(元)
	CouponName          string // 券名称
	SellerCouponConsume string // 商家红包消费金额(元)
	HandlingCharge      string // 卡消费金额(元)
	OutRequestNo        string // 退款批次号/请求号
	Service             string // 服务费(元)
	Fr                  string // 分润(元)
	Body                string // 备注
}

BillTradeEntry ...

type CancelParam

type CancelParam struct {
	TradeNo    string `json:"trade_no"`     // 商户订单号
	OutTradeNo string `json:"out_trade_no"` // 支付宝交易号
}

CancelParam ...

type CancelResponse

type CancelResponse struct {
	ResponseError
	TradeNo    string `json:"trade_no"`     // 支付宝交易号
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
	RetryFlag  string `json:"retry_flag"`   // 是否需要重试
	Action     string `json:"action"`       // 本次撤销触发的交易动作
}

CancelResponse ...

type CloseParam

type CloseParam struct {
	TradeNo    string `json:"trade_no,omitempty"`     // 支付宝交易号
	OutTradeNo string `json:"out_trade_no,omitempty"` // 商户订单号
	OperatorID string `json:"operator_id,omitempty"`  // 卖家端自定义的的操作员 ID
}

CloseParam ...

type CloseResponse

type CloseResponse struct {
	ResponseError
	TradeNo    string `json:"trade_no"`     // 支付宝交易号
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
}

CloseResponse ...

type CommonParam

type CommonParam struct {
	AppID        string `url:"app_id,omitempty"`         // 支付宝分配给开发者的应用ID
	Method       string `url:"method,omitempty"`         // 接口名称
	Format       string `url:"format,omitempty"`         // 仅支持JSON
	ReturnURL    string `url:"return_url,omitempty"`     // 同步返回地址
	Charset      string `url:"charset,omitempty"`        // 请求使用的编码格式,如utf-8,gbk,gb2312等
	SignType     string `url:"sign_type,omitempty"`      // 商户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用RSA2
	Sign         string `url:"sign,omitempty"`           // 商户请求参数的签名串
	Timestamp    string `url:"timestamp,omitempty"`      // 发送请求的时间,格式"yyyy-MM-dd HH:mm:ss"
	Version      string `url:"version,omitempty"`        // 调用的接口版本,固定为:1.0
	NotifyURL    string `url:"notify_url,omitempty"`     // 支付宝服务器主动通知商户服务器里指定的页面http/https路径。
	AppAuthToken string `url:"app_auth_token,omitempty"` // 详见应用授权概述
	BizContent   string `url:"biz_content,omitempty"`    // 请求参数的集合
}

CommonParam ...

type CreateParam

type CreateParam struct {
	OutTradeNo         string                  `json:"out_trade_no"`        // 商户订单号
	SellerID           string                  `json:"seller_id"`           // 卖家支付宝用户ID
	TotalAmount        string                  `json:"total_amount"`        // 订单总金额
	DiscountableAmount string                  `json:"discountable_amount"` // 参与优惠计算的金额
	Subject            string                  `json:"subject"`             // 订单标题
	Body               string                  `json:"body"`                // 订单描述
	BuyerID            string                  `json:"buyer_id"`            // 买家的支付宝用户id
	GoodsDetailList    []*CreateParamGoods     `json:" goods_detail"`       // 订单包含的商品列表信息
	OperatorID         string                  `json:"operator_id"`         // 商户操作员编号
	StoreID            string                  `json:"store_id"`            // 商户门店编号
	TerminalID         string                  `json:"terminal_id"`         // 商户机具终端编号
	ExtendParams       CreateParamExtendParams `json:"extend_params"`       // 业务扩展参数
	TimeoutExpress     string                  `json:"timeout_express"`     // 该笔订单允许的最晚付款时间
	BusinessParams     string                  `json:"business_params"`     // 商户传入业务信息
}

CreateParam ...

type CreateParamExtendParams

type CreateParamExtendParams struct {
	SysServiceProviderID string `json:"sys_service_provider_id"` // 系统商编号
}

CreateParamExtendParams ...

type CreateParamGoods

type CreateParamGoods struct {
	GoodsID       string `json:"goods_id"`       // 商品的编号
	GoodsName     string `json:"goods_name"`     // 商品名称
	Quantity      int    `json:"quantity"`       // 商品数量
	Price         string `json:"price"`          // 商品单价
	GoodsCategory string `json:"goods_category"` // 商品类目
	Body          string `json:"body"`           // 商品描述信息
	ShowURL       string `json:"show_url"`       // 商品的展示地址
}

CreateParamGoods ...

type CreateResponse

type CreateResponse struct {
	ResponseError
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
	TradeNo    string `json:"trade_no"`     // 支付宝交易号
}

CreateResponse ...

type FastpayRefundQueryParam

type FastpayRefundQueryParam struct {
	TradeNo      string `json:"trade_no,omitempty"`       // 支付宝交易号
	OutTradeNo   string `json:"out_trade_no,omitempty"`   // 户订单号
	OutRequestNo string `json:"out_request_no,omitempty"` // 请求退款接口时,传入的退款请求号,如果在退款请求时未传入,则该值为创建交易时的外部交易号
}

FastpayRefundQueryParam ...

type FastpayRefundQueryResponse

type FastpayRefundQueryResponse struct {
	ResponseError
	TradeNo      string `json:"trade_no"`       // 支付宝交易号
	OutTradeNo   string `json:"out_trade_no"`   // 商户订单号
	OutRequestNo string `json:"out_request_no"` // 本笔退款对应的退款请求号
	RefundReason string `json:"refund_reason"`  // 发起退款时,传入的退款原因
	TotalAmount  string `json:"total_amount"`   // 该笔退款所对应的交易的订单金额
	RefundAmount string `json:"refund_amount"`  // 本次退款请求,对应的退款金额
}

FastpayRefundQueryResponse ...

func (*FastpayRefundQueryResponse) IsNeedRetry

func (resp *FastpayRefundQueryResponse) IsNeedRetry() bool

IsNeedRetry ...

func (*FastpayRefundQueryResponse) IsRefundSuccess

func (resp *FastpayRefundQueryResponse) IsRefundSuccess() bool

IsRefundSuccess 商户可使用该接口查询自已通过alipay.trade.refund提交的退款请求是否执行成功。 该接口的返回码10000,仅代表本次查询操作成功,不代表退款成功。如果该接口返回了查询数据,则代表退款成功,如果没有查询到则代表未退款成功,可以调用退款接口进行重试。重试时请务必保证退款请求号一致。

func (*FastpayRefundQueryResponse) IsTradeNotExist

func (resp *FastpayRefundQueryResponse) IsTradeNotExist() bool

IsTradeNotExist ...

type Fill

type Fill func(*CommonParam)

Fill ...

func WithAppAuthToken

func WithAppAuthToken(authToken string) Fill

WithAppAuthToken ...

func WithNotifyURL

func WithNotifyURL(notifyURL string) Fill

WithNotifyURL ...

func WithReturnURL

func WithReturnURL(returnURL string) Fill

WithReturnURL ...

func WithSignType

func WithSignType(signType string) Fill

WithSignType ...

type OrderSettleParam

type OrderSettleParam struct {
	OutRequestNo      string                                          `json:"out_request_no"`     // 结算请求流水号
	TradeNo           string                                          `json:"trade_no"`           // 支付宝订单号
	RoyaltyParameters []*OrderSettleParamOpenAPIRoyaltyDetailInfoPojo `json:"royalty_parameters"` // 分账明细信息
	OperatorID        string                                          `json:"operator_id"`        // 操作员id
}

OrderSettleParam ...

type OrderSettleParamOpenAPIRoyaltyDetailInfoPojo

type OrderSettleParamOpenAPIRoyaltyDetailInfoPojo struct {
	TransOut         string  `json:" trans_out"`        // 分账支出方账户,类型为userId,本参数为要分账的支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字。
	TransIn          string  `json:"trans_in"`          // 分账收入方账户,类型为userId,本参数为要分账的支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字。
	Amount           float64 `json:"amount"`            // 分账的金额,单位为元
	AmountPercentage float64 `json:"amount_percentage"` // 分账信息中分账百分比。取值范围为大于0,少于或等于100的整数。
	Desc             string  `json:"desc"`              // 分账描述
}

OrderSettleParamOpenAPIRoyaltyDetailInfoPojo ...

type OrderSettleResponse

type OrderSettleResponse struct {
	ResponseError
	TradeNo string `json:"trade_no"` // 支付宝交易号
}

OrderSettleResponse ...

type PagePayParam

type PagePayParam struct {
	OutTradeNo         string `json:"out_trade_no"`                   // 商户订单号,64个字符以内、可包含字母、数字、下划线;需保证在商户端不重复
	ProductCode        string `json:"product_code"`                   // 销售产品码,与支付宝签约的产品码名称。 注:目前仅支持FAST_INSTANT_TRADE_PAY
	TotalAmount        string `json:"total_amount"`                   // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	Subject            string `json:"subject"`                        // 订单标题
	Body               string `json:"body,omitempty"`                 // 订单描述
	GoodsDetail        string `json:"goods_detail,omitempty"`         // 订单包含的商品列表信息,Json格式
	PassbackParams     string `json:"passback_params,omitempty"`      // 公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝只会在异步通知时将该参数原样返回。本参数必须进行UrlEncode之后才可以发送给支付宝
	ExtendParams       string `json:"extend_params,omitempty"`        // 业务扩展参数,详见业务扩展参数说明
	GoodsType          string `json:"goods_type,omitempty"`           // 商品主类型:0—虚拟类商品,1—实物类商品(默认) 注:虚拟类商品不支持使用花呗渠道
	TimeoutExpress     string `json:"timeout_express,omitempty"`      // 该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m。 该参数在请求到支付宝时开始计时。
	EnablePayChannels  string `json:"enable_pay_channels,omitempty"`  // 可用渠道,用户只能在指定渠道范围内支付
	DisablePayChannels string `json:"disable_pay_channels,omitempty"` // 禁用渠道
	AuthToken          string `json:"auth_token,omitempty"`           // 获取用户授权信息
	QrPayMode          string `json:"qr_pay_mode,omitempty"`          // PC扫码支付的方式
	QrCodeWidth        string `json:"qrcode_width,omitempty"`         // 商户自定义二维码宽度
}

PagePayParam ...

type PagePayParamExtendParams

type PagePayParamExtendParams struct {
	SysServiceProviderID string `json:"sys_service_provider_id,omitempty"` // 系统商编号
	HbFqNum              string `json:"hb_fq_num,omitempty"`               // 花呗分期数(目前仅支持3、6、12)注:使用该参数需要仔细阅读“花呗分期接入文档”
	HbFqSellerPercent    string `json:"hb_fq_seller_percent,omitempty"`    // 卖家承担收费比例,商家承担手续费传入100,用户承担手续费传入0,仅支持传入100、0两种,其他比例暂不支持注:使用该参数需要仔细阅读“花呗分期接入文档”
}

PagePayParamExtendParams ...

type PayParam

type PayParam struct {
	OutTradeNo         string               `json:"out_trade_no"`        // 商户订单号
	Scene              string               `json:"scene"`               // 支付场景
	AuthCode           string               `json:"auth_code"`           // 支付授权码
	ProductCode        string               `json:"product_code"`        // 销售产品码
	Subject            string               `json:"subject"`             // 订单标题
	BuyerID            string               `json:"buyer_id"`            // 买家的支付宝用户id
	SellerID           string               `json:"seller_id "`          // 商户签约账号对应的支付宝用户ID
	TotalAmount        string               `json:"total_amount"`        // 订单总金额
	DiscountableAmount string               `json:"discountable_amount"` // 参与优惠计算的金额
	Body               string               `json:"body"`                // 订单描述
	GoodsDetailList    []*PayParamGoods     `json:" goods_detail"`       // 订单包含的商品列表信息
	OperatorID         string               `json:"operator_id"`         // 商户操作员编号
	StoreID            string               `json:"store_id"`            // 商户门店编号
	TerminalID         string               `json:"terminal_id"`         // 商户机具终端编号
	ExtendParams       PayParamExtendParams `json:"extend_params"`       // 业务扩展参数
	TimeoutExpress     string               `json:"timeout_express"`     // 该笔订单允许的最晚付款时间
}

PayParam ...

type PayParamExtendParams

type PayParamExtendParams struct {
	SysServiceProviderID string `json:"sys_service_provider_id"` // 系统商编号
}

PayParamExtendParams ...

type PayParamGoods

type PayParamGoods struct {
	GoodsID       string `json:"goods_id"`       // 商品的编号
	GoodsName     string `json:"goods_name"`     // 商品名称
	Quantity      int    `json:"quantity"`       // 商品数量
	Price         string `json:"price"`          // 商品单价
	GoodsCategory string `json:"goods_category"` // 商品类目
	Body          string `json:"body"`           // 商品描述信息
	ShowURL       string `json:"show_url"`       // 商品的展示地址
}

PayParamGoods ...

type PayResponse

type PayResponse struct {
	ResponseError
	TradeNo             string                      `json:"trade_no"`              // 支付宝交易号
	OutTradeNo          string                      `json:"out_trade_no"`          // 商户订单号
	BuyerLogonID        string                      `json:"buyer_logon_id"`        // 买家支付宝账号
	TotalAmount         string                      `json:"total_amount"`          // 交易金额
	ReceiptAmount       string                      `json:"receipt_amount"`        // 实收金额
	BuyerPayAmount      string                      `json:"buyer_pay_amount"`      // 买家付款的金额
	PointAmount         string                      `json:"point_amount"`          // 使用积分宝付款的金额
	InvoiceAmount       string                      `json:"invoice_amount"`        // 交易中可给用户开具发票的金额
	GmtPayment          string                      `json:"gmt_payment"`           // 交易支付时间
	FundBillList        []*PayResponseFundBill      `json:"fund_bill_list"`        // 交易支付使用的资金渠道
	CardBalance         string                      `json:"card_balance"`          // 支付宝卡余额
	StoreName           string                      `json:"store_name"`            // 发生支付交易的商户门店名称
	BuyerUserID         string                      `json:"buyer_user_id"`         // 买家在支付宝的用户id
	DiscountGoodsDetail string                      `json:"discount_goods_detail"` // 本次交易支付所使用的单品券优惠的商品优惠信息
	VoucherDetailList   []*PayResponseVoucherDetail `json:" voucher_detail_list"`  // 本交易支付时使用的所有优惠券信息
	BusinessParams      string                      `json:"business_params"`       // 商户传入业务信息
	BuyerUserType       string                      `json:"buyer_user_type"`       // 买家用户类型
}

PayResponse ...

type PayResponseFundBill

type PayResponseFundBill struct {
	FundChannel string `json:"fund_channel"` // 交易使用的资金渠道
	Amount      string `json:"amount"`       // 该支付工具类型所使用的金额
	RealAmount  string `json:"real_amount"`  // 渠道实际付款金额
}

PayResponseFundBill ...

type PayResponseVoucherDetail

type PayResponseVoucherDetail struct {
	ID                         string `json:"id"`                           // 券id
	Name                       string `json:"name"`                         // 券名称
	Type                       string `json:"type"`                         // 当前有三种类型
	Amount                     string `json:"amount"`                       // 优惠券面额
	MerchantContribute         string `json:"merchant_contribute"`          // 商家出资
	OtherContribute            string `json:" other_contribute"`            // 其他出资方出资金额
	Meomo                      string `json:" memo"`                        // 优惠券备注信息
	TemplateID                 string `json:" template_id"`                 // 券模板id
	PurchaseBuyerContribute    string `json:"purchase_buyer_contribute"`    // 如果使用的这张券是用户购买的,则该字段代表用户在购买这张券时用户实际付款的金额
	PurchaseMerchantContribute string `json:"purchase_merchant_contribute"` // 如果使用的这张券是用户购买的,则该字段代表用户在购买这张券时商户优惠的金额
	PurchaseAntContribute      string `json:"purchase_ant_contribute"`      // 如果使用的这张券是用户购买的,则该字段代表用户在购买这张券时平台优惠的金额
}

PayResponseVoucherDetail ...

type PrecreateParam

type PrecreateParam struct {
	OutTradeNo         string                     `json:"out_trade_no"`         // 商户订单号
	SellerID           string                     `json:"seller_id"`            // 卖家支付宝用户ID
	TotalAmount        string                     `json:"total_amount"`         // 订单总金额
	DiscountableAmount string                     `json:"discountable_amount"`  // 参与优惠计算的金额
	Subject            string                     `json:"subject"`              // 订单标题
	GoodsDetailList    []*PrecreateParamGoods     `json:" goods_detail"`        // 订单包含的商品列表信息
	Body               string                     `json:"body"`                 // 订单描述
	OperatorID         string                     `json:"operator_id"`          // 商户操作员编号
	StoreID            string                     `json:"store_id"`             // 商户门店编号
	DisablePayChannels string                     `json:"disable_pay_channels"` // 禁用渠道,用户不可用指定渠道支付
	EnablePayChannels  string                     `json:"enable_pay_channels"`  // 可用渠道,用户只能在指定渠道范围内支付
	TerminalID         string                     `json:"terminal_id"`          // 商户机具终端编号
	ExtendParams       PrecreateParamExtendParams `json:"extend_params"`        // 业务扩展参数
	TimeoutExpress     string                     `json:"timeout_express"`      // 该笔订单允许的最晚付款时间
	BusinessParams     string                     `json:"business_params"`      // 商户传入业务信息
}

PrecreateParam ...

type PrecreateParamExtendParams

type PrecreateParamExtendParams struct {
	SysServiceProviderID string `json:"sys_service_provider_id"` // 系统商编号
}

PrecreateParamExtendParams ...

type PrecreateParamGoods

type PrecreateParamGoods struct {
	GoodsID       string `json:"goods_id"`       // 商品的编号
	GoodsName     string `json:"goods_name"`     // 商品名称
	Quantity      int    `json:"quantity"`       // 商品数量
	Price         string `json:"price"`          // 商品单价
	GoodsCategory string `json:"goods_category"` // 商品类目
	Body          string `json:"body"`           // 商品描述信息
	ShowURL       string `json:"show_url"`       // 商品的展示地址
}

PrecreateParamGoods ...

type PrecreateResponse

type PrecreateResponse struct {
	ResponseError
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
	TradeNo    string `json:"trade_no"`     // 支付宝交易号
}

PrecreateResponse ...

type QueryParam

type QueryParam struct {
	OutTradeNo string `json:"out_trade_no,omitempty"`
	TradeNo    string `json:"trade_no,omitempty"`
}

QueryParam ...

type QueryResponse

type QueryResponse struct {
	ResponseError
	TradeNo        string                   `json:"trade_no"`         // 支付宝交易号
	OutTradeNo     string                   `json:"out_trade_no"`     // 商家订单号
	BuyerLogonID   string                   `json:"buyer_logon_id"`   // 买家支付宝账号
	TradeStatus    string                   `json:"trade_status"`     // 交易状态
	TotalAmount    string                   `json:"total_amount"`     // 交易的订单金额
	ReceiptAmount  string                   `json:"receipt_amount"`   // 实收金额
	BuyerPayAmount string                   `json:"buyer_pay_amount"` // 买家实付金额
	PointAmount    string                   `json:"point_amount"`
	InvoiceAmount  string                   `json:"invoice_amount"`  // 交易中用户支付的可开具发票的金额
	SendPayDate    string                   `json:"send_pay_date"`   // 本次交易打款给卖家的时间
	StoreID        string                   `json:"store_id"`        // 商户门店编号
	TerminalID     string                   `json:"terminal_id"`     // 商户机具终端编号
	FundBillList   []*QueryResponseFundBill `json:"fund_bill_list"`  // 交易支付使用的资金渠道
	StoreName      string                   `json:"store_name"`      // 请求交易支付中的商户店铺的名称
	BuyerUserID    string                   `json:"buyer_user_id"`   // 买家在支付宝的用户id
	BuyerUserType  string                   `json:"buyer_user_type"` // 买家用户类型
}

QueryResponse ...

type QueryResponseFundBill

type QueryResponseFundBill struct {
	FundChannel string `json:"fund_channel"` // 交易使用的资金渠道
	Amount      string `json:"amount"`       // 该支付工具类型所使用的金额
	RealAmount  string `json:"real_amount"`  // 渠道实际付款金额
}

QueryResponseFundBill ...

type RefundParam

type RefundParam struct {
	OutTradeNo     string                    `json:"out_trade_no,omitempty"`
	TradeNo        string                    `json:"trade_no,omitempty"`
	RefundAmount   string                    `json:"refund_amount,omitempty"`
	RefundReason   string                    `json:"refund_reason,omitempty"`
	OutRequestNo   string                    `json:"out_request_no,omitempty"`
	OperatorID     string                    `json:"operator_id,omitempty"`
	StoreID        string                    `json:"store_id,omitempty"`
	TerminalID     string                    `json:"terminal_id,omitempty"`
	GoodDetailList []*RefundParamGoodsDetail `json:"goods_detail,omitempty"`
}

RefundParam ...

type RefundParamGoodsDetail

type RefundParamGoodsDetail struct {
	GoodsID       string `json:" goods_id,omitempty"`       // 商品的编号
	AlipayGoodsID string `json:"alipay_goods_id,omitempty"` // 支付宝定义的统一商品编号
	GoodsName     string `json:" goods_name,omitempty"`     // 商品名称
	Quantity      string `json:"quantity,omitempty"`        // 商品数量
	Price         string `json:"price,omitempty"`           // 商品单价,单位为元
	GoodsCategory string `json:"goods_category,omitempty"`  // 商品类目
	Body          string `json:"body,omitempty"`            // 商品描述信息
	ShowURL       string `json:"show_url,omitempty"`        // 商品的展示地址
}

RefundParamGoodsDetail ...

type RefundResponse

type RefundResponse struct {
	ResponseError
	TradeNo                      string                            `json:"trade_no"`                        // 支付宝交易号
	OutTradeNo                   string                            `json:"out_trade_no"`                    // 商户订单号
	BuyerLogonID                 string                            `json:"buyer_logon_id"`                  // 用户的登录id
	FundChange                   string                            `json:"fund_change"`                     // 本次退款是否发生了资金变化
	RefundFee                    string                            `json:"refund_fee"`                      // 退款总金额
	GmtRefundPay                 string                            `json:"gmt_refund_pay"`                  // 退款支付时间
	RefundDetailItemList         []*RefundResponseRefundDetailItem `json:"refund_detail_item_list"`         // 退款使用的资金渠道
	StoreName                    string                            `json:"store_name"`                      // 交易在支付时候的门店名称
	BuyerUserID                  string                            `json:"buyer_user_id"`                   // 买家在支付宝的用户id
	PresentRefundBuyerAmount     string                            `json:"present_refund_buyer_amount"`     // 本次退款金额中买家退款金额
	PresentRefundDiscountAmount  string                            `json:"present_refund_discount_amount"`  // 本次退款金额中平台优惠退款金额
	PresentRefundMdiscountAmount string                            `json:"present_refund_mdiscount_amount"` // 本次退款金额中商家优惠退款金额
}

RefundResponse ...

func (*RefundResponse) IsNotEnoughBalance

func (resp *RefundResponse) IsNotEnoughBalance() bool

IsNotEnoughBalance ...

func (*RefundResponse) IsNotEqualTotal

func (resp *RefundResponse) IsNotEqualTotal() bool

IsNotEqualTotal ...

func (*RefundResponse) IsTradeStatusError

func (resp *RefundResponse) IsTradeStatusError() bool

IsTradeStatusError ...

type RefundResponseRefundDetailItem

type RefundResponseRefundDetailItem struct {
	RefundChannel string `json:"refund_channel"` // 交易使用的资金渠道
	BankCode      string `json:"bank_code"`      // 银行卡支付时的银行代码
	Amount        string `json:"amount"`         // 该支付工具类型所使用的金额
	RealAmount    string `json:"real_amount"`    // 渠道实际付款金额
	FundType      string `json:"fund_type"`      // 渠道所使用的资金类型,目前只在资金渠道(fund_channel)是银行卡渠道(BANKCARD)的情况下才返回该信息(DEBIT_CARD:借记卡,CREDIT_CARD:信用卡,MIXED_CARD:借贷合一卡)
}

RefundResponseRefundDetailItem ...

type ResponseError

type ResponseError struct {
	Code    string `json:"code"`
	Msg     string `json:"msg"`
	SubCode string `json:"sub_code"`
	SubMsg  string `json:"sub_msg"`
}

ResponseError ...

func (ResponseError) Success

func (err ResponseError) Success() bool

Success 这个判断不代表业务成功!

type WapPayParam

type WapPayParam struct {
	Body               string                   `json:"body,omitempty"`                 // 对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body。
	Subject            string                   `json:"subject"`                        // 商品的标题/交易标题/订单标题/订单关键字等
	OutTradeNo         string                   `json:"out_trade_no"`                   // 商户网站唯一订单号
	TimeoutExpress     string                   `json:"timeout_express,omitempty"`      // 该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m。注:若为空,则默认为15d。
	TimeExpire         string                   `json:"time_expire,omitempty"`          // 绝对超时时间,格式为yyyy-MM-dd HH:mm。 注:1)以支付宝系统时间为准;2)如果和timeout_express参数同时传入,以time_expire为准。
	TotalAmount        string                   `json:"total_amount"`                   // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	AuthToken          string                   `json:"auth_token,omitempty"`           // 针对用户授权接口,获取用户相关数据时,用于标识用户授权关系注:若不属于支付宝业务经理提供签约服务的商户,暂不对外提供该功能,该参数使用无效。
	ProductCode        string                   `json:"product_code"`                   // 销售产品码,商家和支付宝签约的产品码。该产品请填写固定值:QUICK_WAP_WAY
	GoodsType          string                   `json:"goods_type,omitempty"`           // 商品主类型:0—虚拟类商品,1—实物类商品注:虚拟类商品不支持使用花呗渠道
	PassbackParams     string                   `json:"passback_params,omitempty"`      // 公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝会在异步通知时将该参数原样返回。本参数必须进行UrlEncode之后才可以发送给支付宝
	PromoParams        string                   `json:"promo_params,omitempty"`         // 优惠参数注:仅与支付宝协商后可用
	ExtendParams       *WapPayParamExtendParams `json:"extend_params,omitempty"`        // 业务扩展参数,详见下面的“业务扩展参数说明”
	EnablePayChannels  string                   `json:"enable_pay_channels,omitempty"`  // 可用渠道,用户只能在指定渠道范围内支付当有多个渠道时用“,”分隔注:与disable_pay_channels互斥
	DisablePayChannels string                   `json:"disable_pay_channels,omitempty"` // 禁用渠道,用户不可用指定渠道支付当有多个渠道时用“,”分隔注:与enable_pay_channels互斥
	StoreID            string                   `json:"store_id,omitempty"`             // 商户门店编号。该参数用于请求参数中以区分各门店,非必传项。
	QuitURL            string                   `json:"quit_url,omitempty"`             // 添加该参数后在h5支付收银台会出现返回按钮,可用于用户付款中途退出并返回到该参数指定的商户网站地址。注:该参数对支付宝钱包标准收银台下的跳转不生效。
	ExtUserInfo        *WapPayParamExtUserInfo  `json:"ext_user_info,omitempty"`        // 外部指定买家,详见外部用户ExtUserInfo参数说明
}

WapPayParam ...

type WapPayParamExtUserInfo

type WapPayParamExtUserInfo struct {
	Name          string `json:"name"`            // 姓名
	Mobile        string `json:"mobile"`          // 手机号
	CertType      string `json:"cert_type"`       // 身份证:IDENTITY_CARD、护照:PASSPORT、军官证:OFFICER_CARD、士兵证:SOLDIER_CARD、户口本:HOKOU等。如有其它类型需要支持,请与蚂蚁金服工作人员联系。
	CertNo        string `json:"cert_no"`         // 证件号
	MinAge        string `json:"min_age"`         // 允许的最小买家年龄,买家年龄必须大于等于所传数值 注: 1. need_check_info=T时该参数才有效  2. min_age为整数,必须大于等于0
	FixBuyer      string `json:"fix_buyer"`       // 是否强制校验付款人身份信息 T:强制校验,F:不强制
	NeedCheckInfo string `json:"need_check_info"` // 是否强制校验身份信息  T:强制校验,F:不强制
}

WapPayParamExtUserInfo ...

type WapPayParamExtendParams added in v1.2.2

type WapPayParamExtendParams struct {
	HbFqNum           string `json:"hb_fq_num,omitempty"`            // 花呗分期数(目前仅支持3、6、12)注:使用该参数需要仔细阅读“花呗分期接入文档”
	HbFqSellerPercent string `json:"hb_fq_seller_percent,omitempty"` // 卖家承担收费比例,商家承担手续费传入100,用户承担手续费传入0,仅支持传入100、0两种,其他比例暂不支持注:使用该参数需要仔细阅读“花呗分期接入文档”
}

Jump to

Keyboard shortcuts

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