Install the medusa-payment-paystack plugin, add it to medusa-config.js under plugins with your PAYSTACK_SECRET_KEY, then add the provider to your region (Settings → Regions → select region → Payment Providers → Enable Paystack). On the storefront, call POST /store/carts/:id/payment-sessions, select paystack, then call POST /store/carts/:id/payment-sessions/:provider_id/authorize to get the Paystack authorization_url.
npm install medusa-payment-paystack
// medusa-config.js
const plugins = [
// ... other plugins
{
resolve: 'medusa-payment-paystack',
options: {
secret_key: process.env.PAYSTACK_SECRET_KEY,
},
},
];
module.exports = {
projectConfig: {
// ... your existing config
},
plugins,
};
Set the environment variable:
PAYSTACK_SECRET_KEY=sk_live_your_key_here
Restart your Medusa server. Then go to the Medusa admin dashboard → Settings → Regions → select your Africa region → Payment Providers → enable Paystack.
// In your Medusa storefront (Next.js example)
async function initializePaystackPayment(cartId) {
// Create payment session
await medusaClient.carts.createPaymentSessions(cartId);
// Select Paystack as provider
var cartData = await medusaClient.carts.setPaymentSession(cartId, {
provider_id: 'paystack',
});
// Authorize payment — plugin calls Paystack initialize and returns the URL
var { cart } = await medusaClient.carts.authorizePayment(cartId);
// The plugin stores the Paystack authorization_url in payment session data
var authUrl = cart.payment_session.data.authorization_url;
window.location.href = authUrl; // redirect to Paystack checkout
}
// On callback page (after Paystack redirects back)
async function completePaystackPayment(cartId, reference) {
// Verify with Paystack and complete the Medusa order
var { type, data } = await medusaClient.carts.complete(cartId);
if (type === 'order') {
router.push('/order/' + data.id + '/confirmed');
}
}
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
See the Paystack plugins guide for other e-commerce platform integrations.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course