API Documentation

PayLex API Reference

Accept card, bank and crypto payments in your website, shop or app and receive them in your own wallet. Three GET requests, no signup.

AI-ready

Integrate with your AI assistant

Copy the prompt and paste it into ChatGPT, Claude, Cursor or any coding agent. It reads our integration guide and builds the checkout, callback handler and security checks into your existing system, in your language and framework.

Fetch and follow the instructions at https://paylex.org/agent/prompt.md to set me up for the PayLex payment API.

The link is public and contains no personal data. Your assistant asks for your payout wallet and stack, and keeps an optional API key in an environment variable, never in the chat or in code. Also available as llms.txt.

Direct payouts

Each payment is forwarded to your wallet as soon as it arrives. Card and bank payments as USDC on Polygon.

Non-custodial

Funds go straight to your own wallet. PayLex never holds your money.

Easy integration

Plain HTTPS GET requests and JSON responses. No SDK, no signup.

Integration Flow

No account needed. Optional: send an in Step 1 to see your payments and statistics in the dashboard.

API Key

Optional

The API works without registration. An API key links your payments to your PayLex account.

With an API key

Every payment of a wallet created with your key appears in your dashboard under My Links, with status, amounts and statistics.

Without an API key

Everything works the same and payouts are identical, but payments are not linked to an account and no statistics are available.

Create a key

  1. Create an account or sign in.
  2. Open the dashboard, tab API, and create a key (up to 10 active keys, e.g. one per shop).
  3. Copy the key right away. It starts with plx_ and is shown only once.

Send the key with Step 1 (wallet creation)

Use one of the following. The key is only needed when creating the wallet, not in the payment link (Step 2) and not in callbacks.

X-API-Key: plx_…Recommended
HTTP header
Authorization: Bearer plx_…
HTTP header
api_key=plx_…
Query parameter (ends up in server logs more easily)
cURL with header
curl "https://api.paylex.org/control/wallet.php?address=0xF977814e90dA44bFA03b6295A0616a897441aceC&callback=https%3A%2F%2Fwww.example.com%2Forders.php%3Fnumber%3D827746841326" \
  -H "X-API-Key: plx_your_api_key"

Keep your key secret. Call wallet.php from your server only, never from the browser or an app, and never put the key into payment links.

An invalid or revoked key is rejected with HTTP 401 and no wallet is created. If a key leaks, revoke it in the dashboard and create a new one.

Step 1: Create Wallet

GET
https://api.paylex.org/control/wallet.php

What this does

Creates a unique deposit address for one order and links it to your payout wallet. Call it from your server once per order; it is the first step of every payment.

Request Parameters

addressRequired

Your payout wallet on Polygon (0x + 40 hex characters). Use a wallet you control that can receive USDC on Polygon.

Example: 0xF977814e90dA44bFA03b6295A0616a897441aceC

callbackRequired

URL-encoded http(s) URL of your endpoint that receives the payment confirmation (Step 3).

Important: use a unique callback per order, e.g. with the order id. The same callback URL always returns the same wallet, so two orders sharing one callback could not be told apart.
api_keyOptional

Your PayLex API key, see . Payments of this wallet then appear in your dashboard. Prefer the X-API-Key header.

Response Fields

address_in

Encrypted address for the payment link in Step 2. It is already URL-encoded: use it as-is, do not encode it again.

polygon_address_in

The deposit address itself. Callbacks report it as address_in; store it to match payments to the order. Never use it in payment links.

callback_url

Your callback URL exactly as you sent it.

ipn_token

Token for . Store it with your order.

Errors

HTTP 400

{"status":"error","message":"Invalid address or callback"}

The address is not a valid 0x… wallet or the callback is not an http(s) URL.

HTTP 401

{"status":"error","message":"Invalid or revoked API key"}

Only when an API key was sent.

Any other non-200 response is temporary: show an error and let the customer try again.

Example

GET Request
https://api.paylex.org/control/wallet.php?address=0xF977814e90dA44bFA03b6295A0616a897441aceC&callback=https%3A%2F%2Fwww.example.com%2Forders.php%3Fnumber%3D827746841326
GET Request with API key (optional)
https://api.paylex.org/control/wallet.php?address=0xF977814e90dA44bFA03b6295A0616a897441aceC&callback=https%3A%2F%2Fwww.example.com%2Forders.php%3Fnumber%3D827746841326&api_key=plx_your_api_key
Response
{
  "address_in": "k1PrTuxSNpkdPZwdmCm4K3nMjAYo1sx17ea6uG0LunhFbr7SHBGQ8NBs3b5jkQw9RVoyWIbOyqzh7wtEipPbGg%3D%3D",
  "polygon_address_in": "0x32e854bD1270670C832634CA87858fFd9F3e2c78",
  "callback_url": "https://www.example.com/orders.php?number=827746841326",
  "ipn_token": "aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vb3JkZXJzLnBocD9udW1iZXI9ODI3NzQ2ODQxMzI2"
}

