# Payment links & Payment Buttons

> Real output captured from a running server in test mode (2026-10-02).

A **payment link** is a shareable page (`https://razcryptogateway.com/l/{slug}`) — send it on
WhatsApp, email or as a QR; no code needed. A **Payment Button** is the same thing embedded on a
website that has no server (static sites): the price lives in your dashboard, so nobody can change it
in the browser. Every submission creates a normal [payment](/docs/payments); all payment webhooks apply.

## Create — `POST /v1/payment_links`
| Param | Type | Notes |
|---|---|---|
| `kind` | `link` (default) · `button` | Buttons default to `reusable` and enforce your app's allowed origins |
| `title` | string ≤ 120 | Shown on the page |
| `description`, `customer_name` | string | Optional |
| `amount_type` | `fixed` · `custom` | `custom` = customer types the amount |
| `amount` | decimal string | Required for `fixed` |
| `currency` | fiat code or coin symbol | e.g. `USD`, `INR`, `EUR`, `USDT` |
| `min_amount`, `max_amount` | decimal strings | Limits for `custom` |
| `collect` | `{ name, email, phone }` | each `off` · `optional` · `required` |
| `usage` | `one_time` · `reusable` | One-time links become `completed` after the first paid payment |
| `allowed_chains`, `allowed_coins` | string[] | Optional restrictions |
| `redirect_url` | URL | Where the customer goes after paying |
| `expires_at` | ISO time | Optional |
| `metadata` | object | Copied to every payment |

```bash
curl https://razcryptogateway.com/v1/payment_links \
  -H "Authorization: Bearer sk_test_…" -H "Content-Type: application/json" \
  -d '{"title":"Logo design — 50% advance","customer_name":"Ravi Traders","amount_type":"fixed","amount":"120.00","currency":"USD","collect":{"name":"required","email":"optional"},"usage":"one_time"}'
```
```json
{
  "id": "lnk_heWqzHlk5QC2SWzGMBk9",
  "object": "payment_link",
  "livemode": false,
  "kind": "link",
  "url": "https://razcryptogateway.com/l/3qH4EiHq",
  "slug": "3qH4EiHq",
  "title": "Logo design — 50% advance",
  "description": null,
  "customer_name": "Ravi Traders",
  "amount_type": "fixed",
  "amount": "120",
  "currency": "USD",
  "min_amount": null,
  "max_amount": null,
  "collect": {
    "name": "required",
    "email": "optional",
    "phone": "off"
  },
  "usage": "one_time",
  "status": "active",
  "allowed_chains": null,
  "allowed_coins": null,
  "redirect_url": null,
  "expires_at": null,
  "metadata": {},
  "stats": {
    "views": 0,
    "payments": 0,
    "paid_count": 0,
    "paid_amount": "0"
  },
  "created_at": "2026-10-02T12:51:14.858Z"
}
```

## Other endpoints
| Method | Path | Notes |
|---|---|---|
| GET | `/v1/payment_links/{id}` | Includes `stats` (`views`, `payments`, `paid_count`, `paid_amount`) |
| GET | `/v1/payment_links` | Filters `status`, `kind`; newest first, `limit` (default 20, max 100). Next page: `starting_after={next_cursor}` while `has_more` is true |
| PATCH | `/v1/payment_links/{id}` | `title`, `description`, `expires_at`, `redirect_url`, `metadata`, `status` (`active`/`inactive`) |
| POST | `/v1/payment_links/{id}/deactivate` | Shortcut for `status: "inactive"` |
| GET | `/v1/payments?payment_link={id}` | Payments made through the link (`payment.payment_link` = link id) |

Statuses: `active`, `inactive`, `completed` (one-time link paid), `expired`.
Event: `payment_link.completed` when a one-time link is paid.

## Public link page API (used by our page; no key)
`GET https://razcryptogateway.com/checkout/v1/links/{slug}` → what the page shows (counts a view):
```json
{
  "object": "payment_link_public",
  "title": "Logo design — 50% advance",
  "description": null,
  "customer_name": "Ravi Traders",
  "amount_type": "fixed",
  "amount": "120",
  "currency": "USD",
  "min_amount": null,
  "max_amount": null,
  "collect": {
    "name": "required",
    "email": "optional",
    "phone": "off"
  },
  "test_mode": true,
  "merchant": {
    "name": "Docs Demo Store",
    "accent_color": null,
    "logo_url": null
  }
}
```
`POST https://razcryptogateway.com/checkout/v1/links/{slug}/payments` with `{ "amount"?, "name"?, "email"?, "phone"? }`
(per the link's `collect` rules) → creates the payment and returns where to send the customer:
```json
{
  "payment_id": "pay_hO8lGPIIJhYlNZ5jVPJS",
  "checkout_url": "https://razcryptogateway.com/pay_hO8lGPIIJhYlNZ5jVPJS?t=ct_…"
}
```
Missing a required field:
```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_missing",
    "message": "name is required",
    "param": "name",
    "request_id": "req_tAIwIJxz37T7PZWf",
    "doc_url": "https://razcryptogateway.com/docs/errors#parameter_missing"
  }
}
```

## Payment Button for a static website (no server needed)
1. Dashboard → Payment links & buttons → **Buttons** → New payment button (fixed price, or the customer
   enters the amount).
2. Click **Embed code** and paste it where the button should appear:
```html
<script src="https://razcryptogateway.com/v1/checkout.js" async></script>
<button type="button" data-razcrypto-button="O7MTkxHr">Pay with crypto</button>
```
`checkout.js` wires every `data-razcrypto-button` automatically. To open it from your own code:
```js
RazCrypto.openButton({ button: "O7MTkxHr", onSuccess: (res) => console.log(res), onClose: () => {} });
```
The customer pays in a popup on your page. The price lives in your dashboard, so it cannot be changed in
the browser. Confirm orders from webhooks or the dashboard — the browser result alone should not unlock
paid content.
