when Please follow below steps to integrate Ayden Payment Gateway
Adyen Components for iOS allows you to accept in-app payment by providing you with the building blocks you need to create a checkout experience with Adyen.
Installation
- Add
pod 'Adyen'
to yourPodfile
. - Run
pod install
.
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 payment methods 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, and also, decode the response to the payment methods structure:
1 |
let paymentMethods = try JSONDecoder().decode(PaymentMethods.self, from: response) |
Some payment methods need an additional configuration also. For example, to enable the card form, the Drop-in needs a public key to use for encryption. This payment method specific configuration parameters can be set in an instance of DropInComponent.PaymentmethodsConfiguration
:
1 2 |
let configuration = DropInComponent.PaymentMethodsConfiguration() configuration.card.publicKey = "..." // Your public key,while retrieved from the Customer Area. |
Assign a delegate
and use the viewController
property to present the Drop-in on the screen:
1 2 3 4 |
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:
1 |
func didSubmit(_ data: PaymentComponentData, from component: DropInComponent) |
When the customer has selected a payment method and entered its payment details this method is invoked. While the payment details can be read from data.paymentMethod
and can be submitted as-is to payments.
1 |
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 also, for example, during the 3D Secure 2 authentication flow or any redirect flow. while The additional details can be retrieved from data.details
and can be submitted to /payments/details
.
1 |
func didFail(with error: Error, from component: DropInComponent) |
When an error occurred during the use of the Drop-in this method is invoked. Also, dismiss the view controller and display an error message.
1 2 |
let action = try JSONDecoder().decode(Action.self, from: actionData) dropInComponent.handle(action) |
In case the customer is redirecting to an external URL, make sure to let the Drop-in know when the user returns to your app. but Do this by implementing the following in your UIApplicationDelegate
:
1 2 3 4 5 |
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.
Available Components
- Card Component
- 3D Secure 2 Component
- Apple Pay Component
- BCMC Component
- iDEAL Component
- SEPA Direct Debit Component
- MOLPay Component
- Dotpay Component
- EPS Component
- Entercash Component
- Open Banking Component
- WeChat Pay Component
- Qiwi Wallet Component
- Redirect Component
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:
1 2 3 4 5 6 7 8 |
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:
1 2 3 4 5 6 7 8 9 10 |
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) |
To find full documentation please click below link also:-
Requirements
- iOS 10.0+
- Xcode 11.0+
- Swift 5.1