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

Added "fingerprint" to the Card Model to sync with React-Native #1764

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Flucadetena
Copy link

@Flucadetena
Copy link
Author

After lots of testing I saw the "Type cast error String not Map<String, dynamic>" referred in issue: #1721. Was due to the CustomerSheet returning a PaymentMethod as well as an error. (To be precise, to the way the error was added to the response and as consequence handled)

To reproduce this issue you had to call the "presentCustomerSheet()" select a card and click the "confirm" button. Then call it again and close it without selecting any new option. This would cause the response to have the previously selected option and would add the "Canceled" error as part of the response.

Both on Android and IOS this situation was handled the same way. I read how other components manage this situation to see what was the preferred way of doing this. But realized that no other has this situation, as all prompt the user with a form (payment or otherwise) and if the user closes the form it will simple return a "Canceled" error, but no other info previously saved.

This is the same when the "presentCustomerSheet()" is called for the first time, with no previous selection saved, and close the sheet either by clicking outside or in the "X" icon. This case would simple return and "StripeException" with the "Canceled" code.
The same as with any other Stripe component.

But in the "saved" selection case, it does not want to through an "StripeException" as the user may have discarded the sheet due to his "preferred" paymentMethod already being selected. So it returns a normal responses and adds the error "canceled" as an extra.
The model for this was an StripeError, but due to the process it resulted in "Type error" as it tried to access "json["code"]" when the "json" value was already the "Canceled" error.

In the normal errors, stripe creates a StripeException, that at the end create a "LocalizedErrorMessage" with the "json['code']" value. So that is what I decided to do, as thought it was the more consistent thing with the rest of the platform.

This way it will resolve successfully and return the saved "preferred" paymentMethod, and if you access the error element in the response it will have the same structure and a normal error in an StripeException.

Not sure if this explanation was necessary, sorry for the loooong text, ahhahah. But wanted to explain my decision.

Hope it helps. :)

@Flucadetena
Copy link
Author

Flucadetena commented May 10, 2024

There is an issue I can not solve, but not sure if it is the expected behavior.

When you present the CustomerSheet, add a new Card and confirm, that card won't bring the "fingerprint". The card had to be added prior to this for it to bring the fingerprint back.

You can solve this by calling final selection = await Stripe.instance.retrieveCustomerSheetPaymentOptionSelection(); right after the Stripe.instance.presentCustomerSheet(); returns and it give all the data back.

But it does not seem to be the right flow.

@jonasbark jonasbark requested a review from remonh87 June 21, 2024 10:30
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.

None yet

2 participants