Skip to content

fix: remove deprecated GooglePay functionality in favour of TaskResultContracts#1616

Merged
saralvasquez merged 3 commits into
mainfrom
google-pay-issue
Jun 16, 2026
Merged

fix: remove deprecated GooglePay functionality in favour of TaskResultContracts#1616
saralvasquez merged 3 commits into
mainfrom
google-pay-issue

Conversation

@saralvasquez

Copy link
Copy Markdown
Contributor

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 GooglePayActivity and GooglePayActivityResultContract since the result handling is covered by the new TaskResultContracts. More detailed summary below with documentation from google used to put this PR together

  • Replaces the internal GooglePayActivity and AutoResolveHelper pattern with TaskResultContracts.GetPaymentDataResult() API from Google Wallet
  • Merchants no longer need to declare GooglePayActivity in their AndroidManifest.xml — the SDK handles the payment sheet launch entirely through the activity result contract mechanism
  • Moves loadPaymentData() into GooglePayInternalClient so GooglePayLauncher drives the task directly, and result parsing is now handled inline in the launcher callback

Google 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?

  • Copilot
  • Claude
  • Other (Type Name Here)

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

  • less than 30%
  • 30 - 60%
  • 60 - 100%

Checklist

  • Added a changelog entry
  • Tested and confirmed payment flows affected by this change are functioning as expected

Authors

@saralvasquez saralvasquez requested a review from a team June 11, 2026 17:41
@saralvasquez saralvasquez requested a review from a team as a code owner June 11, 2026 17:41
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities found.

Scanned Files

None

@jaxdesmarais jaxdesmarais left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread CHANGELOG.md Outdated
Comment thread GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt Outdated
private val activityLauncher: ActivityResultLauncher<GooglePayPaymentAuthRequestParams> = registry.register(
private val appContext: Context = context.applicationContext

private val activityLauncher: ActivityResultLauncher<Task<PaymentData>> = registry.register(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this is the crux of the change. Are the any implications to older APIs or is this fully backwards compatible?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 " +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much, I can see it now!

@noguier noguier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@noguier

noguier commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

I see the EXTRA_ENVIRONMENT and EXTRA_PAYMENT_DATA_REQUEST constants are being deprecated rather than deleted, but GooglePayActivity is being deleted. In what situations do we usually deprecate first and then remove, vs remove right away like the GooglePayActivity? Since we are changing the manifest, will it affect merchants with old API?

@saralvasquez

Copy link
Copy Markdown
Contributor Author

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

@noguier

noguier commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This looks good, just a couple of clarifying questions, to get my understanding:
Prior to this changes, we had to create a new activity, that was launching Google Pay, and then handles the result back with onActivityResult. Now we do not have to do it because ActivityResultContract solves the problem of creating an "invisible" just to handle results because we can use TaskResultContracts to launch and deliver results?

@noguier

noguier commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Also from what I have read, and tested this changes are great and are backwards compatible!

@saralvasquez

Copy link
Copy Markdown
Contributor Author

This looks good, just a couple of clarifying questions, to get my understanding: Prior to this changes, we had to create a new activity, that was launching Google Pay, and then handles the result back with onActivityResult. Now we do not have to do it because ActivityResultContract solves the problem of creating an "invisible" just to handle results because we can use TaskResultContracts to launch and deliver results?

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 jaxdesmarais left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all of my questions/comments. These changes look great and way less code for us to maintain long term. 🚀

@saralvasquez saralvasquez merged commit 8318ad9 into main Jun 16, 2026
12 checks passed
@saralvasquez saralvasquez deleted the google-pay-issue branch June 16, 2026 18:33
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.

3 participants