Skip to content

Using Swft Without WordPress

Swft is platform-agnostic. The WooCommerce plugin automates everything for WP merchants — but any platform can use the API directly.

  1. Your backend creates a checkout session via the Swft API
  2. You redirect the customer to checkout.swft.co.uk/{sessionId}
  3. Customer pays — Swft handles 3DS, Apple Pay, Google Pay
  4. Swft calls your webhook with payment_succeeded
  5. You fulfil the order in your platform
Terminal window
npm install @swft-checkout/js
import { 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 customer
redirectToCheckout(session.sessionUrl)

Configure your webhook URL in the Swft dashboard → Settings → Webhook URL.

import { verifySwftWebhook } from '@swft-checkout/js'
// Express example
app.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 })
})

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,
},
},
})

Full API reference: api.swft.co.uk/docs