Apple Pay — Python

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 Python server first.


High-level flow

sequenceDiagram
  participant Browser as Safari Browser
  participant Shop as Your Python 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)

Use the same Apple Pay JS pattern — onvalidatemerchant and onpaymentauthorized call your Flask/Django routes at /apple-pay/validate-merchant and /apple-pay/process.


Step 2 — Merchant validation route

# routes/apple_pay.py
from flask import Blueprint, request, jsonify

apple_pay_bp = Blueprint("apple_pay", __name__)


@apple_pay_bp.route("/apple-pay/validate-merchant", methods=["POST"])
def validate_merchant():
    validation_url = request.json.get("validationURL")
    # POST to Apple's validationURL with merchant identity certificate
    return jsonify({"error": "Implement with DigetPay-provided merchant certificate"}), 501


@apple_pay_bp.route("/apple-pay/process", methods=["POST"])
def process_apple_pay():
    token = request.json.get("token")
    order_id = request.json.get("orderId")
    # Map token to embedded sale payload — confirm with DigetPay
    return jsonify({"status": "pending_implementation"})

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?