在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Adyen/adyen-ios开源软件地址:https://github.com/Adyen/adyen-ios开源编程语言:Swift 98.8%开源软件介绍:Adyen Components for iOSAdyen Components for iOS allows you to accept in-app payments by providing you with the building blocks you need to create a checkout experience. InstallationAdyen Components for iOS are available through either CocoaPods, Carthage or Swift Package Manager. CocoaPods
You can install all modules or add individual modules, depending on your needs and integration type.
The
Carthage
You can add all modules or select individual modules to add to your integration. But make sure to include each module dependency modules.
Swift Package Manager
You can add all modules or select individual modules to add to your integration.
The
Drop-inThe 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 UsagePresenting the Drop-inThe Drop-in requires the response of the let paymentMethods = try JSONDecoder().decode(PaymentMethods.self, from: response) All Components need an let apiContext = APIContext(clientKey: clientKey, environment: Environment.test)
let configuration = DropInComponent.Configuration(apiContext: context.apiContext) Some payment methods need additional configuration. For example let summaryItems = [
PKPaymentSummaryItem(label: "Item A", amount: 75, type: .final),
PKPaymentSummaryItem(label: "Item B", amount: 25, type: .final),
PKPaymentSummaryItem(label: "Total", amount: 100, type: .final)
]
let configuration = DropInComponent.Configuration(apiContext: context.apiContext)
configuration.payment = payment
configuration.applePay = .init(summaryItems: summaryItems,
merchantIdentifier: "merchant.com.adyen.MY_MERCHANT_ID") Also for voucher payment methods like Doku variants, in order for the After serializing the payment methods and creating the configuration, the Drop-in is ready to be initialized. Assign a let dropInComponent = DropInComponent(paymentMethods: paymentMethods, configuration: configuration)
dropInComponent.delegate = self
present(dropInComponent.viewController, animated: true) Implementing DropInComponentDelegateTo handle the results of the Drop-in, the following methods of func didSubmit(_ data: PaymentComponentData, for paymentMethod: PaymentMethod, 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 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 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 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 func didCancel(component: PaymentComponent, from dropInComponent: DropInComponent) This optional method is invoked when user closes a payment component managed by Drop-in. func didOpenExternalApplication(component: DropInComponent) This optional method is invoked after a redirect to an external application has occurred. Handling an actionWhen Using Drop-inIn case of Drop-in integration you must use build-in action handler on the current instance of let action = try JSONDecoder().decode(Action.self, from: actionData)
dropInComponent.handle(action) Using componentsIn case of using individual components - not Drop-in -, create and persist an instance of lazy var actionComponent: AdyenActionComponent = {
let handler = AdyenActionComponent(apiContext: context.apiContext)
handler.delegate = self
handler.presentationDelegate = self
return handler
}() Than use it to handle the action: let action = try JSONDecoder().decode(Action.self, from: actionData)
actionComponent.handle(action) Receiving redirectIn case the customer is redirected to an external URL or App, make sure to let the func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
RedirectComponent.applicationDidOpen(from: url)
return true
} ComponentsIn 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
CustomizationBoth 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 black with white foreground: var style = DropInComponent.Style()
style.listComponent.sectionHeader.title.color = .red
style.formComponent.textField.title.color = .red
style.formComponent.mainButtonItem.button.backgroundColor = .black
style.formComponent.mainButtonItem.button.title.color = .white
let dropInComponent = DropInComponent(paymentMethods: paymentMethods,
configuration: 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,
apiContext: context.apiContext,
style: style) A full list of customization options can be found in the API Reference. Requirements
See alsoSupportIf you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our support team. ContributingWe strongly encourage you to join us in contributing to this repository so everyone can benefit from:
Read our contribution guidelines to find out how. LicenseThis repository is open source and available under the MIT license. For more information, see the LICENSE file. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论