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:
Your Server - Request
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}
BharatX Server - Response
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
Your Android App
// 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(); } });
Your Android App
// 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() } })
React Native App
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(); }});
Flutter App
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:
Your Server - Request
POST https://sdk.bharatx.tech/merchant/credit/checkTransactionStatus
Headers:X-Signature: base64-encoded sha256(requestBody + privateApiKey)X-Partnerid: partnerId
Body:{ "merchantTransactionId": string // unique}
BharatX Server - Response
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 TransactionBharatX Server - Request
POST <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"]}
Your Server - Response
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.
Your Server - Request
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}
BharatX Server - Response
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"