Official code examples and copy-paste snippets for every major language. All examples use the same payment flow: create session → show QR → poll status.
# No SDK required — use native fetch (Node 18+)
# Or with axios:
npm install axios
const API_KEY = 'cpk_live_your_key_here';
const BASE = 'https://paynovax.online';
const HEADERS = {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
};
// 1. Create a payment session
async function createPayment(tokenId, amount) {
const res = await fetch(BASE + '/api/v1/payment/create', {
method: 'POST',
headers: HEADERS,
body: JSON.stringify({ tokenId, amount }),
});
const json = await res.json();
if (!json.success) throw new Error(json.error.message);
return json.data;
}
// 2. Poll until paid or expired
async function waitForPayment(sessionId, intervalMs = 5000) {
while (true) {
const r = await fetch(BASE + `/api/v1/payment/${sessionId}/status`, { headers: HEADERS });
const d = (await r.json()).data;
if (['completed', 'failed', 'expired'].includes(d.status)) return d;
await new Promise(r => setTimeout(r, intervalMs));
}
}
// Usage:
const session = await createPayment(1, '49.99');
console.log('Address:', session.ephemeralAddress);
const result = await waitForPayment(session.sessionId);
console.log('Status:', result.status, 'txHash:', result.txHash);
pip install requests
import requests, time
API_KEY = 'cpk_live_your_key_here'
BASE = 'https://paynovax.online'
HEADERS = {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
}
def create_payment(token_id, amount):
r = requests.post(
BASE + '/api/v1/payment/create',
headers=HEADERS,
json={'tokenId': token_id, 'amount': amount}
)
j = r.json()
if not j['success']: raise Exception(j['error']['message'])
return j['data']
def wait_for_payment(session_id, interval=5):
while True:
r = requests.get(
BASE + f'/api/v1/payment/{session_id}/status',
headers=HEADERS
).json()['data']
if r['status'] in ['completed', 'failed', 'expired']: return r
time.sleep(interval)
# Usage
session = create_payment(1, '49.99')
print('Address:', session['ephemeralAddress'])
result = wait_for_payment(session['sessionId'])
print(f"Status: {result['status']}, txHash: {result.get('txHash')}")
# PHP 8.0+ with curl extension
composer require guzzlehttp/guzzle # optional, example uses curl
<?php
define('API_KEY', 'cpk_live_your_key_here');
define('BASE', 'https://paynovax.online');
function paynovax_request($method, $path, $body = null) {
$ch = curl_init(BASE . $path);
$headers = [
'Content-Type: application/json',
'x-api-key: ' . API_KEY,
];
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $body ? json_encode($body) : null,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
return $result;
}
// Create payment session
$session = paynovax_request('POST', '/api/v1/payment/create', [
'tokenId' => 1,
'amount' => '49.99',
])['data'];
echo "Address: " . $session['ephemeralAddress'] . "\n";
# curl 7.68+ (ships with most systems)
# Create payment session
curl -X POST https://paynovax.online/api/v1/payment/create \
-H "x-api-key: cpk_live_your_key" \
-H "Content-Type: application/json" \
-d '{"tokenId":1,"amount":"49.99"}'
# Poll payment status
curl https://paynovax.online/api/v1/payment/SESSION_ID/status \
-H "x-api-key: cpk_live_your_key"
# List your tokens
curl https://paynovax.online/api/user/tokens \
-H "Authorization: Bearer YOUR_JWT"
# Register a BEP-20 token
curl -X POST https://paynovax.online/api/user/tokens \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{"contractAddress":"0x55d3...","network":"bsc_mainnet"}'
# Whitelist a domain
curl -X POST https://paynovax.online/api/user/domains \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{"domain":"https://myapp.com"}'
# Go 1.21+ — uses standard library only
go mod init myproject
package main
import (
"bytes"; "encoding/json"; "fmt"; "net/http"
)
const (
apiKey = "cpk_live_your_key_here"
base = "https://paynovax.online"
)
func createPayment(tokenID int, amount string) (map[string]interface{}, error) {
payload, _ := json.Marshal(map[string]interface{}{
"tokenId": tokenID, "amount": amount,
})
req, _ := http.NewRequest("POST", base+"/api/v1/payment/create", bytes.NewBuffer(payload))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", apiKey)
resp, _ := http.DefaultClient.Do(req)
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
return result["data"].(map[string]interface{}), nil
}
func main() {
data, _ := createPayment(1, "49.99")
fmt.Println("Address:", data["ephemeralAddress"])
}