pay

package
v0.0.0-...-e1e7c94 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PaymentNotPaid    = "notpaid"
	PaymentProcessing = "processing"
	PaymentFailed     = "failed"
	PaymentExpired    = "expired"
	PaymentSuccess    = "success"
	PaymentUnknown    = "unknown"
)
View Source
const (
	DefaultPort   string = "443"
	DefaultDomain string = "cloud.sealos.io"
)
View Source
const (
	USD = "usd"
	CNY = "cny"
)

const currentcy

View Source
const (
	WechatPrivateKey           = "WechatPrivateKey"
	MchID                      = "MchID"
	MchCertificateSerialNumber = "MchCertificateSerialNumber"
	MchAPIv3Key                = "MchAPIv3Key"
	AppID                      = "AppID"
	NotifyCallbackURL          = "NotifyCallbackURL"

	StatusSuccess      = "SUCCESS"
	StatusProcessing   = "PROCESSING"
	StatusNotPay       = "NOTPAY"
	StatusFail         = "FAILED"
	DefaultCallbackURL = "https://sealos.io/payment/wechat/callback"
)

ENV keys

View Source
const StripeAPIKEY = "STRIPE_API_KEY"

Variables

View Source
var Currency string
View Source
var DefaultURL = fmt.Sprintf("https://%s", env.GetEnvWithDefault("DOMAIN", DefaultDomain))

Functions

func CreateCheckoutSession

func CreateCheckoutSession(amount int64, currency, successURL, cancelURL string) (*stripe.CheckoutSession, error)

func ExpireSession

func ExpireSession(sessionID string) (*stripe.CheckoutSession, error)

ExpireSession

func GetRandomString

func GetRandomString(n int) string

func GetSession

func GetSession(sessionID string) (*stripe.CheckoutSession, error)

func NewClient

func NewClient(ctx context.Context, opts ...core.ClientOption) (*core.Client, error)

func QueryOrder

func QueryOrder(orderID string) (*payments.Transaction, error)

func WechatPay

func WechatPay(amount int64, user, tradeNO, describe, callback string) (string, error)

1 ¥ = amount 100

Types

type Interface

type Interface interface {
	CreatePayment(amount int64, user, describe string) (string, string, error)
	GetPaymentDetails(sessionID string) (string, int64, error)
	ExpireSession(payment string) error
}

func NewPayHandler

func NewPayHandler(paymentMethod string) (Interface, error)

type StripePayment

type StripePayment struct {
}

func (StripePayment) CreatePayment

func (s StripePayment) CreatePayment(amount int64, _, _ string) (string, string, error)

func (StripePayment) ExpireSession

func (s StripePayment) ExpireSession(sessionID string) error

func (StripePayment) GetPaymentDetails

func (s StripePayment) GetPaymentDetails(sessionID string) (string, int64, error)

type WechatPayment

type WechatPayment struct {
}

func (WechatPayment) CreatePayment

func (w WechatPayment) CreatePayment(amount int64, user, describe string) (string, string, error)

func (WechatPayment) ExpireSession

func (w WechatPayment) ExpireSession(_ string) error

func (WechatPayment) GetPaymentDetails

func (w WechatPayment) GetPaymentDetails(sessionID string) (string, int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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