thelastapi
Get started free

Sell from a static site with a checkout link

To accept payments on a static website, call the checkout API from a backend route to generate a single-use hosted checkout link and redirect the buyer.

On this page 8 sections

To accept payments on a static website, generate a single-use hosted checkout link via an API call from a lightweight backend or serverless route, then redirect your buyer to that URL. Because thelastapi checkout pages expire after 1 hour and are tied to a single buyer session, you cannot hard-code a permanent payment link into static HTML. Instead, a button click on your site triggers a small backend function that requests a fresh checkout session and hands the buyer over to a hosted payment page.

thelastapi acts as the merchant of record from the second your project exists. You can take payments online without opening a merchant account, skip tedious underwriting forms before selling, and never touch card numbers directly in your code.

Why static sites need a dynamic handoff

Static websites offer great performance and security, but selling products requires two safeguards that static HTML alone cannot provide:

  • Secret keys must stay off the client. Creating a checkout requires an API key (VIBIZ_API_KEY or VIBIZ_APP_KEY). If you put these keys in static client-side JavaScript or HTML, any visitor can inspect the page source and steal them.
  • Hosted checkout sessions expire. Every checkout session created by thelastapi is built for one customer and expires after 1 hour. A static link pasted into an anchor tag will break as soon as that window passes.

The standard pattern is straightforward. Your static page renders your sales copy, pricing, and purchase buttons. When a visitor clicks to buy, your front end calls a serverless function, an edge worker, or a small backend handler. That backend route calls thelastapi to generate a checkout session and returns the destination URL. The browser then redirects the customer to complete their purchase on the hosted checkout page.

If you are planning to deploy your site and backend quickly, you can deploy a website from Claude or ChatGPT with nothing installed.

Step 1: Create your product catalog

Before you can send customers to a checkout page, define what you are selling. You can register products and prices using the CLI or plain HTTP requests. Catalogs are separate for each environment: use --dev while building and testing, and run the command without --dev when you are ready to sell live.

Add a product using the CLI:

Terminal
# Add a fixed-price product
vibiz payments products add "Ebook" --amount 2000 --lookup-key dev-handbook --dev

# Add a recurring subscription
vibiz payments products add Pro --amount 1500 --interval month --lookup-key pro-monthly --dev

You can also create products over HTTP with an account key (vz_sk_...):

Terminal
curl https://thelastapi.dev/v1/projects/prj_123/payments/products?env=development \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H 'content-type: application/json' \
  -d '{
    "name": "Ebook",
    "price": {
      "unit_amount_cents": 2000,
      "type": "one_time",
      "lookup_key": "dev-handbook"
    }
  }'

Amounts are always set in the smallest unit of the currency. For US dollars, 2000 equals $20.00. The default currency is usd, but thelastapi supports 35 currencies (such as eur, gbp, cad, aud, and jpy). If you want to charge customers overseas, see our guide on how to sell in multiple currencies.

For full details on catalogs and ad-hoc prices, read the Payments documentation.

Step 2: Set up the checkout route handler

Because checkout links cannot be created securely in the browser, create a simple backend route that holds your secret key. You can run this in Next.js, an edge function, or a lightweight Node server.

Using the @vibiz/app library:

TypeScript
import { vibiz } from '@vibiz/app';

export async function handleCheckoutRequest(userId: string) {
  const session = await vibiz.payments.checkout({
    lookup_key: 'dev-handbook',
    user: userId,
    success_url: 'https://example.com/thanks',
    cancel_url: 'https://example.com/pricing',
    metadata: { source: 'static_landing_page' },
  });

  return session.url;
}

If you do not want to add @vibiz/app as a dependency, call the payments endpoint directly using fetch and your VIBIZ_APP_KEY:

TypeScript
const res = await fetch('https://thelastapi.dev/v1/app/payments/checkout', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.VIBIZ_APP_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    lookup_key: 'dev-handbook',
    user: 'usr_guest',
    success_url: 'https://example.com/thanks',
    cancel_url: 'https://example.com/pricing',
  }),
});

const { url } = await res.json();

Learn more about managing server-side transactions in the Payments in the app (@vibiz/app) reference.

Step 3: Trigger checkout from your static site

On your static web page, hook a button or form submission up to your backend route. When the response arrives, direct the browser to the returned URL.

HTML
<button id="checkout-button">Buy Handbook ($20)</button>

