Checkout — Node.js SDK

Hosted Checkout

Create a checkout session that redirects customers to a Simiz-hosted payment page:
const transaction = await simiz.transactions.create({
  amount: 10000,
  currency: 'XAF',
  payment_method: 'CHECKOUT',
  payer: {
    name: 'Jane Doe',
    email: 'jane@example.com',
  },
  description: 'Pro Plan — Monthly',
  callback_url: 'https://your-site.com/webhooks/simiz',
  return_url: 'https://your-site.com/success',
  cancel_url: 'https://your-site.com/cancel',
});

// Redirect customer to the checkout page
console.log(transaction.payment_url);
// https://checkout.simiz.io/cs_xxxxxxxxxxxx
Generate shareable payment links:
// Create a payment link
const link = await simiz.paymentLinks.create({
  amount: 15000,
  currency: 'XAF',
  description: 'Invoice #789',
  customer_email: 'customer@example.com',
  redirect_url: 'https://your-site.com/thank-you',
  expires_at: '2024-12-31T23:59:59Z',
  metadata: {
    invoice_id: 'INV-789',
  },
});

console.log(link.url);
// https://simiz.io/p/pl_xxxxxxxxxxxxx

// List payment links
const links = await simiz.paymentLinks.list({ limit: 10 });

// Disable a payment link
await simiz.paymentLinks.disable('pl_xxx');

Express.js integration example

import express from 'express';
import { Simiz } from '@simiz/node-sdk';

const app = express();
const simiz = new Simiz(process.env.SIMIZ_SECRET_KEY);

// Create checkout and redirect
app.post('/checkout', async (req, res) => {
  const { amount, description } = req.body;

  const transaction = await simiz.transactions.create({
    amount,
    currency: 'XAF',
    payment_method: 'CHECKOUT',
    payer: {
      name: req.user.name,
      email: req.user.email,
    },
    description,
    callback_url: `${process.env.BASE_URL}/webhooks/simiz`,
    return_url: `${process.env.BASE_URL}/success`,
    cancel_url: `${process.env.BASE_URL}/cancel`,
  });

  res.redirect(transaction.payment_url);
});