GTRADEDocs
Accept payments

Hosted checkout & payment links

Every payment has a hosted GTRADE checkout page. Send customers there from your integration, or create a payment link in the dashboard without writing any code.

#How the hosted checkout works

Every Payment has a checkout_url on https://checkout.gtradegateway.io. On that page your customer:

  1. Sees your business name and the amount due in USD.
  2. Chooses a coin and a network, for example USDC on Base or USDT on Tron. Only the options enabled for your account are offered.
  3. Gets the exact crypto amount, the deposit address and a QR code. They can pay from any wallet or exchange.
  4. Watches the payment being detected and confirmed in real time.

You don't handle addresses, exchange rates or blockchain confirmations. GTRADE does, and your server sees the result as the payment status and webhooks.

#Send customers to the checkout

Create the payment on your server, then redirect the browser to checkout_url:

const express = require('express');
const { Gtrade } = require('gtrade-payments');

const app = express();
const gtrade = new Gtrade({ apiKey: process.env.GTRADE_API_KEY, baseUrl: 'https://api.gtradegateway.io' });

app.post('/checkout/:orderId', async (req, res) => {
  const order = await loadOrder(req.params.orderId); // your own lookup
  const payment = await gtrade.payments.create({
    amountUsd: order.totalUsd,
    customerEmail: order.email,
    metadata: { order_id: order.id },
    idempotencyKey: `order-${order.id}`,
  });
  await saveOrderPaymentId(order.id, payment.id); // keep payment.id with the order
  res.redirect(303, payment.checkout_url);
});

app.listen(process.env.PORT || 3000);

Good practice:

  • Store payment.id with your order before redirecting, so webhooks and polling can find the order.
  • Use the order id in the idempotency key, so a double-clicked "Pay" button reuses the same payment.
  • Don't trust the browser. A customer returning to your site doesn't prove payment. Wait for the payment.paid webhook or check the status with GET /v1/payments/{id}.
  • The API doesn't take a return URL. Show the customer how to get back to your site (for example, open the checkout in a new tab and keep an order status page open that polls your server).

A checkout link is valid for a limited time; the checkout shows the customer how long they have. When it expires before the customer pays, the payment becomes cancelled. If the customer still wants to pay, create a new payment with a new idempotency key and send them the new link. See also expired links.

Warning: Tell customers to send the exact amount shown, on the network shown. Funds sent on another network, or in a coin other than the one selected, may not be detected automatically. Contact support if that happens.

No website or developer needed: you can create a payment link in the dashboard and send it by email, chat or invoice.

  1. Sign in to the dashboard.
  2. Make sure a deposit wallet is set up. Until then, the dashboard prompts you to set one up before you can create payment links.
  3. Open Payments → Create Payment Link.
  4. Enter the customer's email and the amount in USD, then select Generate Payment Link.
  5. Use Copy link and send the link to your customer.

The customer pays on the same hosted checkout as API payments. You can follow the payment under Payments → All Payments.

Payments created from dashboard links:

  • appear in GET /v1/payments and can be retrieved by id like any other payment;
  • trigger the same webhook events as API payments;
  • have empty metadata ({}), because metadata can only be set through the API.

#Which one should I use?

API + hosted checkoutDashboard payment link
Best forOnline shops, apps, platformsInvoices, one-off sales, social selling
Developer neededYesNo
AmountSet by your code per orderTyped in the dashboard
Your order data in metadataYesNo
Webhooks and API accessYesYes