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": "25261111111"
        },
        "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 merchant identifier
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-50RequiredReference ID for the transaction
transactionInfo.invoiceIdString1-50RequiredInvoice ID
transactionInfo.amountNumberN/ARequiredTransaction amount (numeric)
transactionInfo.currencyString3RequiredCurrency code (e.g., "USD")
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"
  }
}

Response Parameters

ParameterData TypeLengthDescription
schemaVersionString5API schema version (e.g., "1.0")
timestampString20Date and time of the response
responseIdString1-50Unique response identifier
responseCodeString1-10Response code indicating the result of the request
errorCodeString1-5Error code (e.g., "0" for no error)
responseMsgString0-255Human-readable message for the response
params.accountNoString10-20Account number of the payer
params.accountTypeString5-20Type of the account (e.g., "MWALLET_ACCOUNT")
params.stateString1-15State of the transaction (e.g., "APPROVED")
params.merchantChargesNumberN/AMerchant charges (numeric)
params.referenceIdString1-50Reference ID for the transaction
params.transactionIdString1-50Transaction ID returned from the transaction
params.issuerTransactionIdString1-50Issuer transaction ID
params.txAmountNumberN/AAmount for the transaction (numeric)

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 and referenceId of the original transaction.

Request Structure

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

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_CANCELPURCHASE)
merchantUidString7-15RequiredUnique merchant identifier
apiUserIdString7-15RequiredAPI user identifier for the merchant
apiKeyString20-40RequiredAPI key for request authentication
paymentMethodString5-20RequiredPayment method being used (e.g., MWALLET_ACCOUNT)
transactionIdString1-50RequiredOriginal Transaction ID from previous purchase
referenceIdString1-50OptionalReference ID for the transaction
descriptionString0-255OptionalDescription of the action (e.g., "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"
  }
}

Purchase Reversal Response Parameters


ParameterData TypeLengthDescription
schemaVersionString5API schema version (e.g., "1.0")
timestampString20Date and time of the response
responseIdString1-50Unique response identifier
responseCodeString1-10Response code indicating the result of the request
errorCodeString1-5Error code (e.g., "0" for no error)
responseMsgString0-255Human-readable message for the response
params.descriptionString0-255Description of the response (e.g., "success")
params.stateString1-15State of the transaction (e.g., "approved")
params.transactionIdString1-50Transaction ID returned from the transaction
params.referenceIdString1-50Reference ID returned from the transaction

Summary:

  • Request Key Parameters: Includes details for canceling the purchase, such as transactionId, referenceId, and the cancellation description (e.g., "Cancelled").
  • Response Key Parameters: Contains the result of the cancellation, including transaction status (approved), description, and the associated transaction IDs.

On this page