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:
- Sees your business name and the amount due in USD.
- Chooses a coin and a network, for example USDC on Base or USDT on Tron. Only the options enabled for your account are offered.
- Gets the exact crypto amount, the deposit address and a QR code. They can pay from any wallet or exchange.
- 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);import os
from flask import Flask, redirect
from gtrade_payments import Gtrade
app = Flask(__name__)
gtrade = Gtrade(api_key=os.environ["GTRADE_API_KEY"], base_url="https://api.gtradegateway.io")
@app.post("/checkout/<order_id>")
def checkout(order_id):
order = load_order(order_id) # your own lookup
payment = gtrade.payments.create(
amount_usd=order.total_usd,
customer_email=order.email,
metadata={"order_id": order.id},
idempotency_key=f"order-{order.id}",
)
save_order_payment_id(order.id, payment.id) # keep payment.id with the order
return redirect(payment.checkout_url, code=303)<?php
require __DIR__ . '/vendor/autoload.php';
$gtrade = new \Gtrade\Client(getenv('GTRADE_API_KEY'), ['base_url' => 'https://api.gtradegateway.io']);
$order = loadOrder($_POST['order_id']); // your own lookup
$payment = $gtrade->payments->create([
'amount_usd' => $order['total_usd'],
'customer_email' => $order['email'],
'metadata' => ['order_id' => $order['id']],
'idempotency_key' => 'order-' . $order['id'],
]);
saveOrderPaymentId($order['id'], $payment->id); // keep payment.id with the order
header('Location: ' . $payment->checkout_url, true, 303);Good practice:
- Store
payment.idwith 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.paidwebhook or check the status withGET /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).
#Link lifetime and expiry
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.
#Payment links from the dashboard
No website or developer needed: you can create a payment link in the dashboard and send it by email, chat or invoice.
- Sign in to the dashboard.
- Make sure a deposit wallet is set up. Until then, the dashboard prompts you to set one up before you can create payment links.
- Open Payments → Create Payment Link.
- Enter the customer's email and the amount in USD, then select Generate Payment Link.
- 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/paymentsand 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 checkout | Dashboard payment link | |
|---|---|---|
| Best for | Online shops, apps, platforms | Invoices, one-off sales, social selling |
| Developer needed | Yes | No |
| Amount | Set by your code per order | Typed in the dashboard |
Your order data in metadata | Yes | No |
| Webhooks and API access | Yes | Yes |