Swiftpack.co - Package - Adyen/adyen-ios

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 or Carthage.

CocoaPods

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

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.

Swift Package Manager

  1. Follow Apple's [Adding Package Dependencies to Your App](https://raw.github.com/Adyen/adyen-ios/develop/ https://developer.apple.com/documentation/xcode/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.

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

:warning: 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.

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, to enable the card form, the Drop-in needs a public key to use for encryption. These payment method specific configuration parameters can be set in an instance of DropInComponent.PaymentmethodsConfiguration:

let configuration = DropInComponent.PaymentMethodsConfiguration()
configuration.card.publicKey = "..." // Your public key, retrieved from the Customer Area.

:warning: PaymentMethodsConfiguration.card.publicKey is deprectated in favour of PaymentMethodsConfiguration.clientKey

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

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.


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.

Github

link
Stars: 75

Dependencies

Used By

Total: 0

Releases

3.8.0 -

  • Adds support for Swift Package Manager.
  • Adds support for SwiftUI applications, and adds a sample SwiftUI App.
  • Adds BLIK Component.
  • Update 3DS2 SDK version to 2.2.1.
  • Rewrites the card encryption code into Swift.
  • Improves card type detection visualization.
  • Fixes Adyen.podspec file to work with Xcode 12.
  • Enables hiding the CVC field for stored card payments.
  • Deprecated showsLargeTitle and FormHeaderItem.
  • Deprecated FormFooterItem, FormFooterItemView and FormFooterStyle.
  • Fixes small bug in ApplePayComponent to make sure call backs are invoked when its dismissed.
  • Removes footer note from SEPADirectDebitComponent.
  • Makes ActionComponentData.paymentData optional.
  • Adds an optional LocalizationParameters.bundle to dictate in which bundle to search for translations.
  • Shows a different title for submit buttons in case the amount being paid is 0.0.
  • Fixes a bug where RedirectComponent.delegate is not called when the web view is canceled using a swipe down.
  • Adds an alternative name with ADY prefix for FormViewController in the generated Objective-C headers, to avoid conflict with other SDKs.
  • Fixes a bug where AdyenWeChatPay.xcscheme wasn't being shared for Carthage integration.

3.7.0 -

  • Adds more accurate card brands detection in CardComponent.
  • Adds a closure to ApplePayComponent to be called in case user cancels.
  • Fixes a bug with ApplePayComponent cancellation.
  • Updates 3DS SDK to 2.1.0-rc.6.
  • Adds MBWayComponent and AwaitComponent to handle MB Way payment method and await actions respectively.
  • Adds client key configuration to replace card public key.
  • The card public key is now fetched using the client key in case client key is provided, otherwise falls back to using configured card public key.
  • Adds dismiss(animated:completion:) to RedirectComponent to enable programmatically dismissing it.
  • Adds support to exclude certain card brands from ApplePayComponent.
  • Adds JCB to supported card brands by ApplePayComponent.
  • Adds didCancel(component:from:) to DropInComponentDelegate to call back client code when a managed component is dismissed by the shopper.
  • Adds modalPresentationStyle to RedirectComponentStyle to enable configuring how RedirectComponent is presented.

2.8.6 -

  • Dismisses checkout in case shopper cancels a 3DS 1.0 redirect or a redirect payment method.

3.6.0 -

Functional changes

  • Enable hiding/showing the security code field in card component
  • Fixed the CardExpiryDateValidator to accept cards expiry until 30 years in the future
  • Add CardFundingSource to AnyCardPaymentMethod
  • Implemented blurring sensitive form components UI when an app goes to background
  • Made AmountFormatter public and added a helper function to convert major unit double values into minor unit Int values
  • Add delegate for 'onBrand' and 'onBin' to CardComponent
  • Deprecate 'RedirectComponent. presenterViewController'. Present Redirect from top most viewController on keyWindow
  • Disable cancel on DropIn while the payment is in progress

Style and customization

  • Add customized tintColor
  • Add customized separator
  • Add customization for rounded corners
  • Deprecate barTintColor and barBackgroundColor in NavigationStyle
  • Use preferred system fonts. Enable dynamic font adjustments for contentSize category change

Fixes

  • Fix the preselected payment method component height for iOS 10
  • Fix bug with iOS 10 PreselectedComponent
  • Navigation glitches for "half-screen presentation”
  • Fix background for ListItemView
  • Fix focusing on CVC field
  • Disable "openAll" button while the payment is in progress
  • Enable loading state for PaymentMethodListComponent

Github related

  • Add new issue type: "Assistance needed"

Additional

  • Fix warnings
  • Improve tests coverage
  • Improve documentation
  • Improve translation

3.5.0 -

  • Adds inline validation for text entry in components such as Card and SEPA Direct Debit.
  • Adds BrowserInfo to PaymentComponentData to optionally submit with a /payments request.
  • Adds UI customization options to the preselected payment screen of the Drop-in Component.
  • Improves the Redirect Component to be able to deal with a native app redirect.
  • Fixes an issue with the Apple Pay Component freezing in the Drop-in Component list.
  • Fixes an issue where the keyboard covers the UI.

3.4.1 -

  • Made CardSecurityCodeValidator and CardSecurityCodeFormatter public.

3.4.0 -

  • The Drop-in Component has a new, half-screen presentation style.
  • The Drop-in Component now shows the first available stored payment method prominently.
  • Adds WeChat Pay Component.
  • Adds Qiwi Wallet component.
  • Adds a visual hint for the location of the CVC/CVV in the Card Component.
  • Adds billing and delivery address input options to the Apple Pay Component.
  • Improves the expiration date validation in the Card Component to only allow expiration dates from 3 months in the past to 15 years in the future.
  • Improves card type detection in the Card Component.
  • Improves PaymentMethodDetails to allow encoding without access to the concrete type.
  • Fixes a crash in the Card Component when using non-numerical input.

3.3.0 -

  • Adds more extensive appearance customization options, such as fonts and text colors.
  • Adds an option to specify a custom localization key separator.
  • Fixes an issue where a custom localization table name would apply to default localizations.

3.2.0 -

  • Adds BCMC card component.
  • Adds Interac support to Apple Pay.
  • Adds Korean, Finnish and Norwegian translations.
  • Improves accessibility/screen reading in the card component.
  • Improves error handling of card encryption utility.
  • Improves error handling of Apple Pay component.

3.1.4 -

  • Adds support for Dark Mode.
  • Adds countryCode to the Payment initializer.
  • Improves the accessibility of the form's pay button and "store payment method"-switch.
  • Fixes an issue where the loading state would not be cancelled after cancelling a redirection to Safari.
  • Fixes a crash in the IBANValidator when the given input is less than 4 characters.

2.8.5 -

  • Fixes an issue where multiple payments could be made when repeatedly tapping the pay button.
  • Fixes a crash during deletion of stored payment methods.

3.1.3 -

  • Changes the Apple Pay component initializer to require a Payment structure.
  • Disables the iOS 13 modal dismissal gesture.
  • Fixes the highlighted color of the submit button when a custom tint color is used.
  • Fixes an issue where stored PayPal payment methods in the Drop-In would be presented in a new screen instead of as an alert.
  • Fixes an issue where the Drop-In would get stuck after being redirected back from an issuer.

3.1.2 -

  • Adds public initializers for validators and formatters.
  • Adds public initializers for actions.
  • Lowers the deployment target from iOS 10.3 to 10.0.
  • Fixes an autolayout warning in the Drop-in UI.
  • Fixes a visual navigation bar glitch on iOS 10.
  • Fixes an issue where the 3D Secure 2 component would get stuck after providing a challenge action more than once.

3.1.1 -

  • Adds an option to show/hide the store card checkbox on card component.
  • Fixes an issue where internal view controllers would load xib files from the project.
  • Makes the payload property in ThreeDS2Details public.

3.1.0 -

  • Adds Apple Pay component.
  • Adds expiry date information to stored cards on Drop-In payment method list.
  • Fixes an issue where expiry and cvc fields would not be validated on card component.
  • Fixes an issue where 3D Secure redirect flow would not work.

3.0.1 -

  • Fixes a runtime issue that happened when the library was compiled in release configuration.
  • Add demo server calls on UIHost to test the components flow.

3.0.0 -

  • We restructured the SDK into Components, providing a modular way to build your own UI.
  • You can now also use the Drop-in, a bundle of all available Components so you can start accepting key payment methods on your app.
  • If you want to upgrade to this release, make sure you read the integration documentation for Drop-in and Components. To support version 3.0.0, you need to change your API calls.
  • If you are using earlier releases, you can find the SDK documentation here.

2.8.4 -

  • Add Maestro to supported networks on ApplePay Plugin.

2.8.3 -

  • Use Swift 5 by default.

2.8.2 -

  • Fixes Carthage integration.

2.8.1 -

  • Fixes card expiry date validation when using a non-Gregorian calendar.

2.8.0 -

  • Added support for custom localization.
  • Fixed an issue where navigation bar color would not be propagated from appearance to all screens.

2.7.3 -

  • Updates the 3D-Secure 2.0 SDK to the latest version.

2.7.2 -

  • Fixed the Carthage integration.
  • Updated the examples to the latest version.

2.7.1 -

  • Fixed an issue where payment method selection would be blocked when an app redirect failed.
  • Fixed “Invalid bundle structure” when adding WeChatPay module.

2.7.0 -

  • Added support for Swift 5.
  • The used payment method type is now available in the payment result.
  • Implementation of the payment controller delegate's additional details callback is now required.
  • Added support for 3D-Secure 2.0 to the Custom Integration Example.
  • Fixed an issue where the SDK would try to use an Interface Builder file outside of the SDK.

Release 2.6.0 -

  • Added support for 3D-Secure 2.0 (currently for testing purposes only).

Release 2.5.0 -

  • Added native support for Giropay payments

Release 2.4.0 -

  • Added support for usage as a static framework
  • Improved experience when only one payment method is available

Release 2.3.0 -

  • Added support for surcharge on payment methods.
  • Improved flow for open invoice payments.
  • Fixed a issue where the checkout button would not reflect selected tint colour on preferred payment method screen.