Payment Links integration
This guide walks through a common merchant-backend sequence: create catalog items, configure receiving in the dashboard, create a Payment Link, create a checkout (payment) session, then hand off the hosted checkout URL to the payer. Field-level requirements live in the API reference and the resource pages linked at the end; here we only keep order of operations and what each step is for.
Prerequisites
- Node.js 18+ and
gstable-js(Package & module formats). - An API key that can manage products, payment links, and checkout sessions.
- You know which settlement token and line items you will use (Products, Payment links, Checkout sessions).
Integration sequence
At a high level the flow is:
- Create products — Build or reuse catalog rows (
productIds) for your link and session line items. - Create a receiving account in the GStable dashboard — Accounts are not created through the SDK; use the merchant console to add the receiving account and copy its
accountIdfor API calls. The SDK’sclient.accountnamespace is read-only (list/detail). - Create a Payment Link — Call
client.paymentLink.createwith thataccountId, settlement token, fee model, and line items. KeeplinkId(andlinkUrlif your product uses it) from the response. - Create a payment (checkout) session — Call
client.checkoutSession.createwith the same kind of account / settlement / line item context your checkout needs. The response includespaymentUrl. - Open the checkout page — Redirect or share
paymentUrlto the customer so they complete pay-in on the hosted page.
Some teams use
linkUrlfrom step 3 alone, others rely onpaymentUrlfrom step 4—pick the path your product and operations agreed on, and keep payloads aligned with the references above.
Step 1 — Products
const product = await client.product.create({
// Fields per API / Products reference
});
const productId = product.productId;
Or reuse existing catalog rows:
const { products } = await client.product.list(1, 50);
Step 2 — Account in the dashboard
Create and configure the receiving account in the GStable merchant dashboard. Note the accountId you will pass into client.paymentLink.create and client.checkoutSession.create.
To verify from code:
const accounts = await client.account.list();
Step 3 — Payment Link
const link = await client.paymentLink.create({
// accountId, settlementToken, feeModel, lineItems, … — see Payment links reference
});
// Store link.linkId; use link.linkUrl when your flow needs the link-hosted entry point
Step 4 — Checkout session
const session = await client.checkoutSession.create({
// accountId, settlementToken, lineItems, … — see Checkout sessions reference
});
const checkoutPageUrl = session.paymentUrl;
Step 5 — Checkout page link
Send checkoutPageUrl (session.paymentUrl) to your frontend or customer channel (redirect, email, etc.) so they land on hosted checkout.
Optional — Operating the link later
| Goal | SDK |
|---|---|
| Pause new pay-ins | client.paymentLink.disable(linkId) |
| Resume | client.paymentLink.enable(linkId) |
| Full metadata / item updates | client.paymentLink.update({ ... }) |
| Inspect configuration | client.paymentLink.detail(linkId) |
| Operator list UI | client.paymentLink.list(page, size) |
Optional — After payment
Use webhooks or redirect parameters to receive a session id, then client.checkoutSession.detail(sessionId) (and status-scoped list helpers if you run ops queues) for reconciliation—see Webhooks and Checkout sessions.
Operational tips
- Retries — Follow platform guidance; pass idempotency fields only when the API documents them for that operation.
- Partial catalog reads —
product.listByIdsmay omit unknown ids; handle partial results in your UI. - Errors — Map
GStableError/GStableProductErroras needed; see Error codes.
Further reading
- Payment links (SDK API)
- Products (SDK API)
- Checkout sessions (SDK API)
- Site Guides → Payment Link chapters.