curl --request POST \
--url https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment \
--header 'Abp-TenantId: <abp-tenantid>' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json-patch+json' \
--header 'cap-signature: <cap-signature>' \
--data '
{
"transactionNumber": "<string>",
"reason": "Purchase wrong item",
"timestamp": 1621851652617,
"amount": 123
}
'import requests
url = "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment"
payload = {
"transactionNumber": "<string>",
"reason": "Purchase wrong item",
"timestamp": 1621851652617,
"amount": 123
}
headers = {
"Abp-TenantId": "<abp-tenantid>",
"Authorization": "<authorization>",
"cap-signature": "<cap-signature>",
"Content-Type": "application/json-patch+json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Abp-TenantId': '<abp-tenantid>',
Authorization: '<authorization>',
'cap-signature': '<cap-signature>',
'Content-Type': 'application/json-patch+json'
},
body: JSON.stringify({
transactionNumber: '<string>',
reason: 'Purchase wrong item',
timestamp: 1621851652617,
amount: 123
})
};
fetch('https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'transactionNumber' => '<string>',
'reason' => 'Purchase wrong item',
'timestamp' => 1621851652617,
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Abp-TenantId: <abp-tenantid>",
"Authorization: <authorization>",
"Content-Type: application/json-patch+json",
"cap-signature: <cap-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment"
payload := strings.NewReader("{\n \"transactionNumber\": \"<string>\",\n \"reason\": \"Purchase wrong item\",\n \"timestamp\": 1621851652617,\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Abp-TenantId", "<abp-tenantid>")
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("cap-signature", "<cap-signature>")
req.Header.Add("Content-Type", "application/json-patch+json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment")
.header("Abp-TenantId", "<abp-tenantid>")
.header("Authorization", "<authorization>")
.header("cap-signature", "<cap-signature>")
.header("Content-Type", "application/json-patch+json")
.body("{\n \"transactionNumber\": \"<string>\",\n \"reason\": \"Purchase wrong item\",\n \"timestamp\": 1621851652617,\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Abp-TenantId"] = '<abp-tenantid>'
request["Authorization"] = '<authorization>'
request["cap-signature"] = '<cap-signature>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n \"transactionNumber\": \"<string>\",\n \"reason\": \"Purchase wrong item\",\n \"timestamp\": 1621851652617,\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"tenantId": 123,
"transactionNumber": "<string>",
"refundTransactionNumber": "<string>",
"referenceCode": "<string>",
"amount": 100,
"currencyCode": "MYR",
"refundStatus": 11,
"responseMessage": "<string>",
"paymentSessionNumber": "<string>",
"refundPaymentList": {
"transactionNumber": "<string>",
"amount": 100,
"currencyCode": "MYR",
"refundReason": "<string>",
"refundStatus": 11
}
}Refund Payment
The payment gateway requests a refund payment
Initiate a full or partial refund for a successful payment transaction. See Refund Integration for full vs. partial refund behavior and bank support. The response’s refundStatus reflects the outcome directly — if it comes back as ProcessingRefund, use Query Refund Payment to check when it completes.
curl --request POST \
--url https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment \
--header 'Abp-TenantId: <abp-tenantid>' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json-patch+json' \
--header 'cap-signature: <cap-signature>' \
--data '
{
"transactionNumber": "<string>",
"reason": "Purchase wrong item",
"timestamp": 1621851652617,
"amount": 123
}
'import requests
url = "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment"
payload = {
"transactionNumber": "<string>",
"reason": "Purchase wrong item",
"timestamp": 1621851652617,
"amount": 123
}
headers = {
"Abp-TenantId": "<abp-tenantid>",
"Authorization": "<authorization>",
"cap-signature": "<cap-signature>",
"Content-Type": "application/json-patch+json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Abp-TenantId': '<abp-tenantid>',
Authorization: '<authorization>',
'cap-signature': '<cap-signature>',
'Content-Type': 'application/json-patch+json'
},
body: JSON.stringify({
transactionNumber: '<string>',
reason: 'Purchase wrong item',
timestamp: 1621851652617,
amount: 123
})
};
fetch('https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'transactionNumber' => '<string>',
'reason' => 'Purchase wrong item',
'timestamp' => 1621851652617,
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Abp-TenantId: <abp-tenantid>",
"Authorization: <authorization>",
"Content-Type: application/json-patch+json",
"cap-signature: <cap-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment"
payload := strings.NewReader("{\n \"transactionNumber\": \"<string>\",\n \"reason\": \"Purchase wrong item\",\n \"timestamp\": 1621851652617,\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Abp-TenantId", "<abp-tenantid>")
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("cap-signature", "<cap-signature>")
req.Header.Add("Content-Type", "application/json-patch+json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment")
.header("Abp-TenantId", "<abp-tenantid>")
.header("Authorization", "<authorization>")
.header("cap-signature", "<cap-signature>")
.header("Content-Type", "application/json-patch+json")
.body("{\n \"transactionNumber\": \"<string>\",\n \"reason\": \"Purchase wrong item\",\n \"timestamp\": 1621851652617,\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/RefundPayment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Abp-TenantId"] = '<abp-tenantid>'
request["Authorization"] = '<authorization>'
request["cap-signature"] = '<cap-signature>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n \"transactionNumber\": \"<string>\",\n \"reason\": \"Purchase wrong item\",\n \"timestamp\": 1621851652617,\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"tenantId": 123,
"transactionNumber": "<string>",
"refundTransactionNumber": "<string>",
"referenceCode": "<string>",
"amount": 100,
"currencyCode": "MYR",
"refundStatus": 11,
"responseMessage": "<string>",
"paymentSessionNumber": "<string>",
"refundPaymentList": {
"transactionNumber": "<string>",
"amount": 100,
"currencyCode": "MYR",
"refundReason": "<string>",
"refundStatus": 11
}
}Errors
In addition to standard signature errors, this endpoint can return:| Code | Name | Meaning |
|---|---|---|
| 2010 | TransactionNotFound | transactionNumber does not match a transaction, or the transaction is not in Success status. |
| 2042 | FailedToRequestRefund | Generic refund failure. The message names the specific cause, e.g. a refund is already in progress for this transaction, the requested amount exceeds what’s still available to refund, the channel doesn’t support partial refunds, or the provider is unavailable for this channel. |
| 2044 | MissingRequireField | reason was not supplied. |
| 2094 | InvalidTenantProfile | Tenant could not be resolved (no session tenant and no tenantId in the request body). |
| 2124 | RequestRefundTimeOut | The provider’s refund API timed out while processing the request. |
| 2130 | ChannelNotSupportRefund | The original transaction’s channel is configured to not support refunds. |
| 2160 | InvalidPaymentGatewaySetting | The channel’s provider settings are missing or misconfigured for this tenant. |
A refund amount of0(or negative) is also rejected viaFailedToRequestRefund(2042), with the message “Refund amount cannot be 0”.
Headers
Your unique Merchant ID assigned by CommercePay.
Your API credentials used for authentication (typically a Bearer token).
A unique security hash used to verify the integrity of the request body. See Generate Signature for how to generate this.
Body
Unique CAP Transaction Number
24A description for refund.
"Purchase wrong item"
new Date().getTime()
1621851652617
Please take note: The Amount parameter only accepts integer units. For example, 1000 is equivalent to 10.00 for the backend.Show all...
Example: 100
[Please pass the required amount if issuing a partial refund; ignore this attribute if issuing a full refund.]
Response
Success
Merchant ID.
Unique CAP Transaction Number of the original payment being refunded.
24Unique CAP Transaction Number for the refund transaction itself, distinct from the original payment's transactionNumber.
Merchant Reference Code
Please take note: The Amount parameter only accepts integer units. For example, 1000 is equivalent to 10.00 for the backend.
Invalid Format: 1,000.00
100
Currency code with a 3-letter ISO 4217 standard code
3"MYR"
Status of the refund itself (not the original payment).
| Value | Name | Meaning |
|---|---|---|
| 11 | Refunded | Refund completed successfully. |
| 12 | ProcessingRefund | Refund request accepted, being processed by the provider. |
| 13 | FailedRefund | Refund attempt failed. |
| 16 | RefundWithCharges | Refund completed, but provider/processing charges were deducted from the refunded amount. |
| 17 | RefundReverse | A previously completed refund was reversed by the provider. |
| 18 | Voided | The original transaction was voided instead of refunded, e.g. same-day cancellation. |
11, 12, 13, 16, 17, 18 Human-readable status message for the refund request.
Unique CAP Session Number
24Show child attributes
Show child attributes
