WaafipaydocsWaafiPay

PreAuthorization

The WaafiPay API allows for managing preauthorized transactions through a single endpoint, utilizing different values in the serviceName parameter to perform specific actions: Preauthorization, Cancellation, and Commitment of transactions.


Actions

1. PreAuthorization

  • serviceName: API_PREAUTHORIZE
  • Purpose: Reserves funds for a specific amount on a user’s account without immediately charging.
  • Request Example:Set serviceName to API_PREAUTHORIZE and customize the payerInfo and transactionInfo as required.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$guid}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "API_PREAUTHORIZE",
  "serviceParams": {
    "merchantUid": "{{MERCHANT_UID}}",
    "apiUserId": {{API_USER_ID}},
    "apiKey": "{{API_KEY}}",
    "paymentMethod": "MWALLET_ACCOUNT",
    "payerInfo": {
      "accountNo": "25261111111"
    },
    "transactionInfo": {
      "referenceId": "{{$randomBankAccount}}",
      "invoiceId": "INV99222255",
      "amount": "1",
      "currency": "USD",
      "description": "test preauth"
    }
  }
}

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
channelNameString5-20ConstantChannel of the request (e.g., "WEB")
serviceNameString15-25ConstantThe name of the service being called
merchantUidString7-15RequiredUnique merchant identifier
apiUserIdString7-15RequiredAPI user identifier for the merchant
apiKeyString20-40RequiredAPI key for request authentication
payerInfo.accountNoString10-20RequiredAccount number of the payer
paymentMethodString5-20RequiredPayment method being used (e.g., MWALLET_ACCOUNT)
transactionInfo.amountNumberN/ARequiredTransaction amount (numeric)
transactionInfo.currencyString3RequiredCurrency code (e.g., "USD")
transactionInfo.referenceIdString10-30RequiredUnique reference ID for the transaction
transactionInfo.invoiceIdString10-30OptionalInvoice identifier
transactionInfo.descriptionString5-100OptionalDescription of the transaction

Response structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 08:52:06.287",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "state": "APPROVED",
    "referenceId": "1234",
    "transactionId": "1268664",
    "txAmount": "1.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.stateString1-15State of the transaction (e.g., "APPROVED")
params.referenceIdString1-50Reference ID returned from the transaction
params.transactionIdString1-50Transaction ID returned from the transaction
params.txAmountNumberN/AAmount for the transaction (numeric)

Summary:

  • Request Parameters: Identifiers for the transaction and the user, including service details, payment method, and the amount.
  • Response Parameters: The result of the transaction, including the response code, message, and transaction state.

2. Cancellation

  • serviceName: API_PREAUTHORIZE_CANCEL
  • Purpose: Cancels a previously preauthorized transaction, releasing the reserved funds.
  • Request Example: Set serviceName to API_PREAUTHORIZE and customize the payerInfo and transactionInfo as required.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$guid}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "API_PREAUTHORIZE",
  "serviceParams": {
    "merchantUid": "{{MERCHANT_UID}}",
    "apiUserId": {{API_USER_ID}},
    "apiKey": "{{API_KEY}}",
    "paymentMethod": "MWALLET_ACCOUNT",
    "payerInfo": {
      "accountNo": "25261111111"
    },
    "transactionInfo": {
      "referenceId": "{{$randomBankAccount}}",
      "invoiceId": "INV99222255",
      "amount": "1",
      "currency": "USD",
      "description": "test preauth"
    }
  }
}

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_PREAUTHORIZE_CANCEL)
merchantUidString7-15RequiredUnique merchant identifier
apiUserIdString7-15RequiredAPI user identifier for the merchant
apiKeyString20-40RequiredAPI key for request authentication
referenceIdString1-50RequiredReference ID for the transaction
transactionIdString1-50RequiredTransaction ID
descriptionString0-255OptionalDescription of the action (e.g., "Booking order canceled")

Response

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 08:59:59.986",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "description": "success",
    "state": "approved",
    "transactionId": "1268665",
    "referenceId": "1234"
  }
}

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 Parameters: Includes details for the transaction cancelation request such as referenceId, transactionId, and description (e.g., cancelation description).
  • Response Parameters: Contains status information about the response, including the transaction state (approved), description, and transaction IDs.

3. Commit

  • serviceName: API_PREAUTHORIZE_COMMIT
  • Purpose: Finalizes a previously preauthorized transaction, confirming the reserved funds.
  • Request Example: Set serviceName to API_PREAUTHORIZE_COMMIT and include the referenceId and transactionId.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "API_PREAUTHORIZE_COMMIT",
  "serviceParams": {
    "merchantUid": {{MERCHANT_UID}},
    "apiUserId": {{API_USER_ID}},
    "apiKey": {{API_KEY}},
    "referenceId": "{{referenceId}}",
    "transactionId": "{{transactionId}}",
    "description": "PREAUTH Commited"
  }
}

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_PREAUTHORIZE_COMMIT)
merchantUidString7-15RequiredUnique merchant identifier
apiUserIdString7-15RequiredAPI user identifier for the merchant
apiKeyString20-40RequiredAPI key for request authentication
referenceIdString1-50RequiredReference ID for the transaction
transactionIdString1-50RequiredTransaction ID
descriptionString0-255OptionalDescription of the action (e.g., "PREAUTH Committed")

Response Structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 08:55:45.828",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "description": "success",
    "state": "approved",
    "transactionId": "1268664",
    "referenceId": "1234"
  }
}

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 committing the preauthorization, such as referenceId, transactionId, and a description of the action
  • Response Key Parameters: Contains the result of the commit action, including the state (approved), description, and transaction identifiers.

On this page