Learn by example with our reference implementations and sample applications that demonstrate common ZenPay integrations.
These complete applications demonstrate best practices for integrating ZenPay into your projects. All examples are available on GitHub with step-by-step setup instructions.
React + Node.js implementation
A complete e-commerce store with product listings, shopping cart, and checkout process.
Next.js + TypeScript implementation
A SaaS application with user authentication and subscription management.
React Native implementation
A React Native app demonstrating mobile payment processing with ZenPay.
Python + Django implementation
A marketplace application with multi-vendor payments and Connect integration.
For targeted implementations, explore these code snippets that showcase specific features of the ZenPay API.
Create a basic checkout form for one-time payments
// Create a payment intent on your server
const paymentIntent = await zenpay.paymentIntents.create({
amount: 1999,
currency: 'usd',
payment_method_types: ['card'],
});
// Pass the client secret to your frontend
res.send({ clientSecret: paymentIntent.client_secret });
// Then on your frontend
const {error, paymentIntent} = await zenpay.confirmCardPayment(
clientSecret,
{
payment_method: {
card: cardElement,
billing_details: {
name: 'Jenny Rosen',
},
},
}
);
if (error) {
// Show error to your customer
} else if (paymentIntent.status === 'succeeded') {
// Show success message
}Create a subscription with a free trial
// Create a customer
const customer = await zenpay.customers.create({
email: 'customer@example.com',
payment_method: 'pm_card_visa',
invoice_settings: {
default_payment_method: 'pm_card_visa',
},
});
// Create a subscription with a 14-day trial
const subscription = await zenpay.subscriptions.create({
customer: customer.id,
items: [
{ price: 'price_premium_monthly' },
],
trial_period_days: 14,
});
// Check subscription status
console.log(subscription.status); // 'trialing'Follow these steps to run any example application locally:
git clone https://github.com/zenpay/example-ecommerce.git
cd example-ecommerceCreate a .env file based on the provided .env.example:
ZENPAY_PUBLIC_KEY=pk_test_...
ZENPAY_SECRET_KEY=sk_test_...
WEBHOOK_SECRET=whsec_...npm install
npm run dev