Sending OTP Code
The API endpoint for sending an OTP for STCPay payment.
Endpoint
POST /rest/pay/stcpay/sendOtp
Request Headers
Header | Required | Description |
---|---|---|
Accept | Yes | It must be set to application/JSON. |
Content-Type | Yes | It must be set to application/JSON. |
{
"Accept": "application/json",
"Content-Type": "application/json"
}
Request Body Parameters
Field Name | Field Type | Required | Description |
---|---|---|---|
stcpayMobileCountryCode | String | Yes | The country code for the STCPay mobile number. |
stcpayMobile | String | Yes | The STCPay mobile number to send the OTP to. |
orderNumber | String | Yes | The unique identifier for the transaction. It is the transactionNo generated from the Add Invoice endpoint. |
total | Number | Yes | The total amount for the transaction. |
OrderNumber Parameter
orderNumber
can be received from thetransactionNo
field of the response of Add Invoice endpoint.
An example of the request is as follows:
{
"stcpayMobileCountryCode": "966",
"stcpayMobile": "512345678",
"orderNumber": "16791237111116",
"total": 10
}
Success Response
If the OTP request is successful, the API will return a JSON-encoded response with the following parameters:
Parameter Name | Data Type | Description |
---|---|---|
stcMobile | String | The STC mobile number is associated with the transaction. |
paymentSessionId | String | The unique ID for the payment session. It will be passed to the processPayment endpoint. |
signature | String | The signature for the transaction. It will be passed to the processPayment endpoint. |
stcpayMobile | String | The STCPay mobile number the OTP was sent to. It will be passed to the processPayment endpoint. |
signedBase64Data | String | The signed base64-encoded data for the transaction. It will be passed to the processPayment endpoint. |
Here is an example success response:
{
"stcMobile": "512345678",
"paymentSessionId": "641c1fec04e8e7793c123455",
"signature": "NTkzMjU2MzFhYmIwNGY4****",
"stcpayMobile": "512345678",
"signedBase64Data": "NTk5OTI1NDc3NjQxYz****"
}
Failure Response
If the OTP request fails, the API will return a JSON-encoded response with the following parameters:
Parameter Name | Data Type | Description |
---|---|---|
timestamp | Number | The timestamp for the error. |
status | Number | The HTTP status code for the error. |
error | String | The error message. |
path | String | The API path for the request that caused the error. |
Here is an example failure response:
{
"timestamp": 1679566267336,
"status": 500,
"error": "Internal Server Error",
"path": "/rest/pay/stcpay/sendOtp"
}
Error Codes
The API may return the following HTTP status codes:
Status Code | Description |
---|---|
200 | OK. The request was successful. |
400 | Bad Request. The request parameters were invalid. |
401 | Unauthorized. The request did not include valid authentication credentials. |
404 | Not Found. The requested resource was not found. |
500 | Internal Server Error. An unexpected error occurred on the server. |
Updated 6 months ago