Payment Sessions

Payment Links

Short, shareable URLs for easy payment collection

Every session gets two URLs for sharing: a full checkout URL and a short payment link. Short links are easier to share via SMS, WhatsApp, or print.


TypeExampleUse Case
Full Checkoutsnippe.me/checkout/W0SzdUSHQmDirect embedding, apps
Short Linksnippe.me/p/Ax7kM2SMS, WhatsApp, print, sharing

Session Response

When you create a session, both URLs are included:

{
  "code": 201,
  "data": {
    "reference": "sess_abc123def456",
    "checkout_url": "https://snippe.me/checkout/W0SzdUSHQm",
    "short_code": "Ax7kM2",
    "payment_link_url": "https://snippe.me/p/Ax7kM2"
  }
}
FieldDescription
checkout_urlFull checkout URL with unique token
short_codeShort code for payment links
payment_link_urlComplete short payment link URL

GET /p/:code

Returns a 302 redirect to the full checkout URL:

302 → https://snippe.me/checkout/:token

Usage

Redirect your customers to either checkout_url or payment_link_url. They complete payment on Snippe's hosted checkout page, then get redirected back to your redirect_url.

// After creating a session
const session = await createSession({
  amount: 50000,
  redirect_url: "https://yoursite.com/order/complete",
});

// Redirect customer to payment
window.location.href = session.payment_link_url;

Or share the link directly:

Your payment link: https://snippe.me/p/Ax7kM2

URL Metadata

Every payment link can carry a base64-encoded metadata blob via a ?meta= query parameter. When the customer pays, the same blob is delivered back to your webhook at data.metadata.url_metadata — so your system knows exactly what the payment was for without a separate API call or phone-number lookup.

This turns a payment link into a programmable endpoint: attach an order ID, plan, or user reference to the URL, and let the webhook close the loop.

How it works

Build the metadata object

Any JSON object you want to attach to the link.

{
  "ref": "ORDER-4421",
  "customer_id": "usr_882",
  "plan": "premium"
}

Base64-encode the JSON

import base64, json

metadata = {
    "ref": "ORDER-4421",
    "customer_id": "usr_882",
    "plan": "premium",
}

meta = base64.b64encode(json.dumps(metadata).encode()).decode()
const metadata = {
  ref: "ORDER-4421",
  customer_id: "usr_882",
  plan: "premium",
};

const meta = Buffer.from(JSON.stringify(metadata)).toString("base64");
$metadata = [
    'ref' => 'ORDER-4421',
    'customer_id' => 'usr_882',
    'plan' => 'premium',
];

$meta = base64_encode(json_encode($metadata));
https://snippe.me/p/your-page-slug?meta=eyJyZWYiOiJPUkRFUi00NDIxIiwi...

Share that URL with your customer. They pay normally — the ?meta= parameter is invisible to them.

Read it back from the webhook

Snippe forwards the decoded object on the payment.completed event:

{
  "type": "payment.completed",
  "data": {
    "reference": "PAY17752236163664285",
    "amount": { "value": 15000, "currency": "TZS" },
    "metadata": {
      "page_id": "abc-123",
      "url_metadata": {
        "ref": "ORDER-4421",
        "customer_id": "usr_882",
        "plan": "premium"
      }
    },
    "completed_at": "2026-04-04T14:32:00Z"
  }
}

Read data.metadata.url_metadata and act on it — credit the account, unlock the file, mark the invoice paid, etc.

When to use this

  • SaaS top-ups — encode { user_id, package, credits } and credit the account on payment.completed.
  • WhatsApp/Instagram orders — encode the order reference so your bot can confirm and dispatch.
  • Affiliate or creator attribution — give each partner a link with their ID baked in.
  • Invoices and tickets — encode the invoice ID so your system marks it paid without a manual lookup.

The metadata is base64-encoded for transport, not encrypted — anyone who inspects the URL can decode it. Don't put secrets, PII, or anything you wouldn't be comfortable putting in a query string.

Always verify the webhook signature before trusting url_metadata. Without verification, an attacker could POST a forged event with arbitrary metadata to your webhook URL.


Best Practices

Short links are easier to share via SMS, WhatsApp, or in printed materials.

Always Set redirect_url

Configure redirect_url when creating the session so customers return to your site after payment.

Configure Webhooks

Don't rely solely on redirects. Use webhooks to confirm payment status server-side.

On this page