Skip to main content
Google Pay enables merchants to accept fast payments in using PayPal’s Javascript SDK v6. This integration supports setup in test and production environments and provides a streamlined checkout experience for customers.

Prerequisites

Before beginning your integration, meet these requirements:
Note: You’ll use your sandbox credentials to create a .env file during the Development setup.

Development setup

Configure your local development environment with the required dependencies and credentials.
  1. Install project dependencies:
  1. Create environment configuration:
  1. Start the development server:
To load the application, see http://localhost:3000.

Implementation steps

Implement Google Pay by following the detailed steps.

Step 1: HTML structure setup

Create your basic HTML page and include the Google Pay and PayPal SDK scripts.

Step 2: Initialize PayPal SDK

Set up the PayPal SDK with Google Pay components once it loads.

Step 3: Configure Google Pay button

Create the Google Pay session and set up the payment button.

Step 4: Configure payment data request

Set up the Google Pay payment data request with transaction details.

Step 5: Set up transaction information

Define the transaction details and pricing breakdown for the Google Pay request.

Step 6: Handle payment authorization

Process the payment authorization and complete the transaction.

Step 7: PayPal order configuration

Configure a PayPal order with the Google Pay payment source.

API endpoints

The integration requires these server-side endpoints.

Client token endpoint

Create order endpoint

Capture order endpoint

Key components

Key componentPurposeDetails
PayPal SDK instanceMain entry point for PayPal functionality
  • Includes googlepay-payments component
  • Requires client token from server
Google Pay sessionManages Google Pay payment flow
  • Provides Google Pay–specific settings
  • Handles order confirmation and capture
Google Pay clientInterface with Google Pay API
  • Set to TEST for sandbox
  • Set to PRODUCTION for live
  • Handles payment authorization callbacks

Security considerations

  • Request client tokens from your server only.
  • Never expose client secrets in frontend code.
  • Always process payments through PayPal’s servers.
  • Use HTTPS in production.

Error handling

  • Catch and log errors in both client and server code.
  • Avoid logging sensitive data.
  • Show clear, user-friendly error messages.

Testing

  • Run transactions with different payment amounts.
  • Verify order creation and capture flows.
  • Simulate error scenarios and edge cases.

Next steps

  1. Configure your production credentials and endpoints.
  2. Add 3D Secure (3DS) support if required.
  3. Extend your integration to support multiple currencies.
  4. Strengthen error handling and customer messaging.
  5. Build a complete automated test suite.

Resources