curl --request POST \
--url https://api.fintoc.com/v1/charges/{id}/cancel \
--header 'Authorization: <api-key>'import requests
url = "https://api.fintoc.com/v1/charges/{id}/cancel"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://api.fintoc.com/v1/charges/{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.fintoc.com/v1/charges/{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_HTTPHEADER => [
"Authorization: <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"
"net/http"
"io"
)
func main() {
url := "https://api.fintoc.com/v1/charges/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
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.fintoc.com/v1/charges/{id}/cancel")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fintoc.com/v1/charges/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "ch_o9YDuRzUez2GqV4x",
"object": "charge",
"amount": 5000,
"created_at": "2021-05-17T17:04:10.284Z",
"currency": "CLP",
"failure_code": null,
"metadata": {
"order_id": "0001"
},
"mode": "live",
"status": "canceled",
"subscription_id": "sub_m7N9rAWJS9dWDKEe"
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "Invalid API Key: invalid-*oken"
}
}{
"error": {
"type": "invalid_request_error",
"code": "forbidden_request",
"param": null,
"message": "Can not cancel in progress charge",
"doc_url": "https://docs.fintoc.com/reference/errors"
}
}{
"error": {
"type": "invalid_request_error",
"code": "missing_resource",
"param": "id",
"message": "No such subscriptions/charge: ch_o9YDuRzUez2GqV4x",
"doc_url": "https://docs.fintoc.com/reference/errors"
}
}Cancel a charge
Cancels a charge. Only charges with status pending can be canceled. Once the collection starts, the charge can no longer be canceled.
curl --request POST \
--url https://api.fintoc.com/v1/charges/{id}/cancel \
--header 'Authorization: <api-key>'import requests
url = "https://api.fintoc.com/v1/charges/{id}/cancel"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://api.fintoc.com/v1/charges/{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.fintoc.com/v1/charges/{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_HTTPHEADER => [
"Authorization: <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"
"net/http"
"io"
)
func main() {
url := "https://api.fintoc.com/v1/charges/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
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.fintoc.com/v1/charges/{id}/cancel")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fintoc.com/v1/charges/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "ch_o9YDuRzUez2GqV4x",
"object": "charge",
"amount": 5000,
"created_at": "2021-05-17T17:04:10.284Z",
"currency": "CLP",
"failure_code": null,
"metadata": {
"order_id": "0001"
},
"mode": "live",
"status": "canceled",
"subscription_id": "sub_m7N9rAWJS9dWDKEe"
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "Invalid API Key: invalid-*oken"
}
}{
"error": {
"type": "invalid_request_error",
"code": "forbidden_request",
"param": null,
"message": "Can not cancel in progress charge",
"doc_url": "https://docs.fintoc.com/reference/errors"
}
}{
"error": {
"type": "invalid_request_error",
"code": "missing_resource",
"param": "id",
"message": "No such subscriptions/charge: ch_o9YDuRzUez2GqV4x",
"doc_url": "https://docs.fintoc.com/reference/errors"
}
}Parámetros de ruta
Respuesta
The canceled charge, with status canceled.
A charge is a single collection from the bank account of a subscription. You create a charge on an active subscription, and Fintoc collects the charge from the subscription's bank account on the next collection cycle. A charge starts as pending and ends as succeeded, failed, or canceled.
Reason why the charge failed. Always null unless status is failed. One of insufficient_funds (the bank account did not have enough funds), subscription_inactive (the subscription is no longer active at the bank), charge_amount_limit_exceeded (the amount exceeds the bank's per-charge limit), bank_account_unavailable (the bank account is closed, blocked, or could not be found), or other.
insufficient_funds, subscription_inactive, charge_amount_limit_exceeded, bank_account_unavailable, other, null "insufficient_funds"
¿Esta página le ayudó?