Apple Pay — Node.js

Implement Apple Pay on your own checkout when using Embedded Integration.

With Hosted Checkout, Apple Pay appears automatically on the DigetPay page — see Apple Pay on Hosted Checkout.

With Embedded Integration, you build checkout on your domain. Apple Pay must be implemented on your site; DigetPay processes the payment server-side after you obtain an Apple Pay token.

This guide applies only to Embedded Integration merchants. Do not use this for hosted checkout integrations.

Never send Apple Pay tokens directly from browser JavaScript to DigetPay. POST the token to your Node.js server first.


High-level flow

sequenceDiagram
  participant Browser as Safari Browser
  participant Shop as Your Node Server
  participant Apple as Apple Pay
  participant API as DigetPay API

  Browser->>Shop: Load checkout page
  Shop->>Browser: ApplePaySession config
  Browser->>Apple: User authorizes Apple Pay
  Apple-->>Browser: Payment token
  Browser->>Shop: POST payment token
  Shop->>API: POST /payment/s2s/sale
  API-->>Shop: APPROVED / PENDING / 3DS html

Step 1 — Frontend (Safari)

Same Apple Pay JS pattern as the PHP guide — button calls your Node endpoints:

// public/checkout.js (excerpt)
session.onvalidatemerchant = async (event) => {
  const res = await fetch('/apple-pay/validate-merchant', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ validationURL: event.validationURL }),
  });
  session.completeMerchantValidation(await res.json());
};
session.onpaymentauthorized = async (event) => {
  const res = await fetch('/apple-pay/process', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token: event.payment.token, orderId: 'ORD-1001' }),
  });
  session.completePayment(res.ok ? ApplePaySession.STATUS_SUCCESS : ApplePaySession.STATUS_FAILURE);
};

Step 2 — Merchant validation route

// routes/applePay.js
import express from 'express';
const router = express.Router();

router.post('/validate-merchant', express.json(), async (req, res) => {
  const { validationURL } = req.body;
  // POST to Apple's validationURL with merchant identity certificate
  // Return merchant session JSON to browser
  res.status(501).json({ error: 'Implement with DigetPay-provided merchant certificate' });
});

router.post('/process', express.json(), async (req, res) => {
  const { token, orderId } = req.body;
  // Map token to embedded sale payload — confirm with DigetPay
  res.json({ status: 'pending_implementation' });
});

export default router;

Confirm with DigetPay: Apple Pay token field mapping for embedded sale payload before production.


Step 3 — Domain verification

Host apple-developer-merchantid-domain-association at:

https://yourdomain.com/.well-known/apple-developer-merchantid-domain-association

See Apple Pay Domain Verification.


Staging vs production

EnvironmentAPI base
Fin staginghttps://fin-api.digetpay.com/v1
Productionhttps://api.digetpay.com/v1

Next steps


Did this page help you?