Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 2.89 KB

File metadata and controls

75 lines (55 loc) · 2.89 KB

Create a Transaction

Here, createMerchantTransaction() creates a POST request to /transactions/type/merchantpay

Provided with a valid object representation, this endpoint allows for a new transaction to be created for a given transaction type passed via the URL.

Usage/Examples

A transaction object is to be created before calling the merchant transaction. The example for transaction object as follows,

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>");

Initiate the merchant pay request using the following code

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

recurringPaymentRequest.setTransaction(transactionObject);
AsyncResponse sdkResponse = mmClient.addRequest(recurringPaymentRequest).createMerchantTransaction();

Additionally, if you want to use 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>");
RecurringPaymentRequest recurringPaymentRequest = new RecurringPaymentRequest();

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

recurringPaymentRequest.setTransaction(transactionObjectString);

AsyncResponse sdkResponse = mmClient.addRequest(recurringPaymentRequest).createMerchantTransaction();

Callback Response Example

{ 
  "serverCorrelationId":"06f8ae9f-e6bc-4f54-99a3-7d7df22a6477",
  "status":"pending",
  "notificationMethod":"callback",
  "objectReference":"19081",
  "pollLimit":100
}

Polling Response Example

{
  "serverCorrelationId": "18c55e1a-9619-46c2-a442-740344832d72",
  "status": "pending",
  "notificationMethod": "polling",
  "objectReference": "19105",
  "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 viewTransaction() function to acquire the final representation of the Transaction object.