Check the following high-level procedure to implement Revolut Pay on your website. Use the dropdowns to see the details of each step:
Before you start this tutorial, ensure that you have completed the following steps:
The minimum supported iOS version is: 13.0.
To integrate Revolut Pay into your Xcode project through CocoaPods, add the following pod in your Podfile
:
pod 'RevolutPayments/RevolutPay'
Beginning with iOS 9 and Xcode 7, apps must declare the URL schemes they intend to open, by specifying the schemes in the app's Info.plist
file.
Our SDK opens the Revolut mobile app (if installed), when the user taps the Revolut Pay button, and your app therefore needs to declare the relevant URL scheme.
To declare the URL scheme, add the following to the Info.plist
file:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>revolut</string>
</array>
Import the Revolut Payments module by adding the following line:
import RevolutPayments
Before proceeding with any SDK usage, you must first configure the SDK by calling RevolutPayKit.configure(with:)
.
This step can be done on app launch, in AppDelegate
.
You need to first generate the Merchant Secret and Public API keys. To do this, you have to be accepted as a Merchant in your Revolut Business account. The iOS SDK requires the Merchant Public API key.
First create a RevolutPayKit
object. It provides all the necessary tools for processing the payment of a specific item or list of items (for example, the items on your Checkout screen).
let revolutPayKit = RevolutPayKit()
To create a Revolut Pay button, call the button
or swiftUIButton
method of the object. Through the function parameters, you can configure the visual style of the button and handle all the steps of the payment flow.
let button = revolutPayKit.button(
style: .init(size: .large),
returnURL: "myapp://revolut-pay", // <- Change with your actual return URL
createOrder: { createOrderHandler in
// Get the order token from your backend
createOrderOnBackEnd { orderToken in
createOrderHandler.set(orderToken: orderToken)
}
},
completion: { result in
switch result {
case .success:
// Handle successful payment
case .failure(let error):
// Handle error
}
}
)
For more information about the parameters, see: Parameters: iOS
If you want the shipping address and delivery method to be quickly collected from the user through Revolut Pay, pass the shouldRequestShipping
parameter as true
.
This way, your app can skip the shipping flow during checkout and the user can use existing shipping details stored by Revolut Pay.
By default, Fast checkout is not enabled.
Your backend must support Fast checkout for this functionality to work. For more information, see: Implement Revolut Pay with Fast checkout.
To display the button, simply insert it into your view hierarchy. For example:
view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
button.bottomAnchor.constraint(equalTo: view.bottomAnchor),
button.leadingAnchor.constraint(greaterThanOrEqualTo: view.leadingAnchor),
button.trailingAnchor.constraint(lessThanOrEqualTo: view.trailingAnchor),
button.centerXAnchor.constraint(equalTo: view.centerXAnchor)
])
If all the steps have been followed correctly, you have successfully implemented Revolut Pay! 🎉