Search

Are you looking for test card numbers?

Would you like to contact support?

Payment-method icon

Card iOS Component

Add card payments to your existing iOS Components integration.

Our Card Component renders the available cards in your payment form, and securely collects sensitive card information, so it doesn't touch your server.

Before you begin

This page explains how to add cards to your existing iOS Components integration. The iOS Components integration works the same way for all payment methods. If you haven't done this integration yet, refer to our Components integration guide.

Before starting your integration:

  1. Make sure that you have set up your back end implementation for making API requests.
  2. 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.

Include Card in the list of available payment methods.

  1. Specify in your /paymentMethods request:

  2. Decode the /paymentMethods response with the PaymentMethods structure.

    let paymentMethods = try JSONDecoder().decode(PaymentMethods.self, from: paymentMethodsResponse)

    Find paymentMethods.type card and put it into an object. For example, cardPaymentMethod.

  3. Initialize the Card Component:
    let cardComponent = CardComponent(paymentMethod: cardPaymentMethod, clientKey: clientKey)
    // The client key from your Customer Area.
    cardComponent.clientKey = "YOUR_CLIENT_KEY"
    cardComponent.delegate = self
    // When you're ready to go live, change this to .live or to other environment values.
    // Environment values are described in https://adyen.github.io/adyen-ios/Docs/Structs/Environment.html
    cardComponent.environment = .test
    // In this example, the Pay button will display 10 EUR.
    // The value is in minor units. Change the currencyCode to the currency for the Card Component.
    cardComponent.payment = Payment(amount: Payment.Amount(value: 1000,
                                                                  currencyCode: "EUR"))
    present(cardComponent.viewController, animated: true)

When the shopper is entering their card details, the Component tries to recognize the card brand. When successful, the Component renders the brand icon.

Make a payment

When the shopper proceeds to pay, the Component invokes the didSubmit method containing the data.paymentMethod from the PaymentComponentDelegate.

  1. Pass the data.paymentMethod to your server.
  2. From your server, make a /payments request, specifying:
    • paymentMethod: The data.paymentMethod from the didSubmit event from your client app.

The /payments response contains:

  • pspReference: Our unique identifier for the transaction.
  • resultCode: Use this to present the payment result to your shopper.
  • merchantReference: The reference from the /payments request.
  • additionalData: Additional information about the transaction.
    To specify the fields that you want to receive in additionalData, log in to your Customer Area, and go to Account > API URLs > Additional data settings.

/payments response
{
  "additionalData": {
    "cardSummary": "1111"
  },
  "pspReference": "851572424333194G",
  "resultCode": "Authorised",
  "merchantReference": "YOUR_ORDER_NUMBER"
}

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.
Additional 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 Card Component integration, you need to use:

  • Checkout API v53 or later.
  • iOS Components 3.7.0 or later.

Show the available debit and credit cards

  1. When you make a POST /paymentMethods request from your server, include: The following example shows how you would do this for a shopper in the Netherlands, making a 47.00 EUR payment.
    /paymentMethods request
    curl https://checkout-test.adyen.com/v65/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
    }'
    The response includes the list of available payment methods, with debit and credit cards split into separate objects.
    Response
    {
       ...
       "paymentMethods": [
           {
               "brands": [
                   "mc",
                   "visa",
                   "amex"
               ],
               ...
               "fundingSource": "credit",
               "name": "Credit Card",
               "type": "scheme"
           },
           {
               "brands": [
                   "mc",
                   "visa",
                   "amex"
               ],
               "fundingSource": "debit",
               "name": "Debit Card",
               "type": "scheme"
           }
       ]
    }
  1. To present credit and debit cards separately in your app, you need to instantiate a CardPaymentMethod object for each.

    let debitCard = CardPaymentMethod(type: "scheme", name: "Debit Card", fundingSource: .debit, brands: ["{SUPPORTED_CARD_BRANDs}"])
    let creditCard = CardPaymentMethod(type: "scheme", name: "Credit Card", fundingSource: .credit, brands: ["{SUPPORTED_CARD_BRANDs}"])
  2. Present a separate CardComponent for each funding source type.

    let debitCardComponent = CardComponent(paymentMethod: debitCard)
    debitCardComponent.clientKey = "YOUR_CLIENT_KEY"
    debitCardComponent.delegate = self
    debitCardComponent.environment = .test
    present(cardComponent.viewController, animated: true)
    let creditCardComponent = CardComponent(paymentMethod: creditCard)
    creditCardComponent.clientKey = "YOUR_CLIENT_KEY"
    creditCardComponent.delegate = self
    creditCardComponent.environment = .test
    present(cardComponent.viewController, animated: true)

When the shopper selects to pay with a debit or credit card, the selected Component works like any other Component — it invokes the didSubmit method containing the data.paymentMethod from the PaymentComponentDelegate. 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

When accepting payments in Sweden, present debit cards before credit cards, and label the forms clearly 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, the Component 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 the Component will include data.storePaymentMethod. Pass this to your server.

To create a token, include in your /payments request:

  • storePaymentMethod: The data.storePaymentMethod from 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 adding the Card Component:
let cardComponent = CardComponent(paymentMethod: cardPaymentMethod)
 cardComponent.clientKey = "YOUR_CLIENT_KEY"
 cardComponent.showsStorePaymentMethodField = false
 cardComponent.delegate = self
 cardComponent.environment = .test
 present(cardComponent.viewController, animated: true)

Show a stored card in your payment form

To show a stored card payment in your payment form:

  1. Include in your /paymentMethods request:
    • shopperReference: The unique shopper identifier that you specified when creating the token.
    The /paymentMethods response includes a storedPaymentMethods array containing the stored payment methods for this shopper.
  2. When you decode the paymentMethods response, find the StoredCardPaymentMethod object in the array named stored.
  3. When adding the Card Component, specify:
    • paymentMethod: The StoredCardPaymentMethod object
    let cardComponent = CardComponent(paymentMethod: storedCardPaymentMethod)
    cardComponent.clientKey = "YOUR_CLIENT_KEY"
    cardComponent.delegate = self
    cardComponent.environment = .test
    present(cardComponent.viewController, animated: true)

This will render the stored card in your payment form.

Make a payment with a token

When the shopper proceeds to pay, the Component invokes the didSubmit method containing the data.paymentMethod from the PaymentComponentDelegate.

  1. Pass the data.paymentMethod to your server.
  2. From your server, make a /payments request, specifying:
    • paymentMethod: The data.paymentMethod from the didSubmit event from your client app.
    • shopperReference: The unique shopper identifier that you specified when creating the token.
    • shopperInteractionContAuth.
    • recurringProcessingModel: CardOnFile.
    {
    "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:
    {
    "pspReference": "8815329842815468",
    "resultCode": "Authorised"
    }

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:

  1. Test your integration using our test card numbers.
    You can check the status of test payments in your Customer Area > Transactions > Payments.
  1. Add the cards that you want to accept in your live Customer Area.
  1. Configure the Component using the Client Key from your live Customer Area.

  2. 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.

See also