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 confirmPaymentIntent to process payments via StripeTerminal #342

Conversation

yllaw
Copy link
Contributor

@yllaw yllaw commented Mar 13, 2024

In reference to #341 the confirmPaymentIntent is missing from the terminal payment flow. This step is needed to process payment and change the state of the PaymentIntent to succeeded or requires_capture per the Stripe documentation

I have also replaced TerminalEvents.Completed in favor of TerminalEvents.CollectedPaymentIntent & TerminalEvents.ConfirmedPaymentIntent

Please code review and test.

I have tested this on iOS (Tap to Pay on iPhone) and can confirm it works - the payment intent status changes to succeeded state

EDIT: I have also tested this on a physical Android Device (Simulated Reader since Tap to Pay is not allowed on debuggable android applications)

@yllaw
Copy link
Contributor Author

yllaw commented Mar 18, 2024

@rdlabo Should I add the TerminalEventsEnum.Completed back so that it does not break existing listeners that may use that event?

I think TerminalEventsEnum.Completed may have to be renamed/deprecated from StripeTerminal.collect() method since the end state of the terminal is to confirm payment intent

@rdlabo
Copy link
Member

rdlabo commented Mar 19, 2024

thanks for the great work.

Should I add the TerminalEventsEnum.Completed back so that it does not break existing listeners that may use that event?

It should be necessary, but this time I will remove Completed to clearly communicate that the process itself has changed. So it is fine as it is!

@rdlabo
Copy link
Member

rdlabo commented Mar 19, 2024

Looks good and will be merged.

@rdlabo rdlabo merged commit 0f3caf9 into capacitor-community:main Mar 19, 2024
@rdlabo
Copy link
Member

rdlabo commented Mar 19, 2024

released @capacitor-community/stripe-terminal@5.5.0-beta.0

I will be testing on the device by the end of this week and will officially release it.

@yllaw
Copy link
Contributor Author

yllaw commented Mar 19, 2024

After some research I found that Tap to Pay on Android does not work on Android 14 devices. The Stripe Terminal SDK in the android build.gradle needs to be updated to at least 3.2.1

On my end I updated the Stripe Terminal SDK (core & local-mobile modules) to 3.4. I have tested this on my end on a physical device and was able to use Tap to Pay on Android (without having to simulate the reader connection)

However when running npm run verify I get a build error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:3: AAPT: error: resource android:color/system_background_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:4: AAPT: error: resource android:color/system_error_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:5: AAPT: error: resource android:color/system_error_container_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:6: AAPT: error: resource android:color/system_on_surface_light not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:7: AAPT: error: resource android:color/system_primary_light not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:8: AAPT: error: resource android:color/system_surface_light not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:9: AAPT: error: resource android:color/system_on_background_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:10: AAPT: error: resource android:color/system_on_error_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:11: AAPT: error: resource android:color/system_on_error_container_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:12: AAPT: error: resource android:color/system_on_primary_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:13: AAPT: error: resource android:color/system_on_primary_container_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:14: AAPT: error: resource android:color/system_on_secondary_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:15: AAPT: error: resource android:color/system_on_secondary_container_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:16: AAPT: error: resource android:color/system_on_surface_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:17: AAPT: error: resource android:color/system_on_surface_variant_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:18: AAPT: error: resource android:color/system_on_tertiary_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:19: AAPT: error: resource android:color/system_on_tertiary_container_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:20: AAPT: error: resource android:color/system_outline_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:21: AAPT: error: resource android:color/system_outline_variant_dark not found.
         
     ERROR: /capacitor-community-stripe/packages/terminal/android/build/intermediates/merged_res/release/values-v34/values-v34.xml:22: AAPT: error: resource android:color/system_primary_dark not found.

Could this be because of Android API 34 support?

@rdlabo
Copy link
Member

rdlabo commented Mar 24, 2024

stripe/stripe-terminal-android#387 (comment)

@yllaw The plugin specifies the Terminal SDK as '3.3.+'. https://github.com/capacitor-community/stripe/blob/main/packages/terminal/android/build.gradle#L10C1-L10C135

The next update will update it to '3.4.+', so this does not seem to be a problem. There was a breaking change in 3.4.0, which may be the reason for such an error. This will be addressed in the plugin itself.

@rdlabo
Copy link
Member

rdlabo commented Mar 24, 2024

A version with the method collect changed to collectPaymentMethod is created at #344 . Try it here.

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