Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 2.84 KB

File metadata and controls

70 lines (49 loc) · 2.84 KB

Create A Transaction Batch

Here, createBatchTransaction() creates a POST request to /batchtransactions

Provided with a valid object representation, this endpoint allows for a new transaction batch to be created.

Usage/Examples

Create a bulk Transaction Object before performing the bulk disbursement

List<AccountIdentifier> debitPartyList = new ArrayList<>();
List<AccountIdentifier> creditPartyList = new ArrayList<>();

debitPartyList.add(new AccountIdentifier("<identifier type>", "<identifier>"));
creditPartyList.add(new AccountIdentifier("<identifier type>", "<identifier>"));

Transaction transaction = new Transaction();
transaction.setDebitParty(debitPartyList);
transaction.setCreditParty(creditPartyList);
transaction.setAmount("<amount>");
transaction.setCurrency("<currency>");

List<Transaction> transactions = new ArrayList<>();
transactions.add(transaction);

Perform the bulk transaction using the following code

MMClient mmClient = new MMClient("<Place your consumer key>", "<Place your consumer secret>", "<Place your API key>");
DisbursementRequest disbursementRequest = new DisbursementRequest();
BatchTransaction batchTransaction = new BatchTransaction();

batchTransaction.setTransactions(transactions);
disbursementRequest.setBatchTransaction(batchTransaction);

AsyncResponse sdkResponse = mmClient.addRequest(disbursementRequest).addCallBack("<Place your callback URL>").createBatchTransaction();

Additionally, if you want to use batch transaction details as JSON string, you can use the following code;

MMClient mmClient = new MMClient("<Place your consumer key>", "<Place your consumer secret>", "<Place your API key>");
DisbursementRequest disbursementRequest = new DisbursementRequest();

String batchTransactionJsonString = "{\"transactions\": [{\"amount\": \"16.00\",\"currency\": \"USD\",\"debitParty\": [{\"key\": \"msisdn\",\"value\": \"+44012345678\"}],\"creditParty\": [{\"key\": \"walletid\",\"value\": \"1\"}],\"fees\": [],\"customData\": [],\"metadata\": []}]}";

disbursementRequest.setBatchTransaction(batchTransactionJsonString);

AsyncResponse sdkResponse = mmClient.addRequest(disbursementRequest).addCallBack("<Place your callback URL>").createBatchTransaction();

Response Example

{
  "serverCorrelationId": "75825e07-271e-46e5-8d6a-d6325914abe9",
  "status": "pending",
  "notificationMethod": "callback",
  "objectReference": "1619",
  "pollLimit": 100
}

NOTE

In asynchronous flows, a callback mechanism or polling mechanism is utilised to allow the client to determine the request's final state. Use the viewRequestState() function for the polling mechanism to receive the status of a request, and the viewBatchTransaction() function to acquire the final representation of the Transaction object.