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
// Some codedependencies {
implementation "io.nearpay:nearpay-sdk-store:2.1.72"
}flutter pub add nearpay_flutter_sdk --git-url=https://github.com/nearpayio/nearpay-flutter-sdk.git --git-ref=google
// after installing the plugin , please import the package
import 'package:nearpay_flutter_sdk/nearpay.dart';npm install "https://github.com/nearpayio/nearpay-react-native-sdk.git#google" --save
// after installing the plugin , please import the package
import { EmbededNearpay } from '@nearpaydev/react-native-nearpay-sdk';nearPay = NearPay.Builder()
.context(context)
.authenticationData(AuthenticationData.Email("yourEmail"))
.environment(environment)
.networkConfiguration(NetworkConfiguration.SIM_PREFERRED)
.loadingUi(true)
.build()nearPay = new NearPay.Builder()
.context(this)
.authenticationData(new AuthenticationData.Email("yourEmail"))
.environment(Environments.SANDBOX)
.locale(Locale.getDefault())
.networkConfiguration(NetworkConfiguration.SIM_PREFERRED)
.uiPosition(UIPosition.CENTER_BOTTOM)
.paymentText(new PaymentText("يرجى تمرير الطاقة", "please tap your card"))
.loadingUi(true)
.build();//Initialize SDK
var reqData = {
"authtype" : AuthenticationType.email.values, //Same as above reference
"authvalue" : "[email protected]", // Give auth type value
"locale" : Locale.localeDefault.value, // [optional] locale reference
"environment" : Environments.sandbox.value // [Required] environment reference
};
var jsonResponse = await Nearpay.initialize(reqData);
var jsonData = json.decode(jsonResponse);
var status = jsonData['status'];
if(status == 200){
// Initialize Success with 200
}else if(status == 204){
// Initialize Failed with 204, Plugin iniyialize failed with null
}else if(status == 400){
// Missing parameter Failed with 400, Authentication paramer missing Auth Type and Auth Value
// Auth type and Auth value missing
}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
}
})// Some code// Some code// Some codeLast updated