alipay

package module
v0.0.0-...-0ab57d5 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: MIT Imports: 21 Imported by: 0

README

alipay

这是用Golang封装了支付宝的API接口的SDK。

  • 支持服务商或者普通商户模式。
  • 全部参数和返回值均使用struct类型传递,而不是map类型。
初始化
const (
	isProd = true
)
config := alipay.Config{
	AppId: "xxxxxx",
	AppAuthToken: "yyyyyy",
}
client := alipay.NewClient(isProd, publicKey, privateKey, config)
使用

对于非Client接口,可以直接调用,对于Client接口,需要先通过初始化生成client,然后调用相应方法:

func Test() {
	// 初始化参数
	body := alipay.TradeCreateBody{}
	body.OutTradeNo = "GYWX201910311240354444"
	body.SellerId = "2088102178986262"
	body.TotalAmount = 2.00
	body.Subject = "测试车场阿里支付-停车费"
	body.BuyerId = "2088102179285843"
	notifyUrl := "http://www.example.com"
	// 请求支付
	aliRsp, err := client.TradeCreate(body, notifyUrl)
	if err != nil {
		return
	}
	fmt.Printf("返回值: %+v\n", aliRsp)
}

注意事项:

  • 参数或返回值的类型,请查看接口对应的文件,里面有XXXBodyXXXResponse与之对应。
  • 参数或返回值中的常量,请参照constant.go文件。
  • 具体使用方法,请参照接口对应的测试文件。
接口列表

对应实现文件ap_xxx.go,测试文件ap_xxx_test.go

  • 支付API
    • 统一收单交易支付接口:(Client) TradePay,交易支付触发通知处理方法(Client) NotifyPay
    • 统一收单线下交易预创建:(Client) TradePrecreate
    • app支付接口2.0
    • 手机网站支付接口2.0
    • 统一收单下单并支付页面接口
    • 统一收单交易创建接口:(Client) TradeCreate
    • 统一收单线下交易查询:(Client) TradeQuery
    • 统一收单交易撤销接口:(Client) TradeCancel
    • 统一收单交易关闭接口:(Client) TradeClose
    • 统一收单交易退款接口:(Client) TradeRefund
    • 统一收单退款页面接口
    • 统一收单交易退款查询:(Client) TradeFastpayRefundQuery
    • 统一收单交易结算接口:(Client) TradeOrderSettle
    • 资金授权冻结接口
    • 支付宝订单信息同步接口:(Client) TradeOrderinfoSync
    • 订单咨询服务
    • 聚合支付订单咨询服务
    • 花呗先享会员结算申请
    • NFC用户卡信息同步
    • 广告投放数据查询
    • 航司电话订票待申请接口
    • 网商银行全渠道收单业务订单创建
    • 口碑订单预下单
    • 口碑商品交易购买接口
    • 口碑订单预咨询
    • 口碑商品交易退货接口
    • 口碑商品交易查询接口
    • 码商发码成功回调接口
    • 口碑凭证延期接口
    • 口碑凭证码查询
    • 口碑凭证码撤销核销
    • 统一收单交易退款接口
  • 会员API
  • 店铺API
  • 营销API
  • 生活号API
  • 芝麻信用API
  • 工具类API
    • 用户登陆授权
    • 换取授权访问令牌:(Client) SystemOauthToken
    • 换取应用授权令牌:(Client) OpenAuthTokenApp,授权URL生成方法GetOpenAuthTokenAppURL
    • 查询某个应用授权AppAuthToken的授权信息
    • 应用支付宝公钥证书下载
    • 验签接口
    • 订阅消息主题
    • 变更订阅关系属性
    • 查询消息订阅关系
    • 取消消息订阅关系
    • 上报线下服务异常
    • 口碑业务授权令牌查询
  • 风险控制API
  • 服务市场API
  • 账务API
  • 生活缴费API
  • 车主服务API
  • 数据服务API
  • 教育服务API
  • 卡券API
  • 广告API
  • 资金API
  • 地铁购票API
  • 电子发票API
  • 理财API
  • 开放生态API
  • 小程序API
  • 历史API
文档

Documentation

Index

Constants

View Source
const (

	// 请求格式
	FormatJson = "JSON" // Json格式

	// 编码格式
	CharSetUTF8 = "UTF-8" // UTF8

	// 签名算法类型
	SignTypeRSA  = "RSA"  // RSA签名
	SignTypeRSA2 = "RSA2" // RSA2签名

	// 版本号
	Version1 = "1.0" // 1.0版本

	// 授权类型
	GrantTypeAuthorizationCode = "authorization_code" // 用code获取
	GrantTypeRefreshToken      = "refresh_token"      // 用refresh_token获取

	// 货币类型
	FeeTypeCNY = "CNY" // 人民币

	// 回调通知类型
	NotifyTypeTradeStatusSync = "trade_status_sync" // 交易状态通知

	// 回调中的交易状态
	TradeStatusClosed       = "TRADE_CLOSED"   // 交易关闭
	TradeStatusFinished     = "TRADE_FINISHED" // 交易完结
	TradeStatusSuccess      = "TRADE_SUCCESS"  // 支付成功
	TradeStatusWaitBuyerPay = "WAIT_BUYER_PAY" // 交易创建

	TransInTypeCard  = "cardAliasNo" // 结算收款方的银行卡编号
	TransInTypeUser  = "userId"      // 表示是支付宝账号对应的支付宝唯一用户号
	TransInTypeLogin = "loginName"   // 表示是支付宝登录号

	TransOutTypeUser  = "userId"    // 表示是支付宝账号对应的支付宝唯一用户号
	TransOutTypeLogin = "loginName" // 表示是支付宝登录号

	LogisticsTypePost    = "POST"    // 平邮
	LogisticsTypeExpress = "EXPRESS" // 其他快递
	LogisticsTypeVirtual = "VIRTUAL" // 虚拟物品
	LogisticsTypeEms     = "EMS"     // EMS
	LogisticsTypeDirect  = "DIRECT"  // 无需物流

	SceneByBar  = "bar_code"  // 条码支付
	SceneByWave = "wave_code" // 声波支付

	AuthConfirmModeComplete    = "COMPLETE"     // 转交易支付完成结束预授权,解冻剩余金额
	AuthConfirmModeNotComplete = "NOT_COMPLETE" // 转交易支付完成不结束预授权,不解冻剩余金额

	RoyaltyTypeTransfer  = "transfer"  // 普通分账
	RoyaltyTypeReplenish = "replenish" // 补差

	BizTypeCreditAuth   = "CREDIT_AUTH"   // 信用授权场景下传
	BizTypeCreditDeduct = "CREDIT_DEDUCT" // 信用代扣场景下传

	OrderBizStatusComplete = "COMPLETE" // 同步用户已履约
	OrderBizStatusClosed   = "CLOSED"   // 同步履约已取消
	OrderBizStatusViolated = "VIOLATED" // 用户已违约

	ResponseCodeSuccess             = "10000" // 调用成功
	ResponseCodeServiceNotAvaliable = "20000" // 服务不可用
	ResponseCodeNotAuthrise         = "20001" // 授权权限不足
	ResponseCodeLessParameters      = "40001" // 缺少必选参数
	ResponseCodeInvalidParameters   = "40002" // 非法的参数
	ResponseCodeFailure             = "40004" // 业务处理失败
	ResponseCodePermissionDeny      = "40006" // 权限不足
)

