Transaction Flow
#
Initiate a BharatX TransactionIf the user confirms that they want to use BharatX to pay, your server must make a call to our server to initiate transaction:
POST https://sdk.bharatx.tech/merchant/credit/initiateTransaction
Headers:X-Signature: base64-encoded sha256(requestBody + privateApiKey)X-Partnerid: partnerId
Body:{ "merchantTransactionId": string, // unique "userPhoneNumber": string, "userId": string, // user identifier in perspective of you "amount": number // in paise}
Headers:-
Body:{ "message": string}
Status = 201; message = "TRANSACTION_INITIATED"Status = 400; message = "DUPLICATE_TRANSACTION_ID"Status = 401; message = "AUTHORIZATION_FAILED"Status = 400; message = "BAD_REQUEST"Status = 500; message = "INTERNAL_SERVER_ERROR"
After that, you must also send the transaction ID to our SDK through your app:
- Java
- Kotlin
- React Native
- Flutter
// optional - now would be a good time to show the progress dialogBharatXCommonUtilManager.showBharatXProgressDialog(this);
String transactionId = // from your serverCreditAccessManager.registerTransactionId(activity, transactionId, new CreditAccessManager.RegisterTransactionListener { void onRegistered() { // transaction ID registered successfully BharatXCommonUtilManager.closeBharatXProgressDialog(); }
void onFailure() { // registering this transaction failed BharatXCommonUtilManager.closeBharatXProgressDialog(); } });
// optional - now would be a good time to show the progress dialogBharatXCommonUtilManager.showBharatXProgressDialog(this)
val transactionId = // from your server; type StringCreditAccessManager.registerTransactionId(activity, transactionId, object : CreditAccessManager.RegisterTransactionListener { override fun onRegistered() { // transaction ID registered successfully BharatXCommonUtilManager.closeBharatXProgressDialog() }
override fun onFailure() { // registering this transaction failed BharatXCommonUtilManager.closeBharatXProgressDialog() } })
import BharatXCommonUtilManager from '@bharatx/bharatx-reactnative-common';
// ...
// optional - now would be a good time to show the progress dialogBharatXCommonUtilManager.showBharatXProgressDialog();
const transactionId = // from your server; type StringBharatXCommonUtilManager.registerTransactionId(transactionId, (isSuccess) => { if(isSuccess) { // transaction ID registered successfully BharatXCommonUtilManager.closeBharatXProgressDialog(); } else { // registering this transaction failed BharatXCommonUtilManager.closeBharatXProgressDialog(); }});
import 'package:bharatx_flutter_common/bharatx_flutter_common.dart';
// ...
// optional - now would be a good time to show the progress dialogBharatXCommonUtilManager.showBharatXProgressDialog();
var transactionId = // from your server; type String
final onRegistered = () async { // transaction ID registered successfully await BharatXCommonUtilManager.closeBharatXProgressDialog();};
final onFailure = () async { // transaction ID registered successfully await BharatXCommonUtilManager.closeBharatXProgressDialog();};
BharatXCommonUtilManager.registerTransactionId( transactionId, onRegistered, onFailure);
#
Check Status of a BharatX Transactionwarning
Unless you call the CreditAccessManager.registerTransactionId
method from your app, the transaction will never succeed.
If the transaction has not succeeded by 60 seconds, it will fail automatically.
After initiating the transaction, you can check for its status:
POST https://sdk.bharatx.tech/merchant/credit/checkTransactionStatus
Headers:X-Signature: base64-encoded sha256(requestBody + privateApiKey)X-Partnerid: partnerId
Body:{ "merchantTransactionId": string // unique}
Headers:-
Body:{ "message": string}
Status = 200; message can be one of ["PENDING", "SUCCESS", "FAILURE"]Status = 401; message = "AUTHORIZATION_FAILED"Status = 400; message = "BAD_REQUEST"Status = 500; message = "INTERNAL_SERVER_ERROR"
#
Webhook for Status of a BharatX TransactionPOST <Your Server Webhook URL>
Headers:X-Signature: base64-encoded sha256(requestBody + privateApiKey)Content-Type: application/json
Body:{ "merchantTransactionId": string, "status": string // can be one of ["PENDING", "SUCCESS", "FAILURE"]}
Headers:-
Body:-
Status = 200: Webhook accepted.Any other Status: Our servers will try to send the webhookagain and again with increasing time interval.
#
Refundswarning
If amount is not passed, or if amount is passed as 0, the whole order amount would be refunded.
POST https://sdk.bharatx.tech/merchant/credit/refundTransaction
Headers:X-Signature: base64-encoded sha256(requestBody + privateApiKey)X-Partnerid: partnerId
Body:{ "merchantTransactionId": string, "amount": number // in paise}
Headers:-
Body:{ "message": string}
Status = 200; message = "ok"Status = 400; message = "NO_SUCH_TRANSACTION"Status = 400; message = "REFUND_AMOUNT_TOO_LARGE"Status = 400; message = "ALREADY_REFUNDED"Status = 401; message = "AUTHORIZATION_FAILED"Status = 500; message = "INTERNAL_SERVER_ERROR"
#
DiscountsFor the functionality of discounts (one or multiple ones), the following SDK methods need to be integrated:
- Java
- Kotlin
- React Native
- Flutter
CreditAccessManager.getDiscountsApplicable(this, amountInPaise, new CreditAccessManager.OnCompleteListener<ArrayList<Discount>>() { @Override void onComplete(ArrayList<Discount> result) { // ... } });
// callback methodCreditAccessManager.getDiscountsApplicable(this, amountInPaise, object: CreditAccessManager.OnCompleteListener<ArrayList<Discount>> { override fun onComplete(result: ArrayList<Discount>) { // ... } })
// or if you are using Kotlin Coroutines/in a suspend functionval discountsList = CreditAccessManager.getDiscountsApplicable(this, amountInPaise)
This is not available in our React Native SDK yet.
This is not available in our Flutter SDK yet.
Each Discount object has the following structure:
{ "discountId": "", "amount": 0, "display": { "prefixHexTint": "#FFFFFF", // color hex - you won't need this mostly "prefix": "", "message": "" // prefix + message gives the complete message // prefix is a phrase to capture the user's attention, like FLAT 30 RS OFF }}