Poskub Pay Developer API Docs
Integrate any website, SaaS platform, or POS terminal using standard REST JSON and HMAC-SHA256 IPN webhooks.
1. GET /api/v1/catalog
2. Create Payment Invoice (Live `pk_live_` vs Test `pk_test_`)
Use pk_live_... for real Mainnet settlements and live credit billing, or pk_test_... for real Testnet transactions (base-sepolia, eth-sepolia, bsc-testnet, solana-devnet) with isolated Test Credit + Spread tracking (IPN payloads include livemode: true | false).
# Live Mode (pk_live_...) or Test Mode (pk_test_...)
curl -X POST "https://pay.poskub.store/api/v1/invoices" \
-H "Content-Type: application/json" \
-H "x-api-key: pk_test_your_sandbox_key" \
-d '{
"fiat_amount": 490,
"fiat_currency": "THB",
"order_id": "ORDER-9921",
"description": "POSkub Pro Subscription",
"ipn_url": "https://yourstore.com/api/poskub-pay-ipn",
"success_url": "https://yourstore.com/thank-you"
}'3. Verify IPN Webhook Signature (Node.js)
Always verify x-poskub-pay-signature (sha256=<hex>) using your merchant IPN secret.
import crypto from 'node:crypto';
export function isValidPoskubPayIpn(rawBodyBuffer, signatureHeader, ipnSecret) {
const expected = 'sha256=' + crypto
.createHmac('sha256', ipnSecret)
.update(rawBodyBuffer)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expected, 'utf8'),
Buffer.from(String(signatureHeader || ''), 'utf8')
);
}4. Add New EVM Chain & Token via API (Admin)
Register any new EVM network or ERC-20 token programmatically using ADMIN_API_KEY.
# 1. Add Optimism chain
curl -X POST "https://pay.poskub.store/api/v1/admin/chains" \
-H "Content-Type: application/json" \
-H "x-admin-key: $ADMIN_API_KEY" \
-d '{
"slug": "optimism",
"family": "evm",
"name": "OP Mainnet",
"short_name": "Optimism",
"badge": "OP",
"chain_id": 10,
"rpc_urls": ["https://mainnet.optimism.io"],
"explorer_tx_url": "https://optimistic.etherscan.io/tx/",
"fee_hint": "~$0.01",
"native_symbol": "ETH"
}'
# 2. Add USDC on Optimism
curl -X POST "https://pay.poskub.store/api/v1/admin/tokens" \
-H "Content-Type: application/json" \
-H "x-admin-key: $ADMIN_API_KEY" \
-d '{
"chain_slug": "optimism",
"symbol": "USDC",
"name": "USD Coin",
"contract_address": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
"decimals": 6,
"is_stablecoin": true
}'5. Embeddable Checkout Widget (embed.js — Stripe-style Modal)
Drop-in modal checkout widget for any website with real-time onPaid / onMismatch / onExpired JavaScript callbacks.
<script src="https://pay.poskub.store/embed.js"></script>
<!-- Option A: Declarative button -->
<button data-poskub-pay="INV-YOURCODE">Pay with Crypto</button>
<!-- Option B: Programmatic JS with callbacks -->
<script>
window.PoskubPay.open('INV-YOURCODE', {
onPaid(invoice) {
console.log('Confirmed on-chain:', invoice.tx_hash, invoice.status);
window.PoskubPay.close();
},
onMismatch(mismatch, invoice) {
console.warn('Wrong amount sent:', mismatch.type, mismatch.difference_amount);
},
onExpired(invoice) {
alert('Invoice expired: ' + invoice.public_code);
}
});
</script>6. Official JavaScript / TypeScript SDK (paykub)
Zero-dependency ESM + TypeScript SDK (npm install paykub) covering invoice creation, headless mismatch inspection, timing-safe webhook verification, and browser checkout modals.
// npm install paykub
import { PoskubPayClient } from 'paykub';
import { constructWebhookEvent } from 'paykub/webhooks';
const poskub = new PoskubPayClient({
apiKey: process.env.POSKUB_PAY_API_KEY, // pk_live_... or pk_test_...
baseUrl: 'https://pay.poskub.store',
});
// 1) Create an invoice
const { invoice, checkout_url } = await poskub.createInvoice({
fiat_amount: 490,
fiat_currency: 'THB',
order_id: 'ORDER-9921',
ipn_url: 'https://yourstore.com/api/poskub-pay-ipn',
});
// 2) Verify TX in headless UI (detects underpaid / overpaid safely)
const verifyRes = await poskub.verifyPayment(invoice.public_code, { txHash });
if (verifyRes.mismatch) {
console.log(verifyRes.mismatch.type, verifyRes.mismatch.paid_amount);
}
// 3) Verify incoming IPN webhook (works for both auto & merchant-resolved settlements)
const event = constructWebhookEvent(rawBodyBuffer, req.headers, process.env.POSKUB_PAY_IPN_SECRET);
if (event.event === 'invoice.paid') {
console.log('Order settled:', event.invoice.order_id, event.invoice.status);
}