Variables

This section is empty.

Functions

func GetOpenAuthTokenAppURL

func GetOpenAuthTokenAppURL(isProd bool, appId string, redirectUri string) (result string)

第三方应用授权URL https://opendocs.alipay.com/open/20160728150111277227/intro

func IsValidAuthCode

func IsValidAuthCode(authcode string) (ok bool)

25~30开头的长度为16~24位的数字,实际字符串长度以开发者获取的付款码长度为准

Types

type BodyMap

type BodyMap map[string]interface{}

type BusinessParam

type BusinessParam struct {
	CampusCard      string `json:"campus_card,omitempty"`       // 校园卡编号
	CardType        string `json:"card_type,omitempty"`         // 虚拟卡卡类型
	ActualOrderTime string `json:"actual_order_time,omitempty"` // 实际订单时间
}

type Client

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

func NewClient

func NewClient(isProd bool, publicKey string, privateKey string, config Config) (client *Client)

初始化支付宝客户端

func (Client) ConvertToBodyMap

func (Client) ConvertToBodyMap(params interface{}) (body BodyMap)

生成到BodyMap中

func (Client) FormatPrivateKey

func (c Client) FormatPrivateKey(privateKey string) string

将私钥字符串转换为RSA私钥格式

func (Client) FormatPublicKey

func (c Client) FormatPublicKey(publicKey string) string

将公钥字符串转换为RSA公钥格式

func (Client) FormatURLParam

func (Client) FormatURLParam(body BodyMap) string

格式化请求URL参数

func (Client) GenerateBizContent

func (Client) GenerateBizContent(body interface{}) string

生成业务字段

func (Client) NotifyPay

func (c Client) NotifyPay(bodyStr string) (params NotifyPayParams, origin map[string]interface{}, err error)

支付通知的处理

func (Client) OpenAuthTokenApp

func (c Client) OpenAuthTokenApp(body OpenAuthTokenAppBody) (aliRsp OpenAuthTokenAppResponse, err error)

换取应用授权令牌 https://opendocs.alipay.com/apis/api_9/alipay.open.auth.token.app

func (Client) SystemOauthToken

func (c Client) SystemOauthToken(body SystemOauthTokenBody) (aliRsp SystemOauthTokenResponse, err error)

换取授权访问令牌接口 https://docs.open.alipay.com/api_9/alipay.system.oauth.token

func (Client) TradeCancel

func (c Client) TradeCancel(body TradeCancelBody) (aliRsp TradeCancelResponse, err error)

统一收单交易撤销接口

func (Client) TradeClose

func (c Client) TradeClose(body TradeCloseBody) (aliRsp TradeCloseResponse, err error)

统一收单交易关闭接口

func (Client) TradeCreate

func (c Client) TradeCreate(body TradeCreateBody, notifyUrl string) (aliRsp TradeCreateResponse, err error)

统一收单交易创建接口,对应pay接口支付

func (Client) TradeFastpayRefundQuery

func (c Client) TradeFastpayRefundQuery(body TradeFastpayRefundQueryBody) (aliRsp TradeFastpayRefundQueryResponse, err error)

统一收单交易退款查询接口

func (Client) TradeOrderSettle

func (c Client) TradeOrderSettle(body TradeOrderSettleBody) (aliRsp TradeOrderSettleResponse, err error)

统一收单交易结算接口

func (Client) TradeOrderinfoSync

func (c Client) TradeOrderinfoSync(body TradeOrderinfoSyncBody) (aliRsp TradeOrderinfoSyncResponse, err error)

支付宝订单信息同步接口

func (Client) TradePay

func (c Client) TradePay(body TradePayBody) (aliRsp TradePayResponse, err error)

统一收单交易支付接口

func (Client) TradePrecreate

func (c Client) TradePrecreate(body TradePrecreateBody, notifyUrl string) (aliRsp TradePrecreateResponse, err error)

统一收单交易预创接口,支付动作在支付宝内完成,根据传入的通知地址异步通知服务商(推荐),

func (Client) TradeQuery

func (c Client) TradeQuery(body TradeQueryBody) (aliRsp TradeQueryResponse, err error)

统一收单线下交易查询接口

func (Client) TradeRefund

func (c Client) TradeRefund(body TradeRefundBody) (aliRsp TradeRefundResponse, err error)

统一收单交易退款接口

type Config

type Config struct {
	AppId        string `json:"app_id"`         // 支付宝分配给开发者的应用ID
	Format       string `json:"format"`         // (可不设置) 仅支持JSON
	Charset      string `json:"charset"`        // 请求使用的编码格式,如utf-8,gbk,gb2312等
	SignType     string `json:"sign_type"`      // 商户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用RSA2
	Version      string `json:"version"`        // (可不设置) 调用的接口版本,固定为:1.0
	AppAuthToken string `json:"app_auth_token"` // 应用授权,参见https://docs.open.alipay.com/common/105193
}

公共参数配置

type ExtendParam

type ExtendParam struct {
	ProviderId string `json:"sys_service_provider_id,omitempty"` // 系统商编号
	Reflux     string `json:"industry_reflux_info,omitempty"`    // 行业数据回流信息
	CardType   string `json:"card_type,omitempty"`               // 卡类型
}

type FundBillListInfo

type FundBillListInfo struct {
	FundChannel string `json:"fund_channel"`          // 交易使用的资金渠道
	BankCode    string `json:"bank_code,omitempty"`   // 银行卡支付时的银行代码
	Amount      string `json:"amount"`                // 该支付工具类型所使用的金额
	RealAmount  string `json:"real_amount,omitempty"` // 渠道实际付款金额
	FundType    string `json:"fund_type,omitempty"`   // 渠道所使用的资金类型
}

type Goods

type Goods struct {
	GoodsId        string  `json:"goods_id"`                  // 商品的编号
	GoodsName      string  `json:"goods_name"`                // 商品名称
	Quantity       int     `json:"quantity"`                  // 商品数量
	Price          float32 `json:"price"`                     // 商品单价,单位为元
	GoodsCategory  string  `json:"goods_category,omitempty"`  // 商品类目
	CategoriesTree string  `json:"categories_tree,omitempty"` // 商品类目树
	Body           string  `json:"body,omitempty"`            // 商品描述信息
	ShowUrl        string  `json:"show_url,omitempty"`        // 商品的展示地址
}

type Logistics

type Logistics struct {
	LogisticsType string `json:"logistics_type,omitempty"` // 物流类型(见constant定义)
}

type NotifyPayParams

type NotifyPayParams struct {
	// 通知参数
	NotifyType string `json:"notify_type"` // 通知类型,参见constant.go
	NotifyId   string `json:"notify_id"`   // 91722adff935e8cfa58b3aabf4dead6ibe
	NotifyTime string `json:"notify_time"` // 2017-02-16 21:46:15
	// 公共参数
	AppId     string `json:"app_id"`      // 应用ID
	AuthAppId string `json:"auth_app_id"` // 授权商户应用ID
	Chatset   string `json:"charset"`     // 字符集,参见constant.go
	Version   string `json:"version"`     // 接口版本,参见constant.go
	// 业务参数
	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"`   // 订单总金额
}

支付结果通知的参数

type OpenAuthTokenAppBody

type OpenAuthTokenAppBody struct {
	GrantType    string `json:"grant_type"`              // 参见constant.go。值为authorization_code时,代表用code换取;值为refresh_token时,代表用refresh_token换取
	Code         string `json:"code,omitempty"`          // 授权码,如果grant_type的值为authorization_code,该值必须填写
	RefreshToken string `json:"refresh_token,omitempty"` // 刷新令牌,如果grant_type值为refresh_token,该值不能为空
}

type OpenAuthTokenAppResponse

type OpenAuthTokenAppResponse struct {
	ResponseModel
	UserId          string `json:"user_id"`           // 授权商户的user_id
	AuthAppId       string `json:"auth_app_id"`       // 授权商户的appid
	AppAuthToken    string `json:"app_auth_token"`    // 应用授权令牌
	AppRefreshToken string `json:"app_refresh_token"` // 刷新令牌
	ExpiresIn       int64  `json:"expires_in"`        // 应用授权令牌的有效时间(从接口调用时间作为起始时间),单位到秒
	ReExpiresIn     int64  `json:"re_expires_in"`     // 刷新令牌的有效时间(从接口调用时间作为起始时间),单位到秒
}

type OpenAuthTokenAppResponseModel

type OpenAuthTokenAppResponseModel struct {
	Data OpenAuthTokenAppResponse `json:"alipay_open_auth_token_app_response"` // 返回值信息
	Sign string                   `json:"sign"`                                // 签名,参见https://docs.open.alipay.com/291/106074
}

type PresetPayToolInfo

type PresetPayToolInfo struct {
	Amount         []string `json:"amount"`           // 前置资产金额
	AssertTypeCode string   `json:"assert_type_code"` // 前置资产类型编码

}

type PromoParam

type PromoParam struct {
	ActualOrderTime string `json:"actual_order_time,omitempty"` // 存在延迟扣款这一类的场景,用这个时间表明用户发生交易的时间
}

type ReceiverAddress

type ReceiverAddress struct {
	Name         string `json:"name,omitempty"`          // 收货人的姓名
	Address      string `json:"address,omitempty"`       // 收货地址
	Mobile       string `json:"mobile,omitempty"`        // 收货人手机号
	Zip          string `json:"zip,omitempty"`           // 收货地址邮编
	DivisionCode string `json:"division_code,omitempty"` // 中国标准城市区域码
}

type RefundRoyaltyInfo

type RefundRoyaltyInfo struct {
	RefundAmount string `json:"refund_amount"`             // 退分账金额
	RoyaltyType  string `json:"royalty_type,omitempty"`    // 分账类型
	ResultCode   string `json:"result_code"`               // 退分账结果码
	TransOut     string `json:"trans_out,omitempty"`       // 转出人支付宝账号对应用户ID
	TransOutType string `json:"trans_out_email,omitempty"` // 转出人支付宝账号
	TransIn      string `json:"trans_in,omitempty"`        // 转入人支付宝账号对应用户ID
	TransInType  string `json:"trans_in_email,omitempty"`  // 转入人支付宝账号
}

