Docs

Documentation sections

Code samples

curl

curl https://api.laxopay.com/v1/payments \
  -H "Authorization: Bearer $LAXO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount":10000,"currency":"usd","confirm":true,"payment_method_data":{"type":"card","card":{"number":"4242424242424242"}}}'

Node

const response = await fetch("https://api.laxopay.com/v1/payments", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.LAXO_KEY,
    "Content-Type": "application/json",
    "Idempotency-Key": "order_10001"
  },
  body: JSON.stringify({
    amount: 10000,
    currency: "usd",
    confirm: true,
    payment_method_data: { type: "card", card: { number: "4242424242424242" } }
  })
});
const payment = await response.json();

PHP

$ch = curl_init("https://api.laxopay.com/v1/payments");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("LAXO_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "amount" => 10000,
    "currency" => "usd",
    "confirm" => true,
    "payment_method_data" => ["type" => "card", "card" => ["number" => "4242424242424242"]],
  ]),
]);
$payment = json_decode(curl_exec($ch), true);

Python

import json, os, urllib.request
req = urllib.request.Request(
    "https://api.laxopay.com/v1/payments",
    data=json.dumps({
        "amount": 10000,
        "currency": "usd",
        "confirm": True,
        "payment_method_data": {"type": "card", "card": {"number": "4242424242424242"}},
    }).encode(),
    headers={"Authorization": "Bearer " + os.environ["LAXO_KEY"], "Content-Type": "application/json"},
)
payment = json.load(urllib.request.urlopen(req))

Browser

const response = await fetch("https://api.laxopay.com/v1/payments", {
  method: "POST",
  headers: {
    "Authorization": "Bearer lp_test_...",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    amount: 10000,
    currency: "usd",
    confirm: true,
    payment_method_data: { type: "card", card: { number: "4242424242424242" } }
  })
});
const payment = await response.json();

Call the API from your server when you can. A browser call exposes the secret key to anyone using the page.