Skip to main content

End-to-End Integration Example

Vibe Coding Banner

๐Ÿš€ Ship Faster with Vibe Coding

Why write boilerplate? Use our ready-made AI Prompts with Cursor, Windsurf, Antigravity, Bolt, or Lovable to generate this entire integration in seconds.Get the Vibe Coding Prompts โ†’

This guide walks through a complete Next.js integration with Paymint, showing both server-side and client-side code.

Prerequisites

  • A Next.js 13+ app with App Router
  • Paymint API key (get from dashboard)
  • An authentication system (Clerk, NextAuth, or Supabase)

Installation

Project Structure

After integration, your project will look like this:

Step 1: Create the API Route (Server-Side)

This catch-all route handles all billing operations securely on the server.
Security: Always get the email from your auth session, never from request body or query params!

Alternative: NextAuth

Alternative: Supabase


Step 2: Set Up the Provider (Client-Side)

Create a providers wrapper that includes the PaymintProvider.
Add the provider to your root layout:

Step 3: Build the Pricing Page

Use the useBilling and useCheckout hooks to display products and handle checkout.

Step 4: Handle Post-Checkout Success

Create a server component to verify the subscription after successful payment.
Subscriptions are created via webhooks. There may be a 1-5 second delay between payment and subscription appearing in the database.

Step 5: Subscription Management

Allow users to manage their subscription (cancel, pause, resume).

Environment Variables

Add your API key to .env.local:
The SDK auto-detects sandbox vs production from your API key prefix - no need for additional configuration!

Whatโ€™s Next?

Next.js SDK Reference

Complete API reference for hooks and server utilities

Server SDK Reference

Server-side utilities for advanced use cases