このPAYMENTMETHODは、以前に顧客に取り付けられる、または顧客から取り外したことなく使用した、そして再び使用されなくてもよいです

Josheee:

ここに奇妙な問題を持ちます。ドキュメントの後、私は既存の顧客にPAYMENTMETHODを添付していますが、それは働いていません。大雑把に、I:

  1. 顧客を作成します
  2. 顧客と支払意図を作成します
  3. 支払意図を持つカード要素を作成します
  4. 顧客がカード情報を入力します
  5. 確認の支払いが成功し、バックエンドへの意思バックを送りました
  6. 意図は成功したと、顧客が自分のカードを保存することを選択した場合、意図方法と顧客との支払方法を作成します
  7. エラーが出ます

コード:

  1. パイソン: stripe.Customer.create(email=user.email, name=user.full_name)
  2. パイソン: stripe.PaymentIntent.create(amount=amount, currency="aud", customer=user.stripe_customer_id)
  3. JS: Stripe('{{ stripe_publishable_key }}').elements().create("card");
  4. ユーザーは:カード情報を入力します
  5. JS: stripe.confirmCardPayment('{{ clientSecret }}', { payment_method: { card: card, billing_details: { // name: 'Jenny Rosen' }, } }).then(function (result) { if (result.error) { // Show error to your customer (e.g., insufficient funds) console.log(result.error.message); var displayError = document.getElementById('card-errors'); displayError.textContent = result.error.message; } else { // The payment has been processed! if (result.paymentIntent.status === 'succeeded') { // Show a success message to your customer // There's a risk of the customer closing the window before callback // execution. Set up a webhook or plugin to listen for the // payment_intent.succeeded event that handles any business critical // post-payment actions. $('#fake-submit').click(); } } });
  6. パイソン: stripe.PaymentMethod.attach(stripe.PaymentIntent.retrieve(intent_id).payment_method, customer=user.stripe_customer_id)
  7. エラー: Request req_request_id: This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.
ログイン:

ストライプのドキュメントに問題があるように見えます。

https://stripe.com/docs/payments/save-after-payment#web-collect-card-details彼らが持っています:

    setup_future_usage: 'off_session'

しかし、上https://stripe.com/docs/payments/save-and-reuse#web-collect-card-details彼らはこの臨界線が欠落しています。

彼らはフロントエンドに自分のカードを保存したい場合はしかし、あなたの場合には、ユーザーが選択していますか?その後、バックエンドでカードを保存する必要はありませんし、それを保存することができconfirmCardPaymentコール:https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-data-save_payment_method

save_payment_method ブーリアン

場合はPaymentIntent、顧客に関連付けられていると、このパラメータが設定されtrue、提供さ支払方法は、顧客に添付されます。デフォルトはfalse

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=4582&siteId=1