Our iOS Drop-in renders the available cards in your payment form, and securely collects any sensitive card information, so it doesn't touch your server.
When adding card payments to your integration, you need to:
- Provide your Client Encryption Public Key when initializing the Drop-in.
Before you begin
This page explains how to add card payments to your existing iOS Drop-in integration. The iOS Drop-in integration works the same way for all payment methods. If you haven't done this integration yet, refer to our Drop-in integration guide.
Before starting your integration:
- Make sure that you have set up your back end implementation, and added Drop-in to your payment form.
- Add the cards that you want to accept in your test Customer Area.
Show the available cards in your payment form
For information about the supported countries and currencies for each card, refer to Payment methods.
To show cards in your payment form:
-
Specify in your /paymentMethods request a combination of countryCode and amount.currency. Drop-in uses this information to show the available cards to your shopper.
-
When initializing the Drop-in, create a configuration object and pass the
APIContext
instance that contains the Client Key.let configuration = DropInComponent.Configuration(apiContext: apiContext)
When the shopper is entering their card details, Drop-in tries to recognize the card brand. When successful, Drop-in renders the brand icon.
Make a payment
When the shopper proceeds to pay, Drop-in invokes the didSubmit
method which contains data.paymentMethod
.
- Pass
data.paymentMethod
to your server. - From your server, make a /payments request, specifying:
paymentMethod
: Thedata.paymentMethod
from thedidSubmit
event from your client app.
curl https://checkout-test.adyen.com/v68/payments \
-H "X-API-key: [Your API Key here]" \
-H "Content-Type: application/json" \
-d '{
"amount": {
"currency": "USD",
"value": 1000
},
"reference": "YOUR_ORDER_NUMBER",
"{hint:data.paymentMethod from app}paymentMethod{/hint}": {
"type": "scheme",
"encryptedCardNumber": "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"encryptedExpiryMonth": "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"encryptedExpiryYear": "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"encryptedSecurityCode": "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"holderName": "S. Hopper"
},
"returnUrl": "my-app://",
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
}'
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen::Client.new
adyen.api_key = "YOUR_X-API-KEY"
response = adyen.checkout.payments({
:amount => {
:currency => "USD",
:value => 1000
},
:reference => "YOUR_ORDER_NUMBER",
:paymentMethod => {
:type => "scheme",
:encryptedCardNumber => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
:encryptedExpiryMonth => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
:encryptedExpiryYear => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
:encryptedSecurityCode => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
:holderName => "S. Hopper"
},
:returnUrl => "my-app://",
:merchantAccount => "YOUR_MERCHANT_ACCOUNT"
})
// Set your X-API-KEY with the API key from the Customer Area.
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
PaymentsRequest paymentsRequest = new PaymentsRequest();
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setValue(1000L);
paymentsRequest.setAmount(amount);
String encryptedCardNumber = "adyenjs_0_1_18$...encryptedCardNumber";
String encryptedExpiryMonth = "adyenjs_0_1_18$...encryptedExpiryMonth";
String encryptedExpiryYear = "adyenjs_0_1_18$...encryptedExpiryYear";
String encryptedSecurityCode = "adyenjs_0_1_18$...encryptedSecurityCode";
paymentsRequest.setReference("YOUR_ORDER_NUMBER");
paymentsRequest.addEncryptedCardData(encryptedCardNumber,encryptedExpiryMonth, encryptedExpiryYear, encryptedSecurityCode, "S. Hopper");
paymentsRequest.setReturnUrl("my-app://");
PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);
$params = array(
"amount" => array(
"currency" => "USD",
"value" => 1000
),
"reference" => "YOUR_ORDER_NUMBER",
"paymentMethod" => array(
"type" => "scheme",
"encryptedCardNumber" => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"encryptedExpiryMonth" => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"encryptedExpiryYear" => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"encryptedSecurityCode" => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
"holderName" => "S. Hopper"
),
"returnUrl" => "my-app://",
"merchantAccount" => "YOUR_MERCHANT_ACCOUNT"
);
$result = $service->payments($params);
#Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.client.xapikey = 'YOUR_X-API-KEY'
result = adyen.checkout.payments({
'amount': {
'value': 1000,
'currency': 'USD'
},
'reference': 'YOUR_ORDER_NUMBER',
'paymentMethod': {
'type': 'scheme',
'encryptedCardNumber': 'adyenjs_0_1_18$MT6ppy0FAMVMLH...',
'encryptedExpiryMonth': 'adyenjs_0_1_18$MT6ppy0FAMVMLH...',
'encryptedExpiryYear': 'adyenjs_0_1_18$MT6ppy0FAMVMLH...',
'encryptedSecurityCode': 'adyenjs_0_1_18$MT6ppy0FAMVMLH...',
'holderName': 'S. Hopper'
},
'returnUrl': 'my-app://',
'merchantAccount': 'YOUR_MERCHANT_ACCOUNT'
})
// Set your X-API-KEY with the API key from the Customer Area.
var client = new Client ("YOUR_X-API-KEY", Environment.Test);
var checkout = new Checkout(client);
var amount = new Model.Checkout.Amount("USD", 1000);
var details = new Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
EncryptedCardNumber = "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
EncryptedExpiryMonth = "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
EncryptedExpiryYear = "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
EncryptedSecurityCode = "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
};
var paymentRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
ReturnUrl = @"my-app://",
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
PaymentMethod = details
};
var paymentResponse = checkout.Payments(paymentsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
const config = new Config();
// Set your X-API-KEY with the API key from the Customer Area.
config.apiKey = '[API_KEY]';
config.merchantAccount = '[YOUR_MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.payments({
amount: { currency: "USD", value: 1000 },
paymentMethod: {
type: 'scheme',
encryptedSecurityCode: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
encryptedExpiryMonth: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
encryptedExpiryYear: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
holderName: "S. Hopper",
encryptedCardNumber: "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
},
reference: "YOUR_ORDER_NUMBER",
merchantAccount: config.merchantAccount,
returnUrl: "my-app://"
}).then(res => res);
The /payments response contains:
- pspReference: Our unique identifier for the transaction.
resultCode
: Use this to present the payment result to your shopper.merchantReference
: Thereference
from the /payments request.additionalData
: Additional information about the transaction.
To specify the fields that you want to receive inadditionalData
, log in to your Customer Area, and go to Developers > API URLs > Additional data settings.
Present the payment result
Use the resultCode from the /payments response to present the payment result to your shopper. You will also receive the outcome of the payment asynchronously in a notification webhook.
For card payments, you can receive the following resultCode
values:
resultCode | Description | Action to take |
---|---|---|
Authorised | The payment was successful. | Inform the shopper that the payment has been successful. If you are using manual capture, you also need to capture the payment. |
Cancelled | The shopper cancelled the payment. | Ask the shopper whether they want to continue with the order, or ask them to select a different payment method. |
Error | There was an error when the payment was being processed. For more information, check the
refusalReason
field. |
Inform the shopper that there was an error processing their payment. |
Refused | The payment was refused. For more information, check the
refusalReason
field. |
Ask the shopper to try the payment again using a different payment method. |
resultCode
values are possible in case of the 3D Secure authentication flow. For more information, refer to Result codes.
Present debit and credit cards separately
In some scenarios, you may want to present your shoppers with separate payment forms for debit cards and credit cards. Some examples include:
- In Brazil, many shoppers use Combo cards, allowing for both debit and credit transactions. Having a separate form for Debit Card and Credit Card gives your shoppers a clear indication of whether they are making a debit or credit transaction.
- If you accept payments in Sweden, you need to present debit cards before credit cards in order to comply with local legislation.
For more details, see the corresponding sections about Brazil and Sweden.
Required versions
To present debit and credit cards separately in your iOS Drop-in integration, you need to use:
- Checkout API v53 or later.
- iOS Components 3.6.0 or later.
Show the available debit and credit cards
-
When you make a POST /paymentMethods request from your server, include:
- splitCardFundingSources: Set to true.
curl https://checkout-test.adyen.com/v68/paymentMethods \ -H "x-API-key: YOUR_X-API-KEY" \ -H "content-type: application/json" \ -d '{ "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "countryCode": "NL", "amount": { "currency": "EUR", "value": 4700 }, "splitCardFundingSources": true }'
If your integration is set up correctly, the full /paymentMethods
response is used to initiate the
DropInComponent
class in your client app. Drop-in then automatically renders separate payment forms for Credit card and Debit card.
When the shopper selects the Pay button from any of the payment forms, iOS Drop-in works the same way as when cards are presented in one form— it invokes the didSubmit
method which contains data.paymentMethod
. You can then use the data.paymentMethod
to make a payment.
Brazil
For debit transactions, we highly recommend using 3D Secure and Automatic Capture due to some issuers' restrictions.
Sweden
If you send a /paymentMethods request with countryCode
of SE, Drop-in automatically presents Debit Card before Credit Card, in order to comply with Swedish legislations.
Recurring payments
Adyen's tokenization service allows you to securely store shopper's card details for recurring payments. To make recurring payments, you first need to create a shopper token, and then use the token to make future payments for the shopper.
Create a token
When a shopper chooses to pay with card, Drop-in renders a switch for saving the card details for future payments.
If the shopper chooses to save their card details when making a payment, the didSubmit
method from Drop-in will include a data.storePaymentMethod
. Pass this to your server.
To create a token, include in your /payments request:
storePaymentMethod
: Thedata.storePaymentMethod
from your your client app.- shopperReference: Your unique identifier for the shopper.
If you don't want to show the switch for saving card details, set showsStorePaymentMethodField
to false when creating an instance of Drop-in.
let configuration = DropInComponent.Configuration(apiContext: apiContext)
configuration.card.showsStorePaymentMethodField = false
Show a stored card in your payment form
To show a stored card in your payment form, include in your /paymentMethods request:
- shopperReference: The unique shopper identifier that you specified when creating the token.
Make a payment with a token
When the shopper proceeds to pay, Drop-in invokes the didSubmit
method which contains data.paymentMethod
.
- Pass the
data.paymentMethod
to your server. -
From your server, make a /payments request, specifying:
paymentMethod
: Thedata.paymentMethod
from thedidSubmit
event from your client app.
shopperReference
: The unique shopper identifier that you specified when creating the token.shopperInteraction
: ContAuth.recurringProcessingModel
: CardOnFile.
curl https://checkout-test.adyen.com/v68/payments \ -H "X-API-key: [Your API Key here]" \ -H "Content-Type: application/json" \ -d '{ "amount":{ "value":2000, "currency":"USD" }, "paymentMethod":{ "type":"scheme", "storedPaymentMethodId":"8415718415172204", "encryptedSecurityCode":"adyenjs_0_1_18$MT6ppy0FAMVMLH..." }, "reference":"YOUR_ORDER_NUMBER", "merchantAccount":"YOUR_MERCHANT_ACCOUNT", "returnUrl":"...", "shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", "shopperInteraction":"ContAuth", "recurringProcessingModel":"CardOnFile" }'
The /payments response contains:
resultCode
: Use this to present the payment result to your shopper.
You can also use tokens to make shopper-not-present payments for subscriptions or contracts. For more information, refer to Making a payment for a subscription or contract.
Test and go live
Before making live card payments:
-
Test your integration using our test card numbers. You can check the status of test payments in your Customer Area > Transactions > Payments.
If you want to test API calls but your client-side integration is not yet ready, add a
test_
prefix to the test card credentials. Refer to test with encrypted card details. - Add the cards that you want to accept in your live Customer Area.
-
Configure Drop-in with the client key from your live Customer Area.
- Before you can start accepting card payments in the live environment, you need to assess your PCI DSS compliance and submit the required Self-Assessment Questionnaire A document. For more information, refer to PCI DSS compliance guide.