Google Pay

To use Headless checkout to accept payments via Google Pay:

  1. Add the handling of the show_fields event for displaying additional fields.

Example:

Copy
Full screen
Small screen
headlessCheckout.form.onNextAction((nextAction) => {
  switch (nextAction.type) {
    case 'show_fields':
      this.handleShowFieldsAction(nextAction);
  }
});
  1. Add the psdk-payment-form component to the HTML markup of the payment UI to display additional fields.

Example:

Copy
Full screen
Small screen
@if (showAdditionalFields) {
  <psdk-payment-form></psdk-payment-form>
  <psdk-submit-button text="Pay" />
}
  1. Add the handling of the event for displaying a button to pay via Google Pay.

Example:

Copy
Full screen
Small screen
headlessCheckout.form.onNextAction((nextAction) => {
  switch (nextAction.type) {
    ...
    case 'special_button': {
      if (nextAction.data.buttonName === 'google-pay') {
        showGoogleButton = true;
      }
    }
  }
});
  1. Add the component of the Google Pay button to the HTML markup of the payment UI.

Example:

Copy
Full screen
Small screen
@if (showGoogleButton) {
  <psdk-google-pay-button></psdk-google-pay-button>
}
Implementation sample
Refer to the detailed sample on GitHub.
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Last updated: March 3, 2025

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!