Quickstart
Take your first payment in about 15 minutes: create a hosted checkout on your server → the customer pays on the PolyPay page → a webhook tells your system to fulfil the order.
Choose an integration path
Most merchants need only one of the options below. If no plugin fits, follow the REST API steps on this page; they work with any backend language.
| Your situation | Recommended path |
|---|---|
| You run WHMCS, Shopify, or a digital-goods shop platform | Official plugin, little or no code |
| You code with Codex, Cursor, Claude Code, or another AI tool | PolyPay Skill guides the agent through the integration |
| Your own website or backend (any language) | REST API + Hosted Checkout (This page) |
| PHP / Laravel / WordPress project | PHP SDK |
| Native Android or iOS app | Mobile SDK |
| Charge AI agents or API calls per request | x402 |
Steps 1–2: Prepare a wallet and an API Key
- Create a merchant account and add at least one payout wallet. Funds go straight to that wallet; PolyPay never holds them. Create a payout wallet
- Create an API Key on the dashboard API Keys page. It is shown only once, so store it as a server environment variable (for example POLYPAY_API_KEY), and consider restricting it to your server egress IPs.
Step 3: Create a Hosted Checkout on your server
Call the endpoint below from your backend to get a checkout_url. Without currency and network, the customer first chooses an asset and network on the PolyPay page.
POST https://api.polypay.ai/api/v1/pay/sdk/order/checkout
| Parameter | Required | Description |
|---|---|---|
amount | Required | Order amount in USD, minimum 0.01. PolyPay converts it to the payable quantity of the asset the customer selects. |
mch_order_id | Optional | Your order ID, up to 32 characters. Strongly recommended: the same ID reuses the unexpired payment order, which makes retries and reconciliation safe. |
notify_url | Optional | Webhook URL for payment results. Falls back to the default Webhook URL configured in the dashboard. |
redirect_url | Optional | Where the customer returns after paying. |
locale | Optional | Checkout language such as en or zh. Detected from the browser when omitted. |
currency + network | Optional | Send both when the payment method is already known (for example USDT + Tron) to skip selection and open the payment page directly. |
curl -X POST https://api.polypay.ai/api/v1/pay/sdk/order/checkout \
-H "Content-Type: application/json" \
-H "X-API-Key: $POLYPAY_API_KEY" \
-d '{
"mch_order_id": "ORDER_10001",
"amount": 19.90,
"notify_url": "https://your-site.com/webhooks/polypay",
"redirect_url": "https://your-site.com/orders/ORDER_10001"
}'On success code is 0 and data.checkout_url is the page to open for the customer (payment_url is a legacy alias with the same value).
{
"code": 0,
"message": "",
"data": {
"checkout_url": "https://checkout.polypay.ai/en/pay/202611271785497228532519443",
"payment_url": "https://checkout.polypay.ai/en/pay/202611271785497228532519443"
}
}Step 4: Redirect the browser
The frontend only fetches checkout_url from your backend and redirects to it. No frontend SDK is required.
// Your own backend endpoint returns { checkoutUrl }.
const { checkoutUrl } = await fetch('/api/orders/ORDER_10001/pay', {
method: 'POST'
}).then((response) => response.json());
window.location.href = checkoutUrl;Step 5: Receive and verify the webhook
PolyPay sends a POST request to notify_url when the order status changes. Verify the Ed25519 v2 signature first, then process idempotently by event_id. Treat status 2, 5, or 7 as paid, and return HTTP 2xx when done.
<?php
use PolyPay\PolyPay;
use PolyPay\Exception\SignatureException;
$polypay = new PolyPay(getenv('POLYPAY_API_KEY'));
try {
$event = $polypay->webhookV2('MCH_YOUR_ID', 'production')->handle();
// 2 = paid, 5 = manual recharge, 7 = marked paid by an admin.
if (in_array((int) $event['status'], [2, 5, 7], true)) {
// Look up $event['order_no'], skip if already fulfilled, then fulfil.
}
http_response_code(200);
echo 'OK';
} catch (SignatureException $e) {
http_response_code($e->getHttpStatus());
}Full verification rules and a Node.js example
Step 6: Go-live checklist
- Run one small real payment end to end: create → pay → receive webhook → fulfil.
- The API Key lives only in server environment variables, never in frontend code, Git, or logs.
- The webhook endpoint verifies signature, timestamp, and nonce, and tolerates duplicate deliveries.
- When your order is cancelled, call /order/cancel so PolyPay releases the reserved payable amount.
- Reconcile periodically with /order/detail in case a webhook is not delivered.