Transaction Flow
#
Initiate a BharatX TransactionWhen the server clicks on BharatX payment option, your server must make a call to our server to initiate transaction:
- Request
- Response
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"
#
Show BharatX UI to the user- Java
- Kotlin
- React Native
- Flutter
Your Android App
bharatxPaymentOption.setOnClickListener(new View.OnClickListener() { @Override void onClick(View view) { String transactionId = // ... from your server BharatXTransactionManager.confirmTransactionWithUser( this, amountInPaise, transactionId, new BharatXTransactionManager.TransactionStatusListener() { @Override public void onSuccess() { // transaction success! } // optional @Override public void onFailure(@NotNull BharatXTransactionManager.TransactionFailureReason reason) { // transaction cancelled by user or failed } }); }});
Your Android App
bharatxPaymentOption.setOnClickListener { val transactionId = // ... from your server BharatXTransactionManager.confirmTransactionWithUser( this, amountInPaise, transactionId, object : BharatXTransactionManager.TransactionStatusListener() { override fun onSuccess() { // transaction success! } // optional override fun onFailure(reason: BharatXTransactionManager.TransactionFailureReason) { // transaction cancelled by user or failed } })}
React Native App
import BharatXTransactionManager from '@bharatx/startup-sdk-reactnative';
BharatXTransactionManager.confirmTransactionWithUser( amountInPaise, transactionId, () => { // transaction success! }, // optional (reason) => { // transaction cancelled by user or failed });
Flutter App
import 'package:startup_sdk_flutter/startup_sdk_flutter.dart';
BharatXTransactionManager.confirmTransactionWithUser( amountInPaise, transactionId, () { // transaction success!}, (reason) { // transaction cancelled by user or failed});
#
Check Status of the Transaction#
APIWe recommend you to check transaction status only after the onSuccess
SDK callback since that will
be simpler. You can check for the status using:
- Request
- Response
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:API call after the onSuccess SDK callback (recommended way), message can be one of["SUCCESS", "CANCELLED", "FAILURE"]API call right after initiating the txn, message can be one of["SUCCESS", "CANCELLED", "FAILURE", "PENDING"]
Status = 401; message = "AUTHORIZATION_FAILED"Status = 400; message = "BAD_REQUEST"Status = 500; message = "INTERNAL_SERVER_ERROR"
#
WebhookWe also send a Webhook to let you know when a Transaction Succeeds or Fails. Your server should
respond with a status code 200
, and if it doesn't, our server will try to send the
webhook again and again with increasing time interval.
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 ["SUCCESS", "CANCELLED", "FAILURE"]}
#
Refundswarning
If amount is not passed, or if amount is passed as 0, the whole order amount would be refunded.
- Request
- Response
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"