Using Swft Without WordPress
Swft is platform-agnostic. The WooCommerce plugin automates everything for WP merchants — but any platform can use the API directly.
How it works
Section titled “How it works”- Your backend creates a checkout session via the Swft API
- You redirect the customer to
checkout.swft.co.uk/{sessionId} - Customer pays — Swft handles 3DS, Apple Pay, Google Pay
- Swft calls your webhook with
payment_succeeded - You fulfil the order in your platform
Quick start
Section titled “Quick start”npm install @swft-checkout/jsimport { createSession, redirectToCheckout } from '@swft-checkout/js'
// 1. Create session (run server-side — never expose your API key client-side)const session = await createSession({ merchantApiKey: process.env.SWFT_MERCHANT_API_KEY, currency: 'GBP', lineItems: [ { name: 'Midnight Runner Pro', quantity: 1, price: 12999 }, ], shippingMethods: [ { id: 'standard', label: 'Standard Shipping', cost: 499 }, { id: 'express', label: 'Express Shipping', cost: 999 }, ], subtotal: 12999,})
// 2. Redirect customerredirectToCheckout(session.sessionUrl)Receiving webhooks
Section titled “Receiving webhooks”Configure your webhook URL in the Swft dashboard → Settings → Webhook URL.
import { verifySwftWebhook } from '@swft-checkout/js'
// Express exampleapp.post('/webhooks/swft', express.raw({ type: 'application/json' }), async (req, res) => { const payload = await verifySwftWebhook( req.body, req.headers['x-swft-signature'], process.env.SWFT_WEBHOOK_SECRET )
if (payload.event === 'payment_succeeded') { // Create order in your system await createOrder({ customer: payload.customer, items: payload.lineItems, address: payload.shippingAddress, amount: payload.amount, currency: payload.currency, referenceId: payload.sessionId, }) }
res.json({ received: true })})Platform guides
Section titled “Platform guides”- Next.js — App Router + Pages Router
- Medusa.js — v2 plugin
- Vanilla JS — any platform
- WooCommerce — WordPress plugin (automatic)
Passing extension data
Section titled “Passing extension data”Swft modules (order bumps, gift options, funnels, etc.) are configured via the extensions field:
const session = await createSession({ // ... extensions: { order_bumps: [{ product_id: 456, headline: 'Add matching socks!', price: 699, original_price: 999, discount_label: '30% OFF', }], gift_options: { message: 'Happy Birthday!', wrap: true, wrap_price: 399, }, },})API reference
Section titled “API reference”Full API reference: api.swft.co.uk/docs