Processing Payment

This endpoint allows merchants to validate the OTP and process a payment from a customer's STCPay account.

Endpoint

POST /rest/pay/stcpay/processPayment

Request Headers

HeaderRequiredDescription
AcceptYesIt must be set to application/JSON.
Content-TypeYesIt must be set to application/JSON.
{
  "Accept": "application/json",
  "Content-Type": "application/json"
}

Request Body Parameters

ParameterTypeDescription
stcpayMobileCountryCodeStringThe country code of the customer's mobile number.
stcpayMobileStringThe STCPay mobile number of the customer.
orderNumberStringA unique identifier for the order.
totalDoubleThe total amount to be charged to the customer's STCPay account.
stcpayPaymentOTPStringThe received OTP code to the customer to process the payment.
paymentSessionIdStringThe payment session ID is generated in the sendOtp endpoint.
signatureStringThe signature is generated in the previous step.
signedBase64DataStringThe signed data was generated in the previous step .

An example of the request is as follows:

{
  "stcpayMobileCountryCode": "966",
  "stcpayMobile": "512345678",
  "orderNumber": "16791237111116",
  "total": 10,
  "stcpayPaymentOTP": "12345",
  "paymentSessionId": "641c1fec04e8e7793c123455",
  "signature": "NTkzMjU2MzFhYmIwNGY4****",
  "signedBase64Data": "NTk5OTI1NDc3NjQxYz****"
}

Successful Response

If the request is successful, the API will return an HTTP status code of 200 along with the following response:

ParameterTypeDescription
orderNumberStringThe unique identifier for the order.
orderAmountDoubleThe amount charged to the customer's STCPay account.
msgStringA message indicating the status of the payment.

Example of a successful response:

{
  "orderNumber": "16791237111116",
  "orderAmount": 10.0,
  "msg": "Payment of order 1679564751896 has been processed."
}

Failure Response

If the request fails, the API will return an HTTP status code other than 200, along with the following response:

FieldTypeDescription
timestampLongThe timestamp of the error.
statusIntegerThe API returns the HTTP status code.
errorStringAn explanation of the error that occurred.
pathStringThe path of the API that was called.

Here is an example failure response:

{
  "timestamp": 1679566267336,
  "status": 500,
  "error": "Internal Server Error",
  "path": "/rest/pay/stcpay/sendOtp"
}