Adding Payments

HTTP POST to register an invoice or checkout with Branta.

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:

Time
ttl

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": {
    "merchant": "A Store",
    "payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
    "ttl": "86400",
    "description": "Payment for Invoice #123"
  }
}

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": {
    "uuid": "123",
    "merchant": "A Store",
    "payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
    "ttl": "86400",
    "description": "Payment for Invoice #123"
  }
}

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": {
    "merchant": "A Store",
    "payment": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
    "ttl": "86400",
    "description": "Payment for Invoice #123"
  }
}

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