WaafipaydocsWaafiPay

Purchase

The WaafiPay API supports multiple payment actions through a unified endpoint. For Purchase actions, use the serviceName parameter with different values to initiate a purchase, cancel a purchase, or refund a purchase.

1. Purchase

  • serviceName: API_PURCHASE
  • Purpose: Charges the payer's account, completing the payment.
  • Request Example: Set serviceName to API_PURCHASE and customize payerInfo and transactionInfo as required.

Request Structure

POST /asm
{
    "schemaVersion": "1.0",
    "requestId": "{{$guid}}",
    "timestamp": "{{$timestamp}}",
    "channelName": "WEB",
    "serviceName": "API_PURCHASE",
    "serviceParams": {
        "merchantUid": {{MERCHANT_UID}},
        "apiUserId": {{API_USER_ID}},
        "apiKey": {{API_KEY}},
        "paymentMethod": "MWALLET_ACCOUNT",
        "payerInfo": {
            "accountNo": "252611111111"
        },
        "transactionInfo": {
            "referenceId": "{{$randomBankAccount}}",
            "invoiceId": "154",
            "amount": "10",
            "currency": "USD",
            "description": "{{$randomLoremSentence}}"
        }
    }
}

Request Parameters

ParameterData TypeLengthPresenceDescription
schemaVersionString5ConstantAPI schema version (e.g., "1.0")
requestIdString36 (UUID)RequiredUnique request identifier (e.g., UUID)
timestampString20RequiredDate and time of the request
channelNameString3-10ConstantThe channel through which the request was made
serviceNameString15-25ConstantThe name of the service being called (e.g., API_PURCHASE)
merchantUidString7-15RequiredUnique identifier provided by WaafiPay upon merchant account setup
apiUserIdString7-15RequiredAPI user identifier for the merchant
apiKeyString20-40RequiredAPI key for request authentication
paymentMethodString5-20RequiredPayment method being used (e.g., MWALLET_ACCOUNT)
payerInfo.accountNoString10-20RequiredAccount number of the payer
transactionInfo.referenceIdString1-50RequiredYour unique internal transaction or order reference (e.g. order number, invoice ID, or bill number). Used for querying and reconciliation. Only letters, numbers, dashes, underscores, and dots are allowed.
transactionInfo.invoiceIdString1-50RequiredInvoice ID can be the same as the referenceId
transactionInfo.amountNumberN/ARequiredTransaction Amount to be charged for the customer (numeric) in two decimal places
transactionInfo.currencyString3RequiredISO 4217 currency code for the transaction (e.g. USD, SLSH, DJF)
transactionInfo.descriptionString0-255OptionalDescription of the transaction (e.g., random sentence)

Response Structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 09:04:44.741",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "accountNo": "252611****1111",
    "accountType": "MWALLET_ACCOUNT",
    "state": "APPROVED",
    "merchantCharges": "0.1",
    "referenceId": "1234",
    "transactionId": "1268666",
    "issuerTransactionId": "ISR0011268666",
    "txAmount": "10.0"
  }
}

2.Purchase Reversal

  • serviceName: API_CANCELPURCHASE
  • Purpose: Reverses the payment for a previously completed purchase.
  • Request Example: Set serviceName to API_CANCELPURCHASE and include the transactionId of the original transaction.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$guid}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "API_CANCELPURCHASE",
  "serviceParams": {
    "merchantUid": {{MERCHANT_UID}},
    "apiUserId": {{API_USER_ID}},
    "apiKey": {{API_KEY}},
    "transactionId": "{{transactionId}}",
    "description": "Cancelled"
  }
}

Response Structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 09:07:48.786",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "description": "success",
    "state": "approved",
    "transactionId": "1268667",
    "referenceId": "1234"
  }
}

Summary:

  • Response: Contains the result of the cancellation, including transaction status (approved), description, and the associated transaction ID.

On this page