Quick Start

This section shows you the minimum steps to develop and start experiencing your first transaction. In other words, it gives you the flow of creating your first purchase transaction.

Before you begin

NearPay team needs to create sandbox account for you using your email and phone number and your android package name to be able to start this integration. In addition, you need to have an android physical device that supports NFC to be able to test the integration and run the app on it. Start your first transaction

1. Add this dependency in your project build.gradle to download the plugin from Google:

// Some codedependencies {
    implementation "io.nearpay:nearpay-sdk-store:2.1.72"
}

2. Create single instance of NearPay object with context wherever you need:

nearPay = NearPay.Builder()
                .context(context)
                .authenticationData(AuthenticationData.Email("yourEmail"))
                .environment(environment)
                .networkConfiguration(NetworkConfiguration.SIM_PREFERRED)
                .loadingUi(true)
                .build()

3. Purchase transaction

val amount : Long = 100 // [Required] ammount you want to set .
val customerReferenceNumber = "9ace70b7-977d-4094-b7f4-4ecb17de6753" //[optional] any number you want to add as a refrence
val enableReceiptUi = true// [optional] true will enable the ui and false will disable
val enableReversal = true // it will allow you to enable or disable the reverse button
val finishTimeOut : Long = 10 // Add the number of seconds 
val transactionId = UUID.randomUUID(); // [optional] You can add your UUID here which allows you to ask about the transaction again using the same UUID
val enableUiDismiss = true // [optional] it will allow you to control dismissing the UI

nearpay.purchase(amount, customerReferenceNumber, enableReceiptUi, enableReversal, finishTimeOut, transactionId, enableUiDismiss, object : PurchaseListener{
  override fun onPurchaseApproved(transactionData: TransactionData) {
                TODO("Your Code Here")
}
    override fun onPurchaseFailed(purchaseFailure: PurchaseFailure) {
       //your code here
   }
})

Last updated