stripe

package
v0.5.40 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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 BuildPaymentLinkConfig struct {
	TradeNo     string
	Price       string
	Quantity    int
	Metadata    map[string]string
	RedirectURI string
}

type Option

type Option func(*Options)

func WithRedirectDomain

func WithRedirectDomain(redirectDomain string) Option

func WithRedirectType

func WithRedirectType(redirectType string) Option

func WithSecretKey

func WithSecretKey(secretKey string) Option

func WithWebhookSecret

func WithWebhookSecret(webhookSecret string) Option

type Options

type Options struct {
	SecretKey      string
	WebhookSecret  string
	RedirectType   string
	RedirectDomain string
}

type Stripe

type Stripe struct {
	// contains filtered or unexported fields
}

func NewStripe

func NewStripe(opts ...Option) *Stripe

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) GetPrice

func (s *Stripe) GetPrice(id string) (*stripe.Price, error)

GetPrice 通过ID获取Price对象

func (*Stripe) Provide

func (s *Stripe) Provide(ctx context.Context) any

func (*Stripe) VerifyAppPaymentWebhook

func (s *Stripe) VerifyAppPaymentWebhook(req *http.Request) (*stripe.PaymentIntent, error)

VerifyAppPaymentWebhook 验证移动应用支付的Webhook回调 当移动应用完成支付后,Stripe会发送一个webhook到服务器 该方法用于验证webhook的签名并返回PaymentIntent对象

Jump to

Keyboard shortcuts

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