FasterPay Android SDK

FasterPay Android SDK enables you to integrate the FasterPay’s Checkout Page seamlessly without having the hassle of integrating everything from Scratch. Once your customer is ready to pay, FasterPay will take care of the payment, notify your system about the payment and return the customer back to your Thank You page.


Setting Up your SDK

FasterPay’s Android SDK can be integrated into your existing Android application using the following ways

Download the Compiled Library

  • Download sdk as compiled “.aar” file here
  • Open your project > File > New > New Module
  • Click Import .JAR/.AAR Package then click Next
  • Enter the location of the compiled AAR or JAR file then click Finish

Using Souce code from Github

  • Download the source code :
$ git clone https://github.com/FasterPay/fasterpay-android.git
  • Click File > New > Import Module
  • Enter the location of the library module directory the click Finish

Include the SDK in your code.

  • Include FasterPay Android SDK in your app module’s build.grade file
include ':app', ':fpsdk'
  • Add Andorid SDK dependencies in build.gradle dependencies
dependencies {
    implementation project(":fpsdk")
}

Initiating Payment Request

The following code sample demonstrates initiating a Payment request to FasterPay.

class MainActivity : AppCompatActivity() {

    val fasterPay: FasterPay by lazy {
        FasterPay("<your public key>")
    }

    private fun requestPayment() {
        val form = gateWay.form()
            .amount("0.5")
            .currency("USD")
            .description("Golden Ticket")
            .merchantOrderId(UUID.randomUUID().toString())
            .successUrl("<your definition url>")

        startActivity(gateWay.prepareCheckout(this, form))
    }
}

Defining your success_url

To define success_url in your android application, FasterPay SDK uses the below format.

scheme:host[?queryParameter]

For Example: “com.application.sample://your.app?successId=3122eb”

scheme: with application id
host: define your customize host


Redirecting to your Activity after Payment Completion

To catch the successUrl please open AndroidManifest.xml and add following snippet to your activity

<activity
      android:launchMode="singleInstance">
  ...
  <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="<host in your definition url>"
          android:scheme="<scheme in your definition url>"/>
  </intent-filter>
</activity>

Handle the successUrl inside onNewIntent() method

class MainActivity : AppCompatActivity() {
    ...
    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        val uri = intent?.data
        val successId = uri?.getQueryParameter("successId")
        //handle with successId
    }
}

Initiating SDK in Test Mode.

FasterPay has a Sandbox environment called Test Mode. Test Mode is a virtual testing environment which is an exact replica of the live FasterPay environment. This allows businesses to integrate and test the payment flow without being in the live environment. Businesses can create a FasterPay account, turn on the Test Mode and begin to integrate the widget using the test integration keys.

val fasterPay: FasterPay by lazy {
    FasterPay("<your public key>", true)
}

Read more about Test Mode