Skip to content

Feat/click handler promise#377

Open
paulopontovaz wants to merge 3 commits intogoogle-pay:mainfrom
paulopontovaz:feat/click-handler-promise
Open

Feat/click handler promise#377
paulopontovaz wants to merge 3 commits intogoogle-pay:mainfrom
paulopontovaz:feat/click-handler-promise

Conversation

@paulopontovaz
Copy link
Copy Markdown

Proposed changes
This PR proposes that the consumer application should optionally be able to delay showing the payment sheet until some checks are performed on their side. This was implemented by allowing the click handler to return either a promise or void. The new functionality only happens if the click handler's return type is a promise.

Screenshots / Videos
Promise returns true:
https://github.com/user-attachments/assets/db2ae8b9-ab14-4d49-af8f-14660cfe1710

Promise returns false:
https://github.com/user-attachments/assets/852ca429-9566-462b-8c80-ea3fbca616d2

No promise returned from click handler:
https://github.com/user-attachments/assets/43060b8d-4193-4468-9fe3-4924a103c406

No click handler defined:
https://github.com/user-attachments/assets/1630b02b-ad27-4ada-8261-6355b4b24d9f

This change should allow the consumer application to conditionally show
the payment sheet depending on the returned value of a Promise. If the
click handler returns a promise, then its value is checked. If it is
true then the payment sheet is displayed after the promise resolves.
If the promise returns false then nothing happens.

If the click handler does not return a promise, its return does not
influence the behavior. In other words, the behavior is the same as
before.
@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

2 participants