Update a charge
POST
https://api.ledgerline.dev /v2/charges/{charge} Updates the specified charge by setting the values of the parameters passed. Any parameters not provided are left unchanged.
Parameters
chargestringpathrequiredThe identifier of the charge to act on.
Request body application/x-www-form-urlencoded
descriptionstringAn arbitrary string attached to the object.
metadataobjectSet of key-value pairs.
{
"description": "string",
"metadata": {}
}Code samples
cURL
curl -X POST "https://api.ledgerline.dev/v2/charges/{charge}" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d '{"description":"string","metadata":{}}'TypeScript
const res = await fetch('https://api.ledgerline.dev/v2/charges/{charge}', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify({"description":"string","metadata":{}}),
});
const data = await res.json();Python
import requests
res = requests.request(
"POST",
"https://api.ledgerline.dev/v2/charges/{charge}",
headers={
"Content-Type": "application/x-www-form-urlencoded",
},
json={"description": "string", "metadata": {}},
)
data = res.json()Go
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, _ := http.NewRequest("POST", "https://api.ledgerline.dev/v2/charges/{charge}", strings.NewReader(`{"description":"string","metadata":{}}`))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.ledgerline.dev/v2/charges/{charge}');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"description":"string","metadata":{}}');
$response = curl_exec($ch);
curl_close($ch);
echo $response;Ruby
require 'net/http'
require 'uri'
uri = URI('https://api.ledgerline.dev/v2/charges/{charge}')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = '{"description":"string","metadata":{}}'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(req)
end
puts res.bodyJava
import java.net.URI;
import java.net.http.*;
import java.net.http.HttpRequest.BodyPublishers;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ledgerline.dev/v2/charges/{charge}"))
.header("Content-Type", "application/x-www-form-urlencoded")
.method("POST", BodyPublishers.ofString("{\"description\":\"string\",\"metadata\":{}}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());Responses
200 Returns the object if the request succeeded.
{
"id": "ch_3MmlLrLkdIwHu7ix0snN0B15",
"object": "charge",
"amount": 4800,
"amount_refunded": 0,
"currency": "usd",
"customer": "cus_Qm8xT2vLp0aZ",
"description": "Canvas tote",
"captured": true,
"paid": true,
"status": "succeeded",
"created": 1791787234,
"livemode": false
}402 The request was valid but failed (for example, the card was declined).
Updated
Was this page helpful?