Step 3: Handle Callback

GET
Your callback URL from Step 1

What this does

When the payment arrives, PayLex sends a GET request to your callback URL with the payment details. Use it to update the order status and fulfil the purchase.

Callback Parameters

Your original parameters plus the following payment data:

value_coin

Amount received, in units of coin. For stablecoins this equals USD; for other coins (e.g. POL) convert it with the price.

coin

Coin that was paid, usually polygon_usdc (card and bank payments). Direct crypto payments can also arrive as e.g. polygon_usdt or polygon_pol.

value_forwarded_coin

Amount paid out to your wallet (in coin), after fees.

txid_in

Transaction hash of the incoming payment. Unique per payment: use it to process each payment only once.

txid_out

Transaction hash of the payout to your wallet.

address_in

The deposit address, equal to polygon_address_in from Step 1, so you can match the payment to the order.

address_out

JSON object with the receiving wallets and their share of the payment.

uuid / pending

Id of the notification, and pending=0 once the payment is final. Do not fulfil while pending=1.

Example Callback

GET Request to your server
https://www.example.com/orders.php?number=827746841326&coin=polygon_usdc&value_coin=105.6&txid_in=0xa22a82b4aefbc55f6382e1b5c0b4f0e3c034a654df3bcac431f7fed1942e22bc&txid_out=0x94c2c3e84c2021e6bf377aebf8abf03b49570611bb0c336e357d7f4516f56244&uuid=fa7b54e3-55a8-4f01-a9f5-57150ca157b3&address_in=0x32e854bD1270670C832634CA87858fFd9F3e2c78&value_forwarded_coin=98.74&pending=0

Best practices

  • Answer with HTTP 200 once the payment is processed, and quickly. Any other status (or a timeout) counts as failed and the callback may be sent again.
  • Process each txid_in only once, so repeated callbacks do not fulfil an order twice.
  • Keep a secret, random token in your callback URL and check it, so nobody can call your endpoint with made-up data. Also check that address_in matches the stored polygon_address_in.
  • Compare the received value with your order total before you deliver. Provider fees and exchange rates mean it can differ slightly, so allow a tolerance; customers can also pay less than requested. For high-value orders also verify with .
  • Each callback carries the header X-PayLex-Wallet-Ref, the PayLex reference of the wallet (useful for support requests).

Check Payment Status

GET
https://api.paylex.org/control/payment-status.php

What this does

Returns the payment state of a wallet from Step 1. Use it to double-check a callback or on your order confirmation page; the callback stays the primary signal, so do not poll in a tight loop.

Request Parameters

ipn_tokenRequired

The ipn_token from the wallet creation response (Step 1).

Response Fields

status

paid or unpaid. Unpaid responses contain only this field.

value_coin

Amount received, in units of coin.

coin

Coin that was paid, usually polygon_usdc.

txid_out

Transaction hash of the payout to your wallet.

Example

GET Request
https://api.paylex.org/control/payment-status.php?ipn_token=aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vb3JkZXJzLnBocD9udW1iZXI9ODI3NzQ2ODQxMzI2
Responses (unpaid / paid)
{"status": "unpaid"}

{"status": "paid", "value_coin": "105.6", "txid_out": "0x94c2c3e84c2021e6bf377aebf8abf03b49570611bb0c336e357d7f4516f56244", "coin": "polygon_usdc"}

Utility Endpoints

GET

Read-only helpers, no API key needed.

Convert to USD

https://api.paylex.org/control/convert.php

Converts an amount (value) in a currency (from) to USD; the result is in value_coin. Useful to compare a stablecoin value_coin with an order total in another currency.

GET Request
https://api.paylex.org/control/convert.php?value=78.53&from=EUR
Response
{"status": "success", "value_coin": "87.95", "exchange_rate": "1.11994"}

Coin info and price

https://api.paylex.org/crypto/{network}/{coin}/info.php

Minimum amount and current price of a coin in many currencies. The path follows the callback coin: polygon_pol becomes crypto/polygon/pol/info.php. Multiply value_coin by prices.USD to value a non-stablecoin payment.

GET Request
https://api.paylex.org/crypto/polygon/pol/info.php
Response (shortened)
{"coin": "POL", "minimum": "0.50000000", "prices": {"EUR": "0.082977", "USD": "0.092971", ...}}