Documentation
¶
Index ¶
- Constants
- type AppPaymentConfig
- type BuildPaymentLinkConfig
- type Option
- type Options
- type Stripe
- func (s *Stripe) BuildPaymentLinkURL(conf *BuildPaymentLinkConfig) (string, error)
- func (s *Stripe) GenerateAppPayment(conf *AppPaymentConfig) (*stripe.PaymentIntent, error)
- func (s *Stripe) GetPaymentIntent(id string) (*stripe.PaymentIntent, error)
- func (s *Stripe) GetPrice(id string) (*stripe.Price, error)
- func (s *Stripe) Provide(ctx context.Context) any
- func (s *Stripe) VerifyAppPaymentWebhook(req *http.Request) (*stripe.PaymentIntent, error)
Constants ¶
View Source
const ( InAppPurchaseSuccess = "payment_intent.succeeded" // 支付成功 InAppPurchaseFail = "payment_intent.payment_failed" // 支付失败 InAppPurchaseAttached = "payment_method.attached" // 支付方法附加成功 )
View Source
const ( CheckoutSeesionPaid = "paid" // 已支付 CheckoutSeesionNoPaymentRequired = "no_payment_required" // 无需支付 CheckoutSeesionUnpaid = "unpaid" // 未支付 )
View Source
const ( RedirectTypeRedirect = "redirect" RedirectTypeHostedConfirmation = "hosted_confirmation" )
View Source
const (
CheckoutSeesionCompleted = "checkout.session.completed"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppPaymentConfig ¶
type AppPaymentConfig struct {
Amount int64 // 支付金额(以分为单位)
Currency string // 货币代码,例如 "usd", "cny"
Description string // 订单描述
Metadata map[string]string // 元数据,可以包含订单号等信息
Customer string // 可选,客户ID
ReceiptEmail string // 可选,收据邮箱
}
AppPaymentConfig 用于移动应用程序支付的配置
type BuildPaymentLinkConfig ¶
type Option ¶
type Option func(*Options)
func WithRedirectDomain ¶
func WithRedirectType ¶
func WithSecretKey ¶
func WithWebhookSecret ¶
type Stripe ¶
type Stripe struct {
// contains filtered or unexported fields
}
func (*Stripe) BuildPaymentLinkURL ¶
func (s *Stripe) BuildPaymentLinkURL(conf *BuildPaymentLinkConfig) (string, error)
func (*Stripe) GenerateAppPayment ¶
func (s *Stripe) GenerateAppPayment(conf *AppPaymentConfig) (*stripe.PaymentIntent, error)
GenerateAppPayment 为移动应用创建支付Intent 返回clientSecret,可以在移动应用中使用该值初始化支付流程
func (*Stripe) GetPaymentIntent ¶
func (s *Stripe) GetPaymentIntent(id string) (*stripe.PaymentIntent, error)
GetPaymentIntent 通过ID获取PaymentIntent对象 可用于查询支付状态
func (*Stripe) VerifyAppPaymentWebhook ¶
VerifyAppPaymentWebhook 验证移动应用支付的Webhook回调 当移动应用完成支付后,Stripe会发送一个webhook到服务器 该方法用于验证webhook的签名并返回PaymentIntent对象
Click to show internal directories.
Click to hide internal directories.