Josheee :
여기에 이상한 문제를 가졌어요. 워드 프로세서에 따라, 나는 기존 고객에게 PAYMENTMETHOD를 부착하고 있지만, 제대로 동작하지 않습니다. 대략, I :
- 고객을 만들
- 고객과 지불 의도를 만들
- 지불 의도 카드 요소를 생성
- 고객은 카드 정보를 입력
- 확인 지불 성공 및 백엔드 의도 등을 전송
- 의도는 성공과 고객이 카드를 저장하도록 선택한 경우, 의도 방법 및 고객과의 지불 방법을 만들
- 오류
코드:
- 파이썬 :
stripe.Customer.create(email=user.email, name=user.full_name)
- 파이썬 :
stripe.PaymentIntent.create(amount=amount, currency="aud", customer=user.stripe_customer_id)
- JS :
Stripe('{{ stripe_publishable_key }}').elements().create("card");
- 사용자 : 카드 정보를 입력
- 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(); } } });
- 파이썬 :
stripe.PaymentMethod.attach(stripe.PaymentIntent.retrieve(intent_id).payment_method, customer=user.stripe_customer_id)
- 오류:
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
.