Skip to content

Latest commit

 

History

8,183 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Workflow Status Pod SwiftPM Coverage

Sonarcloud Status SonarCloud Bugs SonarCloud Vulnerabilities Maintainability Rating Reliability Rating Security Rating

Swift Versions Supported Platforms

iOS Logo

Adyen iOS

🚨 Are you integrating with v5?

This branch documents v6, which is currently in alpha and under active development. Its public API can still change, and the v5 API is not available here.

For the latest stable release, use the v5 branch and the v5 integration guides.

Adyen iOS provides you with the building blocks to create a checkout experience for your shoppers, allowing them to pay using the payment method of their choice.

The v6 alpha integrates with Components: one Component per payment method, combined with your own payments flow. Drop-in, the all-in-one solution, is not available in the v6 alpha yet.

SDK lifecycle

Major version State Deprecated End-of-life
6.x.x Alpha (in development) --- ---
5.x.x Active --- ---
4.x.x Inactive December 2026 December 2027
3.x.x End-of-life November 2021 November 2022

More information about our versioning and the Drop-in/Components lifecycle can be found here.

v6 alpha documentation

The v6 API documented in this branch is currently alpha. These guides describe the current public v6 API.

Installation

Adyen iOS is available through either CocoaPods or Swift Package Manager.

Minimum Requirements

  • iOS 16.0
  • Xcode 15.0
  • Swift 5.9

Swift Package Manager

  1. Follow Apple's Adding Package Dependencies to Your App guide on how to add a Swift Package dependency.
  2. Use https://github.com/Adyen/adyen-ios as the repository URL.
  3. Specify the version to be at least 6.0.0-alpha.1.

You can add all modules or select individual modules to add to your integration. The AdyenWeChatPay module needs to be explicitly added to support WeChat Pay. The AdyenTwint module needs to be explicitly added to support Twint native flow. The AdyenSwiftUI module needs to be explicitly added to use the SwiftUI specific helpers.

  • AdyenCheckout: the v6 entry point, includes Adyen, AdyenCard, AdyenComponents, AdyenActions and AdyenSession.
  • Adyen: core module.
  • AdyenUI: shared UI, form items and theming.
  • AdyenCard: the card components.
  • AdyenComponents: all other payment components except WeChat Pay.
  • AdyenActions: action components.
  • AdyenEncryption: encryption.
  • AdyenSession: handler for the simplified checkout flow.
  • AdyenCardScanner: card scanning support.
  • AdyenWeChatPay: WeChat Pay component.
  • AdyenTwint: Twint component.
  • AdyenCashAppPay: Cash App Pay component.
  • AdyenSwiftUI: SwiftUI apps specific module.

⚠️ AdyenWeChatPay and AdyenWeChatPayInternal modules don't support any simulators and can only be tested on a real device.

CocoaPods

  1. Add pod 'Adyen' to your Podfile.
  2. Run pod install.

You can install all modules or add individual modules, depending on your needs and integration type. The Adyen/WeChatPay module needs to be explicitly added to support WeChat Pay. The Adyen/AdyenTwint module needs to be explicitly added to support Twint native flow. The Adyen/SwiftUI module needs to be explicitly added to use the SwiftUI specific helpers.

pod 'Adyen'               // Add the Checkout subspec, the v6 entry point, with the card, components, actions, encryption and session modules.
// Add individual modules
pod 'Adyen/Card'          // Card components.
pod 'Adyen/Session'       // Handler for the simplified checkout flow.
pod 'Adyen/Encryption'    // Encryption module.
pod 'Adyen/Components'    // All other payment components except WeChat Pay.
pod 'Adyen/Actions'       // Action Components.
pod 'Adyen/CardScanner'   // Card scanning support.
pod 'Adyen/WeChatPay'     // WeChat Pay Component.
pod 'Adyen/CashAppPay'    // Cash App Pay Component.
pod 'Adyen/AdyenTwint'    // Twint Component.
pod 'Adyen/SwiftUI'       // SwiftUI apps specific module.

⚠️ Adyen/WeChatPay and AdyenWeChatPayInternal modules doesn't support any simulators and can only be tested on a real device.

Getting started

The v6 API is centered around Checkout.setup(...) as the entry point, CheckoutConfiguration as the shared configuration container, closure-based flow callbacks, and payment components created from the resulting checkout flow. See the v6 foundations guide for the full reference.

Note: Drop-in is not part of the v6 alpha yet. The v6 alpha exposes individual payment components; Drop-in support is planned for a later release.

Session flow

Use the session flow when your backend starts checkout with /sessions. Adyen manages the flow, including payment submission and action handling.

import Adyen
import AdyenActions
import AdyenCard
import AdyenCheckout

let configuration = try CheckoutConfiguration(
    environment: .test,
    amount: amount,
    clientKey: clientKey
) {
    CardConfiguration()
    AuthenticationConfiguration()
        .requestorAppURL(URL(string: "https://your-domain.example/adyen")!)
}

let checkout = try await Checkout.setup(
    with: sessionResponse,
    configuration: configuration,
    presentationDelegate: self
)
.onComplete { result in
    print(result.resultCode)
}
.onFailure { error in
    print(error.localizedDescription)
}

let component = try checkout.createPaymentComponent(for: .scheme)

In session flow the effective amount comes from the /sessions response, and settings such as storePaymentMethodMode and installments are session-controlled. See the session flow guide.

Advanced flow

Use the advanced flow when your backend calls /paymentMethods and handles /payments and /payments/details itself.

let checkout = try await Checkout.setup(
    with: paymentMethods,
    configuration: configuration,
    presentationDelegate: self
)
.onSubmit { data in
    try await callPayments(with: data)
}
.onAdditionalDetails { data in
    try await callDetails(with: data)
}
.onComplete { result in
    print(result.resultCode)
}
.onFailure { error in
    print(error.localizedDescription)
}

let component = try checkout.createPaymentComponent(for: .scheme)

callPayments(with:) returns a SubmitResult and callDetails(with:) returns an AdditionalDetailsResult. See the advanced flow guide.

Action-only flow

If your app only needs to handle actions, set up checkout without a SessionResponse or PaymentMethods, and call checkout.handle(action:) when your backend returns an action.

let checkout = try await Checkout.setup(
    configuration: configuration,
    presentationDelegate: self
)
.onAdditionalDetails { data in
    try await callDetails(with: data)
}
.onComplete { result in
    print(result.resultCode)
}
.onFailure { error in
    print(error.localizedDescription)
}

Presenting a payment component

createPaymentComponent(for:) returns a CheckoutPaymentComponent. Use its viewController for presentation.

guard let viewController = component.viewController else { return }

present(UINavigationController(rootViewController: viewController), animated: true)

Pass a PresentationDelegate to Checkout.setup(...) if checkout should present action components from your own UI layer.

extension CheckoutViewController: PresentationDelegate {
    func present(viewController: UIViewController) {
        present(viewController, animated: true)
    }
}

Handling redirects

Pass incoming URLs to the SDK so active redirect actions can resume after the shopper returns from a browser or an external app. It is safe to pass all incoming URLs; any URL not belonging to an active checkout redirect is ignored.

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    Checkout.handleReturn(url: url)
    return true
}

For SceneDelegate and SwiftUI entry points, see the v6 foundations guide.

Components

In v6 you present each payment method individually with createPaymentComponent(for:), passing either a PaymentMethodType or the identifier of a stored payment method.

// A payment method from the current checkout flow.
let component = try checkout.createPaymentComponent(for: .scheme)

// A stored payment method.
guard let storedCard = checkout.paymentMethods?.stored
    .compactMap({ $0 as? StoredCardPaymentMethod })
    .first else { return }

let storedComponent = try checkout.createPaymentComponent(for: storedCard.identifier)

Available Components

The v6 alpha currently supports:

  • Card, including stored cards
  • Apple Pay
  • BLIK
  • ACH Direct Debit
  • Instant payment methods
  • Stored payment methods

The remaining payment methods are still being migrated to the v6 API. For the components documented so far, see the card component overview.

Customization

Checkout-wide styling is configured with CheckoutTheme on CheckoutConfiguration, and applies to every payment component and action created from that checkout flow. Start from CheckoutColors.default and override only the tokens you need.

let theme = CheckoutTheme(
    colors: CheckoutColors(
        background: .systemBackground,
        container: .secondarySystemBackground,
        primary: .black,
        textOnPrimary: .white,
        highlight: .systemBlue,
        destructive: .systemRed,
        text: .label,
        textSecondary: .secondaryLabel
    )
)

let configuration = try CheckoutConfiguration(
    environment: .test,
    amount: amount,
    clientKey: clientKey
) {
    CardConfiguration()
}
.theme(theme)

A full list of color tokens can be found in the checkout theme guide.

Strings can be overridden at runtime with localizationProvider(_:) on CheckoutConfiguration, or by adding .strings and .xcstrings files to your app bundle to add a fully new language.

See also

Demo App

We provide a fully working Demo App to explore the checkout integration in a sandbox environment.

The Demo App includes:

  • Sample integrations for Session Flow and Advanced Flow
  • UIKit and SwiftUI examples
  • Common payment methods (Card, Apple Pay, Instant Payments, Issuer List)

Note: We recommend using your own backend server. Direct API usage with ADYEN_SERVER_API_KEY is possible for testing only and not for production.

For detailed setup, see the Demo README.

Support

If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our Support Team via Customer Area or via email: support@adyen.com

Contributing

We strongly encourage you to join us in contributing to this repository so everyone can benefit from:

  • New features and functionality
  • Resolved bug fixes and issues
  • Any general improvements

Read our contribution guidelines to find out how.

License

This repository is open source and available under the MIT license. For more information, see the LICENSE file.

Releases

Used by

Contributors

Languages