alipay

package
v0.0.0-...-b0b4114 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success = http.StatusOK

	MethodGet           = "GET"
	MethodPost          = "POST"
	MethodPut           = "PUT"
	MethodDelete        = "DELETE"
	MethodPATCH         = "PATCH"
	HeaderAuthorization = "Authorization"
	HeaderRequestID     = "alipay-request-id"
	HeaderSdkVersion    = "alipay-sdk-version"
	HeaderAppAuthToken  = "alipay-app-auth-token"
	HeaderTimestamp     = "alipay-timestamp"
	HeaderNonce         = "alipay-nonce"
	HeaderSignature     = "alipay-signature"

	SignTypeRSA = "ALIPAY-SHA256withRSA"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientV3

type ClientV3 struct {
	AppId              string
	AppCertSN          string
	AliPayPublicCertSN string
	AliPayRootCertSN   string
	AppAuthToken       string
	IsProd             bool

	DebugSwitch gopay.DebugSwitch
	// contains filtered or unexported fields
}

ClientV3 支付宝 V3

func NewClientV3

func NewClientV3(appid, privateKey string, isProd bool) (client *ClientV3, err error)

NewClientV3 初始化支付宝客户端 V3 appid:应用ID privateKey:应用私钥,支持PKCS1和PKCS8 isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。

func (*ClientV3) DataBillDownloadUrlQuery

func (a *ClientV3) DataBillDownloadUrlQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillDownloadUrlQueryRsp, err error)

查询对账单下载地址 StatusCode = 200 is success

func (*ClientV3) DoAliPayAPISelfV3

func (a *ClientV3) DoAliPayAPISelfV3(ctx context.Context, method, path string, bm gopay.BodyMap, aliRsp any) (res *http.Response, err error)

DoAliPayAPISelfV3 支付宝接口自行实现方法

func (*ClientV3) FundAuthOperationDetailQuery

func (a *ClientV3) FundAuthOperationDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOperationDetailQueryRsp, err error)

资金授权操作查询接口 StatusCode = 200 is success

func (*ClientV3) FundAuthOrderFreeze

func (a *ClientV3) FundAuthOrderFreeze(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOrderFreezeRsp, err error)

资金授权冻结接口 StatusCode = 200 is success

func (*ClientV3) FundAuthOrderUnfreeze

func (a *ClientV3) FundAuthOrderUnfreeze(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOrderUnfreezeRsp, err error)

资金授权解冻接口 StatusCode = 200 is success

func (*ClientV3) FundAuthOrderVoucherCreate

func (a *ClientV3) FundAuthOrderVoucherCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOrderVoucherCreateRsp, err error)

资金授权发码接口 StatusCode = 200 is success

func (*ClientV3) SetAESKey

func (a *ClientV3) SetAESKey(aesKey string)

SetAESKey 设置 biz_content 的AES加密key,设置此参数默认开启 biz_content 参数加密 注意:目前不可用,设置后会报错

func (*ClientV3) SetBodySize

func (a *ClientV3) SetBodySize(sizeMB int)

SetBodySize 设置http response body size(MB)

func (*ClientV3) SetCert

func (a *ClientV3) SetCert(appCertContent, alipayRootCertContent, alipayPublicCertContent []byte) (err error)

应用公钥证书内容设置 app_cert_sn、alipay_root_cert_sn、alipay_cert_sn appCertContent:应用公钥证书文件内容 alipayRootCertContent:支付宝根证书文件内容 alipayPublicCertContent:支付宝公钥证书文件内容

func (*ClientV3) SetHttpClient

func (a *ClientV3) SetHttpClient(client *xhttp.Client)

SetHttpClient 设置自定义的xhttp.Client

func (*ClientV3) SetLogger

func (a *ClientV3) SetLogger(logger xlog.XLogger)

SetLogger 设置自定义的logger

func (*ClientV3) SetRequestIdFunc

func (a *ClientV3) SetRequestIdFunc(requestIdFunc xhttp.RequestIdHandler)

设置自定义RequestId生成函数

func (*ClientV3) SystemOauthToken

func (a *ClientV3) SystemOauthToken(ctx context.Context, bm gopay.BodyMap) (aliRsp *SystemOauthTokenRsp, err error)

换取授权访问令牌 StatusCode = 200 is success

func (*ClientV3) TradeCancel

func (a *ClientV3) TradeCancel(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCancelRsp, err error)

统一收单交易撤销接口 StatusCode = 200 is success

func (*ClientV3) TradeClose

func (a *ClientV3) TradeClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCloseRsp, err error)

统一收单交易关闭接口 StatusCode = 200 is success

func (*ClientV3) TradeCreate

func (a *ClientV3) TradeCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCreateRsp, err error)

