Documentation ¶
Index ¶
- Constants
- Variables
- func AppPay(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (string, error)
- func CommonParamsHandle(alipayCfg *AplipayConfig, bizMap gosupport.BodyMap, ...) (gosupport.BodyMap, error)
- func EncodeAliPaySignParams(bm gosupport.BodyMap) string
- func GetAlipaySign(bm gosupport.BodyMap, signType string, privateKey *rsa.PrivateKey) (sign string, err error)
- func IsError(code string) bool
- func NotifyContentToBodyMap(req *http.Request) (gosupport.BodyMap, error)
- func NotifyContentToBodyMapByUrlValues(valMap url.Values) gosupport.BodyMap
- func PagePay(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (string, error)
- func PinBizContent(bizmap gosupport.BodyMap) string
- func ReturnSuccess() string
- func VerifyNotifySign(notifyContent interface{}, aliPayPublicKey *rsa.PublicKey) (bool, error)
- func VerifySignByCert(sign, signData string, signType string, aliPayPublicKey *rsa.PublicKey) error
- func WapPay(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (string, error)
- type AplipayConfig
- func (m *AplipayConfig) AutoVerifySignByCert(sign, signData string, signDataErr error) (err error)
- func (m *AplipayConfig) GetSignData(bodyStr string, alipayCertSN string) (signData string, err error)
- func (m *AplipayConfig) SetCharset(charset string) *AplipayConfig
- func (m *AplipayConfig) SetNotifyUrl(url string) *AplipayConfig
- func (m *AplipayConfig) SetReturnUrl(url string) *AplipayConfig
- func (m *AplipayConfig) SetSignType(signType string) *AplipayConfig
- type BalanceQueryDto
- type BalanceQueryResponseDto
- type DepositBackInfo
- type ErrorResponseDto
- type HbFqPayInfo
- type RefundPresetPaytool
- type RefundRoyalty
- type TradeFastpayRefundQueryResponseDto
- type TradeFundBill
- type TradeQueryDto
- type TradeQueryResponseDto
- type TradeRefundDto
- type TradeRefundQueryDto
- type TradeRefundResponseDto
- type TradeSettleDetail
- type TradeSettleInfo
Constants ¶
const ( // 签名算法 RSA = "RSA" RSA2 = "RSA2" SM2 = "SM2" JsonFormat = "JSON" UTF8 = "utf-8" SUCCESS = "success" FAIL = "fail" OK = "ok" AlipayGatewayUrl = "https://openapi.alipay.com/gateway.do" )
Variables ¶
Functions ¶
func AppPay ¶
func AppPay(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (string, error)
获取app下单参数:https://opendocs.alipay.com/open/cd12c885_alipay.trade.app.pay?scene=20&pathHash=c0e35284 alipay.trade.app.pay(app支付接口2.0)
func CommonParamsHandle ¶
func CommonParamsHandle(alipayCfg *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (gosupport.BodyMap, error)
公共参数
func EncodeAliPaySignParams ¶
func GetAlipaySign ¶
func NotifyContentToBodyMap ¶
支付宝通知文档: https://opendocs.alipay.com/open/203/105286 https://opendocs.alipay.com/open/204/105301
func PagePay ¶
func PagePay(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (string, error)
pc端下单地址
func PinBizContent ¶
func ReturnSuccess ¶
func ReturnSuccess() string
func VerifyNotifySign ¶
func VerifySignByCert ¶
验证api数据:https://opendocs.alipay.com/common/02mse7#自行实现验签
Types ¶
type AplipayConfig ¶
type AplipayConfig struct { AppId string SignType string Charset string PrivateKey *rsa.PrivateKey // 应用私钥 AliPayPublicKey *rsa.PublicKey // 支付宝证书公钥内容 AliPayPublicCertSN string ReturnUrl string NotifyUrl string Format string IsVerifySign bool // 是否验证支付宝响应结果签名 }
func NewClient ¶
func NewClient(appid, privateKey string) (*AplipayConfig, error)
func (*AplipayConfig) AutoVerifySignByCert ¶
func (m *AplipayConfig) AutoVerifySignByCert(sign, signData string, signDataErr error) (err error)
func (*AplipayConfig) GetSignData ¶
func (m *AplipayConfig) GetSignData(bodyStr string, alipayCertSN string) (signData string, err error)
func (*AplipayConfig) SetCharset ¶
func (m *AplipayConfig) SetCharset(charset string) *AplipayConfig
设置编码格式
func (*AplipayConfig) SetNotifyUrl ¶
func (m *AplipayConfig) SetNotifyUrl(url string) *AplipayConfig
设置支付宝通知地址
func (*AplipayConfig) SetReturnUrl ¶
func (m *AplipayConfig) SetReturnUrl(url string) *AplipayConfig
设置支付后的ReturnUrl
func (*AplipayConfig) SetSignType ¶
func (m *AplipayConfig) SetSignType(signType string) *AplipayConfig
type BalanceQueryDto ¶
type BalanceQueryDto struct { ErrorResponseDto FreezeAmount string `json:"freeze_amount"` //冻结金额,单位(元) TotalAmount string `json:"total_amount"` //支付宝账户余额,单位(元) AvailableAmount string `json:"available_amount"` //账户可用余额,单位(元) SettleAmount string `json:"settle_amount,omitempty"` //待结算金额,单位(元),可选 }
type BalanceQueryResponseDto ¶
type BalanceQueryResponseDto struct { Response *BalanceQueryDto `json:"alipay_data_bill_balance_query_response"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
账户余额查询响应参数
func BalanceQuery ¶
func BalanceQuery(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (*BalanceQueryResponseDto, string, error)
账户余额查询: https://opendocs.alipay.com/open/01inen#查询账户当前余额
type DepositBackInfo ¶
type DepositBackInfo struct { HasDepositBack string `json:"has_deposit_back,omitempty"` DbackStatus string `json:"dback_status,omitempty"` DbackAmount string `json:"dback_amount,omitempty"` BankAckTime string `json:"bank_ack_time,omitempty"` EstBankReceiptTime string `json:"est_bank_receipt_time,omitempty"` }
type ErrorResponseDto ¶
type HbFqPayInfo ¶
type RefundPresetPaytool ¶
type RefundRoyalty ¶
type RefundRoyalty struct { RefundAmount string `json:"refund_amount,omitempty"` RoyaltyType string `json:"royalty_type,omitempty"` ResultCode string `json:"result_code,omitempty"` TransOut string `json:"trans_out,omitempty"` TransOutEmail string `json:"trans_out_email,omitempty"` TransIn string `json:"trans_in,omitempty"` TransInEmail string `json:"trans_in_email,omitempty"` }
type TradeFastpayRefundQueryResponseDto ¶
type TradeFastpayRefundQueryResponseDto struct { Response *TradeRefundQueryDto `json:"alipay_trade_fastpay_refund_query_response"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
退款查询返回
func TradeFastpayRefundQuery ¶
func TradeFastpayRefundQuery(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (*TradeFastpayRefundQueryResponseDto, string, error)
alipay.trade.fastpay.refund.query(统一收单交易退款查询) https://opendocs.alipay.com/open/357441a2_alipay.trade.fastpay.refund.query?scene=common&pathHash=01981dca https://opendocs.alipay.com/open/8c776df6_alipay.trade.fastpay.refund.query?scene=common&pathHash=fb6e1894
type TradeFundBill ¶
type TradeFundBill struct { FundChannel string `json:"fund_channel,omitempty"` // 同步通知里是 fund_channel Amount string `json:"amount,omitempty"` RealAmount string `json:"real_amount,omitempty"` FundType string `json:"fund_type,omitempty"` }
退款查询、交易查询 返回
type TradeQueryDto ¶
type TradeQueryDto struct { ErrorResponseDto TradeNo string `json:"trade_no,omitempty"` OutTradeNo string `json:"out_trade_no,omitempty"` BuyerLogonId string `json:"buyer_logon_id,omitempty"` TradeStatus string `json:"trade_status,omitempty"` TotalAmount string `json:"total_amount,omitempty"` 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 []*TradeFundBill `json:"fund_bill_list"` StoreName string `json:"store_name,omitempty"` BuyerUserId string `json:"buyer_user_id,omitempty"` ChargeAmount string `json:"charge_amount,omitempty"` ChargeFlags string `json:"charge_flags,omitempty"` SettlementId string `json:"settlement_id,omitempty"` TradeSettleInfo *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"` Subject string `json:"subject,omitempty"` Body string `json:"body,omitempty"` AlipaySubMerchantId string `json:"alipay_sub_merchant_id,omitempty"` ExtInfos string `json:"ext_infos,omitempty"` HbFqPayInfo *HbFqPayInfo `json:"hb_fq_pay_info,omitempty"` CreditPayMode string `json:"credit_pay_mode,omitempty"` CreditBizOrderId string `json:"credit_biz_order_id,omitempty"` }
type TradeQueryResponseDto ¶
type TradeQueryResponseDto struct { Response *TradeQueryDto `json:"alipay_trade_query_response"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
func TradeQuery ¶
func TradeQuery(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (*TradeQueryResponseDto, string, error)
alipay.trade.query(统一收单交易查询):https://opendocs.alipay.com/open/02ivbt?scene=common&pathHash=8abc6ffe https://opendocs.alipay.com/open/82ea786a_alipay.trade.query?scene=23&pathHash=0745ecea https://opendocs.alipay.com/open/bff76748_alipay.trade.query?scene=23&pathHash=e3ddce1d
type TradeRefundDto ¶
type TradeRefundDto struct { ErrorResponseDto TradeNo string `json:"trade_no,omitempty"` OutTradeNo string `json:"out_trade_no,omitempty"` BuyerLogonId string `json:"buyer_logon_id,omitempty"` FundChange string `json:"fund_change,omitempty"` RefundFee string `json:"refund_fee,omitempty"` RefundDetailItemList []*TradeFundBill `json:"refund_detail_item_list,omitempty"` StoreName string `json:"store_name,omitempty"` BuyerUserId string `json:"buyer_user_id,omitempty"` SendBackFee string `json:"send_back_fee,omitempty"` OpenId string `json:"open_id,omitempty"` RefundCurrency string `json:"refund_currency,omitempty"` GmtRefundPay string `json:"gmt_refund_pay,omitempty"` RefundPresetPaytoolList []*RefundPresetPaytool `json:"refund_preset_paytool_list,omitempty"` RefundChargeAmount string `json:"refund_charge_amount,omitempty"` RefundSettlementId string `json:"refund_settlement_id,omitempty"` PresentRefundBuyerAmount string `json:"present_refund_buyer_amount,omitempty"` PresentRefundDiscountAmount string `json:"present_refund_discount_amount,omitempty"` PresentRefundMdiscountAmount string `json:"present_refund_mdiscount_amount,omitempty"` HasDepositBack string `json:"has_deposit_back,omitempty"` RefundHybAmount string `json:"refund_hyb_amount,omitempty"` }
type TradeRefundQueryDto ¶
type TradeRefundQueryDto struct { ErrorResponseDto 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"` RefundStatus string `json:"refund_status,omitempty"` RefundRoyaltys []*RefundRoyalty `json:"refund_royaltys,omitempty"` GmtRefundPay string `json:"gmt_refund_pay,omitempty"` RefundDetailItemList []*TradeFundBill `json:"refund_detail_item_list,omitempty"` SendBackFee string `json:"send_back_fee,omitempty"` DepositBackInfo *DepositBackInfo `json:"deposit_back_info,omitempty"` }
type TradeRefundResponseDto ¶
type TradeRefundResponseDto struct { Response *TradeRefundDto `json:"alipay_trade_refund_response"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
发起退款 返回
func TradeRefund ¶
func TradeRefund(config *AplipayConfig, bizMap gosupport.BodyMap, commonMap gosupport.BodyMap) (*TradeRefundResponseDto, string, error)
alipay.trade.refund(统一收单交易退款接口) https://opendocs.alipay.com/open/6c0cdd7d_alipay.trade.refund?scene=common&pathHash=4081e89c
type TradeSettleDetail ¶
type TradeSettleDetail struct { OperationType string `json:"operation_type,omitempty"` OperationSerialNo string `json:"operation_serial_no,omitempty"` OperationDt string `json:"operation_dt,omitempty"` TransOut string `json:"trans_out,omitempty"` TransIn string `json:"trans_in,omitempty"` Amount string `json:"amount,omitempty"` OriTransOut string `json:"ori_trans_out,omitempty"` OriTransIn string `json:"ori_trans_in,omitempty"` }
type TradeSettleInfo ¶
type TradeSettleInfo struct {
TradeSettleDetailList []*TradeSettleDetail `json:"trade_settle_detail_list,omitempty"`
}