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

Add customPaymentMethods option for stripe.elements #678

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

graceg-stripe
Copy link
Contributor

Summary & motivation

  • Add customPaymentMethods option for stripe.elements
  • Add selectedPaymentMethod in elements.submit resolved promise

Testing & documentation

Added valid tests.

@moissela
Copy link

Hi, I found this issue because our production Stripe.JS integration today crashed in an unexpected way.

Actually we're importing this library with a script inside the head of our website in this way:
<script src="https://js.stripe.com/v3/">

After some debugging we found that now elements.submit resolved promise returns an object containing this new key selectedPaymentMethod, and I found this issue about it that has not been merged yet.

Until now we were matching for an empty object (with Objects.keys) to check for a failure in the submit operation but from today all of our payments started to fail because of the new key.

We fixed this switching to result.hasOwnProperty("error") but I'm wondering why it has been changed in this way and how we can avoid this kind of unexpected upstream updates from your library?

I'm almost sure that the relative documentation changed in the last days too: where can I found the docs changelog?

@graceg-stripe
Copy link
Contributor Author

Until now we were matching for an empty object (with Objects.keys) to check for a failure in the submit operation but from today all of our payments started to fail because of the new key.

We fixed this switching to result.hasOwnProperty("error") but I'm wondering why it has been changed in this way and how we can avoid this kind of unexpected upstream updates from your library?

I'm almost sure that the relative documentation changed in the last days too: where can I found the docs changelog?

Thank you for writing in. You're right that there was a recent update to the elements.submit method, which now resolves with a new key, selectedPaymentMethod. Our documentation was indeed updated a couple of days ago to reflect this change.

We recommend coding defensively when handling resolved promises by explicitly checking for an error object, as you've done with result.hasOwnProperty("error"). This approach can help prevent similar issues arising from unexpected updates.

If you have further questions or need additional assistance, please feel free to reach out to Stripe Support.

@graceg-stripe graceg-stripe merged commit 0ad3258 into master Nov 14, 2024
2 checks passed
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