richnologies / ngx-stripe

Angular 6+ wrapper for StripeJS
MIT License
219 stars 77 forks source link

[BUG] Payment Request Button - Do not register event listeners for both `source` or `paymentmethod`. Only one of them will succeed. #169

Closed create-signal closed 2 years ago

create-signal commented 2 years ago

The Payment Request Button Component is registering event listeners on all of 'token', 'source' and 'paymentmethod'. Because of this, stripe seems to try and create both a source and a payment method. This seems to have two different outcomes:

  1. Confirming the card payment will fail with the error "Customer cus_xxxxxxxxxxxxxxxxxxxxxxxx does not have a linked source with ID src_xxxxxxxxxxxxxxxxxxxxxxxx"
  2. An unintended request to /sources will fail with a "token_already_used" error. The payment request lightbox will appear to fail but the payment will succeed. { "error": { "code": "token_already_used", "doc_url": "https://stripe.com/docs/error-codes/token-already-used", "message": "The token tok_xxxxxxxxxxxxxxxxxxxxxxxx has already been used. Each token can only be used once to create a source.", "param": "token", "type": "invalid_request_error" } }

Additionally stripe throws a warning while creating the payment request element - "Do not register event listeners for both source or paymentmethod. Only one of them will succeed."

You can see in this gist (https://gist.github.com/maxchehab/03200297a88480c35b3d3967dd9543dd) at line 4665 how Stripe uses the presence of an event listener on "sources" to determine whether to create a source from the payment request

dskibin commented 2 years ago

Hi @kieran-mgc Seems i have same issue.

richnologies commented 2 years ago

Hi @kieran-mgc and @dskibin,

You're both right, we are working on it, hope to have a fix soon.

Sorry about the inconvenience

Kind regards,

R

dskibin commented 2 years ago

@richnologies thank you!

dskibin commented 2 years ago

Hello @richnologies Sorry for bothering you. But do you have some estimates where fix will be applied?

richnologies commented 2 years ago

Hi @dskibin, sorry.

I just release a new version, 13.2.1 that I think fixes this issue. The component will check now if you're subscribe to the paymentMethod or the source output and only subscribe you to the correspondant inner event.

Please, let me know if this fixes your issue. If you're using an older version, I will be publishing new versions for Angular 9-12 in the next few hours

richnologies commented 2 years ago

Sorry, of course @kieran-mgc, let me know please if it works for you too

Thanks for patience. Busy week :(

dskibin commented 2 years ago

Hi Ricardo. We are using Angular 9. Thank you very much!

On Tue, 17 May 2022 at 18:57, Ricardo Sánchez @.***> wrote:

Hi @dskibin https://github.com/dskibin, sorry.

I just release a new version, 13.2.0 that I think fixes this issue. The component will check now if you're subscribe to the paymentMethod or the source output and only subscribe you to the correspondant inner event.

Please, let me know if this fixes your issue. If you're using an older version, I will be publishing new versions for Angular 9-12 in the next few hours

— Reply to this email directly, view it on GitHub https://github.com/richnologies/ngx-stripe/issues/169#issuecomment-1129211589, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPZLPEIKPVHMHOMRTIJP7DVKPTZJANCNFSM5VNXOPUA . You are receiving this because you were mentioned.Message ID: @.***>

richnologies commented 2 years ago

Done, here is the list of new versions:

dskibin commented 2 years ago

Thank you for your help and library in general!

On Tue, 17 May 2022 at 20:59, Ricardo Sánchez @.***> wrote:

Done, here is the list of new versions:

  • v13.2.1
  • v12.8.2 npm i @.***
  • v11.2.0 npm i @.***
  • v10.3.0 npm i @.***
  • v9.4.0 npm i @.***

— Reply to this email directly, view it on GitHub https://github.com/richnologies/ngx-stripe/issues/169#issuecomment-1129311963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPZLPE7AEFD2LE3D73IXFLVKQCD3ANCNFSM5VNXOPUA . You are receiving this because you were mentioned.Message ID: @.***>

richnologies commented 2 years ago

Hey @dskibin @kieran-mgc,

Did the fix work for you?

dskibin commented 2 years ago

Hi @richnologies, sorry for late response. Yes, the fix worked! Thank you!

create-signal commented 2 years ago

Sorry for the late reply, I haven't had a chance to test this just yet but the commit looks sound. Thanks for working on this issue and for the great library.