我如何授权 50 美元,然后获取 40 美元?

问题描述 投票:0回答:1

我从

SetupIntentParams
开始:

  piparams := &stripe.SetupIntentParams{
    Customer:           stripe.String(cID),
    PaymentMethodTypes: stripe.StringSlice([]string{"card"}),
  }
  si, _ := setupintent.New(piparams)

这有效,我可以通过以下方式将 JSON 发送到 ios:

  send["setup_intent"] = si.ID
  send["client_secret"] = si.ClientSecret
  send["ephemeral_key"] = ek.Secret
  send["customer_id"] = cID
  send["publishable_key"] = PK

ios 使用此功能向客户的帐户添加新的付款方式。

然后 ios 向 go 发送新的 payment_method_id 并使用它来制作

PaymentIntent
:

  piparams := &stripe.PaymentIntentParams{
    Amount:             stripe.Int64(5000),
    Currency:           stripe.String(string(stripe.CurrencyUSD)),
    Customer:           stripe.String(cID),
    PaymentMethod:      stripe.String(pmid),
    Confirm:            stripe.Bool(false),
    SetupFutureUsage:   stripe.String("off_session"),
    ConfirmationMethod: stripe.String(string(stripe.PaymentIntentConfirmationMethodAutomatic)),
  }
  pi, _ := paymentintent.New(piparams)

我小心翼翼地将

SetupFutureUsage
设置为
off_session
,并成功达成付款意向。我还不想获取最终金额。需要一段时间才能知道向用户收取什么费用,然后我想打电话:

  p, _ := paymentintent.Get(pi, nil)
  _, err = paymentintent.Capture(p.ID, &stripe.PaymentIntentCaptureParams{
    AmountToCapture: stripe.Int64(4000),
  })

但我收到以下错误之一:

This PaymentIntent could not be captured because it has a status of requires_confirmation.

"This PaymentIntent could not be captured because it has already been captured.

This PaymentIntent could not be captured because it has a status of requires_action.

取决于我如何设置

    Confirm:            stripe.Bool(false),
    ConfirmationMethod: stripe.String(string(stripe.PaymentIntentConfirmationMethodAutomatic)),

ios 是否确认。我缺少什么?为什么我不能进入 ios 使 PaymentIntent 全部确认并准备好进入 Capture 的状态?

ios go stripe-payments
1个回答
0
投票

所有这些错误都是针对付款意图的不同状态

requires_confirmaion
表示Intent需要确认,如果不需要与客户交互则可以通过
Comfirm: stripe.Bool(true)

requires_action
表示需要完成付款,可能需要 3DS 身份验证。

already_captured
表示您已经做过并且不能再做。

您的应用程序需要在创建后检查生成的付款意图,以确定状态是什么。您的应用程序将需要根据您的付款意图的当前状态采取不同的操作,并且您需要在您的端对该逻辑进行编程。

© www.soinside.com 2019 - 2024. All rights reserved.