Merchant.js is the ultimate JavaScript SDK for managing payments, subscriptions, inventory, and more with zero backend required.
Integrate Stripe, PayPal, Apple Pay and more with pre-built UI components that auto-localize for 180+ markets.
Create customizable billing plans with dunning management, tax calculations, and proration automation.
Track global stock levels in real-time with automatic reordering alerts and demand forecasting tools.
// Start by creating a merchant instance
const merchant = new Merchant({
apiKey: 'your_api_key_here',
environment: 'production' // or 'staging'
});
// Create a checkout flow
merchant.checkout
.create({
items: [
{ product_id: 'sku123', quantity: 1 },
{ gift_card: 'custom', amount: 25 }
],
successUrl: 'https://yourapp.com/confirmed',
cancelUrl: 'https://yourapp.com/cancel'
})
.then(redirectUrl => {
window.location.href = redirectUrl;
});