square

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Name = `square`

Variables

View Source
var SupportedCurrencies = []string{
	"USD", "CAD", "EUR", "GBP", "AUD", "JPY",
}

Functions

func AmountToCentInt

func AmountToCentInt(amount float64) int64

AmountToCentInt 金额转分为整数(Square要求整数分单位)

func CentToAmount

func CentToAmount(cent int64) float64

CentToAmount 分转金额

func MapRefundStatus

func MapRefundStatus(status string) string

MapRefundStatus 映射 Square 退款状态 状态文档: https://developer.square.com/reference/square/enums/RefundStatus

func MappingStatus

func MappingStatus(status string) string

MappingStatus 映射 Square 支付状态 状态文档: https://developer.square.com/reference/square/enums/PaymentStatus

func MoneyFeeToString

func MoneyFeeToString(moneyFee float64) string

MoneyFeeToString 金额转字符串

func New

func New() payment.Driver

Types

type Square

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

func (*Square) IsSupported

func (a *Square) IsSupported(s config.Support) bool

func (*Square) Pay

func (a *Square) Pay(ctx echo.Context, cfg *config.Pay) (*config.PayResponse, error)

Pay 创建支付链接(使用 Square Payments API + Web Payment SDK 流程) 文档: https://developer.squareup.com/reference/square/payments-api/create-payment

func (*Square) PayNotify

func (a *Square) PayNotify(ctx echo.Context) error

PayNotify Square 通过 webhook 发送通知 文档: https://developer.square.com/docs/webhooks/overview

func (*Square) PayQuery

func (a *Square) PayQuery(ctx echo.Context, cfg *config.Query) (*config.Result, error)

PayQuery 查询支付状态 文档: https://developer.squareup.com/reference/square/payments-api/get-payment

func (*Square) Refund

func (a *Square) Refund(ctx echo.Context, cfg *config.Refund) (*config.Result, error)

Refund 发起退款 文档: https://developer.squareup.com/reference/square/refunds-api/create-refund

func (*Square) RefundNotify

func (a *Square) RefundNotify(ctx echo.Context) error

RefundNotify 退款通知处理

func (*Square) RefundQuery

func (a *Square) RefundQuery(ctx echo.Context, cfg *config.Query) (*config.Result, error)

RefundQuery 查询退款状态 文档: https://developer.squareup.com/reference/square/refunds-api/get-refund

func (*Square) SetAccount

func (a *Square) SetAccount(account *config.Account) payment.Driver

func (*Square) SetNotifyCallback

func (a *Square) SetNotifyCallback(callback payment.NotifyCallback) payment.Driver

func (*Square) VerifySign

func (a *Square) VerifySign(ctx echo.Context) error

VerifySign 验证 Square Webhook 签名(HMAC-SHA256) 文档: https://developer.squareup.com/docs/webhooks/overview#step-2-verify-the-webhook-event-signature Square 发送: X-Square-Signature = HMAC-SHA256(notification_url + body, webhook_signature_key)

Jump to

Keyboard shortcuts

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