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 and button styling, see: Parameters: iOS and Revolut Pay button guidelines.
Pass the savePaymentMethodForMerchant
parameter as true
in order to save your customer's payment details during checkout. Customers are able to save both their Revolut account and card details via Revolut Pay.
This way, your customers can grant permission for you to initiate payments on their saved payment method stored by Revolut Pay, without any further action required from the customer. Use this feature to initiate recurring payments, e.g., to take payments for a subscription or to charge a customer later for a specific order.
By default, merchant initiated transactions are disabled.
To learn more about how to save and charge a customer's payment method, see: Charge a customer's saved payment method.
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)
])
Optionally, you can use the Revolut Pay promotional banner widget to offer rewards to customers who create a new Revolut account after checkout. You can add the widget to your app the following way.
First, you need to configure the promotional banner. To configure the promotional banner with minimal required parameters, call the revolutPayKit.promotionalBanner()
method with the following parameters:
let promotionalBanner = revolutPayKit.promotionalBanner(
transactionId: "transaction-id", // Unique ID of the payment corresponding to the promotional offer
amount: 10_00,
currency: .EUR,
customer: .init()
)
This configuration will create a banner with default styling and without any additional information about the customer. Ideally, merchants should provide as much information as possible.
For more information about the parameters, see: Parameters: iOS - Promotional banner.
After configuring the promotional banner, you have to display it in your app. To do this, simply insert it to your view hierarchy. For example:
view.addSubview(promotionalBanner)
promotionalBanner.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
promotionalBanner.topAnchor.constraint(
equalTo: view.safeAreaLayoutGuide.topAnchor,
constant: 16
),
promotionalBanner.trailingAnchor.constraint(
equalTo: view.safeAreaLayoutGuide.trailingAnchor,
constant: -16
),
promotionalBanner.leadingAnchor.constraint(
equalTo: view.safeAreaLayoutGuide.leadingAnchor,
constant: 16
)
])
If all the steps have been followed correctly, you have successfully implemented Revolut Pay! 🎉