Guides • Accept Payments
Implement Revolut Pay on Android
doc

Accept payments via Revolut Pay - Android

Welcome to the implementation guide for Revolut Pay on Android! This page provides a comprehensive walkthrough for integrating Revolut Pay into your Android application.

Overview

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:

  1. Install Android SDK
  2. Configure Android SDK
  3. Create Revolut Pay button
  4. Create Revolut Pay promotional banner

Implement Revolut Pay on Android

0. Before you start

Before you start this tutorial, ensure that you have completed the following steps:

1. Install Android SDK

  1. Since the SDK is hosted on mavenCentral, to fetch the dependency add the following lines to your project level build.gradle:

    allprojects {
    repositories {
    mavenCentral()
    }
    }
  2. Add the dependency to the module level build.gradle:

    implementation 'com.revolut:revolutpayments:1.0.0'
    implementation 'com.revolut:revolutpay:2.3'
  3. Sync your project

note

The minimum Android SDK version that is supported by the SDK is Android 5.0 (API 21).

2. Configure Android SDK

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.

    note

    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.

    caution

    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.

note

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>

3. Create Revolut Pay button

You can add the Revolut Pay button to your app in the following two ways:

Via adding button from kotlin/java code

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.

(Optional) 4. Add the Revolut Pay promotional banner widget

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

Create a custom theme for the banner

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>
AttributeDescriptionFormatRequired
revolutPay_ColorAccentAccent colour of the banner. Default: #0666EBHex colour codeNo
revolutPay_ColorBackgroundBackground colour of the banner. Default: #F7F7F7Hex colour codeNo
revolutPay_BannerCornerRadiusCorner radius of the banner's corners. Default: 12dpDimensionNo
revolutPay_ComponentCornerRadiusCorner radius of the banner's inner components. Default: 12dpDimensionNo
revolutPay_StrokeWidthWidth of the banner's border stroke. Default: 0dpDimensionNo
revolutPay_StrokeColorColour of the banner's border stroke. Default: #BBC4CDHex colour codeNo

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

What's next

Check out the follow pages for further information about:

Was this page helpful?