Documentation
¶
Index ¶
- Variables
- type AuxParam
- type BKAgentRespInfo
- type BuyerInfo
- type ChargeInfo
- type Client
- func (c *Client) CreateQrcode(param CreateQrcode) (result *CreateQrcodeRsp, err error)
- func (c *Client) DecodePhoneNumber(data []byte) (result *MobileNumber, err error)
- func (c *Client) LoadAlipayCertPublicKey(s string) (err error)
- func (c *Client) LoadOptionFunc(opts ...OptionFunc)
- func (c *Client) MerchantFileUpload(param MerchantFileUpload) (result *MerchantFileUploadRsp, err error)
- func (c *Client) OnReceivedData(fn func(method string, data []byte))
- func (c *Client) OrderPush(param OrderPush) (result *OrderPushRsp, err error)
- func (c *Client) Request(payload *Payload, result interface{}) (err error)
- func (c *Client) SetEncryptKey(key string) error
- func (c *Client) SystemOauthToken(param SystemOauthToken) (result *SystemOauthTokenRsp, err error)
- func (c *Client) TradeAppPay(param TradeAppPay) (result string, err error)
- func (c *Client) TradeCreate(param TradeCreate) (result *TradeCreateRsp, err error)
- func (c *Client) TradeFastPayRefundQuery(param TradeFastPayRefundQuery) (result *TradeFastPayRefundQueryRsp, err error)
- func (c *Client) TradePagePay(param TradePagePay) (result *url.URL, err error)
- func (c *Client) TradeQuery(param TradeQuery) (result *TradeQueryRsp, err error)
- func (c *Client) TradeRefund(param TradeRefund) (result *TradeRefundRsp, err error)
- func (c *Client) TradeWapPay(param TradeWapPay) (result *url.URL, err error)
- func (c *Client) URLValues(param Param) (value url.Values, err error)
- func (c *Client) UserInfoShare(param UserInfoShare) (result *UserInfoShareRsp, err error)
- func (c *Client) Verify(signContent, sign []byte) (err error)
- type Code
- type CreateQrcode
- type CreateQrcodeRsp
- type DepositBackInfo
- type DiscountInfo
- type Error
- type ExtInfo
- type FundBill
- type GoodsDetailItem
- type HBFQPayInfo
- type ItemOrder
- type JourneyOrder
- type LogisticsInfo
- type MerchantFileUpload
- type MerchantFileUploadRsp
- type MobileNumber
- type OptionFunc
- type OrderPush
- type OrderPushRsp
- type Param
- type Payload
- func (p *Payload) APIName() string
- func (p *Payload) AddBizField(key string, value interface{}) *Payload
- func (p *Payload) AddParam(key, value string) *Payload
- func (p *Payload) MarshalJSON() ([]byte, error)
- func (p *Payload) NeedEncrypt() bool
- func (p *Payload) NeedVerify() bool
- func (p *Payload) Params() map[string]string
- type RefundChargeInfo
- type RefundRoyalty
- type RefundRoyaltyParameter
- type RefundSubFeeDetail
- type ShopInfo
- type SubFeeDetail
- type SystemOauthToken
- type SystemOauthTokenRsp
- type Trade
- type TradeAppPay
- type TradeCreate
- type TradeCreateRsp
- type TradeFastPayRefundQuery
- type TradeFastPayRefundQueryRsp
- type TradeFundBill
- type TradePagePay
- type TradeQuery
- type TradeQueryRsp
- type TradeRefund
- type TradeRefundRsp
- type TradeSettleDetail
- type TradeSettleInfo
- type TradeStatus
- type TradeWapPay
- type UserInfoShare
- type UserInfoShareRsp
- type VoucherDetail
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BKAgentRespInfo ¶
type BuyerInfo ¶
type BuyerInfo struct { Name string `json:"name,omitempty"` // 姓名 Mobile string `json:"mobile,omitempty"` // 手机号 CertType string `json:"cert_type,omitempty"` // 证件类型。身份证: IDENTITY_CARD 户口本: HOKOU 护照: PASSPORT 军官证: OFFICER_CARD 士兵证: SOLDIER_CARD CertNo string `json:"cert_no,omitempty"` // 证件号 UserId string `json:"user_id,omitempty"` // 支付宝uid ExtInfo []ExtInfo `json:"ext_info,omitempty"` // 扩展信息 }
买家信息
type ChargeInfo ¶
type ChargeInfo struct { ChargeFee string `json:"charge_fee"` OriginalChargeFee string `json:"original_charge_fee"` SwitchFeeRate string `json:"switch_fee_rate"` IsRatingOnTradeReceiver string `json:"is_rating_on_trade_receiver"` IsRatingOnSwitch string `json:"is_rating_on_switch"` ChargeType string `json:"charge_type"` SubFeeDetailList []*SubFeeDetail `json:"sub_fee_detail_list"` }
type Client ¶
func New ¶
func New(appId, privateKey string, isProduction bool, opts ...OptionFunc) (nClient *Client, err error)
初始化客户端
func (*Client) CreateQrcode ¶
func (c *Client) CreateQrcode(param CreateQrcode) (result *CreateQrcodeRsp, err error)
CreateQrcode 小程序生成推广二维码接口 https://opendocs.alipay.com/mini/a25c5d8f_alipay.open.app.qrcode.create?scene=common&pathHash=2334bbff
func (*Client) DecodePhoneNumber ¶
func (c *Client) DecodePhoneNumber(data []byte) (result *MobileNumber, err error)
DecodePhoneNumber 小程序获取会员手机号 https://opendocs.alipay.com/mini/api/getphonenumber 本方法用于解码小程序端 my.getPhoneNumber 获取的数据
func (*Client) LoadAlipayCertPublicKey ¶
加载支付宝公钥
func (*Client) MerchantFileUpload ¶
func (c *Client) MerchantFileUpload(param MerchantFileUpload) (result *MerchantFileUploadRsp, err error)
MerchantFileUpload 商品文件上传接口 https://opendocs.alipay.com/mini/510d4a72_alipay.merchant.item.file.upload?scene=common&pathHash=c08922b1
func (*Client) OnReceivedData ¶
func (*Client) OrderPush ¶
func (c *Client) OrderPush(param OrderPush) (result *OrderPushRsp, err error)
OrderPush 订单数据同步接口 https://opendocs.alipay.com/mini/84f9ee3c_alipay.merchant.order.sync?scene=common&pathHash=103117c9
func (*Client) SetEncryptKey ¶
SetEncryptKey 接口内容加密密钥 https://opendocs.alipay.com/common/02mse3
func (*Client) SystemOauthToken ¶
func (c *Client) SystemOauthToken(param SystemOauthToken) (result *SystemOauthTokenRsp, err error)
SystemOauthToken 换取授权访问令牌接口 https://docs.open.alipay.com/api_9/alipay.system.oauth.token
func (*Client) TradeAppPay ¶
func (c *Client) TradeAppPay(param TradeAppPay) (result string, err error)
TradeAppPay App支付接口 https://docs.open.alipay.com/api_1/alipay.trade.app.pay
func (*Client) TradeCreate ¶
func (c *Client) TradeCreate(param TradeCreate) (result *TradeCreateRsp, err error)
TradeCreate 统一收单交易创建接口 https://docs.open.alipay.com/api_1/alipay.trade.create/
func (*Client) TradeFastPayRefundQuery ¶
func (c *Client) TradeFastPayRefundQuery(param TradeFastPayRefundQuery) (result *TradeFastPayRefundQueryRsp, err error)
TradeFastPayRefundQuery 统一收单交易退款查询接口 https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query
func (*Client) TradePagePay ¶
func (c *Client) TradePagePay(param TradePagePay) (result *url.URL, err error)
TradePagePay 统一收单下单并支付页面接口 https://docs.open.alipay.com/api_1/alipay.trade.page.pay
func (*Client) TradeQuery ¶
func (c *Client) TradeQuery(param TradeQuery) (result *TradeQueryRsp, err error)
TradeQuery 统一收单线下交易查询接口 https://docs.open.alipay.com/api_1/alipay.trade.query/
func (*Client) TradeRefund ¶
func (c *Client) TradeRefund(param TradeRefund) (result *TradeRefundRsp, err error)
TradeRefund 统一收单交易退款接口 https://docs.open.alipay.com/api_1/alipay.trade.refund/
func (*Client) TradeWapPay ¶
func (c *Client) TradeWapPay(param TradeWapPay) (result *url.URL, err error)
TradeWapPay 手机网站支付接口 https://docs.open.alipay.com/api_1/alipay.trade.wap.pay/
func (*Client) UserInfoShare ¶
func (c *Client) UserInfoShare(param UserInfoShare) (result *UserInfoShareRsp, err error)
UserInfoShare 支付宝会员授权信息查询接口 https://docs.open.alipay.com/api_2/alipay.user.info.share
type Code ¶
type Code string
Code 支付宝接口响应错误码 https://doc.open.alipay.com/docs/doc.htm?treeId=291&articleId=105806&docType=1
const ( CodeSuccess Code = "10000" // 接口调用成功 CodeUnknowError Code = "20000" // 服务不可用 CodeInvalidAuthToken Code = "20001" // 授权权限不足 CodeMissingParam Code = "40001" // 缺少必选参数 CodeInvalidParam Code = "40002" // 非法的参数 CodeInsufficientConditions Code = "40003" // 条件异常 CodeBusinessFailed Code = "40004" // 业务处理失败 CodeCallLimited Code = "40005" // 调用频次超限 CodePermissionDenied Code = "40006" // 权限不足 )
公共错误码 https://opendocs.alipay.com/common/02km9f#API%20%E5%85%AC%E5%85%B1%E9%94%99%E8%AF%AF%E7%A0%81
type CreateQrcode ¶
type CreateQrcode struct { AuxParam AppAuthToken string `json:"-"` // 可选 UrlParam string `json:"url_param"` // 跳转小程序的页面路径,小程序中能访问到的页面路径 QueryParam string `json:"query_param"` // 小程序的启动参数,打开小程序的query ,在小程序 onLaunch的方法中获取 Describe string `json:"describe"` // 对应的二维码描述 Color string `json:"color"` // 圆形二维码颜色(十六进制颜色色值),仅圆形二维码支持颜色设置,方形二维码默认为黑色 Size string `json:"size"` // 合成后图片的大小规格,有s、m、l三档可选,s: 8cm大小 m: 12cm大小 l: 30cm大小 }
CreateQrcode 小程序生成推广二维码接口 https://opendocs.alipay.com/mini/a25c5d8f_alipay.open.app.qrcode.create?scene=common&pathHash=2334bbff
func (CreateQrcode) APIName ¶
func (c CreateQrcode) APIName() string
func (CreateQrcode) Params ¶
func (c CreateQrcode) Params() map[string]string
type CreateQrcodeRsp ¶
type CreateQrcodeRsp struct { Error QrCodeUrl string `json:"qr_code_url"` // 方形二维码图片链接地址 QrCodeUrlCircleWhite string `json:"qr_code_url_circle_white"` // 圆形二维码地址,白色slogan QrCodeUrlCircleBlue string `json:"qr_code_url_circle_blue"` // 圆形二维码地址,蓝色slogan }
CreateQrcodeRsp 小程序生成推广二维码接口响应参数
type DepositBackInfo ¶
type DiscountInfo ¶
type DiscountInfo struct { ExternalDiscountId string `json:"external_discount_id"` // 外部优惠id DiscountName string `json:"discount_name"` // 优惠名称 DiscountQuantity int64 `json:"discount_quantity,omitempty"` // 优惠数量 DiscountAmount float64 `json:"discount_amount"` // 优惠金额 单位为【元】 DiscountPageLink string `json:"discount_page_link,omitempty"` // 优惠跳转链接地址 }
订单优惠信息
type Error ¶
type GoodsDetailItem ¶
type GoodsDetailItem struct { GoodsId string `json:"goods_id"` AliPayGoodsId string `json:"alipay_goods_id"` GoodsName string `json:"goods_name"` Quantity string `json:"quantity"` Price string `json:"price"` GoodsCategory string `json:"goods_category"` Body string `json:"body"` ShowUrl string `json:"show_url"` }
type HBFQPayInfo ¶
type HBFQPayInfo struct {
UserInstallNum string `json:"user_install_num"` // 用户使用花呗分期支付的分期数
}
type ItemOrder ¶
type ItemOrder struct { SkuId string `json:"sku_id"` // 商品 sku id ItemId string `json:"item_id"` // 商品ID 支付宝平台侧商品ID ItemName string `json:"item_name"` // 商品名称 UnitPrice float64 `json:"unit_price"` // 商品单价(单位:元)。 小程序订单助手业务中,为必传;其他业务场景参见对应的产品文档。 Quantity int64 `json:"quantity"` // 商品数量(单位:自拟)小程序订单助手业务中,为必传;其他业务场景参见对应的产品文档。 Unit string `json:"unit"` // 商品规格,例如:斤 Status string `json:"status"` // 商品状态枚举 初始状态: INIT 已退款: REFUNDED 已关闭: CLOSED 处理中: PROCESSING 待支付: WAIT_PAY 业务完结: BIZ_FINISHED 已完结: SUCCESS_FINISHED 已支付: PAID 已提交: SUBMITTED 业务关闭: BIZ_CLOSED (注意事项: 默认无需传入,如需使用请联系业务负责人) StatusDesc string `json:"status_desc"` // 商品状态描述,默认无需传入,如需使用请联系业务负责人 ExtInfo []ExtInfo `json:"ext_info,omitempty"` // 扩展信息 }
商品信息
type JourneyOrder ¶
type JourneyOrder struct { MerchantJourneyNo string `json:"merchant_journey_no"` // 商户行程单号 注意事项 同一个pid下的行程单号需唯一。同一个pid下外部行程单号唯一 JourneyDesc string `json:"journey_desc,omitempty"` // 行程描述 JourneyIndex string `json:"journey_index,omitempty"` // 描述本行程为整个行程中的第几程 Title string `json:"title,omitempty"` // 行程标题 Status string `json:"status,omitempty"` // 行程状态 注:行程状态必须与支付宝侧进行约定 StatusDesc string `json:"status_desc,omitempty"` // 行程状态描述 Type string `json:"type"` // 行程类型,例如:airticket SubType string `json:"sub_type"` // 行程子类型,例如:abroad JourneyCreateTime string `json:"journey_create_time"` // 行程创建时间 JourneyModifyTime string `json:"journey_modify_time"` // 行程修改时间 Action string `json:"action,omitempty"` // 操作动作 删除后的行程不再展示: DELETE ExtInfo []ExtInfo `json:"ext_info"` // 扩展信息 }
行程信息
type LogisticsInfo ¶
type LogisticsInfo struct { TrackingNo string `json:"tracking_no"` // 物流单号 LogisticsCode string `json:"logistics_code"` // 物流公司编号。 物流公司编号值请查看产品文档。该值为空时,有可能匹配不到物流信息。若有则必传 }
物流信息
type MerchantFileUpload ¶
type MerchantFileUpload struct { AuxParam AppAuthToken string `json:"-"` // 可选 Scene string `json:"-"` // 业务场景描述。 小程序订单中心场景固定为 SYNC_ORDER。 }
MerchantFileUpload 商品文件上传接口 https://opendocs.alipay.com/mini/510d4a72_alipay.merchant.item.file.upload?scene=common&pathHash=c08922b1
func (MerchantFileUpload) APIName ¶
func (o MerchantFileUpload) APIName() string
func (MerchantFileUpload) Params ¶
func (o MerchantFileUpload) Params() map[string]string
type MerchantFileUploadRsp ¶
type MerchantFileUploadRsp struct { MaterialId string `json:"material_id"` // 文件在商品中心的素材标识(素材ID长期有效) MaterialKey string `json:"material_key"` // 文件在商品中心的素材标示,创建/更新商品时使用 }
MerchantFileUploadRsp 商品文件上传接口响应接口
type MobileNumber ¶
type MobileNumber struct { Code Code `json:"code"` Msg string `json:"msg"` Mobile string `json:"mobile"` }
MobileNumber 小程序获取会员手机号 https://opendocs.alipay.com/mini/api/getphonenumber
type OptionFunc ¶
type OptionFunc func(c *Client)
func WithFileInformation ¶
func WithFileInformation(name, path string, fileType bool) OptionFunc
加载文件信息
type OrderPush ¶
type OrderPush struct { AuxParam AppAuthToken string `json:"-"` // 可选 OutBizNo string `json:"out_biz_no"` // 外部订单号 out_biz_no唯一对应一笔订单,相同的订单需传入相同的out_biz_no BuyerInfo BuyerInfo `json:"buyer_info"` // 买家信息 ServiceCode string `json:"service_code,omitempty"` // 服务code:传入小程序后台提报的服务id,将订单与服务关联,有利于提高服务曝光机会;入参服务id的类目须与订单类型相符,若不相符将会报错;如订单类型为“外卖”,则入参的服务ID所对应的服务类目也必须得是”外卖“;service_code 通过 alipay.open.app.service.apply,(服务提报申请)接口创建服务后获取。 Amount float64 `json:"amount"` // 订单总金额:某笔交易订单优惠前的总金额,单位为【元】SERVICE_ORDER且不涉及金额可不传入该字段,其他场景必传 PayAmount float64 `json:"pay_amount"` // 用户应付金额 :用户最终结算时需要支付金额(不包含选择支付宝付款时,支付宝给予的优惠减免金额),单位为【元】SERVICE_ORDER且不涉及金额可不传入该字段,其他场景必传 OrderType string `json:"order_type"` // 订单类型 服务订单: SERVICE_ORDER CategoryId string `json:"category_id,omitempty"` // 标准服务类目 DiscountAmount float64 `json:"discount_amount,omitempty"` // 商户总计优惠金额:代表商户侧给予用户的总计优惠金额 (不包含选择支付宝付款时,支付宝给予的优惠减免金额),单位为【元】。 TradeNo string `json:"trade_no"` // 订单所对应的支付宝交易号 TradeType string `json:"trade_type"` // 交易号类型 交易: TRADE 受托: ENTRUST 转账: TRANSFER PayTimeoutExpress string `json:"pay_timeout_express,omitempty"` // 支付超时时间,超过时间支付宝自行关闭订单,例如:15h ItemOrderList []ItemOrder `json:"item_order_list,omitempty"` // 商品信息列表,可选 LogisticsInfoList []LogisticsInfo `json:"logistics_info_list,omitempty"` // "物流信息 列表最多支持物流信息个数,请参考产品文档 注:若该值不为空,且物流信息同步至我的快递,则在查询订单时可返回具体物流信息" ShopInfo ShopInfo `json:"shop_info,omitempty"` // 门店信息,扫码点餐获取返佣时必填。 OrderCreateTime string `json:"order_create_time,omitempty"` // 订单创建时间 注意事项: 当order_type为SERVICE_ORDER时必传 OrderModifiedTime string `json:"order_modified_time"` // 订单修改时间 注意事项: 用于订单状态或数据变化较快的顺序控制,SERVICE_ORDER按照行业标准化接入场景必须传入该字段控制乱序。order_modified_time较晚的同步会被最终存储,order_modified_time相同的两次同步会被幂等处理 OrderPayTime string `json:"order_pay_time,omitempty"` // 订单支付时间 注意事项: 当pay_channel为非ALIPAY时,且订单状态已流转到“支付”或支付后时,需要将支付时间传入 SendMsg string `json:"send_msg"` // 是否需要小程序订单代理发送模版消息。不传默认不发送,需要发送: Y 不需要发送: N DiscountInfoList []DiscountInfo `json:"discount_info_list,omitempty"` // 订单优惠信息 SyncContent string `json:"sync_content"` // 同步内容 全部(默认): ALL 仅行程信息: JOURNEY_ONLY JourneyOrderList []JourneyOrder `json:"journey_order_list,omitempty"` // 行程信息 SourceApp string `json:"source_app"` // 用于区分用户下单的订单来源 支付宝端内: Alipay 钉钉小程序: DingTalk ExtInfo []ExtInfo `json:"ext_info"` // 扩展信息 }
OrderPush 订单数据同步接口 https://opendocs.alipay.com/mini/84f9ee3c_alipay.merchant.order.sync?scene=common&pathHash=103117c9
type OrderPushRsp ¶
type OrderPushRsp struct { RecordId string `json:"record_id"` // 同步订单记录id (自2022年5月19日起,新接入商户,除点餐场景,该字段不再返回) OrderId string `json:"order_id"` // 支付宝订单号 OrderStatus string `json:"order_status"` // 订单状态 DistributeResult []struct { SceneCode string `json:"scene_code"` // 分发场景code 订单消息: SERVICE_MSG SceneName string `json:"scene_name"` // 分发场景名,对应scene_code NotDistributeReason string `json:"not_distribute_reason"` // 未分发到场景的具体原因 } `json:"distribute_result"` // 分发结果 若未分发到场景侧,则会返回具体的未分发原因 SyncSuggestions []struct { Type string `json:"type"` // 同步建议类型 Message string `json:"message"` // 同步建议内容 } `json:"sync_suggestions"` // 订单同步优化建议 }
OrderPushRsp 订单数据同步接口响应参数
type Param ¶
type Param interface { // APIName 用于提供访问的 method,即接口名称 APIName() string // Params 公共请求参数 Params() map[string]string // NeedEncrypt 该接口是否支持内容加密,有的接口不支持内容加密,比如文件上传接口:alipay.open.file.upload NeedEncrypt() bool // NeedVerify 是否对支付宝接口返回的数据进行签名验证, 为了安全建议都需要对签名进行验证,本方法存在是因为部分接口不支持签名验证。 // 比如:应用支付宝公钥证书下载 https://opendocs.alipay.com/common/06ue2z NeedVerify() bool }
type Payload ¶
type Payload struct { Encrypt bool // 是否进行内容加密 Verify bool // 是否验证签名 // contains filtered or unexported fields }
func NewPayload ¶
func (*Payload) AddBizField ¶
AddBizField 添加请求参数 biz_content 的字段,这里添加的信息会序列化成 JSON 字符串,然后通过 biz_content 参数传递。
这里添加的参数一般为支付宝接口文档中的【请求参数】,参考:https://opendocs.alipay.com/apis/api_1/alipay.trade.query/#%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0。
一般情况下,支付宝接口文档中的【请求参数】都是通过调用本方法添加。但是也有例外,如 https://opendocs.alipay.com/mini/05snwo#%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0 中的【请求参数】就需要调用 AddParam 进行添加,因为其【公共请求参数】中没有 biz_content 字段。
func (*Payload) AddParam ¶
AddParam 添加公共请求参数。
这里添加的参数一般为支付宝接口文档中的【公共请求参数】,参考:https://opendocs.alipay.com/apis/api_1/alipay.trade.query/#%E5%85%AC%E5%85%B1%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0。
一般情况下,不需要调用本方法添加公共请求参数,因为公共参数基本都是必须且其值相对固定,都已处理。除了个别参数,如:app_auth_token。
func (*Payload) NeedEncrypt ¶
func (*Payload) NeedVerify ¶
type RefundChargeInfo ¶
type RefundChargeInfo struct { RefundChargeFee string `json:"refund_charge_fee"` // 实退费用 SwitchFeeRate string `json:"switch_fee_rate"` // 签约费率 ChargeType string `json:"charge_type"` // 收单手续费trade,花呗分期手续hbfq,其他手续费charge RefundSubFeeDetailList []*RefundSubFeeDetail `json:"refund_sub_fee_detail_list,omitempty"` // 组合支付退费明细 }
type RefundRoyalty ¶
type RefundRoyalty struct { RefundAmount string `json:"refund_amount"` RoyaltyType string `json:"royalty_type"` ResultCode string `json:"result_code"` TransOut string `json:"trans_out"` TransOutEmail string `json:"trans_out_email"` TransIn string `json:"trans_in"` TransInEmail string `json:"trans_in_email"` }
type RefundRoyaltyParameter ¶
type RefundRoyaltyParameter struct { RoyaltyType string `json:"royalty_type,omitempty"` // 可选 分账类型. 普通分账为:transfer;补差为:replenish;为空默认为分账transfer; TransOut string `json:"trans_out,omitempty"` // 可选 支出方账户。如果支出方账户类型为userId,本参数为支出方的支付宝账号对应的支付宝唯一用户号,以2088开头的纯16位数字;如果支出方类型为loginName,本参数为支出方的支付宝登录号。 泛金融类商户分账时,该字段不要上送。 TransOutType string `json:"trans_out_type,omitempty"` // 可选 支出方账户类型。userId表示是支付宝账号对应的支付宝唯一用户号;loginName表示是支付宝登录号; 泛金融类商户分账时,该字段不要上送。 TransInType string `json:"trans_in_type,omitempty"` // 可选 收入方账户类型。userId表示是支付宝账号对应的支付宝唯一用户号;cardAliasNo表示是卡编号;loginName表示是支付宝登录号; TransIn string `json:"trans_in"` // 必选 收入方账户。如果收入方账户类型为userId,本参数为收入方的支付宝账号对应的支付宝唯一用户号,以2088开头的纯16位数字;如果收入方类型为cardAliasNo,本参数为收入方在支付宝绑定的卡编号;如果收入方类型为loginName,本参数为收入方的支付宝登录号; Amount string `json:"amount,omitempty"` // 可选 分账的金额,单位为元 Desc string `json:"desc,omitempty"` // 可选 分账描述 RoyaltyScene string `json:"royalty_scene,omitempty"` // 可选 可选值:达人佣金、平台服务费、技术服务费、其他 TransInName string `json:"trans_in_name,omitempty"` // 可选 分账收款方姓名,上送则进行姓名与支付宝账号的一致性校验,校验不一致则分账失败。不上送则不进行姓名校验 }
type RefundSubFeeDetail ¶
type ShopInfo ¶
type ShopInfo struct { MerchantShopId string `json:"merchant_shop_id"` // 商户门店id 支持英文、数字的组合 AlipayShopId string `json:"alipay_shop_id"` // 蚂蚁门店shop_id Name string `json:"name"` // 店铺名称 Address string `json:"address"` // 店铺地址 PhoneNum string `json:"phone_num"` // 联系电话-支持固话或手机号 仅支持数字、+、- 。例如 手机:1380***1111、固话:021-888**888 MerchantShopLinkPage string `json:"merchant_shop_link_page"` // 店铺详情链接地址,例如:pages/shop/index Type string `json:"type"` // 仅当alipay_shop_id字段值为非标准蚂蚁门店时使用,其他场景无需传入 蚂蚁门店: ALIPAY_SHOP 饿了么门店: ELEME_SHOP }
门店信息
type SubFeeDetail ¶
type SystemOauthToken ¶
type SystemOauthToken struct { AuxParam AppAuthToken string `json:"-"` // 可选 GrantType string `json:"-"` // 值为 authorization_code 时,代表用code换取;值为refresh_token时,代表用refresh_token换取 Code string `json:"-"` RefreshToken string `json:"-"` }
SystemOauthToken 换取授权访问令牌接口请求参数 https://docs.open.alipay.com/api_9/alipay.system.oauth.token
func (SystemOauthToken) APIName ¶
func (s SystemOauthToken) APIName() string
func (SystemOauthToken) Params ¶
func (s SystemOauthToken) Params() map[string]string
type SystemOauthTokenRsp ¶
type SystemOauthTokenRsp struct { Error UserId string `json:"user_id"` AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` RefreshToken string `json:"refresh_token"` ReExpiresIn int64 `json:"re_expires_in"` AuthStart string `json:"auth_start"` OpenId string `json:"open_id"` }
SystemOauthTokenRsp 换取授权访问令牌接口请求参数
type Trade ¶
type Trade struct { AuxParam NotifyURL string `json:"-"` ReturnURL string `json:"-"` AppAuthToken string `json:"-"` // 可选 // biz content,这四个参数是必须的 Body string `json:"body,omitempty"` Subject string `json:"subject"` // 订单标题 OutTradeNo string `json:"out_trade_no"` // 商户订单号,64个字符以内、可包含字母、数字、下划线;需保证在商户端不重复 TotalAmount string `json:"total_amount"` // 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] ProductCode string `json:"product_code"` // 销售产品码,与支付宝签约的产品码名称。 参考官方文档, App 支付时默认值为 QUICK_MSECURITY_PAY }
type TradeAppPay ¶
type TradeAppPay struct {
Trade
}
TradeAppPay App支付接口请求参数 https://docs.open.alipay.com/api_1/alipay.trade.app.pay/
func (TradeAppPay) APIName ¶
func (t TradeAppPay) APIName() string
func (TradeAppPay) NeedEncrypt ¶
func (t TradeAppPay) NeedEncrypt() bool
func (TradeAppPay) Params ¶
func (t TradeAppPay) Params() map[string]string
type TradeCreate ¶
type TradeCreate struct { Trade DiscountableAmount string `json:"discountable_amount"` // 可打折金额. 参与优惠计算的金额,单位为元,精确到小数点后两位 BuyerId string `json:"buyer_id"` // 买家支付宝用户ID。 2088开头的16位纯数字,小程序场景下获取用户ID请参考:用户授权; 其它场景下获取用户ID请参考:网页授权获取用户信息; 注:交易的买家与卖家不能相同。 BuyerOpenId string `json:"buyer_open_id"` // 新版接口无法获取user_id, 这里只能传递openid值 OpAppId string `json:"op_app_id,omitempty"` // 小程序支付中,商户实际经营主体的小程序应用的appid, 注意事项:商户需要先在产品管理中心绑定该小程序appid,否则下单会失败 OpBuyerOpenId string `json:"op_buyer_open_id,omitempty"` // 买家支付宝用户唯一标识(商户实际经营主体的小程序应用关联的买家open_id) GoodsDetail []*GoodsDetailItem `json:"goods_detail,omitempty"` OperatorId string `json:"operator_id"` TerminalId string `json:"terminal_id"` SellerId string `json:"seller_id,omitempty"` // 卖家支付宝用户ID TimeExpire string `json:"time_expire,omitempty"` // 订单绝对超时时间。格式为yyyy-MM-dd HH:mm:ss。【示例值】2021-12-31 10:05:00 TimeoutExpress string `json:"timeout_express,omitempty"` // 订单相对超时时间。从交易创建时间开始计算。该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m。当面付场景默认值为3h。time_expire和timeout_express两者只需传入一个或者都不传,如果两者都传,优先使用time_expire。 PassbackParams string `json:"passback_params,omitempty"` // 公用回传参数。 如果请求时传递了该参数,支付宝会在异步通知时将该参数原样返回。【示例值】merchantBizType%3d3C%26merchantBizNo%3d2016010101111 }
TradeCreate 统一收单交易创建接口请求参数 https://docs.open.alipay.com/api_1/alipay.trade.create/
func (TradeCreate) APIName ¶
func (t TradeCreate) APIName() string
func (TradeCreate) Params ¶
func (t TradeCreate) Params() map[string]string
type TradeCreateRsp ¶
type TradeCreateRsp struct { Error TradeNo string `json:"trade_no"` // 支付宝交易号 OutTradeNo string `json:"out_trade_no"` }
TradeCreateRsp 统一收单交易创建接口响应参数
type TradeFastPayRefundQuery ¶
type TradeFastPayRefundQuery struct { AuxParam AppAuthToken string `json:"-"` // 可选 OutTradeNo string `json:"out_trade_no,omitempty"` // 与 TradeNo 二选一 TradeNo string `json:"trade_no,omitempty"` // 与 OutTradeNo 二选一 OutRequestNo string `json:"out_request_no"` // 必须 请求退款接口时,传入的退款请求号,如果在退款请求时未传入,则该值为创建交易时的外部交易号 QueryOptions []string `json:"query_options,omitempty"` // 可选 查询选项,商户通过上送该参数来定制同步需要额外返回的信息字段,数组格式。 refund_detail_item_list }
TradeFastPayRefundQuery 统一收单交易退款查询接口请求参数 https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query
func (TradeFastPayRefundQuery) APIName ¶
func (t TradeFastPayRefundQuery) APIName() string
func (TradeFastPayRefundQuery) Params ¶
func (t TradeFastPayRefundQuery) Params() map[string]string
type TradeFastPayRefundQueryRsp ¶
type TradeFastPayRefundQueryRsp struct { Error TradeNo string `json:"trade_no"` // 支付宝交易号 OutTradeNo string `json:"out_trade_no"` // 创建交易传入的商户订单号 OutRequestNo string `json:"out_request_no"` // 本笔退款对应的退款请求号 TotalAmount string `json:"total_amount"` // 发该笔退款所对应的交易的订单金额 RefundAmount string `json:"refund_amount"` // 本次退款请求,对应的退款金额 RefundStatus string `json:"refund_status"` // 退款状态。枚举值: REFUND_SUCCESS 退款处理成功; 未返回该字段表示退款请求未收到或者退款失败; RefundRoyaltys []*RefundRoyalty `json:"refund_royaltys"` // 退分账明细信息 GMTRefundPay string `json:"gmt_refund_pay"` // 退款时间。 RefundDetailItemList []*TradeFundBill `json:"refund_detail_item_list"` // 本次退款使用的资金渠道; 默认不返回该信息,需要在入参的query_options中指定"refund_detail_item_list"值时才返回该字段信息。 SendBackFee string `json:"send_back_fee"` // 本次商户实际退回金额; DepositBackInfo []*DepositBackInfo `json:"deposit_back_info"` // 银行卡冲退信息 RefundHYBAmount string `json:"refund_hyb_amount"` // 本次请求退惠营宝金额 RefundChargeInfoList []*RefundChargeInfo `json:"refund_charge_info_list,omitempty"` // 退费信息 }
TradeFastPayRefundQueryRsp 统一收单交易退款查询接口响应参数
type TradeFundBill ¶
type TradePagePay ¶
type TradePagePay struct { Trade AuthToken string `json:"auth_token,omitempty"` // 针对用户授权接口,获取用户相关数据时,用于标识用户授权关系 QRPayMode string `json:"qr_pay_mode,omitempty"` // PC扫码支付的方式,支持前置模式和跳转模式。 QRCodeWidth string `json:"qrcode_width,omitempty"` // 商户自定义二维码宽度 注:qr_pay_mode=4时该参数生效 }
TradePagePay 统一收单下单并支付页面接口请求参数 https://opendocs.alipay.com/apis/api_1/alipay.trade.page.pay
func (TradePagePay) APIName ¶
func (t TradePagePay) APIName() string
func (TradePagePay) Params ¶
func (t TradePagePay) Params() map[string]string
type TradeQuery ¶
type TradeQuery struct { AuxParam AppAuthToken string `json:"-"` // 可选 OutTradeNo string `json:"out_trade_no,omitempty"` // 订单支付时传入的商户订单号, 与 TradeNo 二选一 TradeNo string `json:"trade_no,omitempty"` // 支付宝交易号 OrgPid string `json:"org_pid,omitempty"` // 可选 银行间联模式下有用,其它场景请不要使用; 双联通过该参数指定需要查询的交易所属收单机构的pid; QueryOptions []string `json:"query_options,omitempty"` // 可选 查询选项,商户传入该参数可定制本接口同步响应额外返回的信息字段,数组格式。支持枚举如下:trade_settle_info:返回的交易结算信息,包含分账、补差等信息; fund_bill_list:交易支付使用的资金渠道;voucher_detail_list:交易支付时使用的所有优惠券信息;discount_goods_detail:交易支付所使用的单品券优惠的商品优惠信息;mdiscount_amount:商家优惠金额; }
TradeQuery 统一收单线下交易查询接口请求参数 https://docs.open.alipay.com/api_1/alipay.trade.query/
func (TradeQuery) APIName ¶
func (t TradeQuery) APIName() string
func (TradeQuery) Params ¶
func (t TradeQuery) Params() map[string]string
type TradeQueryRsp ¶
type TradeQueryRsp struct { Error TradeNo string `json:"trade_no"` // 支付宝交易号 OutTradeNo string `json:"out_trade_no"` // 商家订单号 BuyerLogonId string `json:"buyer_logon_id"` // 买家支付宝账号 TradeStatus TradeStatus `json:"trade_status"` // 交易状态 TotalAmount string `json:"total_amount"` // 交易的订单金额 TransCurrency string `json:"trans_currency"` // 标价币种 SettleCurrency string `json:"settle_currency"` // 订单结算币种 SettleAmount string `json:"settle_amount"` // 结算币种订单金额 PayCurrency string `json:"pay_currency"` // 订单支付币种 PayAmount string `json:"pay_amount"` // 支付币种订单金额 SettleTransRate string `json:"settle_trans_rate"` // 结算币种兑换标价币种汇率 TransPayRate string `json:"trans_pay_rate"` // 标价币种兑换支付币种汇率 BuyerPayAmount string `json:"buyer_pay_amount"` // 买家实付金额,单位为元,两位小数。 PointAmount string `json:"point_amount"` // 积分支付的金额,单位为元,两位小数。 InvoiceAmount string `json:"invoice_amount"` // 交易中用户支付的可开具发票的金额,单位为元,两位小数。 SendPayDate string `json:"send_pay_date"` // 本次交易打款给卖家的时间 ReceiptAmount string `json:"receipt_amount"` // 实收金额,单位为元,两位小数 StoreId string `json:"store_id"` // 商户门店编号 TerminalId string `json:"terminal_id"` // 商户机具终端编号 FundBillList []*FundBill `json:"fund_bill_list,omitempty"` // 交易支付使用的资金渠道 StoreName string `json:"store_name"` // 请求交易支付中的商户店铺的名称 BuyerUserId string `json:"buyer_user_id"` // 买家在支付宝的用户id BuyerUserName string `json:"buyer_user_name"` // 买家名称; IndustrySepcDetailGov string `json:"industry_sepc_detail_gov"` // 行业特殊信息-统筹相关 IndustrySepcDetailAcc string `json:"industry_sepc_detail_acc"` // 行业特殊信息-个账相关 ChargeAmount string `json:"charge_amount"` // 该笔交易针对收款方的收费金额; ChargeFlags string `json:"charge_flags"` // 费率活动标识,当交易享受活动优惠费率时,返回该活动的标识; SettlementId string `json:"settlement_id"` // 支付清算编号,用于清算对账使用; TradeSettleInfo *TradeSettleInfo `json:"trade_settle_info,omitempty"` // 返回的交易结算信息,包含分账、补差等信息 AuthTradePayMode string `json:"auth_trade_pay_mode"` // 预授权支付模式,该参数仅在信用预授权支付场景下返回。信用预授权支付:CREDIT_PREAUTH_PAY BuyerUserType string `json:"buyer_user_type"` // 买家用户类型。CORPORATE:企业用户;PRIVATE:个人用户。 MdiscountAmount string `json:"mdiscount_amount"` // 商家优惠金额 DiscountAmount string `json:"discount_amount"` // 平台优惠金额 Subject string `json:"subject"` // 订单标题; Body string `json:"body"` // 订单描述; AlipaySubMerchantId string `json:"alipay_sub_merchant_id"` // 间连商户在支付宝端的商户编号; ExtInfos string `json:"ext_infos"` // 交易额外信息,特殊场景下与支付宝约定返回。 PassbackParams string `json:"passback_params"` // 公用回传参数。返回支付时传入的passback_params参数信息 HBFQPayInfo *HBFQPayInfo `json:"hb_fq_pay_info"` // 若用户使用花呗分期支付,且商家开通返回此通知参数,则会返回花呗分期信息。json格式其它说明详见花呗分期信息说明。 注意:商家需与支付宝约定后才返回本参数。 CreditPayMode string `json:"credit_pay_mode"` // 信用支付模式。表示订单是采用信用支付方式(支付时买家没有出资,需要后续履约)。"creditAdvanceV2"表示芝麻先用后付模式,用户后续需要履约扣款。 此字段只有信用支付场景才有值,商户需要根据字段值单独处理。此字段以后可能扩展其他值,建议商户使用白名单方式识别,对于未识别的值做失败处理,并联系支付宝技术支持人员。 CreditBizOrderId string `json:"credit_biz_order_id"` // 信用业务单号。信用支付场景才有值,先用后付产品里是芝麻订单号。 HYBAmount string `json:"hyb_amount"` // 惠营宝回票金额 BKAgentRespInfo *BKAgentRespInfo `json:"bk_agent_resp_info"` // 间联交易下,返回给机构的信 息 ChargeInfoList []*ChargeInfo `json:"charge_info_list"` // 计费信息列表 DiscountGoodsDetail string `json:"discount_goods_detail"` // 本次交易支付所使用的单品券优惠的商品优惠信息 VoucherDetailList []*VoucherDetail `json:"voucher_detail_list,omitempty"` // 本交易支付时使用的所有优惠券信息 }
TradeQueryRsp 统一收单线下交易查询接口响应参数
type TradeRefund ¶
type TradeRefund struct { AuxParam AppAuthToken string `json:"-"` // 可选 OutTradeNo string `json:"out_trade_no,omitempty"` // 与 TradeNo 二选一 TradeNo string `json:"trade_no,omitempty"` // 与 OutTradeNo 二选一 RefundAmount string `json:"refund_amount"` // 必须 需要退款的金额,该金额不能大于订单金额,单位为元,支持两位小数 RefundReason string `json:"refund_reason"` // 可选 退款的原因说明 OutRequestNo string `json:"out_request_no"` // 必须 标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传。 RefundRoyaltyParameters []*RefundRoyaltyParameter `json:"refund_royalty_parameters,omitempty"` // 可选 退分账明细信息。 注: 1.当面付且非直付通模式无需传入退分账明细,系统自动按退款金额与订单金额的比率,从收款方和分账收入方退款,不支持指定退款金额与退款方。2.直付通模式,电脑网站支付,手机 APP 支付,手机网站支付产品,须在退款请求中明确是否退分账,从哪个分账收入方退,退多少分账金额;如不明确,默认从收款方退款,收款方余额不足退款失败。不支持系统按比率退款。 QueryOptions []string `json:"query_options,omitempty"` // 可选 查询选项。 商户通过上送该参数来定制同步需要额外返回的信息字段,数组格式。支持:refund_detail_item_list:退款使用的资金渠道;deposit_back_info:触发银行卡冲退信息通知; }
TradeRefund 统一收单交易退款接口请求参数 https://docs.open.alipay.com/api_1/alipay.trade.refund/
func (TradeRefund) APIName ¶
func (t TradeRefund) APIName() string
func (TradeRefund) Params ¶
func (t TradeRefund) Params() map[string]string
type TradeRefundRsp ¶
type TradeRefundRsp struct { Error TradeNo string `json:"trade_no"` // 支付宝交易号 OutTradeNo string `json:"out_trade_no"` // 商户订单号 BuyerLogonId string `json:"buyer_logon_id"` // 用户的登录id BuyerUserId string `json:"buyer_user_id"` // 买家在支付宝的用户id FundChange string `json:"fund_change"` // 本次退款是否发生了资金变化 RefundFee string `json:"refund_fee"` // 退款总金额 StoreName string `json:"store_name"` // 交易在支付时候的门店名称 RefundDetailItemList []*TradeFundBill `json:"refund_detail_item_list,omitempty"` // 退款使用的资金渠道 SendBackFee string `json:"send_back_fee"` // 本次商户实际退回金额。 说明:如需获取该值,需在入参query_options中传入 refund_detail_item_list。 RefundHYBAmount string `json:"refund_hyb_amount"` // 本次请求退惠营宝金额 RefundChargeInfoList []*RefundChargeInfo `json:"refund_charge_info_list,omitempty"` // 退费信息 }
TradeRefundRsp 统一收单交易退款接口响应参数
type TradeSettleDetail ¶
type TradeSettleInfo ¶
type TradeSettleInfo struct {
TradeSettleDetailList []*TradeSettleDetail `json:"trade_settle_detail_list"`
}
type TradeStatus ¶
type TradeStatus string
const ( TradeStatusWaitBuyerPay TradeStatus = "WAIT_BUYER_PAY" //(交易创建,等待买家付款) TradeStatusClosed TradeStatus = "TRADE_CLOSED" //(未付款交易超时关闭,或支付完成后全额退款) TradeStatusSuccess TradeStatus = "TRADE_SUCCESS" //(交易支付成功) TradeStatusFinished TradeStatus = "TRADE_FINISHED" //(交易结束,不可退款) )
type TradeWapPay ¶
type TradeWapPay struct { Trade QuitURL string `json:"quit_url,omitempty"` AuthToken string `json:"auth_token,omitempty"` // 针对用户授权接口,获取用户相关数据时,用于标识用户授权关系 TimeExpire string `json:"time_expire,omitempty"` // 绝对超时时间,格式为yyyy-MM-dd HH:mm。 }
TradeWapPay 手机网站支付接口请求参数 https://docs.open.alipay.com/api_1/alipay.trade.wap.pay/
func (TradeWapPay) APIName ¶
func (t TradeWapPay) APIName() string
func (TradeWapPay) Params ¶
func (t TradeWapPay) Params() map[string]string
type UserInfoShare ¶
type UserInfoShare struct {}
UserInfoShare 支付宝会员授权信息查询接口请求参数 https://docs.open.alipay.com/api_2/alipay.user.info.share
func (UserInfoShare) APIName ¶
func (u UserInfoShare) APIName() string
func (UserInfoShare) Params ¶
func (u UserInfoShare) Params() map[string]string
type VoucherDetail ¶
type VoucherDetail struct { Id string `json:"id"` // 券id Name string `json:"name"` // 券名称 Type string `json:"type"` // 当前有三种类型: ALIPAY_FIX_VOUCHER - 全场代金券, ALIPAY_DISCOUNT_VOUCHER - 折扣券, ALIPAY_ITEM_VOUCHER - 单品优惠 Amount string `json:"amount"` // 优惠券面额,它应该会等于商家出资加上其他出资方出资 MerchantContribute string `json:"merchant_contribute"` // 商家出资(特指发起交易的商家出资金额) OtherContribute string `json:"other_contribute"` // 其他出资方出资金额,可能是支付宝,可能是品牌商,或者其他方,也可能是他们的一起出资 Memo string `json:"memo"` // 优惠券备注信息 }