Quick Start
This section provides a step-by-step guide for creating your first purchase transaction.
Before you begin
The NearPay team is required to create a sandbox account for you using your email and phone number, as well as your Android package name to initiate this integration process.
Additionally, you must possess an Android physical device capable of supporting NFC to test the integration and run the app on it.
Start your first transaction
- Ensure that you download the
nearpay-sdk
plugin by adding this dependency to your project.
// Add it to your build.gradle
dependencies {
implementation("io.nearpay:nearpay-sdk-store:2.1.88")
}
- To create a single instance of a NearPay object with
context
, you can do so wherever you need it.
val nearPay = new NearPay.Builder()
.context(this)
.authenticationData(AuthenticationData.UserEnter)
.environment(Environments.SANDBOX)
.locale(Locale.getDefault())
.networkConfiguration(NetworkConfiguration.SIM_PREFERRED)
.uiPosition(UIPosition.CENTER_BOTTOM)
.paymentText(new PaymentText("يرجى تمرير الطاقة", "please tap your card"))
.loadingUi(true)
.build();
- 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 requestId = 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, requestId, enableUiDismiss, object : PurchaseListener{
override fun onPurchaseApproved(transactionData: TransactionData) {
TODO("Your Code Here")
}
override fun onPurchaseFailed(purchaseFailure: PurchaseFailure) {
//your code here
}
})
Your setup is complete, allowing you to test the payment feature. Follow our detailed SDK flow description for guidance after installing the application.