Welcome to the implementation guide for Revolut Pay on Android! This page provides a comprehensive walkthrough for integrating Revolut Pay into your Android application.
Check the following high-level procedure of implementing Revolut Pay in your Android app. Use the links to jump to the details of each step:
Before you start this tutorial, ensure that you have completed the following steps:
Since the SDK is hosted on mavenCentral
, to fetch the dependency add the following lines to your project level build.gradle
:
allprojects {
repositories {
mavenCentral()
}
}
Add the dependency to the module level build.gradle
:
implementation 'com.revolut:revolutpayments:1.0.0'
implementation 'com.revolut:revolutpay:2.3'
Sync your project
The minimum Android SDK version that is supported by the SDK is Android 5.0 (API 21).
Initialize the SDK by invoking RevolutPayments.revolutPay.init(environment: RevolutPayEnvironment, returnUri: Uri, merchantPublicKey: String, requestShipping: Boolean, customer: Customer?)
, where you will need to define:
environment
: either MAIN
or SANDBOX
. Use the Revolut Business Sandbox environment to test your Merchant account integration before you push the code changes to the production environment.
returnUri
: a URI that represents a deep link used by the Revolut app, to return to your app after the payment is confirmed or rejected. This will greatly improve the customer experience, as it will allow them to return to your app after authorizing the payment.
The deep link should be registered in manifest to allow opening an activity, if you want to support automatic redirection.
The returnUri
might be based on a custom host
-scheme
combination that can be defined within your application.
Here is an example of an activity that can handle returnUri
(note that launchMode
should be set to singleTop
, otherwise it will not be possible to return to your app):
<activity
android:name=".MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="return_uri_host"
android:scheme="return_uri_scheme" />
</intent-filter>
</activity>
merchantPublicKey
: a public key for your merchant account from Revolut console.
requestShipping
: If you want the shipping address and delivery method to be quickly collected from the user through Revolut Pay, pass the requestShipping
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.
customer
: object containing customer details the merchant already has (name, email, phone number, date of birth).
For more details about the available parameters, see: Parameters: Android.
Now you can integrate the Revolut Pay button into your layout. It can be done either by including it in your .xml
file, or by creating it via RevolutPayments.revolutPay.provideButton()
method.
Since the SDK relies on the internet connection to process your order, you need to make sure that the internet permission is added to your app. In case it isn't, add the following line to the manifest:
<queries>
<package android:name="com.revolut.revolut" />
</queries>
You can add the Revolut Pay button to your app in the following two ways:
In case you want to create a button from code, you can use the RevolutPayments.revolutPay.provideButton()
method, which has the following parameters:
context
- an instance of context used to create a view
buttonParams
- a set of parameters allowing to setup the appearance of the button
RevolutPayments.revolutPay.provideButton(
context: Context,
buttonParams: ButtonParams
): RevolutPayButton
For more details about the available parameters and button styling, see: Parameters: Android and Revolut Pay button guidelines.
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.
To create the promotional banner, you can use the RevolutPayments.revolutPay.providePromotionalBannerWidget()
method, which has the following parameters:
context
- an instance of context used to create a view
bannerParams
- a set of parameters allowing to setup the widget
themeId
- (optional) resource ID of the visual theme to be applied to the banner. If it's not provided, the default theme will be applied.
RevolutPayments.revolutPay.providePromotionalBannerWidget(
context: Context,
bannerParams: BannerParams,
themeId: Int
): RevolutPayButton
For more details about the available parameters, see: Parameters: Android
To apply a customised theme to the banner, create a resource file with the following content:
<style name="RevolutPay_RevolutPayBanner">
<item name="revolutPay_ColorAccent">#0666EB</item>
<item name="revolutPay_ColorBackground">#F7F7F7</item>
<item name="revolutPay_BannerCornerRadius">12dp</item>
<item name="revolutPay_ComponentCornerRadius">12dp</item>
<item name="revolutPay_StrokeWidth">0dp</item>
<item name="revolutPay_StrokeColor">#BBC4CD</item>
</style>
Attribute | Description | Format | Required |
---|---|---|---|
revolutPay_ColorAccent | Accent colour of the banner. Default: #0666EB | Hex colour code | No |
revolutPay_ColorBackground | Background colour of the banner. Default: #F7F7F7 | Hex colour code | No |
revolutPay_BannerCornerRadius | Corner radius of the banner's corners. Default: 12dp | Dimension | No |
revolutPay_ComponentCornerRadius | Corner radius of the banner's inner components. Default: 12dp | Dimension | No |
revolutPay_StrokeWidth | Width of the banner's border stroke. Default: 0dp | Dimension | No |
revolutPay_StrokeColor | Colour of the banner's border stroke. Default: #BBC4CD | Hex colour code | No |
After defining the resource file for your custom theme, reference it in the RevolutPayments.revolutPay.providePromotionalBannerWidget()
method:
RevolutPayments.revolutPay.providePromotionalBannerWidget(
context: Context,
params: BannerParams,
themeId: Int = R.style.RevolutPay_RevolutPayBanner
): RevolutPayButton
Check out the follow pages for further information about: