Integrate our drop-in Checkout SDK into your iOS app.
The Checkout SDK is our quickest way of integrating 250+ supported payment methods and 3D Secure into your iOS app.
The SDK handles presenting a list of payment methods to the shopper, collecting their details, and submitting them to Adyen. It also takes care of encrypting and transmitting sensitive payment data, so it never touches your server. To use the SDK, you'll also need to set up a server that can create a payment session and verify the result of payments.
To accept online payments with the Checkout SDK, you'll need to:
- Integrate the iOS SDK.
- Create a payment session from your server.
- Verify the payment result on your server.
Before accepting live payments, we also recommend that you test your integration.
To see an example of an iOS SDK integration, check out our GitHub.
Before you begin
- Sign up for an Adyen test account at https://www.adyen.com/signup.
- Get your API Key. Save a copy as you'll need it for API calls you make to the Adyen payments platform.
For more information on these steps, refer to Get started with Adyen.
Step 1: Integrate SDK
To add the Checkout SDK to your app:
Import the SDK
Add the SDK to your project using either CocoaPods or Carthage:
pod 'Adyen'to your
github "adyen/adyen-ios"to your
- Link the framework with your target as described in Carthage Readme.
- Integrate payment form
Integrate the payment form into your app by initiating and starting a
Request payment session
As part of the
CheckoutControllerDelegateprotocol, implement the following method.
This will be called when the SDK generates a
token. Pass this
tokento your server to create a payment session. Then, provide the retrieved
responseHandlerclosure. This will initiate the payment method selection.
For many local payment methods, such as iDEAL and SOFORT, the shopper will be redirected to a webpage or app to verify the payment. Once completed, they'll be redirected back to your app. Implement the following method of your
UIApplicationDelegateto handle the shopper returning to your app.
Handle payment result
After the payment has been processed, implement the
didFinishmethod of the
CheckoutControllerDelegateprotocol to get the payment result. Present the result to the shopper in your app. For a list of possible payment results and what these mean, refer to Result codes.
You'll also receive a
payloadvalue. Send this to your server to verify the result of the payment.
Step 2: Create payment session
If you have a subscription or recurring business model, we recommend using our tokenization service. See Recurring and subscription payments for details.
merchantAccount name, a
channel of iOS, and the URL scheme of your app for the
Also include the
amount, your unique
reference for this payment, and the
countryCode of the shopper.
Finally, include the
token generated by the SDK.
You can also use our demo server until you have implemented your own:
Execute this code from your server, not your app. This helps to prevent tampering with transaction data.
The response will contain a
paymentSession. Use this to initialize the SDK.
Step 3: Verify payment result
If the payment was successful you'll receive an Authorised
resultCode and a
pspReference, which is our unique identifier for the transaction. If you've set up notifications, you'll also receive a successful AUTHORISATION notification.
If you received a different
resultCode, check our result codes documentation for what action you should take.
Next, let's look at how you can test your integration.
Testing your integration
You can check the status of a test payment in your Customer Area, under Transactions > Payments.
When you've completed testing, there are some additional steps you'll need to complete before you can accept live payments from shoppers. Refer to Getting started with Adyen for more information.
Customizing your Checkout
If you need more control over the look of the payment form, we recommend building your own UI.
Recurring and subscription payments
To tokenize the shopper's payment details collected by the SDK, send additional parameters when creating a payment session. Pass
enableRecurring as true. Also provide a
shopperReference to uniquely identify this shopper. This will act as the container for the shopper's tokenized payment details. The
shopperReference will be stored when the token is created.
resultCodeis Authorised, a
recurringDetailReferencevalue is also returned in the response. This is the identifier for the shopper's tokenized payment details.
resultCode is Pending, the payment details will be tokenized when the payment reaches an Authorised status. You will be informed of the status change through a webhook via our notification service. The
recurringDetailReference is included in the notification if the payment has been authorised. For other result codes, see Pending and Refusal result codes.
Lastly, save the
recurringDetailReference. You will use this and your corresponding
shopperReference to make future payments. For more information, see Making payments with tokens.
Set up notifications
Receive confirmation when a payment is authorised or fails.
Add payment methods
Learn about payment methods and how to integrate them.
Find out how to cancel, refund, or capture a payment using our API.