package key import "fmt" type PaymentType int64 const ( PaymentTypeNone PaymentType = iota PaymentTypeDirect PaymentTypeApple PaymentTypeGoogle PaymentTypeHuawei PaymentTypeAws PaymentTypePix ) var paymentTypeNameMap = map[PaymentType]string{ PaymentTypeDirect: "Direct", PaymentTypeGoogle: "Google", PaymentTypeApple: "Apple", PaymentTypeAws: "Aws", PaymentTypeHuawei: "Huawei", PaymentTypePix: "Pix", } var paymentTypeReasonMap = map[PaymentType]string{ PaymentTypeDirect: ReasonDirectPay, PaymentTypeApple: ReasonApplePay, PaymentTypeGoogle: ReasonGooglePay, PaymentTypeHuawei: ReasonHuaweiPay, PaymentTypeAws: ReasonAwsPay, PaymentTypePix: ReasonPixPay, } func (p PaymentType) Val() int64 { return int64(p) } func (p PaymentType) Reason() string { return paymentTypeReasonMap[p] } func (p PaymentType) String() string { if s, ok := paymentTypeNameMap[p]; ok { return s } return fmt.Sprintf("paymentType=%d?", p) } func (p *PaymentType) FromString(s string) PaymentType { for k, v := range paymentTypeNameMap { if v == s { *p = k return k } } return PaymentTypeNone } const ( PaymentPlatformOnePay = "OnePay" PaymentPlatformCashPay = "CashPay" PaymentPlatformLambdaPay = "LambdaPay" ) const ( PaymentCallbackStatusSuccess = "SUCCESS" PaymentCallbackStatusFail = "FAIL" PaymentCallbackStatusRefund = "REFUND" PaymentCallbackStatusUnknown = "UNKNOWN" PaymentCallbackStatusIgnore = "IGNORE" ) const TextPaymentOrderStateHeader = "TextPaymentOrderState" const ( PaymentOrderStateCreated = "Created" // 支付订单状态:已创建 PaymentOrderStateRemittanceInvokeFail = "RemittanceInvokeFail" // 支付订单状态:汇款下单失败 PaymentOrderStateRemittanceInProgress = "RemittanceInProgress" // 支付订单状态:汇款进行中 PaymentOrderStateRemittanceCallbackFail = "RemittanceCallbackFail" // 支付订单状态:汇款回调失败 PaymentOrderStateRemittanceSuccess = "RemittanceSuccess" // 支付订单状态:汇款已验证 PaymentOrderStateCompleted = "Completed" // 支付订单状态:用户到账 ) const ( // Create order StepPaymentServerCreateOrderStart = "ServerCreateOrderStart" // 服务器创建订单开始 StepPaymentServerCreateOrderVerifyFail = "ServerCreateOrderVerifyFail" // 服务器创建订单参数错误 StepPaymentServerCreateOrderVerifySuccess = "ServerCreateOrderVerifySuccess" // 服务器创建订单参数正确 StepPaymentServerCreateOrderSuccess = "ServerCreateOrderSuccess" // 服务器创建订单成功 // Invoke StepPaymentServerInvokeStart = "ServerInvokeStart" // 服务器发起第三方请求开始 StepPaymentServerInvokeSuccess = "ServerInvokeSuccess" // 服务器发起第三方请求成功 StepPaymentServerInvokeFail = "ServerInvokeFail" // 服务器发起第三方请求失败 // Callback StepPaymentServerCallbackStart = "ServerCallbackStart" // 服务器收到第三方回调开始 StepPaymentServerCallbackVerifyFail = "ServerCallbackVerifyFail" // 服务器收到第三方回调参数错误 StepPaymentServerCallbackVerifySuccess = "ServerCallbackVerifySuccess" // 服务器收到第三方回调参数正确 StepPaymentServerCallbackFail = "ServerCallbackFail" // 服务器收到第三方回调失败 StepPaymentServerCallbackSuccess = "ServerCallbackSuccess" // 服务器收到第三方回调成功 // Settle StepPaymentServerSettleSuccess = "ServerSettleSuccess" // 服务器结算成功 // Client StepPaymentClientCreateOrder = "ClientCreateOrder" // 客户端创建订单 StepPaymentClientCreateOrderSuccess = "ClientCreateOrderSuccess" // 客户端创建订单成功(展示二维码) StepPaymentClientSettleSuccess = "ClientSettleSuccess" // 客户端结算成功 ) const ( // Purchase StepPaymentServerPurchaseStart = "ServerPurchaseStart" // 服务器发起购买开始 StepPaymentServerPurchaseVerifyFail = "ServerPurchaseVerifyFail" // 服务器发起购买失败 StepPaymentServerPurchaseSuccess = "ServerPurchaseSuccess" // 服务器发起购买成功 )