Cancel Payment
curl --request POST \
--url https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <api-key>' \
--header 'private-secret-key: <api-key>' \
--header 'public-api-key: <api-key>' \
--data '
{
"description": "Duplicate",
"reason": "REQUESTED_BY_CUSTOMER",
"merchant_reference": "AAB01-432245"
}
'import requests
url = "https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel"
payload = {
"description": "Duplicate",
"reason": "REQUESTED_BY_CUSTOMER",
"merchant_reference": "AAB01-432245"
}
headers = {
"public-api-key": "<api-key>",
"private-secret-key": "<api-key>",
"X-Idempotency-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'public-api-key': '<api-key>',
'private-secret-key': '<api-key>',
'X-Idempotency-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
description: 'Duplicate',
reason: 'REQUESTED_BY_CUSTOMER',
merchant_reference: 'AAB01-432245'
})
};
fetch('https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel', 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://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel",
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([
'description' => 'Duplicate',
'reason' => 'REQUESTED_BY_CUSTOMER',
'merchant_reference' => 'AAB01-432245'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Idempotency-Key: <api-key>",
"private-secret-key: <api-key>",
"public-api-key: <api-key>"
],
]);
$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://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel"
payload := strings.NewReader("{\n \"description\": \"Duplicate\",\n \"reason\": \"REQUESTED_BY_CUSTOMER\",\n \"merchant_reference\": \"AAB01-432245\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("public-api-key", "<api-key>")
req.Header.Add("private-secret-key", "<api-key>")
req.Header.Add("X-Idempotency-Key", "<api-key>")
req.Header.Add("Content-Type", "application/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://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel")
.header("public-api-key", "<api-key>")
.header("private-secret-key", "<api-key>")
.header("X-Idempotency-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"Duplicate\",\n \"reason\": \"REQUESTED_BY_CUSTOMER\",\n \"merchant_reference\": \"AAB01-432245\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["public-api-key"] = '<api-key>'
request["private-secret-key"] = '<api-key>'
request["X-Idempotency-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"Duplicate\",\n \"reason\": \"REQUESTED_BY_CUSTOMER\",\n \"merchant_reference\": \"AAB01-432245\"\n}"
response = http.request(request)
puts response.read_body{
"id": "438bea6c-9061-4416-b824-469c3c05868d",
"type": "CANCEL",
"status": "SUCCEEDED",
"category": "CARD",
"amount": {
"captured": 0,
"currency": "USD",
"currency_conversion": null,
"refunded": 0,
"value": 30000
},
"merchant_reference": "",
"created_at": "2024-06-06T14:03:08.384014Z",
"updated_at": "2024-06-06T14:03:08.453617Z",
"provider_data": {
"id": "YUNO_TEST_PAYMENT_GW",
"transaction_id": "",
"account_id": "",
"status": "SUCCEEDED",
"sub_status": "",
"status_detail": "SUCCEEDED",
"response_message": null,
"response_code": "SUCCEEDED",
"raw_response": {
"message": "provider response"
},
"third_party_transaction_id": null,
"third_party_account_id": null,
"iso8583_response_code": "00",
"iso8583_response_message": "Approved or completed successfully"
},
"response_code": "SUCCEEDED",
"response_message": "Transaction successful",
"payment": {
"id": "2d6f75c1-c4bc-4d2d-80ec-0af4d12c85da",
"account_id": "",
"description": "Test",
"country": "US",
"status": "CANCELED",
"sub_status": "CANCELED",
"merchant_order_id": "0000023",
"created_at": "2024-06-06T14:01:34.286228Z",
"updated_at": "2024-06-06T14:03:08.484781Z",
"amount": {
"captured": 0,
"currency": "USD",
"currency_conversion": null,
"refunded": 0,
"value": 30000
},
"split_marketplace": []
},
"customer_payer": null,
"simplified_mode": false,
"receipt": false,
"receipt_url": null,
"receipt_language": null
}{
"code": "INVALID_REQUEST",
"messages": [
"Invalid request"
]
}{
"code": "INVALID_CREDENTIALS",
"messages": [
"Invalid credentials"
]
}{
"code": "AUTHORIZATION_REQUIRED",
"messages": [
"The merchant has no authorization to use this API."
]
}Cancel Payment
POST
/
payments
/
{payment_id}
/
transactions
/
{transaction_id}
/
cancel
Cancel Payment
curl --request POST \
--url https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <api-key>' \
--header 'private-secret-key: <api-key>' \
--header 'public-api-key: <api-key>' \
--data '
{
"description": "Duplicate",
"reason": "REQUESTED_BY_CUSTOMER",
"merchant_reference": "AAB01-432245"
}
'import requests
url = "https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel"
payload = {
"description": "Duplicate",
"reason": "REQUESTED_BY_CUSTOMER",
"merchant_reference": "AAB01-432245"
}
headers = {
"public-api-key": "<api-key>",
"private-secret-key": "<api-key>",
"X-Idempotency-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'public-api-key': '<api-key>',
'private-secret-key': '<api-key>',
'X-Idempotency-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
description: 'Duplicate',
reason: 'REQUESTED_BY_CUSTOMER',
merchant_reference: 'AAB01-432245'
})
};
fetch('https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel', 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://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel",
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([
'description' => 'Duplicate',
'reason' => 'REQUESTED_BY_CUSTOMER',
'merchant_reference' => 'AAB01-432245'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Idempotency-Key: <api-key>",
"private-secret-key: <api-key>",
"public-api-key: <api-key>"
],
]);
$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://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel"
payload := strings.NewReader("{\n \"description\": \"Duplicate\",\n \"reason\": \"REQUESTED_BY_CUSTOMER\",\n \"merchant_reference\": \"AAB01-432245\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("public-api-key", "<api-key>")
req.Header.Add("private-secret-key", "<api-key>")
req.Header.Add("X-Idempotency-Key", "<api-key>")
req.Header.Add("Content-Type", "application/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://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel")
.header("public-api-key", "<api-key>")
.header("private-secret-key", "<api-key>")
.header("X-Idempotency-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"Duplicate\",\n \"reason\": \"REQUESTED_BY_CUSTOMER\",\n \"merchant_reference\": \"AAB01-432245\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/payments/{payment_id}/transactions/{transaction_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["public-api-key"] = '<api-key>'
request["private-secret-key"] = '<api-key>'
request["X-Idempotency-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"Duplicate\",\n \"reason\": \"REQUESTED_BY_CUSTOMER\",\n \"merchant_reference\": \"AAB01-432245\"\n}"
response = http.request(request)
puts response.read_body{
"id": "438bea6c-9061-4416-b824-469c3c05868d",
"type": "CANCEL",
"status": "SUCCEEDED",
"category": "CARD",
"amount": {
"captured": 0,
"currency": "USD",
"currency_conversion": null,
"refunded": 0,
"value": 30000
},
"merchant_reference": "",
"created_at": "2024-06-06T14:03:08.384014Z",
"updated_at": "2024-06-06T14:03:08.453617Z",
"provider_data": {
"id": "YUNO_TEST_PAYMENT_GW",
"transaction_id": "",
"account_id": "",
"status": "SUCCEEDED",
"sub_status": "",
"status_detail": "SUCCEEDED",
"response_message": null,
"response_code": "SUCCEEDED",
"raw_response": {
"message": "provider response"
},
"third_party_transaction_id": null,
"third_party_account_id": null,
"iso8583_response_code": "00",
"iso8583_response_message": "Approved or completed successfully"
},
"response_code": "SUCCEEDED",
"response_message": "Transaction successful",
"payment": {
"id": "2d6f75c1-c4bc-4d2d-80ec-0af4d12c85da",
"account_id": "",
"description": "Test",
"country": "US",
"status": "CANCELED",
"sub_status": "CANCELED",
"merchant_order_id": "0000023",
"created_at": "2024-06-06T14:01:34.286228Z",
"updated_at": "2024-06-06T14:03:08.484781Z",
"amount": {
"captured": 0,
"currency": "USD",
"currency_conversion": null,
"refunded": 0,
"value": 30000
},
"split_marketplace": []
},
"customer_payer": null,
"simplified_mode": false,
"receipt": false,
"receipt_url": null,
"receipt_language": null
}{
"code": "INVALID_REQUEST",
"messages": [
"Invalid request"
]
}{
"code": "INVALID_CREDENTIALS",
"messages": [
"Invalid credentials"
]
}{
"code": "AUTHORIZATION_REQUIRED",
"messages": [
"The merchant has no authorization to use this API."
]
}A payment with a PENDING status due to an AUTHORIZE transaction status can be canceled before it is completed if the payment is no longer required. Sending a cancel request will update the payment status to CANCELLED.
If you need a receipt for the canceled transaction, you can retrieve it after it has been created. To do this, use the Retrieve Payment by ID endpoint and check the
3DS PaymentsPayments in a PENDING status due to 3DS authentication cannot be canceled. These payments are in a temporary state awaiting user authentication. The payment status will automatically update to either FRAUD VERIFIED or CANCELLED based on the outcome of the authentication process.
Alternative Payment MethodsAlternative payment methods such as PIX also support payment cancellation with a PENDING status. Reach out to your technical account manager for more information.
receipt_url field in the payment.transaction object. See The Payment Object for receipt, receipt_url, and receipt_language.
To use this endpoint, you have to provide an X-Idempotency-Key in your request. Check the Authentication page for more information.Authorizations
Path Parameters
The unique identifier of the payment (UUID, 36 chars).
The unique identifier of the transaction (UUID, 36 chars).
Body
application/json
Identification of the payment transaction defined by the merchant (MAX 255; MIN 3).
Description of the cancellation.(MAX 255; MIN 3)
Reason for the cancellation. Values can be DUPLICATE, FRAUDULENT, and REQUESTED_BY_CUSTOMER.
Available options:
DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER Specifies additional data for required the transaction response
Show child attributes
Show child attributes
Response
200
Example:
"438bea6c-9061-4416-b824-469c3c05868d"
Example:
"CANCEL"
Example:
"SUCCEEDED"
Example:
"CARD"
Show child attributes
Show child attributes
Example:
""
Example:
"2024-06-06T14:03:08.384014Z"
Example:
"2024-06-06T14:03:08.453617Z"
Show child attributes
Show child attributes
Example:
"SUCCEEDED"
Example:
"Transaction successful"
Show child attributes
Show child attributes
Example:
false
Example:
false
Was this page helpful?