What's New

4.0.0-beta.1

2021-03-22T12:15:22Z

Minimum API version

We recommend you use Checkout API v67.

Backwards compatibility with earlier API versions is not fully tested - we would appreciate your feedback :)

Breaking changes

  • Makes clientKey required on PaymentMethodsConfiguration.

  • Removed cancelHandler from the applePay component.

  • Drops support for iOS 10.0.

  • Made paymentData optional in RedirectAction, ActionComponentData and RedirectComponent.

  • RedirectComponent requires presentationDelegate to present its UI.

  • Adds a PaymentMethod object to DropInDelegate.didSubmit, so you can identify which payment method is being submitted.

  • Removed deprecated classes, functions, properties.

  • Renamed DropInActionComponent to AdyenActionComponent and moved it to the AdyenActions module.

  • Refactored the SDK into a new module structure:

  • AdyenComponents contains any payment component, for example QiwiWalletComponent, MBWayComponent, ApplePayComponent, and BLIKComponent.

  • AdyenCard contains any card payment related components, for example CardComponent, StoredCardComponent, and BCMCComponent.

  • AdyenActions contains all action components, for example AwaitComponent, VoucherComponent, and RedirectComponent.

  • AdyenEncryption contains the encryption helpers.

  • AdyenSwiftUI contains SwiftUI related integration helpers, for example ViewControllerPresenter, ViewModifier.

  • AdyenDropIn contains DropInComponent.

  • AdyenWeChatPay contains the WeChat Pay component.

New

  • The ThreeDS2Component supports the new 3D Secure flow from Checkout API v67. The old flow is still supported if you’re using an API version earlier than v67.
  • DokuComponent adds support for Indonesian bank transfers and cash payments at convenience stores through Doku Wallet, Doku Alfamart, and Doku Indomaret.
  • VoucherComponent handles actions for voucher payment flows, for example Doku Alfamart.
  • Adds support for stored payment details for BLIK.
  • You can configure button border color and width using ButtonStyle.

Improvements

  • Removed hard dependency on Checkout API versions pre 67.
  • Allow the title for DropIn to be centered.
  • Allow custom image for the cancel button.
  • Get Apple Pay supported networks from /paymentMethods response, and remove ApplePayConfiguration.excludedCardNetworks.
  • Improved accuracy for card brand detection.
  • Added CVC length validation for the stored cards component.
  • You can now use CardEncryptor to encrypt individual card fields, for example CVC or expiry month.
  • Refactored the Demo example apps (for UIKit and SwiftUI) to make it easier to follow.

Fixes

  • Fixed MBWayComponent to show Portugal and Spain in the phone prefix drop down list of phone extensions.
  • Fixed a bug where gift card payment methods had a missing logo.
  • Fixes localization warning when using Swift Package Manager.
  • Swish redirects are now fixed by adding the returnUrlQueryString option to RedirectDetails.

Note: Please refer to the migration guide for details about the breaking changes.

GitHub Workflow Status Pod carthage compatible SwiftPM codecov codebeat badge

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

Adyen Components for iOS

Adyen Components for iOS allows you to accept in-app payments by providing you with the building blocks you need to create a checkout experience.


DropIn preview


Installation

Adyen Components for iOS are available through either CocoaPods, Carthage or Swift Package Manager.

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/SwiftUI module needs to be explicitly added to use the SwiftUI specific helpers..

pod 'Adyen'               // Add DropIn with all modules except WeChat Pay and SwiftUI.
// Add individual modules
pod 'Adyen/Card'          // Card components.
pod 'Adyen/Encryption'    // Encryption module.
pod 'Adyen/Components'    // All other payment components except WeChat Pay.
pod 'Adyen/Actions'       // Action Components.
pod 'Adyen/WeChatPay'     // WeChat Pay Component.
pod 'Adyen/SwiftUI'       // SwiftUI apps specific module.

⚠️ 3DS2 SDK binary dependency through CocoaPods doesn't support arm64 Simulator builds. arm64 needs to be excluded as described here to be able to make Any Simulator builds.

Carthage

  1. Add github "adyen/adyen-ios" to your Cartfile.
  2. Run carthage update.
  3. Link the framework with your target as described in Carthage Readme.

You can add all modules or select individual modules to add to your integration. But make sure to include each module dependency modules.

  • AdyenDropIn: DropInComponent.
  • AdyenCard: the card components.
  • AdyenComponents: all other payment components except WeChat Pay.
  • AdyenActions: action components.
  • AdyenEncryption: encryption.
  • AdyenWeChatPay: WeChat Pay component.
  • AdyenSwiftUI: SwiftUI apps specific module.

⚠️ 3DS2 SDK binary dependency through Carthage doesn't support arm64 Simulator builds. arm64 needs to be excluded as described here to be able to make Any Simulator builds

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

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 AdyenSwiftUI module needs to be explicitly added to use the SwiftUI specific helpers.

  • AdyenDropIn: all modules except AdyenWeChatPay.
  • AdyenCard: the card components.
  • AdyenComponents: all other payment components except WeChat Pay.
  • AdyenActions: action components.
  • AdyenEncryption: encryption.
  • AdyenWeChatPay: WeChat Pay component.
  • AdyenSwiftUI: SwiftUI apps specific module.

⚠️ Please make sure to use Xcode 12.0+ when adding Adyen using Swift Package Manager.

⚠️ Swift Package Manager for Xcode 12.0 and 12.1 has a know issue when it comes to importing a dependency that in turn depend on a binary dependencies. A workaround is described here.

⚠️ AdyenWeChatPay Module doesn't support arm64 Simulator builds, because of a limitation in the underlying libWeChatSDK.a static library dependency. arm64 needs to be excluded as described here or exclude AdyenWeChatPay from your dependencies, to be able to make Any Simulator builds .

Drop-in

The Drop-in handles the presentation of available payment methods and the subsequent entry of a customer's payment details. It is initialized with the response of /paymentMethods, and provides everything you need to make an API call to /payments and /payments/details.

Usage

Presenting the Drop-in

The Drop-in requires the response of the /paymentMethods endpoint to be initialized. To pass the response to Drop-in, decode the response to the PaymentMethods structure:

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

Some payment methods need additional configuration. For example ApplePayComponent. These payment method specific configuration parameters can be set in an instance of DropInComponent.PaymentmethodsConfiguration:

let configuration = DropInComponent.PaymentMethodsConfiguration()
configuration.applePay.summaryItems = "..." // Apple Pay summary items.
configuration.applePay.merchantIdentifier = "..." // Apple Pay merchant identifier.

All Payment Components needs a client key, please read more here about the client key and how to get it.

let configuration = DropInComponent.PaymentMethodsConfiguration()
configuration.clientKey = "..." // Your client key, retrieved from the Customer Area.

Also for voucher payment methods like Doku variants, in order for the DokuComponent to enable the shopper to save the voucher, access to the shopper photos is requested, so a suitable text need to be added to key NSPhotoLibraryAddUsageDescription in the application Info.plist.

After serializing the payment methods and creating the configuration, the Drop-in is ready to be initialized. Assign a delegate and use the viewController property to present the Drop-in on the screen:

let dropInComponent = DropInComponent(paymentMethods: paymentMethods,
paymentMethodsConfiguration: configuration)
dropInComponent.delegate = self
present(dropInComponent.viewController, animated: true)

Implementing DropInComponentDelegate

To handle the results of the Drop-in, the following methods of DropInComponentDelegate should be implemented:


func didSubmit(_ data: PaymentComponentData, from component: DropInComponent)

This method is invoked when the customer has selected a payment method and entered its payment details. The payment details can be read from data.paymentMethod and can be submitted as-is to /payments.


func didProvide(_ data: ActionComponentData, from component: DropInComponent)

This method is invoked when additional details are provided by the Drop-in after the first call to /payments. This happens, for example, during the 3D Secure 2 authentication flow or any redirect flow. The additional details can be retrieved from data.details and can be submitted to /payments/details.


func didFail(with error: Error, from component: DropInComponent)

This method is invoked when an error occurred during the use of the Drop-in. Dismiss the Drop-in's view controller and display an error message.


func didCancel(component: PresentableComponent, from dropInComponent: DropInComponent)

This method is invoked when user closes a payment component managed by Drop-in.


func didComplete(from component: DropInComponent)

This method is invoked when the action component finishes, without any further steps needed by the application, for example in case of voucher payment methods. The application just needs to dismiss the DropInComponent..


Handling an action

When /payments or /payments/details responds with a non-final result and an action, you can use the Drop-in to handle the action:

let action = try JSONDecoder().decode(Action.self, from: actionData)
dropInComponent.handle(action)

In case the customer is redirected to an external URL, make sure to let the Drop-in know when the user returns to your app. Do this by implementing the following in your UIApplicationDelegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    Adyen.applicationDidOpen(url)

    return true
}

Components

In order to have more flexibility over the checkout flow, you can use our Components to present each payment method individually. Implementation details of our Components can be found in our Components API Reference.

Available Components

Customization

Both the Drop-in and the Components offer a number of customization options to allow you to match the appearance of your app. For example, to change the section header titles and form field titles in the Drop-in to red, and turn the submit button's background to blue:

var style = DropInComponent.Style()
style.listComponent.sectionHeader.title.color = .red
style.formComponent.textField.title.color = .red
style.formComponent.footer.button.backgroundColor = .purple

let dropInComponent = DropInComponent(paymentMethods: paymentMethods,
                                      paymentMethodsConfiguration: configuration,
                                      style: style)

Or, to create a black Card Component with white text:

var style = FormComponentStyle()
style.backgroundColor = .black
style.header.title.color = .white
style.textField.title.color = .white
style.textField.text.color = .white
style.switch.title.color = .white

let component = CardComponent(paymentMethod: paymentMethod,
                              publicKey: Configuration.cardPublicKey,
                              style: style)

A full list of customization options can be found in the API Reference.

Requirements

  • iOS 10.0+
  • Xcode 11.0+
  • Swift 5.1

See also

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.

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.

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

Last updated: Wed Oct 20 2021 05:42:12 GMT-0500 (GMT-05:00)