Google Pay
To use Headless checkout to accept payments via Google Pay:
- Add the handling of the
show_fields
event for displaying additional fields.
Example:
Copy
- typescript
1headlessCheckout.form.onNextAction((nextAction) => {
2 switch (nextAction.type) {
3 case 'show_fields':
4 this.handleShowFieldsAction(nextAction);
5 }
6});
- Add the
psdk-payment-form
component to the HTML markup of the payment UI to display additional fields.
Example:
Copy
- html
1@if (showAdditionalFields) {
2 <psdk-payment-form></psdk-payment-form>
3 <psdk-submit-button text="Pay" />
4}
- Add the handling of the event for displaying a button to pay via Google Pay.
Example:
Copy
- typescript
1headlessCheckout.form.onNextAction((nextAction) => {
2 switch (nextAction.type) {
3 ...
4 case 'special_button': {
5 if (nextAction.data.buttonName === 'google-pay') {
6 showGoogleButton = true;
7 }
8 }
9 }
10});
- Add the component of the Google Pay button to the HTML markup of the payment UI.
Example:
Copy
- html
1@if (showGoogleButton) {
2 <psdk-google-pay-button></psdk-google-pay-button>
3}
Was this article helpful?
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.Found a typo or other text error? Select the text and press Ctrl+Enter.