Create Credit Purchase
curl --request POST \
--url https://api.dispersed.com/v1/compute/ledger/credit-purchases \
--header 'Content-Type: application/json' \
--data '
{
"amount": 25,
"cancel_url": "https://console.dispersed.com/billing?checkout=cancelled",
"redirect_url": "https://console.dispersed.com/billing?checkout=success",
"memo": "<string>"
}
'import requests
url = "https://api.dispersed.com/v1/compute/ledger/credit-purchases"
payload = {
"amount": 25,
"cancel_url": "https://console.dispersed.com/billing?checkout=cancelled",
"redirect_url": "https://console.dispersed.com/billing?checkout=success",
"memo": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 25,
cancel_url: 'https://console.dispersed.com/billing?checkout=cancelled',
redirect_url: 'https://console.dispersed.com/billing?checkout=success',
memo: '<string>'
})
};
fetch('https://api.dispersed.com/v1/compute/ledger/credit-purchases', 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.dispersed.com/v1/compute/ledger/credit-purchases",
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' => 25,
'cancel_url' => 'https://console.dispersed.com/billing?checkout=cancelled',
'redirect_url' => 'https://console.dispersed.com/billing?checkout=success',
'memo' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.dispersed.com/v1/compute/ledger/credit-purchases"
payload := strings.NewReader("{\n \"amount\": 25,\n \"cancel_url\": \"https://console.dispersed.com/billing?checkout=cancelled\",\n \"redirect_url\": \"https://console.dispersed.com/billing?checkout=success\",\n \"memo\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.dispersed.com/v1/compute/ledger/credit-purchases")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 25,\n \"cancel_url\": \"https://console.dispersed.com/billing?checkout=cancelled\",\n \"redirect_url\": \"https://console.dispersed.com/billing?checkout=success\",\n \"memo\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dispersed.com/v1/compute/ledger/credit-purchases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 25,\n \"cancel_url\": \"https://console.dispersed.com/billing?checkout=cancelled\",\n \"redirect_url\": \"https://console.dispersed.com/billing?checkout=success\",\n \"memo\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-11-07T05:31:56Z",
"session_id": "<string>",
"session_url": "<string>",
"submitted_amount": 123,
"checkout_session": {
"id": "<string>",
"object": "checkout.session",
"currency": "<string>",
"mode": "<string>",
"payment_status": "<string>",
"created": 123,
"expires_at": 123,
"client_reference_id": "<string>",
"amount_subtotal": 123,
"amount_total": 123,
"status": "<string>",
"metadata": {},
"payment_intent": "<string>",
"url": "<string>",
"success_url": "<string>",
"cancel_url": "<string>",
"return_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}Compute Ledger
Create Credit Purchase
POST
/
v1
/
compute
/
ledger
/
credit-purchases
Create Credit Purchase
curl --request POST \
--url https://api.dispersed.com/v1/compute/ledger/credit-purchases \
--header 'Content-Type: application/json' \
--data '
{
"amount": 25,
"cancel_url": "https://console.dispersed.com/billing?checkout=cancelled",
"redirect_url": "https://console.dispersed.com/billing?checkout=success",
"memo": "<string>"
}
'import requests
url = "https://api.dispersed.com/v1/compute/ledger/credit-purchases"
payload = {
"amount": 25,
"cancel_url": "https://console.dispersed.com/billing?checkout=cancelled",
"redirect_url": "https://console.dispersed.com/billing?checkout=success",
"memo": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 25,
cancel_url: 'https://console.dispersed.com/billing?checkout=cancelled',
redirect_url: 'https://console.dispersed.com/billing?checkout=success',
memo: '<string>'
})
};
fetch('https://api.dispersed.com/v1/compute/ledger/credit-purchases', 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.dispersed.com/v1/compute/ledger/credit-purchases",
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' => 25,
'cancel_url' => 'https://console.dispersed.com/billing?checkout=cancelled',
'redirect_url' => 'https://console.dispersed.com/billing?checkout=success',
'memo' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.dispersed.com/v1/compute/ledger/credit-purchases"
payload := strings.NewReader("{\n \"amount\": 25,\n \"cancel_url\": \"https://console.dispersed.com/billing?checkout=cancelled\",\n \"redirect_url\": \"https://console.dispersed.com/billing?checkout=success\",\n \"memo\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.dispersed.com/v1/compute/ledger/credit-purchases")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 25,\n \"cancel_url\": \"https://console.dispersed.com/billing?checkout=cancelled\",\n \"redirect_url\": \"https://console.dispersed.com/billing?checkout=success\",\n \"memo\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dispersed.com/v1/compute/ledger/credit-purchases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 25,\n \"cancel_url\": \"https://console.dispersed.com/billing?checkout=cancelled\",\n \"redirect_url\": \"https://console.dispersed.com/billing?checkout=success\",\n \"memo\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-11-07T05:31:56Z",
"session_id": "<string>",
"session_url": "<string>",
"submitted_amount": 123,
"checkout_session": {
"id": "<string>",
"object": "checkout.session",
"currency": "<string>",
"mode": "<string>",
"payment_status": "<string>",
"created": 123,
"expires_at": 123,
"client_reference_id": "<string>",
"amount_subtotal": 123,
"amount_total": 123,
"status": "<string>",
"metadata": {},
"payment_intent": "<string>",
"url": "<string>",
"success_url": "<string>",
"cancel_url": "<string>",
"return_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"status": 123,
"timestamp": "<string>",
"details": []
}
}Body
application/json
Purchase amount in EUR.
Example:
25
URL to redirect to if the user cancels the Stripe Checkout. Must be an allowed Console domain.
Example:
"https://console.dispersed.com/billing?checkout=cancelled"
URL to redirect to after successful Stripe Checkout. Must be an allowed Console domain.
Example:
"https://console.dispersed.com/billing?checkout=success"
Optional memo for the purchase
Response
Credit purchase checkout session created
When the purchase was created
Stripe Checkout session ID. Deprecated: use checkout_session.id
Stripe Checkout URL. Deprecated: use checkout_session.url
The submitted purchase amount in EUR
Full Stripe Checkout session metadata. Null when the upstream API has not yet been updated.
Show child attributes
Show child attributes
⌘I