Apple Pay
Set up scheduled recurring payments with Apple Pay, on the hosted payment page or in a server-to-server integration.
Apple Pay supports recurring payments that you start without your customer: merchant-initiated transactions. The flow is the same as for recurring card payments, with payment_method set to apple-pay.
Scheduled series only
Apple Pay only supports scheduled recurring payments. Set schedule_type to scheduled.
Before you start, make sure Apple Pay works for regular payments. See Apple Pay.
Hosted payment page
Create the first transaction
Your customer sees the details of the recurring series on their device when they approve the payment. Send these fields in payment_method_details, so the information is correct:
| Field | Description |
|---|---|
recurring_type | first |
schedule_type | scheduled |
recurring_expiry | Date of the last payment in the series, such as 2027-10-12. |
recurring_frequency | Interval between payments, such as 30. |
recurring_management_url | Page where your customer can view, change or cancel their subscription. |
curl https://api.dev.gingerpayments.com/v1/orders/ \
--user "$API_KEY:" \
--header "Content-Type: application/json" \
--data '{
"merchant_order_id": "AP-SUB-001",
"amount": 4000,
"currency": "EUR",
"description": "Subscription setup with Apple Pay",
"return_url": "https://www.example.com/return",
"transactions": [
{
"payment_method": "apple-pay",
"payment_method_details": {
"recurring_type": "first",
"schedule_type": "scheduled",
"recurring_expiry": "2027-10-12",
"recurring_frequency": 30,
"recurring_management_url": "https://www.example.com/account/subscription"
}
}
],
"customer": {
"merchant_customer_id": "CUST-ABCDE",
"email_address": "jane.doe@example.com",
"first_name": "Jane",
"last_name": "Doe",
"address_type": "billing",
"address": "123 Abbey Road",
"postal_code": "NW8 9AY",
"country": "GB",
"city": "London",
"ip_address": "203.0.113.10"
}
}'Redirect your customer to the payment_url of the transaction in the response. When the order is completed, retrieve the order and store the id of the transaction: this is the first_transaction_id for the next charges.
Charge subsequent payments
When a payment is due, create an order with recurring_type set to recurring and the first_transaction_id:
curl https://api.dev.gingerpayments.com/v1/orders/ \
--user "$API_KEY:" \
--header "Content-Type: application/json" \
--data '{
"merchant_order_id": "AP-SUB-001-CYCLE-02",
"amount": 4000,
"currency": "EUR",
"description": "Monthly subscription",
"webhook_url": "https://www.example.com/webhook",
"transactions": [
{
"payment_method": "apple-pay",
"payment_method_details": {
"recurring_type": "recurring",
"first_transaction_id": "c2e94b17-6a0f-4d38-8e51-b7f3a9d2c064"
}
}
],
"customer": {
"merchant_customer_id": "CUST-ABCDE",
"email_address": "jane.doe@example.com",
"first_name": "Jane",
"last_name": "Doe",
"address_type": "billing",
"address": "123 Abbey Road",
"postal_code": "NW8 9AY",
"country": "GB",
"city": "London",
"ip_address": "203.0.113.10"
}
}'The payment is processed without your customer. Follow the result with a webhook.
Server-to-server
In a server-to-server integration, you can use both the encrypted and the decrypted payload flow for the first transaction.
Because you integrate with Apple Pay directly, you show the recurring details to your customer yourself. Add a recurringPaymentRequest to the ApplePaySession payment request, with:
| Parameter | Description |
|---|---|
recurringFrequency | How often the payment recurs. |
recurringStartDate | When the recurring payments start. |
recurringEndDate | When the recurring payments end. |
recurringManagementUrl | Page where your customer can manage their subscription. |
Create the order
Create an order with an apple-pay transaction, with recurring_type set to first and schedule_type set to scheduled, as on the hosted payment page above.
Complete the payment
Complete the payment with the encrypted payload flow or the decrypted payload flow.
Charge subsequent payments
When the first transaction succeeds, use its id as the first_transaction_id for the next charges, as on the hosted payment page above.
Testing
Apple Pay recurring payments can't be tested in a project in test mode. You can test the same recurring flow with card payments in test mode.