fix:支付
This commit is contained in:
@@ -29,15 +29,15 @@ type Pay interface {
|
||||
}
|
||||
|
||||
type GeneratePrepaymentReq struct {
|
||||
OrderSn string `json:"order_sn"` // 订单编号
|
||||
Amount int64 `json:"amount"` // 支付金额
|
||||
Currency string `json:"currency"` // 支付货币
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ProductDescription string `json:"product_description"` // 商品描述
|
||||
ProductImages []*string `json:"product_imageso"` // 商品照片
|
||||
Quantity int64 `json:"quantity"` //数量
|
||||
SuccessURL string `json:"success_url"` // 支付成功回调
|
||||
CancelURL string `json:"cancel_url"` // 支付取消回调
|
||||
Metadata map[string]string `json:"metadata"` // 元数据
|
||||
Amount int64 `json:"amount"` // 支付金额
|
||||
Currency string `json:"currency"` // 支付货币
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ProductDescription string `json:"product_description"` // 商品描述
|
||||
ProductImages []*string `json:"product_imageso"` // 商品照片
|
||||
Quantity int64 `json:"quantity"` //数量
|
||||
SuccessURL string `json:"success_url"` // 支付成功回调
|
||||
CancelURL string `json:"cancel_url"` // 支付取消回调
|
||||
}
|
||||
|
||||
type GeneratePrepaymentRes struct {
|
||||
|
||||
@@ -50,7 +50,7 @@ func (stripePay *Stripe) GeneratePrepayment(req *GeneratePrepaymentReq) (res *Ge
|
||||
case "session":
|
||||
// session 方式
|
||||
params := &stripe.CheckoutSessionParams{
|
||||
PaymentIntentData: &stripe.CheckoutSessionPaymentIntentDataParams{Metadata: map[string]string{"order_sn": req.OrderSn}},
|
||||
PaymentIntentData: &stripe.CheckoutSessionPaymentIntentDataParams{Metadata: req.Metadata},
|
||||
// Params: stripe.Params{Metadata: map[string]string{"order_id": "1111111111111"}},
|
||||
PaymentMethodTypes: stripe.StringSlice([]string{
|
||||
"card",
|
||||
@@ -79,7 +79,6 @@ func (stripePay *Stripe) GeneratePrepayment(req *GeneratePrepaymentReq) (res *Ge
|
||||
case "intent":
|
||||
// 密钥方式
|
||||
params := &stripe.PaymentIntentParams{
|
||||
Params: stripe.Params{Metadata: map[string]string{"order_sn": req.OrderSn}},
|
||||
Amount: stripe.Int64(req.Amount),
|
||||
Currency: stripe.String(string(req.Currency)),
|
||||
PaymentMethodTypes: stripe.StringSlice([]string{
|
||||
@@ -87,6 +86,9 @@ func (stripePay *Stripe) GeneratePrepayment(req *GeneratePrepaymentReq) (res *Ge
|
||||
// "ideal",
|
||||
}),
|
||||
}
|
||||
for key, item := range req.Metadata {
|
||||
params.AddMetadata(key, item)
|
||||
}
|
||||
resPaymentintent, err := paymentintent.New(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user