统一收单交易创建接口 StatusCode = 200 is success

func (*ClientV3) TradeFastPayRefundQuery

func (a *ClientV3) TradeFastPayRefundQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeFastPayRefundQueryRsp, err error)

统一收单交易退款查询 StatusCode = 200 is success

func (*ClientV3) TradePay

func (a *ClientV3) TradePay(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePayRsp, err error)

统一收单交易支付接口 StatusCode = 200 is success

func (*ClientV3) TradePrecreate

func (a *ClientV3) TradePrecreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePrecreateRsp, err error)

统一收单线下交易预创建 StatusCode = 200 is success

func (*ClientV3) TradeQuery

func (a *ClientV3) TradeQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeQueryRsp, err error)

统一收单交易查询 StatusCode = 200 is success

func (*ClientV3) TradeRefund

func (a *ClientV3) TradeRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRefundRsp, err error)

统一收单交易退款接口 StatusCode = 200 is success

func (*ClientV3) UserAuthRelationshipQuery

func (a *ClientV3) UserAuthRelationshipQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAuthRelationshipQueryRsp, err error)

用户授权关系查询 StatusCode = 200 is success

func (*ClientV3) UserCertifyOpenInitialize

func (a *ClientV3) UserCertifyOpenInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserCertifyOpenInitializeRsp, err error)

身份认证初始化服务 StatusCode = 200 is success

func (*ClientV3) UserCertifyOpenQuery

func (a *ClientV3) UserCertifyOpenQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserCertifyOpenQueryRsp, err error)

身份认证记录查询 StatusCode = 200 is success

func (*ClientV3) UserDelOauthDetailQuery

func (a *ClientV3) UserDelOauthDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserDelOauthDetailQueryRsp, err error)

查询解除授权明细 StatusCode = 200 is success

func (*ClientV3) UserInfoShare

func (a *ClientV3) UserInfoShare(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserInfoShareRsp, err error)

支付宝会员授权信息查询接口 StatusCode = 200 is success

type DataBillDownloadUrlQueryRsp

type DataBillDownloadUrlQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	BillDownloadUrl string `json:"bill_download_url"`
	BillFileCode    string `json:"bill_file_code"`
}

type DepositBackInfo

type DepositBackInfo struct {
	HasDepositBack     string `json:"has_deposit_back"`
	DbackStatus        string `json:"dback_status"`
	DbackAmount        string `json:"dback_amount"`
	BankAckTime        string `json:"bank_ack_time"`
	EstBankReceiptTime string `json:"est_bank_receipt_time"`
}

type Detail

type Detail struct {
	Field       string `json:"field"`
	Value       string `json:"value"`
	Location    string `json:"location"`
	Issue       string `json:"issue"`
	Description string `json:"description"`
}

type ErrResponse

type ErrResponse struct {
	Code    string    `json:"code"`    // 详细错误码,参考接口描述及公共错误码,商家需要对该错误码处理。
	Message string    `json:"message"` // 错误描述,具体错误原因的文字描述,开发者可参考该描述判断错误原因。
	Details []*Detail `json:"details,omitempty"`
	Links   []*Link   `json:"links,omitempty"`
}

type FundAuthOperationDetailQueryRsp

type FundAuthOperationDetailQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	AuthNo                  string `json:"auth_no"`
	OutOrderNo              string `json:"out_order_no"`
	OrderStatus             string `json:"order_status"`
	TotalFreezeAmount       string `json:"total_freeze_amount"`
	RestAmount              string `json:"rest_amount"`
	TotalPayAmount          string `json:"total_pay_amount"`
	OrderTitle              string `json:"order_title"`
	PayerLogonId            string `json:"payer_logon_id"`
	PayerUserId             string `json:"payer_user_id"`
	PayerOpenId             string `json:"payer_open_id"`
	ExtraParam              string `json:"extra_param"`
	OperationId             string `json:"operation_id"`
	OutRequestNo            string `json:"out_request_no"`
	Amount                  string `json:"amount"`
	OperationType           string `json:"operation_type"`
	Status                  string `json:"status"`
	Remark                  string `json:"remark"`
	GmtCreate               string `json:"gmt_create"`
	GmtTrans                string `json:"gmt_trans"`
	PreAuthType             string `json:"pre_auth_type"`
	TransCurrency           string `json:"trans_currency"`
	TotalFreezeCreditAmount string `json:"total_freeze_credit_amount"`
	TotalFreezeFundAmount   string `json:"total_freeze_fund_amount"`
	TotalPayCreditAmount    string `json:"total_pay_credit_amount"`
	TotalPayFundAmount      string `json:"total_pay_fund_amount"`
	RestCreditAmount        string `json:"rest_credit_amount"`
	RestFundAmount          string `json:"rest_fund_amount"`
	CreditAmount            string `json:"credit_amount"`
	FundAmount              string `json:"fund_amount"`
	CreditMerchantExt       string `json:"credit_merchant_ext"`
}

