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

[14.x] Handle automatic payment method updates #1534

Merged
merged 5 commits into from
May 21, 2023
Merged

[14.x] Handle automatic payment method updates #1534

merged 5 commits into from
May 21, 2023

Conversation

shatterproof
Copy link
Contributor

Vendors, including Visa and Mastercard, often reissue and update stored payment methods in place for Stripe users. This can involve updating the expiration date, but frequently also changes the entire card number as well.

The Stripe events log filtered for this type of event shows how often it happens, which we are seeing several times per day in our own apps (more than I would have expected).

These automatic updates allow the payment methods to continue to be successfully charged by Stripe, but has the side effect of causing the Cashier user model to become out of sync with the outdated pm_last_four stored.

Fortunately, Stripe sends a payment_method.automatically_updated webhook when this happens that can be listened to for triggering an update of the locally stored payment method to ensure it stays in sync, which is the purpose of this PR.

Since this is a non-breaking change, I believe it is a good candidate for a 14.x release to benefit users right away. Enabling it does require adding that webhook in the Stripe dashboard though, which I can note in the upgrade guide and docs upon merge.

@driesvints
Copy link
Member

Hi @shatterproof. Although this looks good to me, I'm wondering if the customer.updated event already is sent alongside this to handle it? I guess not otherwise you wouldn't have sent this in?

@shatterproof
Copy link
Contributor Author

Hey Dries, that is correct. I was surprised to find a customer.updated event isn't triggered alongside the payment_method.automatically_updated events. I had a long backlog of customers with automatically updated cards out of sync with Stripe to go through, but after implementing this change locally it has been working perfectly so wanted to share it with others.

It is an issue many might not even realize is happening, but could easily cause confusion or frustration for end users when an old card number is being shown to them in an app while a different one is getting charged by Stripe for recurring payments.

@driesvints
Copy link
Member

Thanks @shatterproof. Can you add a section in the upgrade guide? This can target v14.13.0. And also feel free to send in a PR to the docs 👍

@shatterproof
Copy link
Contributor Author

Definitely, I can take care of both tomorrow.

@driesvints driesvints marked this pull request as draft May 19, 2023 07:49
@driesvints
Copy link
Member

Thanks, feel free to mark this as ready once done.

@taylorotwell taylorotwell merged commit e34eb45 into laravel:14.x May 21, 2023
@shatterproof shatterproof deleted the pm-automatic-update branch May 21, 2023 16:53
@shatterproof
Copy link
Contributor Author

@driesvints For the release can the version be adjusted to v14.13 as mentioned above to match the upgrade guide?

@driesvints
Copy link
Member

As sorry, I messed that up. I changed the release in the upgrade guide instead.

@driesvints
Copy link
Member

Thanks for your work on this btw!

@shatterproof
Copy link
Contributor Author

That works, thanks!

Also no problem at all, contributing to a package I’ve been using for years is an honor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants