Before implementing Apple Pay payments, ensure you have completed the Apple Pay prerequisites.
Apple Pay overview
- Customer initiates payment on their iOS device
- Receive
payment_tokenvia Apple SDK - Create a payment with Yuno including the stringified token
- Yuno processes with your configured provider(s) and returns a response
- Monitor response status via webhooks
One-time payments
To integrate a single transaction, such as an online purchase, use Yuno’s API to create a payment. This requires you to obtain certain information from the Apple SDK’s response, which is generated when the customer authorizes the payment.Example Apple Pay response
The Apple Pay SDK returns an object like the example below, we call this response thepayment_token.
Example one-time payment request
Here is an example of a one-time Apple Pay payment request using Yuno’s Direct API. The request includes the stringified Apple Pay response insidepayment_token, as received from the Apple Pay SDK, along with required fields such as amount, currency, and account information. Adjust the values as needed for your integration.
Recurring payments with Direct API
Recurring Apple Pay payments with Direct integration require implementation of Customer Initiated Transactions (CIT) and Merchant Initiated Transactions (MIT).-
Customer Initiated Transaction (CIT): The first transaction where the customer authorizes recurring payments. This generates a
vaulted_tokenfor future use. -
Merchant Initiated Transaction (MIT): Subsequent automated transactions using the
vaulted_tokenwithout customer interaction.
Customer Initiated Transaction (CIT)
When a customer authorizes the subscription and you have a response from the Apple SDK, use the stringifiedpayment_token in Yuno’s create payment API to create the CIT.
Key parameters for CIT
vault_on_success: true: Indicates this is a recurring payment setup and generates the vaulted token for future MIT transactionsdetail.wallet.stored_credentials.usage: FIRST: Indicates this is the initial transaction in a recurring seriesdetail.wallet.payment_token: Must be the stringified Apple SDK response, thepayment_token
CIT response handling
When the CIT is successful, you’ll receive a response containing thevaulted_token. It can be used for subsequent transactions. Exercise extreme caution storing this value.
Merchant Initiated Transaction (MIT)
MIT transactions are processed automatically for recurring billing using thevaulted_token from the CIT.
Example MIT request
Key parameters for MIT
vaulted_token: The vaulted token generated during the CITdetail.card.stored_credentials.usage: "USED": Indicates this is a subsequent transaction in a recurring series- No
payment_tokenrequired: Uses the storedvaulted_tokeninstead
Troubleshooting
- Merchant validation failed: verify Apple Pay certificates and merchant ID configuration
- Invalid or expired Apple token: obtain a fresh token from Apple SDK and ensure it is stringified
- Unsupported network or country: confirm your provider supports Apple Pay for the requested currency/country
- Duplicate charges: always send an
Idempotency-Keywith create payment calls