fix: remove deprecated GooglePay functionality in favour of TaskResultContracts#1616
Conversation
Dependency Review✅ No vulnerabilities found.Scanned FilesNone |
jaxdesmarais
left a comment
There was a problem hiding this comment.
I mainly just have general questions around my own understanding of Android and the new API. Overall it looks like this change cleans up a lot of old code which is a win in my book. It also looks to be non breaking, so seems like a good change to make.
| private val activityLauncher: ActivityResultLauncher<GooglePayPaymentAuthRequestParams> = registry.register( | ||
| private val appContext: Context = context.applicationContext | ||
|
|
||
| private val activityLauncher: ActivityResultLauncher<Task<PaymentData>> = registry.register( |
There was a problem hiding this comment.
It seems like this is the crux of the change. Are the any implications to older APIs or is this fully backwards compatible?
There was a problem hiding this comment.
Great question. I tested with older versions of the APIs on emulator and it worked just fine but I'll make sure to test on all supported API versions to make sure we won't run into issues
There was a problem hiding this comment.
Ok so I couldn't get some of the older emulators to work well enough to test, but we do have confirmation that the new API is backwards compatible back to versions that are so old we don't even support. So I think we should be good
| GooglePayPaymentAuthResult( | ||
| null, | ||
| GooglePayException( | ||
| "An error was encountered during the Google Pay " + |
There was a problem hiding this comment.
is there a way we can display the status object in our demo app, so that we can see what caused an error right away?
There was a problem hiding this comment.
This is actually already covered in the demo app. This PR doesn't change how results are getting delivered, it only changes what's delivering them. If you take a look at the delete results contract file you can see that the handling of the payment status and sending of GooglePayPaymentAuthResult are very similar to how it looks in the Launcher now
There was a problem hiding this comment.
Thank you very much, I can see it now!
noguier
left a comment
There was a problem hiding this comment.
While i am still going through all the code changes, I just wanted to confirm that i tested the flow on the physical device, and API 23, and all are working as expected.
|
I see the |
|
Great question! The general rule is that if the merchant can touch a piece of code you can't delete it until a major version. Those constants are technically publicly accessible by merchants. They shouldn't/wouldn't ever have used them for anything, but since they could be accessed it's safer to deprecate than completely remove them. The files that were deleted on the other hand were all internal so there is no chance that a merchant would be using any piece of them and are safe to completely delete. After some searching it looks like the changes that Google made to wallet that allowed this PR are backwards compatible all the way to version 21 which we don't even support so we should be fine for all API version we support in the SDK |
|
This looks good, just a couple of clarifying questions, to get my understanding: |
|
Also from what I have read, and tested this changes are great and are backwards compatible! |
Yeah exactly! They basically took on the responsibility of launching and delivering results so we don't need to do all the weird handling with the transparent activity or custom results contracts etc. I think you've got a firm understanding of the changes |
jaxdesmarais
left a comment
There was a problem hiding this comment.
Thanks for addressing all of my questions/comments. These changes look great and way less code for us to maintain long term. 🚀
Summary of changes
This ticket came in as a part of a github issue. The problem was that we were still using a depreacted method that was later removed in newer versions of google wallet in the google pay component. The newer recommended method of gathering payment data from google pay allows for pretty big changes to the SDK. This includes getting rid of
GooglePayActivityandGooglePayActivityResultContractsince the result handling is covered by the newTaskResultContracts. More detailed summary below with documentation from google used to put this PR togetherTaskResultContracts.GetPaymentDataResult()API from Google WalletGoogle documentation:
https://developers.google.com/android/reference/com/google/android/gms/wallet/contract/TaskResultContracts
https://developers.google.com/pay/api/android/guides/tutorial#initiate-payment
Sample integration pattern:
https://github.com/google-pay/android-quickstart/blob/468fc42e6d465e1b296bf2441835c3f053ef2c4b/java/app/src/main/java/com/google/android/gms/samples/pay/activity/CheckoutActivity.java
Note on deleted files - these changes feel like they are on the border of a major version change but all the changes are to internal files only so integrations shouldn't need to change. Let me know what you all think
AI Usage
Which AI Agent Was Used?
How was AI used?
Used claude code to research sources for replacements for the deprecated method and for suggestions on how to integrate the new preferred methods into our code base. Let it generate tests to cover the changed functionality
Estimated AI Code Contribution
Checklist
Authors