The meCash Docs is live ๐ŸŽ‰ ๐ŸŽ‰
Transactions
Get All Transactions

Transactions API Guide

The *Transactions API allows users to retrieve a paginated list of transactions based on their status using the GET method. This API supports filtering transactions using the state parameter and provides details about each transaction, including the recipient, quote, and processing timestamps.


How It Works

  1. The user sends a GET request to the transactions endpoint, optionally filtering by state (e.g., COMPLETED, PENDING, FAILED, REFUNDED).
  2. The API returns a paginated list of transactions, including metadata such as totalPages, size, and page.
  3. Each transaction includes details such as the recipient, payment channel, quote details, and processing timestamps.

Request Method & Endpoint

Endpoint:

GET https://{{baseURL}}/v1/transaction?state=COMPLETED&page=0&size=1

Query Parameters

ParameterTypeDescriptionRequired
stateStringFilter by transaction state (COMPLETED, PENDING, FAILED, REFUNDED)โœ… Yes
pageIntegerPage number (starting from 0)โœ… Yes
sizeIntegerNumber of transactions per pageโœ… Yes

Headers

HeaderValueRequired
Content-Typeapplication/jsonโœ… Yes
x-api-keyYOUR_API_KEY:<your-api-key>โœ… Yes

cURL Request Example

curl --location --request GET 'https://{{baseURL}}/v1/transaction?state=COMPLETED&page=0&size=1' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY

Success Response (200 OK)

If the request is successful, the API returns the following JSON response:

response.json
{
    "message": "transactions fetched successfully",
    "page": 0,
    "size": 1,
    "totalPages": 1,
    "status": "success",
    "data": [
        {
            "id": "c18d83fe-cb89-470b-81c9-a563ac80f31b",
            "remark": "",
            "reason": "Gift",
            "referenceNumber": "TFDZQ3LOEGWXA",
            "type": "SEND",
            "state": "COMPLETED",
            "quote": {
                "id": "dafc0c85-576e-4dc1-a456-3f7db90b9a1c",
                "source": {
                    "currency": "NGN",
                    "country": "NG",
                    "amount": 18000.00
                },
                "target": {
                    "currency": "CNY",
                    "country": "CN",
                    "amount": 71.13
                },
                "rate": 253.05,
                "fee": {
                    "amount": 2060.00
                }
            },
            "recipient": {
                "name": "Zen Lui",
                "firstName": "Zen",
                "lastName": "Lui",
                "relationship": "SELF",
                "type": "MOBILE",
                "account": {
                    "sortCode": "",
                    "accountNumber": "8612343562723",
                    "branchCode": "",
                    "mobileProvider": ""
                },
                "paymentChannel": "ALI_PAY",
                "currency": "CNY",
                "country": "CN"
            },
            "created": "2025-02-27T14:11:09.720913",
            "processed": "2025-02-27T14:15:55.819866"
        }
    ]
}

Response Breakdown

General Information

FieldTypeDescription
messageStringResponse message
pageIntegerCurrent page number
sizeIntegerNumber of transactions per page
totalPagesIntegerTotal number of pages available
statusStringStatus of the response (success or error)

Transaction Details

FieldTypeDescription
idStringUnique transaction ID
remarkStringAdditional transaction remarks
reasonStringReason for the transaction (e.g., Gift)
referenceNumberStringUnique reference number for tracking
typeStringTransaction type (e.g., SEND)
stateStringTransaction status (COMPLETED, PENDING, etc.)
createdString (ISO 8601)Timestamp when the transaction was created
processedString (ISO 8601)Timestamp when the transaction was processed

Quote Details

FieldTypeDescription
quote.idStringUnique identifier for the quote
quote.source.currencyStringSource currency (e.g., NGN)
quote.source.countryStringSource country (e.g., NG)
quote.source.amountFloatAmount sent in source currency
quote.target.currencyStringTarget currency (e.g., CNY)
quote.target.countryStringTarget country (e.g., CN)
quote.target.amountFloatAmount received in target currency
quote.rateFloatExchange rate applied
quote.fee.amountFloatTransaction fee applied

Recipient Details

FieldTypeDescription
recipient.nameStringFull name of the recipient
recipient.firstNameStringFirst name of the recipient
recipient.lastNameStringLast name of the recipient
recipient.relationshipStringRelationship to the sender (e.g., SELF)
recipient.typeStringPayment type (e.g., MOBILE)
recipient.account.accountNumberStringAccount or mobile number
recipient.paymentChannelStringPayment method (e.g., ALI_PAY)
recipient.currencyStringRecipient's currency
recipient.countryStringRecipient's country

Payout States

The transaction can have one of the following states:

StateDescription
COMPLETEDThe transaction was successfully processed.
PENDINGThe transaction is still being processed.
REFUNDEDThe transaction has been refunded.
FAILEDThe transaction failed to process.

Error Handling

Status CodeMeaningExample Response
400Bad Request{ "message": "Invalid parameters" }
401Unauthorized{ "message": "Invalid API key" }
422Unprocessable Entity{ "message": "Invalid query parameters" }
500Internal Server Error{ "message": "An internal error occurred" }

Key Takeaways

  • This API retrieves a paginated list of transactions based on their state.
  • Transactions include recipient details, quote information, and timestamps.
  • The state filter helps users get transactions in specific processing stages.

Best Practices

  • โœ… Include a valid API key (x-api-key) in the request headers for authentication.
  • โœ… Use pagination (page & size) to manage large transaction data efficiently.
  • โœ… Filter transactions by state to retrieve relevant records.
  • โœ… Ensure correct handling of timestamps (created & processed).