Use the Paystack Product API (POST /product) to create products with a name, description, price, and currency. Each product can be linked to a payment page, giving you a shareable URL for purchasing that product. This works for simple storefronts with a few products. For inventory management, cart functionality, or complex pricing, build a custom integration.
async function createProduct(name, description, priceInKobo, currency) {
var response = await fetch('https://api.paystack.co/product', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: name,
description: description,
price: priceInKobo,
currency: currency,
unlimited: true, // No stock limit
}),
});
var data = await response.json();
if (data.status) {
return {
id: data.data.id,
productCode: data.data.product_code,
name: data.data.name,
price: data.data.price,
};
}
throw new Error('Failed to create product: ' + data.message);
}
// Create some products
var ebook = await createProduct(
'M-Pesa Integration Guide (PDF)',
'A 120-page PDF covering Daraja API integration for Node.js developers.',
999900, // 9,999 NGN
'NGN'
);
var course = await createProduct(
'Full-Stack AI Engineering Course',
'26-week live bootcamp with mentorship.',
12000000, // 120,000 NGN
'NGN'
);
Product fields:
name: Product name shown to customersdescription: Detailed description of the productprice: Price in smallest currency unit (kobo for NGN)currency: Currency code (NGN, GHS, ZAR, KES, USD)unlimited: Set to true for unlimited stock, or false with a quantity for limited stockimage: Optional product image URL// List all products
async function listProducts() {
var response = await fetch('https://api.paystack.co/product', {
headers: {
Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
},
});
var data = await response.json();
return data.data;
}
// Get a specific product
async function getProduct(productId) {
var response = await fetch('https://api.paystack.co/product/' + productId, {
headers: {
Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
},
});
var data = await response.json();
return data.data;
}
// Update a product (e.g., change price)
async function updateProduct(productId, updates) {
var response = await fetch('https://api.paystack.co/product/' + productId, {
method: 'PUT',
headers: {
Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(updates),
});
var data = await response.json();
return data.data;
}
// Update price
await updateProduct(ebook.id, { price: 799900 }); // New price: 7,999 NGN
Products are also visible and editable in the Paystack dashboard. Non-technical team members can update prices, descriptions, and stock levels from the dashboard while your code handles the integration.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
The most straightforward way to sell a product is to connect it to a payment page. The page becomes the storefront for that product.
// Create a payment page linked to a product
async function createProductPage(product) {
var response = await fetch('https://api.paystack.co/page', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: product.name,
amount: product.price,
description: product.description,
slug: product.name.toLowerCase().replace(/[^a-z0-9]+/g, '-'),
redirect_url: 'https://yoursite.com/thank-you',
metadata: {
product_code: product.productCode,
},
}),
});
var data = await response.json();
return {
pageUrl: 'https://paystack.com/pay/' + data.data.slug,
pageId: data.data.id,
};
}
var ebookPage = await createProductPage(ebook);
console.log('Buy here: ' + ebookPage.pageUrl);
// Share this URL on social media, WhatsApp, email, etc.
Now you have a URL you can share anywhere. When a customer visits that URL, they see the product details and can pay immediately. No website needed.
If you want a page that shows multiple products, you can build a simple HTML page that lists your products with "Buy" buttons linking to their payment pages:
<!-- Simple storefront - static HTML -->
<div class="products">
<div class="product">
<h3>M-Pesa Integration Guide (PDF)</h3>
<p>120-page PDF for Node.js developers</p>
<p><strong>N9,999</strong></p>
<a href="https://paystack.com/pay/mpesa-guide">Buy Now</a>
</div>
<div class="product">
<h3>Full-Stack AI Engineering Course</h3>
<p>26-week live bootcamp with mentorship</p>
<p><strong>N120,000</strong></p>
<a href="https://paystack.com/pay/fullstack-ai">Buy Now</a>
</div>
</div>
This "storefront" is just a static HTML page with links. Each "Buy Now" button takes the customer to the corresponding Paystack payment page. You can host this HTML file on any static hosting (GitHub Pages, Netlify, Vercel, or even a Google Drive shared page).
For digital products, set up a webhook handler that delivers the product (sends a download link, grants access) when the payment succeeds. Without the webhook, you would need to check your dashboard manually for each sale.
Payment pages and the Product API do not handle fulfillment. When a customer pays, you need a separate mechanism to deliver the product. Webhooks are that mechanism.
// Webhook handler for product sales
app.post('/webhooks/paystack', function(req, res) {
res.sendStatus(200);
var event = req.body;
if (event.event === 'charge.success') {
var metadata = event.data.metadata || {};
var productCode = metadata.product_code;
var customerEmail = event.data.customer.email;
if (productCode === 'PROD_mpesaguide') {
// Send the PDF download link
sendDownloadLink(customerEmail, 'https://yoursite.com/downloads/mpesa-guide.pdf');
} else if (productCode === 'PROD_fullstackai') {
// Create a course account
createCourseAccess(customerEmail);
}
}
});
Without this webhook handler, sales happen but you deliver manually. For a few sales a week, manual delivery works. For dozens or hundreds, automate it.
The Product API and payment pages are a starting point. You will outgrow them when you need:
When these needs arise, build a custom checkout using Initialize Transaction. Your backend manages products, pricing, and inventory. Paystack handles the payment collection. This is the natural evolution from "quick and simple" to "full-featured store."
For the complete guide to custom integration, see accepting payments with Paystack.
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