Adding Payments
HTTP POST to register an invoice or checkout with Branta.
Adds a new payment to Branta. Expires after ttl seconds.
Authorization
is required to authorize the request. This API key is unique to each client and must be included in the header of every request. Failure to provide a valid API key will result in an unauthorized error.
Make sure to keep your API key confidential.
POST /v1/payments HTTP/1.1
Host: staging.branta.pro
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 119
{
"payment": {
"payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"ttl": "86400",
"alt_payments": "[\"lnbc....\", \"bc1q...\"]"
}
}
No content
TTL
Each payment has a Time-to-Live (TTL
) in seconds associated with it. Branta will remove the payment from our system after TTL
seconds from posting.
Minimum TTL: 30 seconds
(Requests below this range will default to 30 seconds)
Maximum TTL: 31536000 seconds
(Requests above this range will default to 1 year)
Invalid TTLs will be set to 7 days.
Some common values are:
15 minutes
900
60 minutes
3600
1 day
86400
7 days
604800
30 days
2592000
1 year
31536000
Javascript
const url = "https://staging.branta.pro/v1/payments";
const apiToken = "your token here";
const payload = {
"payment": {
"payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"ttl": "86400"
}
}
const options = {
method: "POST",
headers: {
"API_KEY": apiToken,
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
};
fetch(url, options)
.then(response => {
console.log("Response Status Code:", response.status);
})
.catch(error => {
console.error("An error occurred:", error);
});
Python
import requests
url = "https://staging.branta.pro/v1/payments"
api_token = "your token here"
payload = {
"payment": {
"payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"ttl": "86400"
}
}
headers = {
"API_KEY": api_token,
"Content-Type": "application/json"
}
try:
response = requests.post(url, json=payload, headers=headers)
print("Response:", response.status_code)
except requests.exceptions.RequestException as e:
print("An error occurred:", e)
Ruby
require 'net/http'
require 'uri'
require 'json'
url = URI.parse("https://staging.branta.pro/v1/payments")
api_token = "your token here"
payload = {
"payment": {
"payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"ttl": "86400"
}
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url.path, {
"API_KEY" => api_token,
"Content-Type" => "application/json"
})
request.body = payload.to_json
begin
response = http.request(request)
puts "Response Status Code: #{response.code}"
rescue => e
puts "An error occurred: #{e.message}"
end
Last updated