Cashier-stripe: Payment confirmation Page creates a new payment method for the customer on Stripe

Created on 8 Jul 2020  路  5Comments  路  Source: laravel/cashier-stripe

  • Cashier Version: v10.2.1
  • Laravel Version: 5.8.0
  • PHP Version: 7.3
  • Database Driver & Version: Mysql 5.7

Description:

I tried to implement failed payments confirmation handler by adding the CASHIER_PAYMENT_NOTIFICATION env key. Everything seems to work fine except that it adds a new Payment Method for the customer EVERY time. wondering if this is something correct or not. shouldn't we just confirm the payment? or update the current payment method if needed?
Screen Shot 2020-07-08 at 4 19 41 PM

Steps To Reproduce:

Add a new subscription with this card 4000002760003184 which asks for 3D if you have it enabled. then Cashier sends a confirm payment email after the first invoice payment gets failed.

Things I have tried to fix it with no success

I have tried to replace this inside the Casher's resources/views/payment.blade.php:

    stripe.handleCardPayment(
        '{{ $payment->clientSecret() }}', this.cardElement, {
            payment_method_data: {
                billing_details: { name: this.name }
            }
        }

With confirmCardPayment, but it still creates a new payment method

    stripe.confirmCardPayment(
        '{{ $payment->clientSecret() }}', {
            payment_method: {
                card: this.cardElement,
                billing_details: { name: this.name }
            }
        }
enhancement

Most helpful comment

I have these scenarios handled inside our app, So I think I can help to put some time at the weekend to do the same thing here as well. It would be great if we use the user's card here as well since it would be easier for them to remember what card they're using and also they might not need to write their card again when just confirming the payment requires_action.

All 5 comments

I've forwarded this question to Stripe themselves on how we can prevent this. I'll get back to you once they give an answer. Thanks!

So as it turns out we can re-use the payment method id of the payment intent to set the it as the payment method to be verified. We'll need to update the payment page to do that instead.

  • When the state is requires_payment_method: show new card fields
  • When the state is requires_action just let them confirm it
   stripe.confirmCardPayment(
          clientSecret,
          {
            payment_method: "pm_xxxx"
          }
        ).then(function(x) {

We'll need to also test the scenario where the card can't be verified and a new one needs to be added.

Marking this as an enhancement because the current way still works but is a bit cumbersome.

I have these scenarios handled inside our app, So I think I can help to put some time at the weekend to do the same thing here as well. It would be great if we use the user's card here as well since it would be easier for them to remember what card they're using and also they might not need to write their card again when just confirming the payment requires_action.

Was this page helpful?
0 / 5 - 0 ratings