type ResponseModel

type ResponseModel struct {
	Code    string `json:"code"`               // 网关返回码,参见https://docs.open.alipay.com/common/105806
	Msg     string `json:"msg"`                // 网关返回码描述,参见https://docs.open.alipay.com/common/105806
	SubCode string `json:"sub_code,omitempty"` // 业务返回码,参见具体的API接口文档
	SubMsg  string `json:"sub_msg,omitempty"`  // 业务返回码描述,参见具体的API接口文档
}

公共响应参数

type RoyaltyParameter

type RoyaltyParameter struct {
	RoyaltyType      string  `json:"royalty_type,omitempty"`      // 分账类型
	TransOut         string  `json:"trans_out,omitempty"`         // 支出方账户
	TransOutType     string  `json:"trans_out_type,omitempty"`    // 支出方账户类型
	TransInType      string  `json:"trans_in_type,omitempty"`     // 收入方账户类型
	TransIn          string  `json:"trans_in"`                    // 分账类型
	Amount           float32 `json:"amount,omitempty"`            // 分账的金额
	AmountPercentage int     `json:"amount_percentage,omitempty"` // 分账信息中分账百分比,取值范围为大于0,少于或等于100的整数。
	Desc             string  `json:"desc,omitempty"`              // 分账描述
}

type Settle

type Settle struct {
	SettleDetailInfos []SettleDetail `json:"settle_detail_infos"`     // 结算详细信息
	MerchantType      string         `json:"merchant_type,omitempty"` // 商户id类型
}

type SettleDetail

type SettleDetail struct {
	TransInType      string  `json:"trans_in_type"`                // 结算收款方的账户类型(见constant定义)
	TransIn          string  `json:"trans_in"`                     // 结算收款方
	SummaryDimension string  `json:"summary_dimension,omitempty"`  // 结算汇总维度
	SettleEntityId   string  `json:"settle_entity_id,omitempty"`   // 结算主体标识
	SettleEntityType string  `json:"settle_entity_type,omitempty"` // 结算主体类型
	Amount           float32 `json:"amount"`                       // 结算的金额,单位为元。目前必须和交易金额相同
}

type SystemOauthTokenBody

type SystemOauthTokenBody struct {
	GrantType    string `json:"grant_type"`              // 参见constant.go。值为authorization_code时,代表用code换取;值为refresh_token时,代表用refresh_token换取
	Code         string `json:"code,omitempty"`          // 授权码,用户对应用授权后得到。
	RefreshToken string `json:"refresh_token,omitempty"` // 刷新令牌,上次换取访问令牌时得到。见出参的refresh_token字段
}

type SystemOauthTokenData

type SystemOauthTokenData struct {
	UserId       string `json:"user_id"`       // 支付宝用户的唯一userId,2088102150477652
	AccessToken  string `json:"access_token"`  // 访问令牌。通过该令牌调用需要授权类接口,20120823ac6ffaa4d2d84e7384bf983531473993
	ExpiresIn    int64  `json:"expires_in"`    // 访问令牌的有效时间,单位是秒。3600
	RefreshToken string `json:"refresh_token"` // 刷新令牌。通过该令牌可以刷新access_token,20120823ac6ffdsdf2d84e7384bf983531473993
	ReExpiresIn  int64  `json:"re_expires_in"` // 刷新令牌的有效时间,单位是秒。3600
}

type SystemOauthTokenResponse

type SystemOauthTokenResponse struct {
	Error ResponseModel        `json:"error_response,omitempty"`
	Data  SystemOauthTokenData `json:"alipay_system_oauth_token_response"` // 返回值信息
}

type SystemOauthTokenResponseModel

