Documentation
¶
Overview ¶
payment 包提供了多种支付方式的统一接口实现
Package payment 支付相关功能 ¶
payment 包提供了多种支付方式的统一接口实现
Package payment 支付相关功能 ¶
payment 包提供了多种支付方式的统一接口实现
payment 包提供了多种支付方式的统一接口实现
Package payment 支付相关功能 提供多种支付方式的统一接口,包括支付宝、微信支付、Stripe等
Package payment 支付相关功能 ¶
Package payment 支付相关功能 ¶
Package payment 支付相关功能
Index ¶
- Constants
- func BytesToString(b []byte) (s string)
- func GetOwnerAndNameFromId(id string) (string, string)
- func GetRandomString(l int) string
- type AirWallexIntentInfo
- type AirWallexIntentResp
- type AirWallexTokenInfo
- type AirwallexClient
- func (c *AirwallexClient) CreateIntent(r *PayReq) (*AirWallexIntentResp, error)
- func (c *AirwallexClient) GetCheckoutUrl(intent *AirWallexIntentResp, r *PayReq) (string, error)
- func (c *AirwallexClient) GetIntentByOrderId(orderId string) (*AirWallexIntentInfo, error)
- func (c *AirwallexClient) GetToken() (string, error)
- type AirwallexIntent
- type AirwallexIntents
- type AirwallexPaymentProvider
- func (pp *AirwallexPaymentProvider) GetInvoice(...) (string, error)
- func (pp *AirwallexPaymentProvider) GetResponseError(err error) string
- func (pp *AirwallexPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *AirwallexPaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type AlipayPaymentProvider
- func (pp *AlipayPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *AlipayPaymentProvider) GetResponseError(err error) string
- func (pp *AlipayPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *AlipayPaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type BalancePaymentProvider
- func (pp *BalancePaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *BalancePaymentProvider) GetResponseError(err error) string
- func (pp *BalancePaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *BalancePaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type DummyPaymentProvider
- func (pp *DummyPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *DummyPaymentProvider) GetResponseError(err error) string
- func (pp *DummyPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *DummyPaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type GcInvoiceReqInfo
- type GcInvoiceRespInfo
- type GcNotifyRespInfo
- type GcPayReqInfo
- type GcPayRespInfo
- type GcPaymentProvider
- func (pp *GcPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *GcPaymentProvider) GetResponseError(err error) string
- func (pp *GcPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *GcPaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type GcRequestBody
- type GcResponseBody
- type NotifyResult
- type PayReq
- type PayResp
- type PaymentProvider
- type PaymentState
- type PaypalPaymentProvider
- func (pp *PaypalPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *PaypalPaymentProvider) GetResponseError(err error) string
- func (pp *PaypalPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *PaypalPaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type StripePaymentProvider
- func (pp *StripePaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *StripePaymentProvider) GetResponseError(err error) string
- func (pp *StripePaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *StripePaymentProvider) Pay(r *PayReq) (*PayResp, error)
- type WechatPayNotifyResponse
- type WechatPaymentProvider
- func (pp *WechatPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, ...) (string, error)
- func (pp *WechatPaymentProvider) GetResponseError(err error) string
- func (pp *WechatPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
- func (pp *WechatPaymentProvider) Pay(r *PayReq) (*PayResp, error)
Constants ¶
const (
PaymentEnvWechatBrowser = "WechatBrowser" // 微信浏览器环境
)
支付环境常量定义
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString 0 拷贝转换 slice byte 为 string
func GetOwnerAndNameFromId ¶
Types ¶
type AirWallexIntentInfo ¶
type AirWallexIntentResp ¶
type AirWallexIntentResp struct {
Id string `json:"id"` // 支付意图ID
ClientSecret string `json:"client_secret"` // 客户端密钥
MerchantOrderId string `json:"merchant_order_id"` // 商户订单ID
}
AirWallexIntentResp Airwallex支付意图响应结构体
type AirWallexTokenInfo ¶
type AirWallexTokenInfo struct {
Token string `json:"token"` // 访问令牌
ExpiresAt string `json:"expires_at"` // 过期时间字符串
// contains filtered or unexported fields
}
AirWallexTokenInfo Airwallex令牌信息结构体
type AirwallexClient ¶
type AirwallexClient struct {
ClientId string // 客户端ID
APIKey string // API密钥
APIEndpoint string // API端点
APICheckout string // 结账页面URL
// contains filtered or unexported fields
}
AirwallexClient Airwallex客户端结构体
func (*AirwallexClient) CreateIntent ¶
func (c *AirwallexClient) CreateIntent(r *PayReq) (*AirWallexIntentResp, error)
func (*AirwallexClient) GetCheckoutUrl ¶
func (c *AirwallexClient) GetCheckoutUrl(intent *AirWallexIntentResp, r *PayReq) (string, error)
func (*AirwallexClient) GetIntentByOrderId ¶
func (c *AirwallexClient) GetIntentByOrderId(orderId string) (*AirWallexIntentInfo, error)
func (*AirwallexClient) GetToken ¶
func (c *AirwallexClient) GetToken() (string, error)
type AirwallexIntent ¶
type AirwallexIntent struct {
Amount json.Number `json:"amount"`
Currency string `json:"currency"`
Id string `json:"id"`
Status string `json:"status"`
Descriptor string `json:"descriptor"`
MerchantOrderId string `json:"merchant_order_id"`
LatestPaymentAttempt struct {
Status string `json:"status"`
} `json:"latest_payment_attempt"`
Metadata map[string]interface{} `json:"metadata"`
}
type AirwallexIntents ¶
type AirwallexIntents struct {
Items []AirwallexIntent `json:"items"`
}
type AirwallexPaymentProvider ¶
type AirwallexPaymentProvider struct {
Client *AirwallexClient // Airwallex客户端实例
}
AirwallexPaymentProvider Airwallex支付提供者结构体
func NewAirwallexPaymentProvider ¶
func NewAirwallexPaymentProvider(clientId string, apiKey string) (*AirwallexPaymentProvider, error)
NewAirwallexPaymentProvider 创建新的Airwallex支付提供者实例 clientId: Airwallex客户端ID apiKey: Airwallex API密钥 返回Airwallex支付提供者实例和可能的错误
func (*AirwallexPaymentProvider) GetInvoice ¶
func (pp *AirwallexPaymentProvider) GetInvoice(paymentName, personName, personIdCard, personEmail, personPhone, invoiceType, invoiceTitle, invoiceTaxId string) (string, error)
GetInvoice 获取发票信息 paymentName: 支付名称 personName: 个人姓名 personIdCard: 身份证号 personEmail: 邮箱 personPhone: 电话 invoiceType: 发票类型 invoiceTitle: 发票抬头 invoiceTaxId: 税号 返回发票URL和可能的错误
func (*AirwallexPaymentProvider) GetResponseError ¶
func (pp *AirwallexPaymentProvider) GetResponseError(err error) string
GetResponseError 获取响应错误信息 err: 错误对象 返回错误描述字符串
func (*AirwallexPaymentProvider) Notify ¶
func (pp *AirwallexPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理Airwallex支付回调通知 body: 回调请求体 orderId: 订单ID 返回通知结果和可能的错误
type AlipayPaymentProvider ¶
AlipayPaymentProvider 支付宝支付提供商 实现支付宝支付功能
func NewAlipayPaymentProvider ¶
func NewAlipayPaymentProvider(appId string, appCertificate string, appPrivateKey string, authorityPublicKey string, authorityRootPublicKey string) (*AlipayPaymentProvider, error)
NewAlipayPaymentProvider 创建新的支付宝支付提供商实例 参数:
- appId: 应用ID
- appCertificate: 应用证书
- appPrivateKey: 应用私钥
- authorityPublicKey: 支付宝公钥
- authorityRootPublicKey: 支付宝根证书
返回:
- *AlipayPaymentProvider: 支付宝支付提供商实例
- error: 错误信息
func (*AlipayPaymentProvider) GetInvoice ¶
func (pp *AlipayPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取支付宝发票 当前不支持发票功能,返回空字符串 参数:
- paymentName: 支付名称
- personName: 个人姓名
- personIdCard: 身份证号
- personEmail: 邮箱
- personPhone: 电话
- invoiceType: 发票类型
- invoiceTitle: 发票抬头
- invoiceTaxId: 税号
返回:
- string: 发票信息(空)
- error: 错误信息
func (*AlipayPaymentProvider) GetResponseError ¶
func (pp *AlipayPaymentProvider) GetResponseError(err error) string
GetResponseError 获取支付宝响应错误信息 根据错误状态返回相应的字符串 参数:
- err: 错误对象
返回:
- string: 错误响应字符串
func (*AlipayPaymentProvider) Notify ¶
func (pp *AlipayPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理支付宝支付通知 查询订单状态并返回通知结果 参数:
- body: 通知内容
- orderId: 订单ID
返回:
- *NotifyResult: 通知结果
- error: 错误信息
type BalancePaymentProvider ¶
type BalancePaymentProvider struct{}
BalancePaymentProvider 余额支付提供者结构体
func NewBalancePaymentProvider ¶
func NewBalancePaymentProvider() (*BalancePaymentProvider, error)
NewBalancePaymentProvider 创建新的余额支付提供者实例 返回余额支付提供者实例和可能的错误
func (*BalancePaymentProvider) GetInvoice ¶
func (pp *BalancePaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取发票信息 paymentName: 支付名称 personName: 个人姓名 personIdCard: 身份证号 personEmail: 邮箱 personPhone: 电话 invoiceType: 发票类型 invoiceTitle: 发票抬头 invoiceTaxId: 税号 返回发票URL和可能的错误
func (*BalancePaymentProvider) GetResponseError ¶
func (pp *BalancePaymentProvider) GetResponseError(err error) string
GetResponseError 获取响应错误信息 err: 错误对象 返回错误描述字符串
func (*BalancePaymentProvider) Notify ¶
func (pp *BalancePaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理余额支付回调通知 body: 回调请求体 orderId: 订单ID 返回通知结果和可能的错误
type DummyPaymentProvider ¶
type DummyPaymentProvider struct{}
DummyPaymentProvider 虚拟支付提供商 用于测试和开发环境的模拟支付
func NewDummyPaymentProvider ¶
func NewDummyPaymentProvider() (*DummyPaymentProvider, error)
NewDummyPaymentProvider 创建新的虚拟支付提供商实例 返回:
- *DummyPaymentProvider: 虚拟支付提供商实例
- error: 错误信息
func (*DummyPaymentProvider) GetInvoice ¶
func (pp *DummyPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取虚拟发票 返回空字符串,不支持发票功能 参数:
- paymentName: 支付名称
- personName: 个人姓名
- personIdCard: 身份证号
- personEmail: 邮箱
- personPhone: 电话
- invoiceType: 发票类型
- invoiceTitle: 发票抬头
- invoiceTaxId: 税号
返回:
- string: 发票信息(空)
- error: 错误信息
func (*DummyPaymentProvider) GetResponseError ¶
func (pp *DummyPaymentProvider) GetResponseError(err error) string
GetResponseError 获取虚拟响应错误信息 返回空字符串 参数:
- err: 错误对象
返回:
- string: 错误响应字符串(空)
func (*DummyPaymentProvider) Notify ¶
func (pp *DummyPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理虚拟支付通知 直接返回支付成功状态 参数:
- body: 通知内容
- orderId: 订单ID
返回:
- *NotifyResult: 通知结果
- error: 错误信息
type GcInvoiceReqInfo ¶
type GcInvoiceReqInfo struct {
BusNo string `json:"busno"` // 业务号
PayerName string `json:"payername"` // 支付者姓名
IdNum string `json:"idnum"` // 身份证号
PayerType string `json:"payertype"` // 支付者类型
InvoiceTitle string `json:"invoicetitle"` // 发票抬头
Tin string `json:"tin"` // 税号
Phone string `json:"phone"` // 电话
Email string `json:"email"` // 邮箱
}
GcInvoiceReqInfo GC发票请求信息结构体
type GcInvoiceRespInfo ¶
type GcInvoiceRespInfo struct {
BusNo string `json:"busno"` // 业务号
State string `json:"state"` // 状态
EbillCode string `json:"ebillcode"` // 电子票据代码
EbillNo string `json:"ebillno"` // 电子票据号码
CheckCode string `json:"checkcode"` // 校验码
Url string `json:"url"` // 发票URL
Content string `json:"content"` // 内容
}
GcInvoiceRespInfo GC发票响应信息结构体
type GcNotifyRespInfo ¶
type GcNotifyRespInfo struct {
Xmpch string `json:"xmpch"` // 商户号
OrderDate string `json:"orderdate"` // 订单日期
OrderNo string `json:"orderno"` // 订单号
Amount float64 `json:"amount"` // 金额
Jylsh string `json:"jylsh"` // 交易流水号
TradeNo string `json:"tradeno"` // 交易号
PayMethod string `json:"paymethod"` // 支付方式
OrderState string `json:"orderstate"` // 订单状态
ReturnType string `json:"return_type"` // 返回类型
PayerId string `json:"payerid"` // 支付者ID
PayerName string `json:"payername"` // 支付者姓名
}
GcNotifyRespInfo GC通知响应信息结构体
type GcPayReqInfo ¶
type GcPayReqInfo struct {
OrderDate string `json:"orderdate"` // 订单日期
OrderNo string `json:"orderno"` // 订单号
Amount string `json:"amount"` // 金额
Xmpch string `json:"xmpch"` // 商户号
Body string `json:"body"` // 商品描述
ReturnUrl string `json:"return_url"` // 返回URL
NotifyUrl string `json:"notify_url"` // 通知URL
PayerId string `json:"payerid"` // 支付者ID
PayerName string `json:"payername"` // 支付者姓名
Remark1 string `json:"remark1"` // 备注1
Remark2 string `json:"remark2"` // 备注2
}
GcPayReqInfo GC支付请求信息结构体
type GcPayRespInfo ¶
type GcPayRespInfo struct {
Jylsh string `json:"jylsh"` // 交易流水号
Amount string `json:"amount"` // 金额
PayerId string `json:"payerid"` // 支付者ID
PayerName string `json:"payername"` // 支付者姓名
PayUrl string `json:"payurl"` // 支付URL
}
GcPayRespInfo GC支付响应信息结构体
type GcPaymentProvider ¶
GcPaymentProvider GC支付提供者结构体
func NewGcPaymentProvider ¶
func NewGcPaymentProvider(clientId string, clientSecret string, host string) *GcPaymentProvider
NewGcPaymentProvider 创建新的GC支付提供者实例 clientId: 客户端ID(商户号) clientSecret: 客户端密钥 host: 主机地址 返回GC支付提供者实例
func (*GcPaymentProvider) GetInvoice ¶
func (pp *GcPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取GC支付的发票 参数:
- paymentName: 支付名称(订单号)
- personName: 个人姓名
- personIdCard: 个人身份证号
- personEmail: 个人邮箱
- personPhone: 个人电话
- invoiceType: 发票类型
- invoiceTitle: 发票抬头
- invoiceTaxId: 发票税号
返回值:
- string: 发票URL
- error: 错误信息
func (*GcPaymentProvider) GetResponseError ¶
func (pp *GcPaymentProvider) GetResponseError(err error) string
GetResponseError 根据错误信息返回响应状态 参数:
- err: 错误信息
返回值:
- string: 响应状态("success"或"fail")
func (*GcPaymentProvider) Notify ¶
func (pp *GcPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理GC支付的回调通知 body: 通知请求体字节数组 orderId: 订单ID 返回通知结果和可能的错误
type GcRequestBody ¶
type GcRequestBody struct {
Op string `json:"op"` // 操作类型
Xmpch string `json:"xmpch"` // 商户号
Version string `json:"version"` // 版本号
Data string `json:"data"` // 数据(Base64编码)
RequestTime string `json:"requesttime"` // 请求时间
Sign string `json:"sign"` // 签名
}
GcRequestBody GC请求体结构体
type GcResponseBody ¶
type GcResponseBody struct {
Op string `json:"op"` // 操作类型
Xmpch string `json:"xmpch"` // 商户号
Version string `json:"version"` // 版本号
ReturnCode string `json:"return_code"` // 返回码
ReturnMsg string `json:"return_msg"` // 返回消息
Data string `json:"data"` // 数据(Base64编码)
NotifyTime string `json:"notifytime"` // 通知时间
Sign string `json:"sign"` // 签名
}
GcResponseBody GC响应体结构体
type NotifyResult ¶
type NotifyResult struct {
PaymentName string // 支付名称
PaymentStatus PaymentState // 支付状态
NotifyMessage string // 通知消息
ProductName string // 产品名称
ProductDisplayName string // 产品显示名称
ProviderName string // 支付提供商名称
Price float64 // 价格
Currency string // 货币类型
OrderId string // 订单ID
}
NotifyResult 支付通知结果结构体 包含支付通知回调的结果信息
type PayReq ¶
type PayReq struct {
ProviderName string // 支付提供商名称
ProductName string // 产品名称
PayerName string // 付款人姓名
PayerId string // 付款人ID
PayerEmail string // 付款人邮箱
PaymentName string // 支付名称
ProductDisplayName string // 产品显示名称
ProductDescription string // 产品描述
ProductImage string // 产品图片
Price float64 // 价格
Currency string // 货币类型
ReturnUrl string // 返回URL
NotifyUrl string // 通知URL
PaymentEnv string // 支付环境
}
PayReq 支付请求结构体 包含支付所需的所有参数信息
type PayResp ¶
type PayResp struct {
PayUrl string // 支付URL
OrderId string // 订单ID
AttachInfo map[string]interface{} // 附加信息
}
PayResp 支付响应结构体 包含支付后返回的信息
type PaymentProvider ¶
type PaymentProvider interface {
// Pay 执行支付操作
// 参数:
// - req: 支付请求信息
// 返回:
// - *PayResp: 支付响应信息
// - error: 错误信息
Pay(req *PayReq) (*PayResp, error)
// Notify 处理支付通知
// 参数:
// - body: 通知内容
// - orderId: 订单ID
// 返回:
// - *NotifyResult: 通知结果
// - error: 错误信息
Notify(body []byte, orderId string) (*NotifyResult, error)
// GetInvoice 获取发票
// 参数:
// - paymentName: 支付名称
// - personName: 个人姓名
// - personIdCard: 身份证号
// - personEmail: 邮箱
// - personPhone: 电话
// - invoiceType: 发票类型
// - invoiceTitle: 发票抬头
// - invoiceTaxId: 税号
// 返回:
// - string: 发票信息
// - error: 错误信息
GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
// GetResponseError 获取响应错误信息
// 参数:
// - err: 错误对象
// 返回:
// - string: 错误响应字符串
GetResponseError(err error) string
}
PaymentProvider 支付提供商接口 定义所有支付提供商必须实现的方法
type PaymentState ¶
type PaymentState string
PaymentState 支付状态类型
const ( PaymentStatePaid PaymentState = "Paid" // 已支付 PaymentStateCreated PaymentState = "Created" // 已创建 PaymentStateCanceled PaymentState = "Canceled" // 已取消 PaymentStateTimeout PaymentState = "Timeout" // 超时 PaymentStateError PaymentState = "Error" // 错误 )
支付状态常量定义
type PaypalPaymentProvider ¶
PaypalPaymentProvider PayPal支付提供者结构体
func NewPaypalPaymentProvider ¶
func NewPaypalPaymentProvider(clientID string, secret string) (*PaypalPaymentProvider, error)
NewPaypalPaymentProvider 创建新的PayPal支付提供者实例 clientID: PayPal应用的客户端ID secret: PayPal应用的密钥 返回PayPal支付提供者实例和可能的错误
func (*PaypalPaymentProvider) GetInvoice ¶
func (pp *PaypalPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取发票信息 paymentName: 支付名称 personName: 个人姓名 personIdCard: 身份证号 personEmail: 邮箱 personPhone: 电话 invoiceType: 发票类型 invoiceTitle: 发票抬头 invoiceTaxId: 税号 返回发票URL和可能的错误
func (*PaypalPaymentProvider) GetResponseError ¶
func (pp *PaypalPaymentProvider) GetResponseError(err error) string
GetResponseError 获取响应错误信息 err: 错误对象 返回错误描述字符串
func (*PaypalPaymentProvider) Notify ¶
func (pp *PaypalPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理PayPal支付回调通知 body: 回调请求体 orderId: 订单ID 返回通知结果和可能的错误
type StripePaymentProvider ¶
type StripePaymentProvider struct {
PublishableKey string // 可发布密钥
SecretKey string // 秘密密钥
// contains filtered or unexported fields
}
StripePaymentProvider Stripe支付提供商 实现Stripe支付功能
func NewStripePaymentProvider ¶
func NewStripePaymentProvider(PublishableKey, SecretKey string) (*StripePaymentProvider, error)
NewStripePaymentProvider 创建新的Stripe支付提供商实例 参数:
- PublishableKey: Stripe可发布密钥
- SecretKey: Stripe秘密密钥
返回:
- *StripePaymentProvider: Stripe支付提供商实例
- error: 错误信息
func (*StripePaymentProvider) GetInvoice ¶
func (pp *StripePaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取Stripe发票 当前不支持发票功能,返回空字符串 参数:
- paymentName: 支付名称
- personName: 个人姓名
- personIdCard: 身份证号
- personEmail: 邮箱
- personPhone: 电话
- invoiceType: 发票类型
- invoiceTitle: 发票抬头
- invoiceTaxId: 税号
返回:
- string: 发票信息(空)
- error: 错误信息
func (*StripePaymentProvider) GetResponseError ¶
func (pp *StripePaymentProvider) GetResponseError(err error) string
GetResponseError 获取Stripe响应错误信息 根据错误状态返回相应的字符串 参数:
- err: 错误对象
返回:
- string: 错误响应字符串
func (*StripePaymentProvider) Notify ¶
func (pp *StripePaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理Stripe支付通知 查询结账会话和支付意图状态并返回通知结果 参数:
- body: 通知内容
- orderId: 订单ID
返回:
- *NotifyResult: 通知结果
- error: 错误信息
type WechatPayNotifyResponse ¶
type WechatPayNotifyResponse struct {
Code string `json:"Code"` // 响应代码
Message string `json:"Message"` // 响应消息
}
WechatPayNotifyResponse 微信支付通知响应结构体
type WechatPaymentProvider ¶
WechatPaymentProvider 微信支付提供商 实现微信支付功能
func NewWechatPaymentProvider ¶
func NewWechatPaymentProvider(mchId string, apiV3Key string, appId string, serialNo string, privateKey string) (*WechatPaymentProvider, error)
NewWechatPaymentProvider 创建新的微信支付提供商实例 参考文档: https://pay.weixin.qq.com/docs/merchant/products/native-payment/preparation.html 参数:
- mchId: 商户号
- apiV3Key: API v3密钥
- appId: 应用ID
- serialNo: 证书序列号
- privateKey: 私钥
返回:
- *WechatPaymentProvider: 微信支付提供商实例
- error: 错误信息
func (*WechatPaymentProvider) GetInvoice ¶
func (pp *WechatPaymentProvider) GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
GetInvoice 获取微信支付发票 当前不支持发票功能,返回空字符串 参数:
- paymentName: 支付名称
- personName: 个人姓名
- personIdCard: 身份证号
- personEmail: 邮箱
- personPhone: 电话
- invoiceType: 发票类型
- invoiceTitle: 发票抬头
- invoiceTaxId: 税号
返回:
- string: 发票信息(空)
- error: 错误信息
func (*WechatPaymentProvider) GetResponseError ¶
func (pp *WechatPaymentProvider) GetResponseError(err error) string
GetResponseError 获取微信支付响应错误信息 根据错误状态构造微信支付通知响应 参数:
- err: 错误对象
返回:
- string: 错误响应JSON字符串
func (*WechatPaymentProvider) Notify ¶
func (pp *WechatPaymentProvider) Notify(body []byte, orderId string) (*NotifyResult, error)
Notify 处理微信支付通知 查询订单状态并返回通知结果 参数:
- body: 通知内容
- orderId: 订单ID
返回:
- *NotifyResult: 通知结果
- error: 错误信息