Native app
Native app integration provides you with complete control over the Apple Pay user experience within your iOS application. While Dintero handles the payment processing, you implement the Apple Pay user interface directly using Apple's frameworks (like PassKit), providing a seamless and highly customized experience for your customers.
Prerequisites
Apple Pay Merchant Onboarding
Before you can implement Apple Pay in your app, you must complete Apple's merchant onboarding process through your Apple Developer Account. This process involves several key steps:
-
Create a Merchant Identifier: This is a unique identifier that registers your business with Apple as a merchant capable of accepting payments. A single merchant identifier can be used for multiple apps and websites.
-
Create a Payment Processing Certificate: This certificate is associated with your merchant ID and is used to encrypt payment data. Contact integration@dintero.com and request a Certificate Signing Request (CSR) from Dintero and use the CSR to create this certificate with Apple. After the certificate has been created you have to download the certificate and get in touch with integration@dintero.com for instructions on how send us your certificate.
-
Enable Apple Pay in Xcode: You need to enable the Apple Pay capability within your Xcode project settings and link it to the merchant identifier you created.
Note: This process requires an active Apple Developer Program account and can take some time, so it's best to plan accordingly.
Enable Apple Pay on Your Dintero Account
During your onboarding you will be able to select Apple Pay as a payment method. If it's not enabled, you can go to settings and payment methods. From there, you can enable Apple Pay as a payment method for your account. If you use payment profiles, ensure that Apple Pay is added to the relevant profiles.
Creating an apple pay payment session
Example payment session request body, note that the return_url must match the app url namespace and that initial_recipient=merchant
must be set if the link in the session payment response should be followed.
{
"url": {
"return_url": "yourapp://redirect?initial_recipient=merchant",
"callback_url": "https://your-backend-callback-handler.com/endpoint"
},
"order": {
"amount": 20100,
"currency": "NOK",
"merchant_reference": "<unique-reference>",
"items": [
{
"id": "<item-id>",
"line_id": "<unique-id-per-line>",
"description": "Item to be paid for",
"amount": 20100,
"quantity": 1,
"vat_amount": 4020,
"vat": 25
}
]
},
"configuration": {
"channel": "in_app",
"dintero_psp": {
"applepay": {
"enabled": true
}
}
},
"expires_at": "2099-12-31T23:23:59.999Z"
}
Integration with Dintero
The native payment flow with Apple Pay and Dintero is a collaborative process between your app and Dintero's API. The general flow is as follows:
-
User Initiates Payment: The user taps the Apple Pay button in your app to begin the checkout process.
-
You Request Payment Session: Your app requests a payment session from Dintero's API.
-
You Request Payment Data from Apple Pay: Your app uses the PassKit framework to present the Apple Pay payment sheet to the user.
-
Apple Pay Returns Encrypted Payment Data: After the user authenticates the payment with Face ID, Touch ID, or their passcode, Apple Pay returns an encrypted PKPaymentToken.
-
You Post the Payment Data to Dintero: Your app sends the encrypted payment token to your backend, which then forwards it to Dintero's API to authorize and capture the payment.
-
You Initiate the Payment: Dintero's API processes the transaction, decrypts the payment data using the uploaded certificate, and communicates with the card network to complete the payment.
This integration gives you full control over the user experience while leveraging Dintero's secure and reliable payment processing backend.
Note that only the Visa and Mastercard payment networks are supported as of today.
Best Practices
Make sure you follow the following best practices.
- Never log or store Apple Pay tokens
- Implement proper error handling to avoid exposing sensitive information
- Validate all payment responses on your server
Example application
See https://github.com/Dintero/dintero-ios-native-example for an example application on how to accept Apple Pay payments.