Payment links
A payment link is a page OnCharge hosts for you, https://app.oncharge.io/l/<code>, that takes a payment without a website or a cart. Share it by email, chat or social media, or print its QR code. Customers see your store's name, what they are paying for, and pay by card or crypto, whichever your store has turned on.
Every payment through a link is an ordinary OnCharge checkout session. It shows under Payments → Transactions, can be refunded and disputed like any other payment, fires the usual webhooks, and is paid out on the usual terms: goods you ship are paid out once the carrier confirms delivery (Shipments & payouts).
Make a link#
In the dashboard, open Payments → Payment links and choose New link. Or call POST /api/v1/payment-links, signed like every merchant API request (Authentication):
{
"title": "Consultation deposit",
"amount": 5000,
"currency": "USD",
"collect_phone": true,
"success_url": "https://shop.example.com/thank-you"
}{
"id": "5f0c9d4e-2a1b-4c3d-9e8f-7a6b5c4d3e2f",
"object": "payment_link",
"code": "k7Hq2mNpR4sT",
"url": "https://app.oncharge.io/l/k7Hq2mNpR4sT",
"title": "Consultation deposit",
"amount_type": "fixed",
"amount": 5000,
"currency": "USD",
"status": "active",
"stats": { "views": 0, "checkouts": 0, "payments": 0, "revenue": 0, "refunded": 0 },
"qr_code": "data:image/svg+xml;base64,…"
}| Field | What it does |
|---|---|
title, description | What the customer sees. |
amount_type | fixed (default): the customer pays amount per item. customer_chosen: they enter an amount between min_amount and max_amount (useful for donations, tips and deposits); preset_amount pre-fills it. |
currency | Default USD. Card payments are USD only on stores paid out per delivered order. |
adjustable_quantity, max_quantity | Let the customer choose how many (up to max_quantity, at most 99). |
collect_shipping | Ask for a shipping address. Required if your store ships what it sells: the order is paid out once the carrier confirms delivery to that address. |
collect_phone | Ask for a phone number. The customer's email is always asked for. |
success_url | Where a paid customer goes next. It must be https on one of your store's registered domains (Integrations → Domains). Without it, they see an OnCharge thank-you page. |
rails | ["card"], ["crypto"] or both (default). Your store must have the way to pay turned on. |
expires_at | When the link stops taking payments (at most two years ahead). |
Amounts are in minor units (cents). A link takes payments from 50 cents up to $10,000 each: amount × max_quantity, or max_amount, must stay within $10,000.
With the Node SDK:
import { OnCharge } from '@oncharge/node';
const oncharge = new OnCharge({ apiKey: process.env.ONCHARGE_API_KEY!, apiSecret: process.env.ONCHARGE_API_SECRET! });
const link = await oncharge.paymentLinks.create({ title: 'Tip jar', amount_type: 'customer_chosen', min_amount: 100, max_amount: 50000 });
console.log(link.url);Track and manage links#
GET /api/v1/payment-linkslists your links, newest first (active,limitandbeforeto page), each withstats: views, checkouts started, payments, revenue (before refunds) and what was refunded.GET /api/v1/payment-links/{id}returns one link with its QR code.POST /api/v1/payment-links/{id}changes any field, or turns the link off ("active": false) and back on ("active": true).POST /api/v1/payment-links/{id}/deactivateturns it off. Its payments stay; a visit says the link is no longer active, and checkouts already started from it can't be completed (a crypto payment whose address was already given out can still finish). The same applies when a link expires or your store is not active.
In the SDK: paymentLinks.list(), retrieve(), update() and deactivate().
Payments and webhooks#
When a customer pays, OnCharge creates a checkout session for the amount × quantity and sends them to OnCharge's hosted checkout. Its webhooks are the ones you already handle (payment.authorized, payment.captured, payment.refused, refund.* and chargeback.*), with data.payment_link_id set to the link's id (and data.reference to link_<code>) so you can tell which link a payment came from. To ship the order, report its tracking number with the event's session_id (Shipments & payouts).
Protection against card testing#
Links are public, so OnCharge screens every checkout they start:
- Rate limits per visitor and per link.
- A visitor whose cards are declined several times on a link can't start more checkouts there for a while; a link that sees a run of declines from several visitors pauses itself for a few minutes. One visitor alone can't pause your link for everyone.
- Your risk policy runs before the checkout is created (in
enforcemode a deny refuses it) and again on the checkout page. - The global ban list applies as on every checkout.