Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment confirmation Page creates a new payment method for the customer on Stripe #971

Closed
mehrancodes opened this issue Jul 8, 2020 · 5 comments · Fixed by #987
Closed

Comments

@mehrancodes
Copy link

mehrancodes commented Jul 8, 2020

  • 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 }
            }
        }
@driesvints
Copy link
Member

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!

@driesvints
Copy link
Member

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.

@driesvints driesvints added enhancement and removed bug labels Jul 9, 2020
@driesvints
Copy link
Member

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

@mehrancodes
Copy link
Author

mehrancodes commented Jul 9, 2020

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.

@driesvints
Copy link
Member

PR: #987

taylorotwell added a commit that referenced this issue Aug 28, 2020
* #971 Added ability to confirm payments that require action

* #971 updated Vue method names

* indent

* Cleanup and fix error

* Fix language reference

* Update payment.blade.php

Co-authored-by: Mehran Rasoli <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants