Integrate Flux into your website
A copy-paste friendly guide for adding Paytring-powered checkout to any site or app. Written so an AI coding assistant can implement it end-to-end.
1. How it works
Flux gives your backend a single REST endpoint that returns a hosted checkout URL. You redirect the buyer to that URL, they pay, and Paytring sends them back to your success page. You don't handle card data — Paytring is the merchant of record.
- Your server calls
POST /api/public/v1/orders/create - Flux creates a Paytring order and returns a
checkout_url+ a shortshort_url - You redirect (or link) the buyer to either URL
- Buyer completes payment on Paytring's hosted page
- Paytring redirects them back to your
callback_url
2. Before you start
- You need a Flux merchant account — sign up.
- Submit KYC and sign the MoR agreement. Your account must be approved before live orders work.
- You'll need a server (Node, Python, PHP, anything that can do HTTPS). Never call this API from the browser — your secret key would leak.
3. Generate API keys
- Open the dashboard → Settings → API Keys.
- Click Generate new key and give it a label (e.g. "production server").
- Copy the secret key (
sk_live_…) now. You won't be able to see it again — only the prefix is stored. - Store it in your server's secret manager / environment variables (e.g.
FLUX_API_KEY).
sk_live_… like a password. If it ever leaks, revoke it immediately from the API Keys page.4. The endpoint
Base URL:
https://flux.paytr.ingEndpoint:
POST /api/public/v1/orders/create
Authorization: Bearer sk_live_xxx
Content-Type: application/jsonRequest body
{
"amount": 49.99,
"currency": "USD",
"customer": {
"name": "Jane Doe",
"email": "jane@example.com",
"phone": "9999999999"
},
"receipt_id": "order_2026_001",
"callback_url": "https://yoursite.com/payment/return",
"notes": { "order_id": "2026_001", "plan": "pro" }
}| Field | Type | Description |
|---|---|---|
| amount | number | Required. Amount in major units (e.g. 49.99 = $49.99). |
| currency | string | ISO 4217 code. Defaults to USD. |
| customer.name | string | Buyer's full name. |
| customer.email | string | Buyer's email — receipt is sent here. |
| customer.phone | string | Buyer's phone, 7–20 chars. |
| receipt_id | string | Optional. Your internal order ID. |
| callback_url | string | Optional. Where Paytring sends the buyer after payment. |
| notes | object | Optional. Map of <string,string> stored with the order. |
Response
{
"order_id": "ord_abc123",
"checkout_url": "https://checkout.paytring.com/...",
"short_url": "https://flux.paytr.ing/l/k7m4nq2",
"payment_link_id": "f2c1...-uuid"
}Use short_url when sharing on SMS/WhatsApp/email — it's compact and forwards the buyer to the same Paytring checkout.
5. Copy-paste examples
cURL
curl -X POST https://flux.paytr.ing/api/public/v1/orders/create \
-H "Authorization: Bearer $FLUX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 49.99,
"currency": "USD",
"customer": {
"name": "Jane Doe",
"email": "jane@example.com",
"phone": "9999999999"
},
"callback_url": "https://yoursite.com/payment/return"
}'Node.js (server-side)
// pages/api/checkout.js (Next.js example)
export default async function handler(req, res) {
const r = await fetch(
"https://flux.paytr.ing/api/public/v1/orders/create",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FLUX_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: req.body.amount,
currency: "USD",
customer: req.body.customer,
callback_url: `${process.env.SITE_URL}/payment/return`,
}),
},
);
const data = await r.json();
if (!r.ok) return res.status(r.status).json(data);
// Redirect the buyer to the hosted checkout
res.redirect(303, data.short_url);
}Python (Flask)
import os, requests
from flask import Flask, request, redirect
app = Flask(__name__)
@app.post("/checkout")
def checkout():
r = requests.post(
"https://flux.paytr.ing/api/public/v1/orders/create",
headers={
"Authorization": f"Bearer {os.environ['FLUX_API_KEY']}",
"Content-Type": "application/json",
},
json={
"amount": float(request.form["amount"]),
"currency": "USD",
"customer": {
"name": request.form["name"],
"email": request.form["email"],
"phone": request.form["phone"],
},
"callback_url": "https://yoursite.com/payment/return",
},
timeout=15,
)
r.raise_for_status()
return redirect(r.json()["short_url"], code=303)PHP
<?php
$ch = curl_init("https://flux.paytr.ing/api/public/v1/orders/create");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("FLUX_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"amount" => 49.99,
"currency" => "USD",
"customer" => [
"name" => $_POST["name"],
"email" => $_POST["email"],
"phone" => $_POST["phone"],
],
"callback_url" => "https://yoursite.com/payment/return",
]),
]);
$res = json_decode(curl_exec($ch), true);
header("Location: " . $res["short_url"]);
6. Handling the return
After payment, Paytring redirects the buyer to your callback_url. Show a "thanks" page and confirm the order in your system. The order_id and receipt_id you sent will be preserved so you can reconcile.
7. Errors
| Status | Meaning |
|---|---|
| 401 | Missing / invalid / revoked API key |
| 400 | Validation failed — check the response body for details |
| 403 | Your KYC is not approved yet |
| 502 | Paytring rejected the order — check amount/customer fields |
| 500 | Internal error — please retry |
All error responses are JSON like { "error": "..." }.
8. Testing your integration
- Make a small live order ($1) from your server using the cURL snippet above.
- Open the returned
short_urlin a browser — Paytring's checkout should appear. - Complete the test transaction with a card supported by your Paytring account.
- Verify the order shows up in your Flux dashboard under Payment Links.
Need help?
Email support@paytring.com with your merchant ID and we'll help you get integrated.
