Skip to main content
With PayPal’s JavaScript SDK v6, you can accept Apple Pay for secure, one-tap payments. You’ll set up a test environment, add the needed frontend and backend, and then launch Apple Pay in both sandbox and production.

Prerequisites

Before beginning your integration, meet these requirements:
  • Create a PayPal Developer account with Apple Pay enabled.
  • Obtain an Apple Developer Program membership for live payments.
  • Set up an HTTPS environment or ngrok for local development.

Development setup

Configure your local development environment to work with Apple Pay’s HTTPS requirement and PayPal’s domain validation.
  1. Install and configure ngrok:
  2. Update the Vite configuration:
  3. Register your domain with PayPal:
    • Add your ngrok domain to PayPal’s Apple Pay settings
    • Download and save the domain association file

Implementation steps

Implement Apple Pay by following the detailed steps.

Step 1: HTML structure setup

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

Step 2: Initialize PayPal SDK

Set up the v6 SDK with Apple Pay components once it loads.

Step 3: Configure Apple Pay button

Generate the Apple Pay button element and configure it for your payment flow.

Step 4: Configure payment request

Set up your payment details and start the Apple Pay session when users tap the button.

Step 5: Handle Apple Pay events

Implement event handlers to process the payment through Apple Pay’s workflow.

Step 6: Add server integration

Implement server endpoints for token generation and order management.

Server-side requirements

Your backend needs these endpoints to support the Apple Pay integration:
  • Client token generation endpoint: Returns browser-safe client token for SDK initialization
  • Order creation endpoint: Creates PayPal order and returns order ID for payment processing
  • Order capture endpoint: Captures authorized payment and returns transaction details
  • Proper CORS and security headers: Ensures secure communication between client and server

Testing

Use the following steps to test your Apple Pay integration.
  1. Open Safari browser on macOS or iOS device.
  2. Sign into your sandbox iCloud account.
  3. Add test credit cards to your Apple Pay wallet.
  4. Test the complete payment flow.

Production deployment

Deploy your Apple Pay integration to production.
  1. Replace all sandbox URLs with production endpoints.
  2. Update your application to use production PayPal credentials.
  3. Register your production domain with Apple Pay.
  4. Test the integration with a real Apple Pay setup
  5. Add proper error monitoring to track payment issues

Security considerations

  • Use HTTPS in production.
  • Ensure your merchant domain is valid.
  • Keep domain association files current.
  • Use secure client tokens for frontend.
  • Implement proper error handling.

Troubleshooting

IssueSolution
Button not appearing
  • Check Safari Apple Pay settings
  • Verify domain registration
  • Ensure HTTPS connection
Merchant validation fails
  • Check domain association file
  • Verify PayPal domain registration
  • Confirm ngrok domain in vite config
Payment authorization fails
  • Use sandbox iCloud account
  • Check test credit card setup
  • Verify server endpoints

Resources