type FundAuthOrderFreezeRsp

type FundAuthOrderFreezeRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	AuthNo        string `json:"auth_no"`
	OutOrderNo    string `json:"out_order_no"`
	OperationId   string `json:"operation_id"`
	OutRequestNo  string `json:"out_request_no"`
	Amount        string `json:"amount"`
	PayerUserId   string `json:"payer_user_id"`
	PayerOpenId   string `json:"payer_open_id"`
	Status        string `json:"status"`
	PayerLogonId  string `json:"payer_logon_id"`
	GmtTrans      string `json:"gmt_trans"`
	PreAuthType   string `json:"pre_auth_type"`
	TransCurrency string `json:"trans_currency"`
	CreditAmount  string `json:"credit_amount"`
	FundAmount    string `json:"fund_amount"`
}

type FundAuthOrderUnfreezeRsp

type FundAuthOrderUnfreezeRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	AuthNo       string  `json:"auth_no"`
	OutOrderNo   string  `json:"out_order_no"`
	OperationId  string  `json:"operation_id"`
	OutRequestNo string  `json:"out_request_no"`
	Amount       float64 `json:"amount"`
	Status       string  `json:"status"`
	GmtTrans     string  `json:"gmt_trans"`
	CreditAmount float64 `json:"credit_amount"`
	FundAmount   float64 `json:"fund_amount"`
}

type FundAuthOrderVoucherCreateRsp

type FundAuthOrderVoucherCreateRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	OutOrderNo   string `json:"out_order_no"`
	OutRequestNo string `json:"out_request_no"`
	CodeType     string `json:"code_type"`
	CodeValue    string `json:"code_value"`
	CodeUrl      string `json:"code_url"`
}

type FundBill

type FundBill struct {
	FundChannel string `json:"fund_channel"`
	Amount      string `json:"amount"`
	RealAmount  string `json:"real_amount"`
}
type Link struct {
	Link string `json:"link"`
	Desc string `json:"desc"`
	Rel  string `json:"rel"`
}

type OtherContributeDetail

type OtherContributeDetail struct {
	ContributeType   string `json:"contribute_type"`
	ContributeAmount string `json:"contribute_amount"`
}

type RefundChargeInfo

type RefundChargeInfo struct {
	RefundChargeFee        string                `json:"refund_charge_fee"`
	SwitchFeeRate          string                `json:"switch_fee_rate"`
	ChargeType             string                `json:"charge_type"`
	RefundSubFeeDetailList []*RefundSubFeeDetail `json:"refund_sub_fee_detail_list"`
}

type RefundDetailItem

type RefundDetailItem struct {
	FundChannel string `json:"fund_channel"`
	Amount      string `json:"amount"`
	RealAmount  string `json:"real_amount"`
	FundType    string `json:"fund_type"`
}

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"`
	OriTransOut   string `json:"ori_trans_out"`
	OriTransIn    string `json:"ori_trans_in"`
}

type RefundSubFeeDetail

type RefundSubFeeDetail struct {
	RefundChargeFee string `json:"refund_charge_fee"`
	SwitchFeeRate   string `json:"switch_fee_rate"`
}

type RefundVoucherDetail

type RefundVoucherDetail struct {
	Id                         string                   `json:"id"`
	Name                       string                   `json:"name"`
	Type                       string                   `json:"type"`
	Amount                     string                   `json:"amount"`
	MerchantContribute         string                   `json:"merchant_contribute"`
	OtherContribute            string                   `json:"other_contribute"`
	Memo                       string                   `json:"memo"`
	TemplateId                 string                   `json:"template_id"`
	OtherContributeDetail      []*OtherContributeDetail `json:"other_contribute_detail"`
	PurchaseBuyerContribute    string                   `json:"purchase_buyer_contribute"`
	PurchaseMerchantContribute string                   `json:"purchase_merchant_contribute"`
	PurchaseAntContribute      string                   `json:"purchase_ant_contribute"`
}

type SystemOauthTokenRsp

type SystemOauthTokenRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	UserId       string `json:"user_id"`
	OpenId       string `json:"open_id"`
	AccessToken  string `json:"access_token"`
	ExpiresIn    string `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	ReExpiresIn  string `json:"re_expires_in"`
	AuthStart    string `json:"auth_start"`
}

type TradeCancelRsp

type TradeCancelRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	TradeNo    string `json:"trade_no"`
	OutTradeNo string `json:"out_trade_no"`
	RetryFlag  string `json:"retry_flag"`
	Action     string `json:"action"`
}

type TradeCloseRsp

type TradeCloseRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	TradeNo    string `json:"trade_no"`
	OutTradeNo string `json:"out_trade_no"`
}

type TradeCreateRsp

type TradeCreateRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	TradeNo    string `json:"trade_no"`
	OutTradeNo string `json:"out_trade_no"`
}

type TradeFastPayRefundQueryRsp

type TradeFastPayRefundQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	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"`
	RefundRoyaltys          []*RefundRoyalty       `json:"refund_royaltys"`
	GmtRefundPay            string                 `json:"gmt_refund_pay"`
	RefundDetailItemList    []*RefundDetailItem    `json:"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"`
	DepositBackInfoList     []*DepositBackInfo     `json:"deposit_back_info_list"`
	RefundVoucherDetailList []*RefundVoucherDetail `json:"refund_voucher_detail_list"`
}

type TradePayRsp

type TradePayRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	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        []*FundBill      `json:"fund_bill_list"`
	StoreName           string           `json:"store_name"`
	DiscountGoodsDetail string           `json:"discount_goods_detail"`
	BuyerUserId         string           `json:"buyer_user_id"`
	BuyerOpenId         string           `json:"buyer_open_id"`
	VoucherDetailList   []*VoucherDetail `json:"voucher_detail_list"`
	MdiscountAmount     string           `json:"mdiscount_amount"`
	DiscountAmount      string           `json:"discount_amount"`
}

type TradePrecreateRsp

type TradePrecreateRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	OutTradeNo string `json:"out_trade_no"`
	QrCode     string `json:"qr_code"`
}

type TradeQueryRsp

type TradeQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	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"`
	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"`
	StoreName       string      `json:"store_name"`
	BuyerUserId     string      `json:"buyer_user_id"`
	BuyerOpenId     string      `json:"buyer_open_id"`
	BuyerUserType   string      `json:"buyer_user_type"`
	MdiscountAmount string      `json:"mdiscount_amount"`
	DiscountAmount  string      `json:"discount_amount"`
	ExtInfos        string      `json:"ext_infos"`
}

type TradeRefundRsp

type TradeRefundRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	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"`
	RefundDetailItemList    []*RefundDetailItem    `json:"refund_detail_item_list"`
	StoreName               string                 `json:"store_name"`
	BuyerUserId             string                 `json:"buyer_user_id"`
	BuyerOpenId             string                 `json:"buyer_open_id"`
	SendBackFee             string                 `json:"send_back_fee"`
	RefundHybAmount         string                 `json:"refund_hyb_amount"`
	RefundChargeInfoList    []*RefundChargeInfo    `json:"refund_charge_info_list"`
	RefundVoucherDetailList []*RefundVoucherDetail `json:"refund_voucher_detail_list"`
}

type UserAuthRelationshipQueryRsp

type UserAuthRelationshipQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	QueryDetail string `json:"query_detail"`
}

type UserCertifyOpenInitializeRsp

type UserCertifyOpenInitializeRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	CertifyId string `json:"certify_id"`
}

type UserCertifyOpenQueryRsp

type UserCertifyOpenQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	Passed       string `json:"passed"`
	IdentityInfo string `json:"identity_info"`
	MaterialInfo string `json:"material_info"`
	FailReason   string `json:"fail_reason"`
}

type UserDelOauthDetail

type UserDelOauthDetail struct {
	DelAuthTime string `json:"del_auth_time"`
	UserId      string `json:"user_id"`
	OpenId      string `json:"open_id"`
}

type UserDelOauthDetailQueryRsp

type UserDelOauthDetailQueryRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	Details []*UserDelOauthDetail `json:"details"`
}

type UserInfoShareRsp

type UserInfoShareRsp struct {
	StatusCode  int         `json:"status_code"`
	ErrResponse ErrResponse `json:"-"`

	UserId   string `json:"user_id"`
	OpenId   string `json:"open_id"`
	Avatar   string `json:"avatar"`
	City     string `json:"city"`
	NickName string `json:"nick_name"`
	Province string `json:"province"`
	Gender   string `json:"gender"`
}

type VoucherDetail

type VoucherDetail struct {
	Id                         string `json:"id"`
	Name                       string `json:"name"`
	Type                       string `json:"type"`
	Amount                     string `json:"amount"`
	MerchantContribute         string `json:"merchant_contribute"`
	OtherContribute            string `json:"other_contribute"`
	Memo                       string `json:"memo"`
	TemplateId                 string `json:"template_id"`
	PurchaseBuyerContribute    string `json:"purchase_buyer_contribute"`
	PurchaseMerchantContribute string `json:"purchase_merchant_contribute"`
	PurchaseAntContribute      string `json:"purchase_ant_contribute"`
}

Jump to

Keyboard shortcuts

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