Skip to content
Last updated

Initial Setup

Overview

The Ryft Android Drop-In SDK lets you integrate card (and optionally Google Pay) payments into your Android application with minimal effort.

In the next sections on this page, you will learn how to set up a basic payment form using the Ryft Android Drop-In SDK.

Requirements

Before you begin, ensure that you have the following prerequisites in place:

  • minSdkVersion set to at least 21 in your build.gradle file.
  • compileSdkVersion set to at least 28 in your build.gradle file (required for Google Pay support).

Installation

The Ryft Android Drop-In SDK is distributed via Maven Central.

To install the Ryft Android SDK, you can follow these steps:

  1. Add Maven Central to your project's repositories (if not already added):

    Add Maven Central Repository
    allprojects {
        repositories {
            // ...
            mavenCentral()
            // ...
        }
    }

    Please note that if you are using Gradle version 7.0 or higher, Maven Central is included by default.

  2. Add the Ryft Android SDK dependency to your app-level build.gradle file:

    Add Ryft Android SDK Dependency - Groovy
    dependencies {
        implementation "com.ryftpay:ryft-android:$latest_version"
    }

    For the latest version of the Ryft Android SDK, please refer to the GitHub releases page and use the associated tag.

Initialisation

The drop-in component provides you with all the necessary functions to collect and process payments from your customers. It will also handle formatting and validation of card details.

The drop-in must be initialised within the onCreate method of your activity or fragment to ensure it is set up correctly before being used.

When initialising the drop-in, you should provide:

  • The activity or fragment that handles your checkout process.
  • A class for handling the result, e.g., the activity or fragment itself.

Here's an example of how to initialise the Ryft Android Drop-In SDK in your activity:

Initialise Ryft Android Drop-In SDK - Kotlin (Fragment)
class CheckoutFragment : Fragment(), RyftDropInResultListener {

    private lateinit var ryftDropIn: RyftDropIn
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ryftDropIn = DefaultRyftDropIn(
            fragment = this,
            listener = this
        )
    }
    
    override fun onPaymentResult(result: RyftPaymentResult) {
        // TODO see next section
    }
}

Next Steps

Now that you have initialised the Ryft Android Drop-In SDK, you can proceed to display the payment UI to your users.

For more information on how to do this, please refer to the Showing the Drop-in UI section.