WaafipaydocsWaafiPay

Hosted Payment Page

WaafiPay provides a Hosted Payment Page (HPP) for handling purchases, refunds, and transaction inquiries through a secure, web-based interface. Use the serviceName parameter to specify the action for each transaction.

1. Initiate Purchase

  • serviceName: HPP_PURCHASE
  • Purpose: Redirects customers to a secure HPP to complete their transaction.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "HPP_PURCHASE",
    "serviceParams": {
    "merchantUid": "{{MERCHANT_UID}}",
    "storeId": {{STORE_ID}},
	  "hppKey": "{{HPP_KEY}}",
    "paymentMethod": "CREDIT_CARD",
    "hppSuccessCallbackUrl": "http://localhost:3000/api/hpp/success",
    "hppFailureCallbackUrl": "http://localhost:3000/api/hpp/failure",
    "hppRespDataFormat": 4,
    "transactionInfo": {
      "referenceId": "WS_{{$randomBankAccount}}",
      "invoiceId": "WS_{{$randomBankAccount}}",
      "amount": 10,
      "currency": "EUR",
      "description": "payment"
    }
  }
}

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., HPP_PURCHASE)
merchantUidString7-15RequiredUnique merchant identifier
storeIdNumberN/ARequiredThe store ID where the purchase is made
hppKeyString20-40RequiredHPP key for secure purchase initiation
paymentMethodString5-20RequiredPayment method being used (e.g., CREDIT_CARD)
hppSuccessCallbackUrlString0-255RequiredURL for success callback from the HPP system
hppFailureCallbackUrlString0-255RequiredURL for failure callback from the HPP system
hppRespDataFormatNumber1-3RequiredResponse data format for the HPP system
transactionInfo.referenceIdString1-50RequiredReference ID for the transaction
transactionInfo.invoiceIdString1-50RequiredInvoice ID for the transaction
transactionInfo.amountNumberN/ARequiredTransaction amount (numeric)
transactionInfo.currencyString3RequiredCurrency code (e.g., "EUR")
transactionInfo.descriptionString0-255OptionalDescription of the transaction (e.g., "payment")

Response Structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 09:19:10.131",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "hppUrl": "https://sandbox.waafipay.net/hpp/token/4542676573566A5261366B6A485049715056534A45773D3D",
    "directPaymentLink": "https://sandbox.waafipay.net/hpp/token/4542676573566A5261366B6A485049715056534A45773D3D?r=10629",
    "orderId": "1185941",
    "hppRequestId": "10629",
    "referenceId": "WS_123"
  }
}

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.hppUrlString0-255URL for the HPP page (to process the payment)
params.directPaymentLinkString0-255Direct link for processing the payment
params.orderIdString1-50Order ID for the transaction
params.hppRequestIdString1-50HPP request ID
params.referenceIdString1-50Reference ID for the transaction

Summary:

  • Request Key Parameters: Includes details for initiating an HPP purchase, such as paymentMethod, hppSuccessCallbackUrl, transactionInfo.referenceId, and transactionInfo.amount.
  • Response Key Parameters: Contains the result of the purchase request, including the URLs for the HPP page (hppUrl, directPaymentLink), the order details (orderId, hppRequestId), and the referenceId of the transaction.

2. Refund Purchase

  • serviceName: HPP_REFUNDPURCHASE
  • Purpose: Processes a refund for a previously completed transaction.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "HPP_REFUNDPURCHASE",
  "serviceParams": {
    "merchantUid": "{{MERCHANT_UID}}",
    "storeId": {{STORE_ID}},
    "hppKey": "{{HPP_KEY}}",
    "amount": "10",
    "transactionId": 1255515,
    "description": "Hpp refund"
  }
}

Refund 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., HPP_REFUNDPURCHASE)
merchantUidString7-15RequiredUnique merchant identifier
storeIdString7-15RequiredStore ID associated with the refund
hppKeyString20-40RequiredHPP key for secure refund initiation
amountNumberN/ARequiredRefund amount (numeric)
transactionIdNumberN/ARequiredTransaction ID being refunded
descriptionString0-255OptionalDescription of the refund request (e.g., "Hpp refund")

Refund Response Structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 09:24:48.347",
  "responseId": "12314",
  "responseCode": "5202",
  "errorCode": "E10207",
  "responseMsg": "RCS_TRAN_ALREADY_CANCELLED",
  "params": {}
}

Refund 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., "E10207" for an error)
responseMsgString0-255Human-readable message for the response
paramsObjectN/AEmpty object, as there is no further data in this response

Summary:

  • Request Key Parameters: Includes details for initiating an HPP refund, such as amount, transactionId, and a description (e.g., "Hpp refund").
  • Response Key Parameters: Contains the result of the refund request, including an error code (E10207), message (RCS_TRAN_ALREADY_CANCELLED), and an empty params object indicating no additional data.

3. Retrieve Transaction Information

  • serviceName: HPP_GETTRANINFO
  • Purpose: Fetches transaction details for a specific transaction.

Request Structure

{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "HPP_GETTRANINFO",
  "serviceParams": {
      "merchantUid": {{MERCHANT_UID}},
      "storeId": {{STORE_ID}},
      "hppKey": {{HPP_KEY}},
      "referenceId": "WS:6671753970"
  }
}

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., HPP_GETTRANINFO)
merchantUidString7-15RequiredUnique merchant identifier
storeIdString7-15RequiredStore ID associated with the transaction
hppKeyString20-40RequiredHPP key for secure transaction information fetch
referenceIdString1-50RequiredReference ID for the transaction

Response Structure

POST /asm
{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 12:19:05.05",
  "responseId": "123114",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "tranStatusDesc": "Approved",
    "amount": "2.0",
    "payerId": "252700000000",
    "paymentMethod": "mwallet_account",
    "description": "payment",
    "tranDate": "2024-11-05 10:58:50.0",
    "currency": "USD",
    "invoiceId": "16F7F28E21EC",
    "tranAmount": "2.0",
    "transactionId": "126895",
    "tranStatusId": "3",
    "status": "Approved"
  }
}

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.tranStatusDescString0-255Description of the transaction status (e.g., "Approved")
params.amountNumberN/AAmount of the transaction
params.payerIdString1-50Payer's unique identifier
params.paymentMethodString1-50Payment method used (e.g., "mwallet_account")
params.descriptionString0-255Description of the transaction (e.g., "payment")
params.tranDateString20Date and time of the transaction
params.currencyString3Currency code (e.g., "USD")
params.invoiceIdString1-50Invoice ID for the transaction
params.tranAmountNumberN/AAmount of the transaction
params.transactionIdString1-50Transaction ID
params.tranStatusIdString1-10Status ID of the transaction
params.statusString0-255Status of the transaction (e.g., "Approved")

Summary:

  • Request Key Parameters: Includes details for fetching transaction information, such as referenceId, merchantUid, and hppKey.
  • Response Key Parameters: Contains detailed transaction information, including tranStatusDesc (e.g., "Approved"), payerId, amount, transactionId, and other transaction-specific details such as currency, status, and invoiceId.