Apple Pay
Set up scheduled recurring payments with Apple Pay, on the hosted payment page or in your own checkout.
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 on the hosted payment page or in your own checkout.
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 them in payment_method_details, as in the example below: recurring_type set to first, schedule_type set to scheduled, and the recurring_expiry, recurring_frequency and recurring_management_url of the series. See Create an order in the API reference for these fields.
curl https://api.secure.vayapay.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.secure.vayapay.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.
Your own checkout
In your own checkout, 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 the frequency, the start and end date of the series, and the page where your customer can manage their subscription. Apple's reference describes the fields.
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
Test in your test project with an Apple Pay sandbox tester account: its Wallet holds test cards instead of real ones. See Apple's sandbox testing for how to set it up.