Payment Cancellation
- Endpoint:
/pws/payment/cancel - HTTP Method:
POST - Request Content-Type:
application/json - Response Content-Type:
application/json - Authorization: A valid AccessToken is required. (See: 2. Authentication – Obtaining AccessToken)
Description
This service allows the cancellation of a payment previously made on the Netahsilat portal.
Cancellation can only be performed for completed transactions.
The cancellation request is made using the referenceCode field.
Depending on the authorization response from the bank, the cancellation result will be successful or unsuccessful.
Header Information
| Header Name | Required | Description |
|---|---|---|
| Authorization | Yes | Valid token in Bearer {AccessToken} format. |
| Content-Type | No | application/json |
Request Body
| Field Name | Type | Required | Description |
|---|---|---|---|
| referenceCode | string | Yes | The reference code of the transaction to be canceled (e.g., NTH2P00000002250) |
| reason | string | No | Reason for cancellation (e.g., “User request”, “Duplicate transaction”) |
- Sample Request
- Successful Response
{
"referenceCode": "NTH2P00000002250",
"reason": "test cancel"
}
{
"message": "",
"statusCode": 200,
"exceptions": null,
"data": {
"lastAmount": 0.0,
"transactionStatusId": 1,
"errorCode": null,
"isSuccess": true,
"errorMessage": null
},
"oldData": null,
"errors": null
}
Fields (data)
-
lastAmount: Amount after cancellation (usually0.0for successful cancellations). -
transactionStatusId: Transaction status code (e.g.,1 = Successful/Approvedaccording to system-wide status set). -
isSuccess: Result of the cancellation (true/false). -
errorCode/errorMessage: Details if an error occurs.
Sample cURL
curl --location 'https://pgw.netahsilatdemo.com/pws/payment/cancel' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJwd3N2MS5hcGkiLCJlcnB2MS5hcGkiLCJjYXR2MS5hcGkiLCJ2ZW5kb3J2MS5hcGkiXSwiYWN0b3J0Ijoic2VydmljZSIsInJvbGUiOiJzZXJ2aWNlIiwiVW5pcXVlIjoiOGE2NjQxZGYtMGU4Ny00OWVkLWEyOTgtNjNjN2M3Y2JjNTk1IiwiVGVuYW50SWQiOiI2NzA2ODNjMS0yZmUwLTQ4NDYtODdiMi02Y2JhOWI3OTNhYjIiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL2V4cGlyYXRpb24iOiI2Mzg5NzA3MjQxNDMzMzI2OTUiLCJuYmYiOjE3NjEzMDI4MTQsImV4cCI6MTc2MTQ3NTYxNCwiaWF0IjoxNzYxMzAyODE0LCJpc3MiOiJzc28uYXBpIiwiYXVkIjoiZWNvenVtLnNzbyJ9.IbmVm9oVxUvDXhzYnCncNMYPBFqqJTXFQLkFYfhSbUA' \
--data '{
"referenceCode": "NTH2P00000002250",
"reason": "test cancel"
}'
### Notes & Best Practices {#notes-and-best-practices}
-
Cancellation can only be performed using referenceCode.
-
The operation can only be applied to completed payments.
-
Depending on bank authorization rules, cancellation may not be possible for some transactions.
-
If the same
referenceCodeis used for another cancellation call, the system may behave idempotently; the second call may return a “already canceled” response. -
Sending the
reasonfield facilitates reporting in transaction records. -
After a successful cancellation, the transaction amount is updated to 0.00 in the system.
-
The AccessToken must belong to the user or authorized merchant performing the transaction.