type SystemOauthTokenResponseModel struct {
	SystemOauthTokenResponse
	Sign string `json:"sign"` // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeCancelBody

type TradeCancelBody struct {
	OutTradeNo string `json:"out_trade_no,omitempty"` // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	TradeNo    string `json:"trade_no,omitempty"`     // 支付宝交易号,和商户订单号不能同时为空
}

type TradeCancelResponse

type TradeCancelResponse struct {
	ResponseModel
	// 响应参数
	TradeNo            string `json:"trade_no"`                       // 支付宝交易号
	OutTradeNo         string `json:"out_trade_no"`                   // 商户订单号
	RetryFlag          string `json:"retry_flag"`                     // 是否需要重试
	Action             string `json:"action"`                         // 本次撤销触发的交易动作
	GmtRefundPay       string `json:"gmt_refund_pay,omitempty"`       // 返回的退款时间
	RefundSettlementId string `json:"refund_settlement_id,omitempty"` // 返回的退款清算编号
}

type TradeCancelResponseModel

type TradeCancelResponseModel struct {
	Data TradeCancelResponse `json:"alipay_trade_cancel_response"` // 返回值信息
	Sign string              `json:"sign"`                         // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeCloseBody

type TradeCloseBody struct {
	OutTradeNo string `json:"out_trade_no,omitempty"` // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	TradeNo    string `json:"trade_no,omitempty"`     // 支付宝交易号,和商户订单号不能同时为空
	OperatorId string `json:"operator_id,omitempty"`  // 卖家端自定义的的操作员 ID
}

type TradeCloseResponse

type TradeCloseResponse struct {
	ResponseModel
	// 响应参数
	TradeNo    string `json:"trade_no"`     // 支付宝交易号
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
}

type TradeCloseResponseModel

type TradeCloseResponseModel struct {
	Data TradeCloseResponse `json:"alipay_trade_close_response"` // 返回值信息
	Sign string             `json:"sign"`                        // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeCreateBody

type TradeCreateBody struct {
	OutTradeNo          string           `json:"out_trade_no"`                    // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	SellerId            string           `json:"seller_id,omitempty"`             // 卖家支付宝用户ID。如果该值为空,则默认为商户签约账号对应的支付宝用户ID
	TotalAmount         float32          `json:"total_amount"`                    // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	DiscountAmount      float32          `json:"discountable_amount,omitempty"`   // 可打折金额
	Subject             string           `json:"subject"`                         // 订单标题
	Body                string           `json:"body,omitempty"`                  // 对交易或商品的描述
	BuyerId             string           `json:"buyer_id,omitempty"`              // 买家的支付宝唯一用户号
	GoodsDetail         []Goods          `json:"goods_detail,omitempty"`          // 订单包含的商品列表信息
	ProductCode         string           `json:"product_code,omitempty"`          // 销售产品码
	OperatorId          string           `json:"operator_id,omitempty"`           // 商户操作员编号
	StoreId             string           `json:"store_id,omitempty"`              // 商户门店编号
	TerminalId          string           `json:"terminal_id,omitempty"`           // 商户机具终端编号
	ExtendParams        *ExtendParam     `json:"extend_params,omitempty"`         // 业务扩展参数
	TimeoutExpress      string           `json:"timeout_express,omitempty"`       // 该笔订单允许的最晚付款时间,逾期将关闭交易
	SettleInfo          *Settle          `json:"settle_info,omitempty"`           // 描述结算信息
	LogisticsDetail     *Logistics       `json:"logistics_detail,omitempty"`      // 物流信息
	BusinessParams      *BusinessParam   `json:"business_params,omitempty"`       // 商户传入业务信息
	ReceiverAddressInfo *ReceiverAddress `json:"receiver_address_info,omitempty"` // 收货人及地址信息
}

type TradeCreateResponse

type TradeCreateResponse struct {
	ResponseModel
	// 响应参数
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
	TradeNo    string `json:"trade_no"`     // 支付宝交易号
}

type TradeCreateResponseModel

type TradeCreateResponseModel struct {
	Data TradeCreateResponse `json:"alipay_trade_create_response"` // 返回值信息
	Sign string              `json:"sign"`                         // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeFastpayRefundQueryBody

type TradeFastpayRefundQueryBody struct {
	TradeNo      string `json:"trade_no,omitempty"`     // 支付宝订单号
	OutTradeNo   string `json:"out_trade_no,omitempty"` // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	OutRequestNo string `json:"out_request_no"`         // 标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传
	OrgPId       string `json:"org_pid,omitempty"`      // 退款的交易所属收单机构的pid
}

type TradeFastpayRefundQueryResponse

type TradeFastpayRefundQueryResponse struct {
	ResponseModel
	// 响应参数
	TradeNo               string              `json:"trade_no,omitempty"`                        // 支付宝交易号
	OutTradeNo            string              `json:"out_trade_no,omitempty"`                    // 商户订单号
	OutRequestNo          string              `json:"out_request_no,omitempty"`                  // 标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传
	RefundReason          string              `json:"refund_reason,omitempty"`                   // 退款的原因说明
	TotalAmount           string              `json:"total_amount,omitempty"`                    // 订单总金额
	RefundAmount          string              `json:"refund_amount,omitempty"`                   // 退款总金额
	RefundRoyaltys        []RefundRoyaltyInfo `json:"refund_royaltys,omitempty"`                 // 退分账明细信息
	GmtRefundPay          string              `json:"gmt_refund_pay,omitempty"`                  // 退款支付时间
	FundBillList          []FundBillListInfo  `json:"refund_detail_item_list,omitempty"`         // 退款使用的资金渠道
	SendbackFee           string              `json:"send_back_fee,omitempty"`                   // 本次商户实际退回金额
	RefundSettlementId    string              `json:"refund_settlement_id,omitempty"`            // 支付清算编号
	RefundBuyerAmount     string              `json:"present_refund_buyer_amount,omitempty"`     // 本次退款金额中买家退款金额
	RefundDiscountAmount  string              `json:"present_refund_discount_amount,omitempty"`  // 本次退款金额中平台优惠退款金额
	RefundMdiscountAmount string              `json:"present_refund_mdiscount_amount,omitempty"` // 本次退款金额中商家优惠退款金额
}

type TradeFastpayRefundQueryResponseModel

type TradeFastpayRefundQueryResponseModel struct {
	Data TradeFastpayRefundQueryResponse `json:"alipay_trade_fastpay_refund_query_response"` // 返回值信息
	Sign string                          `json:"sign"`                                       // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeOrderSettleBody

type TradeOrderSettleBody struct {
	OutRequestNo      string             `json:"out_request_no"`        // 结算请求流水号
	TradeNo           string             `json:"trade_no"`              // 支付宝订单号
	RoyaltyParameters []RoyaltyParameter `json:"royalty_parameters"`    // 分账明细信息
	OperatorId        string             `json:"operator_id,omitempty"` // 商户操作员编号
}

type TradeOrderSettleResponse

type TradeOrderSettleResponse struct {
	ResponseModel
	// 响应参数
	TradeNo string `json:"trade_no"` // 支付宝交易号
}

type TradeOrderSettleResponseModel

type TradeOrderSettleResponseModel struct {
	Data TradeOrderSettleResponse `json:"alipay_trade_order_settle_response"` // 返回值信息
	Sign string                   `json:"sign"`                               // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeOrderinfoSyncBody

type TradeOrderinfoSyncBody struct {
	TradeNo       string `json:"trade_no"`                  // 支付宝订单号
	OrigRequestNo string `json:"orig_request_no,omitempty"` // 原始业务请求单号
	OutRequestNo  string `json:"out_request_no"`            // 标识一笔交易多次请求,同一笔交易多次信息同步时需要保证唯一
	BizType       string `json:"biz_type"`                  // 交易信息同步对应的业务类型
	OrderBizInfo  string `json:"order_biz_info,omitempty"`  // 商户传入同步信息
}

type TradeOrderinfoSyncResponse

type TradeOrderinfoSyncResponse struct {
	ResponseModel
	// 响应参数
	TradeNo     string `json:"trade_no"`               // 支付宝交易号
	OutTradeNo  string `json:"out_trade_no,omitempty"` // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	BuyerUserId string `json:"buyer_user_id"`          // 买家在支付宝的用户id
}

type TradeOrderinfoSyncResponseModel

type TradeOrderinfoSyncResponseModel struct {
	Data TradeOrderinfoSyncResponse `json:"alipay_trade_orderinfo_sync_response"` // 返回值信息
	Sign string                     `json:"sign"`                                 // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradePayBody

type TradePayBody struct {
	OutTradeNo         string       `json:"out_trade_no"`                   // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	Scene              string       `json:"scene"`                          // 支付场景
	AuthCode           string       `json:"auth_code"`                      // 支付授权码
	ProductCode        string       `json:"product_code,omitempty"`         // 销售产品码
	Subject            string       `json:"subject"`                        // 订单标题
	BuyerId            string       `json:"buyer_id,omitempty"`             // 买家的支付宝唯一用户号
	SellerId           string       `json:"seller_id,omitempty"`            // 卖家支付宝用户ID。如果该值为空,则默认为商户签约账号对应的支付宝用户ID
	TotalAmount        float32      `json:"total_amount,omitempty"`         // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	TransCurrency      string       `json:"trans_currency,omitempty"`       // 标价币种
	SettleCurrency     string       `json:"settle_currency,omitempty"`      // 订单结算币种
	DiscountAmount     float32      `json:"discountable_amount,omitempty"`  // 可打折金额
	Body               string       `json:"body,omitempty"`                 // 对交易或商品的描述
	GoodsDetail        *[]Goods     `json:"goods_detail,omitempty"`         // 订单包含的商品列表信息
	OperatorId         string       `json:"operator_id,omitempty"`          // 商户操作员编号
	StoreId            string       `json:"store_id,omitempty"`             // 商户门店编号
	TerminalId         string       `json:"terminal_id,omitempty"`          // 商户机具终端编号
	ExtendParams       *ExtendParam `json:"extend_params,omitempty"`        // 业务扩展参数
	TimeoutExpress     string       `json:"timeout_express,omitempty"`      // 该笔订单允许的最晚付款时间,逾期将关闭交易
	AuthConfirmMode    string       `json:"auth_confirm_mode,omitempty"`    // 预授权确认模式
	TerminalParams     string       `json:"terminal_params,omitempty"`      // 商户传入终端设备相关信息
	PromoParams        *PromoParam  `json:"promo_params,omitempty"`         // 优惠明细参数
	AdvancePaymentType string       `json:"advance_payment_type,omitempty"` // 支付模式类型
}

type TradePayResponse

type TradePayResponse struct {
	ResponseModel
	// 响应参数
	TradeNo             string              `json:"trade_no"`                        // 支付宝交易号
	OutTradeNo          string              `json:"out_trade_no"`                    // 商户订单号
	BuyerLogonId        string              `json:"buyer_logon_id"`                  // 买家支付宝账号
	SettleAmount        string              `json:"settle_amount,omitempty"`         // 结算币种订单金额
	PayCurrency         string              `json:"pay_currency,omitempty"`          // 订单支付币种
	PayAmount           string              `json:"pay_amount,omitempty"`            // 支付币种订单金额
	SettleTransRate     string              `json:"settle_trans_rate,omitempty"`     // 结算币种兑换标价币种汇率
	TransPayRate        string              `json:"trans_pay_rate,omitempty"`        // 标价币种兑换支付币种汇率
	TotalAmount         string              `json:"total_amount"`                    // 订单总金额
	TransCurrency       string              `json:"trans_currency,omitempty"`        // 标价币种
	SettleCurrency      string              `json:"settle_currency,omitempty"`       // 订单结算币种
	ReceiptAmount       string              `json:"receipt_amount"`                  // 实收金额
	BuyerPayAmount      string              `json:"buyer_pay_amount,omitempty"`      // 买家实付金额
	PointAmount         string              `json:"point_amount,omitempty"`          // 积分支付的金额
	InvoiceAmount       string              `json:"invoice_amount,omitempty"`        // 可开具发票的金额
	GmtPayment          string              `json:"gmt_payment"`                     // 交易支付时间
	FundBillList        *[]FundBillListInfo `json:"fund_bill_list"`                  // 交易支付使用的资金渠道
	CardBalance         string              `json:"card_balance,omitempty"`          // 支付宝卡余额
	StoreName           string              `json:"store_name,omitempty"`            // 请求交易支付中的商户店铺的名称
	BuyerUserId         string              `json:"buyer_user_id"`                   // 买家在支付宝的用户id
	DiscountGoodsDetail string              `json:"discount_goods_detail,omitempty"` // 本次交易支付所使用的单品券优惠的商品优惠信息
	VoucherDetailList   *[]VoucherDetail    `json:"voucher_detail_list,omitempty"`   // 本交易支付时使用的所有优惠券信息
	AdvanceAmount       string              `json:"advance_amount,omitempty"`        // 先享后付2.0垫资金额
	AuthTradePayMode    string              `json:"auth_trade_pay_mode,omitempty"`   // 预授权支付模式
	ChargeAmount        string              `json:"charge_amount,omitempty"`         // 该笔交易针对收款方的收费金额
	ChargeFlags         string              `json:"charge_flags,omitempty"`          // 费率活动标识
	SettlementId        string              `json:"settlement_id,omitempty"`         // 支付清算编号
	BusinessParams      string              `json:"business_params,omitempty"`       // 商户传入业务信息
	BuyerUserType       string              `json:"buyer_user_type,omitempty"`       // 买家用户类型
	MdiscountAmount     string              `json:"mdiscount_amount,omitempty"`      // 商家优惠金额
	DiscountAmount      string              `json:"discount_amount,omitempty"`       // 平台优惠金额
	BuyerUserName       string              `json:"buyer_user_name,omitempty"`       // 买家为个人用户时为买家姓名,买家为企业用户时为企业名称
}

type TradePayResponseModel

type TradePayResponseModel struct {
	Data TradePayResponse `json:"alipay_trade_pay_response"` // 返回值信息
	Sign string           `json:"sign"`                      // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradePrecreateBody

type TradePrecreateBody struct {
	OutTradeNo           string         `json:"out_trade_no"`                      // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	SellerId             string         `json:"seller_id,omitempty"`               // 卖家支付宝用户ID。如果该值为空,则默认为商户签约账号对应的支付宝用户ID
	TotalAmount          float32        `json:"total_amount"`                      // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
	DiscountAmount       float32        `json:"discountable_amount,omitempty"`     // 可打折金额
	Subject              string         `json:"subject"`                           // 订单标题
	GoodsDetail          []Goods        `json:"goods_detail,omitempty"`            // 订单包含的商品列表信息
	Body                 string         `json:"body,omitempty"`                    // 对交易或商品的描述
	ProductCode          string         `json:"product_code,omitempty"`            // 销售产品码
	OperatorId           string         `json:"operator_id,omitempty"`             // 商户操作员编号
	StoreId              string         `json:"store_id,omitempty"`                // 商户门店编号
	DisablePayChannels   string         `json:"disable_pay_channels,omitempty"`    // 禁用渠道
	EnablePayChannels    string         `json:"enable_pay_channels,omitempty"`     // 可用渠道
	TerminalId           string         `json:"terminal_id,omitempty"`             // 商户机具终端编号
	ExtendParams         *ExtendParam   `json:"extend_params,omitempty"`           // 业务扩展参数
	TimeoutExpress       string         `json:"timeout_express,omitempty"`         // 该笔订单允许的最晚付款时间,逾期将关闭交易
	SettleInfo           *Settle        `json:"settle_info,omitempty"`             // 描述结算信息
	MerchantOrderNo      string         `json:"merchant_order_no,omitempty"`       // 商户原始订单号
	BusinessParams       *BusinessParam `json:"business_params,omitempty"`         // 商户传入业务信息
	QrCodeTimeoutExpress string         `json:"qr_code_timeout_express,omitempty"` // 该笔订单允许的最晚付款时间
}

type TradePrecreateResponse

type TradePrecreateResponse struct {
	ResponseModel
	// 响应参数
	OutTradeNo string `json:"out_trade_no"` // 商户订单号
	QrCode     string `json:"qr_code"`      // 当前预下单请求生成的二维码码串
}

type TradePrecreateResponseModel

type TradePrecreateResponseModel struct {
	Data TradePrecreateResponse `json:"alipay_trade_precreate_response"` // 返回值信息
	Sign string                 `json:"sign"`                            // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeQueryBody

type TradeQueryBody struct {
	OutTradeNo   string   `json:"out_trade_no,omitempty"`  // 商户订单号
	TradeNo      string   `json:"trade_no,omitempty"`      // 支付宝交易号,和商户订单号不能同时为空
	OrgPid       string   `json:"org_pid,omitempty"`       // 交易所属收单机构的pid
	QueryOptions []string `json:"query_options,omitempty"` // 查询选项,定制查询返回信息
}

type TradeQueryResponse

type TradeQueryResponse struct {
	ResponseModel
	// 响应参数
	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"`                     // 订单总金额
	TransCurrency    string              `json:"trans_currency,omitempty"`         // 标价币种
	SettleCurrency   string              `json:"settle_currency,omitempty"`        // 订单结算币种
	SettleAmount     string              `json:"settle_amount,omitempty"`          // 结算币种订单金额
	PayCurrency      string              `json:"pay_currency,omitempty"`           // 订单支付币种
	PayAmount        string              `json:"pay_amount,omitempty"`             // 支付币种订单金额
	SettleTransRate  string              `json:"settle_trans_rate,omitempty"`      // 结算币种兑换标价币种汇率
	TransPayRate     string              `json:"trans_pay_rate,omitempty"`         // 标价币种兑换支付币种汇率
	BuyerPayAmount   string              `json:"buyer_pay_amount,omitempty"`       // 买家实付金额
	PointAmount      string              `json:"point_amount,omitempty"`           // 积分支付的金额
	InvoiceAmount    string              `json:"invoice_amount,omitempty"`         // 可开具发票的金额
	SendPayDate      string              `json:"send_pay_date,omitempty"`          // 本次交易打款给卖家的时间
	ReceiptAmount    string              `json:"receipt_amount,omitempty"`         // 实收金额
	StoreId          string              `json:"store_id,omitempty"`               // 商户门店编号
	TerminalId       string              `json:"terminal_id,omitempty"`            // 商户机具终端编号
	FundBillList     *[]FundBillListInfo `json:"fund_bill_list"`                   // 交易支付使用的资金渠道
	StoreName        string              `json:"store_name,omitempty"`             // 请求交易支付中的商户店铺的名称
	BuyerUserId      string              `json:"buyer_user_id"`                    // 买家在支付宝的用户id
	ChargeAmount     string              `json:"charge_amount,omitempty"`          // 该笔交易针对收款方的收费金额
	ChargeFlags      string              `json:"charge_flags,omitempty"`           // 费率活动标识
	SettlementId     string              `json:"settlement_id,omitempty"`          // 支付清算编号
	TradeSettle      *TradeSettleInfo    `json:"trade_settle_info,omitempty"`      // 返回的交易结算信息
	AuthTradePayMode string              `json:"auth_trade_pay_mode,omitempty"`    // 预授权支付模式
	BuyerUserType    string              `json:"buyer_user_type,omitempty"`        // 买家用户类型
	MdiscountAmount  string              `json:"mdiscount_amount,omitempty"`       // 商家优惠金额
	DiscountAmount   string              `json:"discount_amount,omitempty"`        // 平台优惠金额
	BuyerUserName    string              `json:"buyer_user_name,omitempty"`        // 买家为个人用户时为买家姓名,买家为企业用户时为企业名称
	Subject          string              `json:"subject,omitempty"`                // 订单标题
	Body             string              `json:"body,omitempty"`                   // 订单描述
	SubMerchantId    string              `json:"alipay_sub_merchant_id,omitempty"` // 间连商户在支付宝端的商户编号
	ExtInfos         string              `json:"ext_infos,omitempty"`              // 交易额外信息
}

type TradeQueryResponseModel

type TradeQueryResponseModel struct {
	Data TradeQueryResponse `json:"alipay_trade_query_response"` // 返回值信息
	Sign string             `json:"sign"`                        // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeRefundBody

type TradeRefundBody struct {
	OutTradeNo              string             `json:"out_trade_no,omitempty"`              // 商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复
	TradeNo                 string             `json:"trade_no,omitempty"`                  // 支付宝订单号
	RefundAmount            float32            `json:"refund_amount"`                       // 退款金额
	RefundCurrency          string             `json:"refund_currency,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"`               // 商户机具终端编号
	GoodsDetail             []Goods            `json:"goods_detail,omitempty"`              // 退款包含的商品列表信息
	RefundRoyaltyParameters []RoyaltyParameter `json:"refund_royalty_parameters,omitempty"` // 退分账明细信息
	OrgPId                  string             `json:"org_pid,omitempty"`                   // 退款的交易所属收单机构的pid
}

type TradeRefundResponse

type TradeRefundResponse struct {
	ResponseModel
	// 响应参数
	TradeNo               string             `json:"trade_no"`                                  // 支付宝交易号
	OutTradeNo            string             `json:"out_trade_no"`                              // 商户订单号
	BuyerLogonId          string             `json:"buyer_logon_id"`                            // 买家支付宝账号
	FundChange            string             `json:"fund_change"`                               // 本次退款是否发生了资金变化
	RefundFee             string             `json:"refund_fee"`                                // 退款总金额
	RefundCurrency        string             `json:"refund_currency,omitempty"`                 // 退款币种信息
	GmtRefundPay          string             `json:"gmt_refund_pay"`                            // 退款支付时间
	FundBillList          []FundBillListInfo `json:"refund_detail_item_list,omitempty"`         // 退款使用的资金渠道
	StoreName             string             `json:"store_name,omitempty"`                      // 请求交易支付中的商户店铺的名称
	BuyerUserId           string             `json:"buyer_user_id"`                             // 买家在支付宝的用户id
	RefundPaytoolList     *PresetPayToolInfo `json:"refund_preset_paytool_list,omitempty"`      // 退回的前置资产列表
	RefundSettlementId    string             `json:"refund_settlement_id,omitempty"`            // 支付清算编号
	RefundBuyerAmount     string             `json:"present_refund_buyer_amount,omitempty"`     // 本次退款金额中买家退款金额
	RefundDiscountAmount  string             `json:"present_refund_discount_amount,omitempty"`  // 本次退款金额中平台优惠退款金额
	RefundMdiscountAmount string             `json:"present_refund_mdiscount_amount,omitempty"` // 本次退款金额中商家优惠退款金额
}

type TradeRefundResponseModel

type TradeRefundResponseModel struct {
	Data TradeRefundResponse `json:"alipay_trade_refund_response"` // 返回值信息
	Sign string              `json:"sign"`                         // 签名,参见https://docs.open.alipay.com/291/106074
}

type TradeSettleDetail

type TradeSettleDetail struct {
	OperationType     string  `json:"operation_type"`                // 结算操作类型
	OperationSerialNo string  `json:"operation_serial_no,omitempty"` // 商户操作序列号
	OperationDate     string  `json:"operation_dt"`                  // 操作日期
	TransOut          string  `json:"trans_out,omitempty"`           // 转出账号
	TransIn           string  `json:"trans_in,omitempty"`            // 转入账号
	Amount            float32 `json:"amount"`                        // 实际操作金额
}

type TradeSettleInfo

type TradeSettleInfo struct {
	TradeSettleDetailList []TradeSettleDetail `json:"trade_settle_detail_list,omitempty"` // 交易结算明细信息
}

type VoucherDetail

type VoucherDetail struct {
	Id                         string `json:"id"`                                     // 券id
	Name                       string `json:"name"`                                   // 券名称
	Type                       string `json:"type"`                                   // 券类型
	Amount                     string `json:"amount"`                                 // 优惠券面额
	MerchantContribute         string `json:"merchant_contribute,omitempty"`          // 商家出资金额
	OtherContribute            string `json:"other_contribute,omitempty"`             // 其他出资方出资金额
	Memo                       string `json:"memo,omitempty"`                         // 优惠券备注信息
	TemplateId                 string `json:"template_id,omitempty"`                  // 券模板id
	PurchaseBuyerContribute    string `json:"purchase_buyer_contribute,omitempty"`    // 用户实际付款的金额
	PurchaseMerchantContribute string `json:"purchase_merchant_contribute,omitempty"` // 商户优惠的金额
	PurchaseMAntContribute     string `json:"purchase_ant_contribute,omitempty"`      // 平台优惠的金额
}

Jump to

Keyboard shortcuts

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