curl --request POST \
--url https://gate.chip-in.asia/api/v1/purchases/{id}/refund/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"amount": 120
}'import requests
url = "https://gate.chip-in.asia/api/v1/purchases/{id}/refund/"
payload = { "amount": 120 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 120})
};
fetch('https://gate.chip-in.asia/api/v1/purchases/{id}/refund/', 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://gate.chip-in.asia/api/v1/purchases/{id}/refund/",
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([
'amount' => 120
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://gate.chip-in.asia/api/v1/purchases/{id}/refund/"
payload := strings.NewReader("{\n \"amount\": 120\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://gate.chip-in.asia/api/v1/purchases/{id}/refund/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 120\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gate.chip-in.asia/api/v1/purchases/{id}/refund/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 120\n}"
response = http.request(request)
puts response.read_body{
"type": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_on": 1619740800,
"updated_on": 1619740800,
"client": {
"email": "customer@example.com",
"bank_account": "<string>",
"bank_code": "<string>",
"phone": "+60 123456789",
"full_name": "<string>",
"personal_code": "<string>",
"street_address": "<string>",
"country": "<string>",
"city": "<string>",
"zip_code": "<string>",
"state": "<string>",
"shipping_street_address": "<string>",
"shipping_country": "<string>",
"shipping_city": "<string>",
"shipping_zip_code": "<string>",
"shipping_state": "<string>",
"cc": [
"customer@example.com"
],
"bcc": [
"customer@example.com"
],
"legal_name": "<string>",
"brand_name": "<string>",
"registration_number": "<string>",
"tax_number": "<string>"
},
"payment": {
"is_outgoing": false,
"payment_type": "purchase",
"amount": 123,
"currency": "<string>",
"net_amount": 123,
"fee_amount": 123,
"pending_amount": 123,
"pending_unfreeze_on": 1619740800,
"description": "<string>",
"paid_on": 1619740800,
"remote_paid_on": 1619740800
},
"transaction_data": {},
"related_to": {
"type": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"reference_generated": "<string>",
"reference": "<string>",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"company_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"is_test": true,
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"brand_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}"{\n \"__all__\": {\n \"message\": \"descriptive error message\",\n \"code\": \"error_code\"\n }\n}\n"Refund a paid purchase
Will generate a Payment object and return it as a successful response.
Optional amount argument can be included in the request body to request a partial refund.
Consult refund_availability field on Purchase on details whether this Purchase can be refunded or not.
If this operation takes too long to be processed on the acquirer side - you will get a response with status code 200 and a Purchase object having status = pending_refund in body (you will receive a corresponding Webhook callback too for a purchase.pending_refund event). To be notified of a successful operation completion, please subscribe to payment.refunded callback event - it will deliver a Payment generated by this refund.
If refund fails due to payment processing error, you will receive HTTP response code 400 with error code purchase_refund_error. In this case, to get more details about the error, you should perform a GET /purchases/{id}/ request for the Purchase you tried to refund. In transaction_data.attempts[] array (newest element first) you’ll find the corresponding attempt with error code and description in .error parameter.
curl --request POST \
--url https://gate.chip-in.asia/api/v1/purchases/{id}/refund/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"amount": 120
}'import requests
url = "https://gate.chip-in.asia/api/v1/purchases/{id}/refund/"
payload = { "amount": 120 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 120})
};
fetch('https://gate.chip-in.asia/api/v1/purchases/{id}/refund/', 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://gate.chip-in.asia/api/v1/purchases/{id}/refund/",
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([
'amount' => 120
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://gate.chip-in.asia/api/v1/purchases/{id}/refund/"
payload := strings.NewReader("{\n \"amount\": 120\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://gate.chip-in.asia/api/v1/purchases/{id}/refund/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 120\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gate.chip-in.asia/api/v1/purchases/{id}/refund/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 120\n}"
response = http.request(request)
puts response.read_body{
"type": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_on": 1619740800,
"updated_on": 1619740800,
"client": {
"email": "customer@example.com",
"bank_account": "<string>",
"bank_code": "<string>",
"phone": "+60 123456789",
"full_name": "<string>",
"personal_code": "<string>",
"street_address": "<string>",
"country": "<string>",
"city": "<string>",
"zip_code": "<string>",
"state": "<string>",
"shipping_street_address": "<string>",
"shipping_country": "<string>",
"shipping_city": "<string>",
"shipping_zip_code": "<string>",
"shipping_state": "<string>",
"cc": [
"customer@example.com"
],
"bcc": [
"customer@example.com"
],
"legal_name": "<string>",
"brand_name": "<string>",
"registration_number": "<string>",
"tax_number": "<string>"
},
"payment": {
"is_outgoing": false,
"payment_type": "purchase",
"amount": 123,
"currency": "<string>",
"net_amount": 123,
"fee_amount": 123,
"pending_amount": 123,
"pending_unfreeze_on": 1619740800,
"description": "<string>",
"paid_on": 1619740800,
"remote_paid_on": 1619740800
},
"transaction_data": {},
"related_to": {
"type": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"reference_generated": "<string>",
"reference": "<string>",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"company_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"is_test": true,
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"brand_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}"{\n \"__all__\": {\n \"message\": \"descriptive error message\",\n \"code\": \"error_code\"\n }\n}\n"Authorizations
Body
Response
OK
A record of a performed financial transaction. Can be generated e.g. as a result of refund operation.