capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
MIT License
184 stars 75 forks source link

feat: add logic to allow countries and block others #324

Closed rgarciadelongoria closed 4 months ago

rgarciadelongoria commented 6 months ago

Hello again @rdlabo.

I'm Rubén García de Longoria, a little over a year ago I made this PR PR to add the shipping address functionality.

Now I come to propose a new improvement that we have implemented in our App.

The problem:

Our App sells ecological products to different countries. The final price varies depending on the destination country.

The user has selected a destination country in the App, but the Apple Pay address may be from a different country.

The problem is that the plugin, although it has the didSelectShippingContact event to detect this change in JavaScript, there is no possibility of modifying the figure in Apple Pay once opened. It would have to be developed natively within the plugin.

The solution:

What we do is prohibit the user from selecting addresses from a country other than the destination country once the Apple Pay interface is opened.

I have added two new properties to the plugin:

Captura de pantalla 2023-11-28 a las 15 29 26

allowedCountries: An array of ISO codes of countries for which we allow sales.

allowedCountriesError: A string for the message to display if an incorrect country is selected. By default it shows "Please enter a valid address"

Captura de pantalla 2023-11-28 a las 15 22 32

An example of use would be the following:

Captura de pantalla 2023-11-28 a las 15 31 04

Below I leave you a couple of videos where you can see the problem, in our case we limit the payment to addresses in the same country.

First the user is in Spain and can only choose addresses in Spain

https://github.com/capacitor-community/stripe/assets/84543810/8046ae60-12a9-450b-9e0f-32fd134cb938

Then the user is in Germany and can only choose German addresses.

https://github.com/capacitor-community/stripe/assets/84543810/644b2ff5-383c-41f1-92b1-61511b4f6fb7


We would love to help other users with the same problem.

We have thought that the most generic solution is to include an array of allowed IOS, but we can discuss new options if they are considered necessary.

If this PR was accepted it would be of great help to us and our users.

As always, happy to collaborate with you.

All the best

rdlabo commented 4 months ago

Thanks for the great job. And sorry again for the time you have given me.

We will be releasing v6 shortly and will merge with it. Just a little more time!

rdlabo commented 4 months ago

There was one area of concern. As soon as this is resolved, I will merged. Thanks for the great job.

rdlabo commented 4 months ago

We have decided to put out a new release of v5 and will release this pull request as well. Thanks for your contribution!

Note: We will release this Issue as soon as it is resolved. https://github.com/capacitor-community/stripe/issues/331

rdlabo commented 3 months ago

We have officially released a version including this pull request, albeit late!