Medusa.js
npm install @swft-checkout/medusa @swft-checkout/jsimport { defineConfig } from '@medusajs/medusa'
export default defineConfig({ plugins: [{ resolve: '@swft-checkout/medusa', options: { merchantApiKey: process.env.SWFT_MERCHANT_API_KEY, webhookSecret: process.env.SWFT_WEBHOOK_SECRET, }, }],})Create checkout session
Section titled “Create checkout session”import { SwftSessionService } from '@swft-checkout/medusa'
const swft = new SwftSessionService({ merchantApiKey: process.env.SWFT_MERCHANT_API_KEY,})
// In your storefront API route:const session = await swft.createFromCart(cart)return { sessionUrl: session.sessionUrl }Webhook
Section titled “Webhook”The plugin registers POST /webhooks/swft automatically. Set your webhook URL in the Swft dashboard to https://your-medusa-instance.com/webhooks/swft.
Environment variables
Section titled “Environment variables”| Variable | Description |
|---|---|
SWFT_MERCHANT_API_KEY | From swft.co.uk/dashboard |
SWFT_WEBHOOK_SECRET | From Swft dashboard → Settings → Webhook Secret |