<script>
  const button = document.getElementById('checkout-button');

  button.addEventListener('click', async () => {
    button.disabled = true;
    button.innerText = 'Loading checkout...';

    try {
      const response = await fetch('/api/create-checkout', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
      });

      const data = await response.json();
      if (data.url) {
        window.location.href = data.url;
      } else {
        alert('Could not start checkout.');
        button.disabled = false;
        button.innerText = 'Buy Handbook ($20)';
      }
    } catch (err) {
      alert('Network error. Please try again.');
      button.disabled = false;
      button.innerText = 'Buy Handbook ($20)';
    }
  });
</script>

You can also use this pattern to sell items without pre-registering them in a catalog. For ad-hoc one-off sales, explore how to sell a one-time product with a hosted checkout link.

Step 4: Brand your checkout page

When your buyer leaves your static landing page, the checkout page can reflect your brand's look and feel. You can customize the name, logo, colors, font, and border styling for your project once, and every checkout page will inherit those styles automatically.

Apply your branding via the API:

Terminal
curl -X PATCH https://thelastapi.dev/v1/projects/prj_123/payments?env=production \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H 'content-type: application/json' \
  -d '{
    "brand": {
      "name": "Acme Tools",
      "logo_url": "https://example.com/logo.png",
      "button_color": "#1a73e8",
      "background_color": "#ffffff",
      "font": "inter",
      "border_style": "rounded"
    }
  }'
  • name: Displayed at the top of the page when no logo image is provided.
  • logo_url and icon_url: Direct https URLs to image assets (PNG or JPG), up to 2,000 characters.
  • font: Choose from 26 supported fonts, including inter, roboto, lato, montserrat, and open_sans.
  • border_style: Accepts pill, rounded, or rectangular.

Step 5: Deliver purchases with webhooks

A static site cannot listen for background payment notifications, so your backend route or serverless worker must handle fulfillment. thelastapi sends events as payments clear.

Register your endpoint in development:

Terminal
vibiz payments webhook http://localhost:3000/api/vibiz/webhook --dev

In your webhook handler, verify the raw incoming request signature:

TypeScript
import { vibiz } from '@vibiz/app';

export async function POST(req: Request) {
  let event;
  try {
    event = await vibiz.webhooks.receive(req);
  } catch {
    return new Response('bad signature', { status: 400 });
  }

  if (event.type === 'payment.succeeded') {
    const payment = event.data.object;
    // fulfill the order using payment.user or payment.metadata
  }

  return new Response('ok');
}

The system retries failed deliveries with exponential backoff for up to 3 days, so make sure your code dedupes incoming requests on event.id. Review Webhooks: thelastapi tells the app when someone pays for implementation specifics.

Fees and how money moves

When you accept payments through thelastapi, there are no monthly platform fees or upfront application costs. Fees are deducted directly from each processed payment:

WhatCostNotes
Card processing2.9% + 30¢Most US cards; deducted per transaction
thelastapi platform fee2.0% (200 bps)Deducted from the balance per payment
Dispute fee$15Deducted when opened; returned if won
RefundsOriginal payment amountProcessing and thelastapi fees are not returned
WithdrawalsFreeNo thelastapi withdrawal charge

Live earnings enter your balance under a pending status for a 7-day hold period (hold_days). Once cleared, funds shift to your available balance.

To withdraw funds to your bank account:

  1. Complete identity and bank verification once in the console under Payments ▸ Get paid.
  2. Run vibiz payments withdraw from the CLI or click Withdraw in the console.

To see the movement of funds from customer card to your bank account, review Payments: how money moves.

Ready to take your first transaction? Run vibiz init <name> to launch a project, configure your checkout route, and start collecting card payments today.

Frequently asked questions

Can I put a checkout link directly in my static HTML without a backend?

No, checkout sessions expire after 1 hour and are limited to a single buyer, so you must generate them dynamically using a backend route or serverless function that keeps your API key secure.

What card statement name do my customers see after purchasing?

Buyers see `VIBIZ, INC* <SUFFIX>` on their credit card statements, where the suffix is a custom 1 to 10 character business identifier you define in your project settings.

How long does it take for money from a sale to become available for withdrawal?

Live payments remain in a pending hold status for 7 days before moving to your available balance, after which you can withdraw them directly to your verified bank account.

Does thelastapi support multiple currencies on static checkouts?

Yes, you can set prices or ad-hoc checkouts in 35 supported currencies (including USD, EUR, GBP, CAD, and JPY), and funds are settled into your account balance in USD.