Documentation

Everything you need to integrate PAYFLUX into your application in minutes.

1. Authentication

All API requests must be authenticated using an API Key. You can generate one from your Merchant Dashboard. Keep your key secret. Never expose it in client-side code.

Base URL: https://fampay-merchant-api.onrender.com/v1

2. Create an Order

Before accepting a payment, you need to create an Order on your server. This secures the amount and generates a unique checkout URL.

POST /api/v1/orders
const response = await fetch('https://fampay-merchant-api.onrender.com/v1/orders', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    apiKey: 'sk_live_123456789',
    amount: 500, // Amount in INR
    returnUrl: 'https://yourwebsite.com/success' // Optional redirect URL
  })
});

const data = await response.json();
// data.data.checkoutUrl contains the Hosted Checkout Link

Redirect your customer to the checkoutUrl. PAYFLUX will handle the QR generation, auto-polling, and success animations.

3. Webhooks (Server Notification)

Even though the Checkout UI redirects the user back to your site, you should rely on Webhooks to fulfill the order securely. Customers might close their browser before the redirect finishes.

Verifying Webhook Signatures

We sign every webhook with a x-payflux-signature header using HMAC-SHA256.

const crypto = require('crypto');

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-payflux-signature'];
  const payload = JSON.stringify(req.body);
  const secret = 'whsec_your_webhook_secret_here';

  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');

  if (signature !== expectedSignature) {
    return res.status(400).send('Invalid signature');
  }

  const event = req.body;
  if (event.event === 'payment.success') {
    // Fulfill the order in your database
    fulfillOrder(event.payload.order.id);
  }

  res.status(200).send('OK');
});

4. Test Mode & Simulation

Test your entire integration end-to-end without spending real money or scanning actual QR codes!

How to use Test Mode

  • Step 1: Go to your Dashboard → API Keys and click Create Test Key.
  • Step 2: Use this key (starts with sk_test_) in your backend when calling the /api/v1/orders endpoint.
  • Step 3: Redirect the user to the checkoutUrl.
  • Step 4: Instead of a real UPI QR code, you will see a "Simulate Success" button. Clicking this button will instantly verify the payment and redirect the user back to your site, exactly as a real payment would!

Note: Test mode payments will also trigger your configured Webhooks, allowing you to thoroughly test your server's webhook handlers without real transactions.

5. Mobile App Integration

Integrating PAYFLUX into your mobile app (React Native, Flutter, Android, iOS) is incredibly simple. You don't need a heavy SDK. Just use an In-App Browser or WebView.

React Native Example

After creating an order via your backend, open the checkoutUrl using Expo WebBrowser or React Native InAppBrowser.

import * as WebBrowser from 'expo-web-browser';

const handlePayment = async () => {
  // 1. Get checkoutUrl from your backend
  const response = await fetch('https://your-backend.com/create-order', { method: 'POST' });
  const data = await response.json();
  
  // 2. Open the Payflux Secure Checkout in an In-App Browser
  if (data.checkoutUrl) {
    await WebBrowser.openBrowserAsync(data.checkoutUrl);
    
    // 3. Once browser is closed, poll your backend for payment status
    checkPaymentStatus(data.orderId);
  }
};

Flutter Example

import 'package:url_launcher/url_launcher.dart';

Future<void> handlePayment() async {
  // 1. Get checkoutUrl from your backend
  final checkoutUrl = await createOrderOnBackend();
  
  // 2. Open Payflux Checkout
  final Uri url = Uri.parse(checkoutUrl);
  if (!await launchUrl(url, mode: LaunchMode.inAppWebView)) {
    throw Exception('Could not launch $url');
  }
}

The checkout page will automatically render the "Pay via UPI App Directly" button on mobile devices, which will seamlessly open PhonePe, GPay, or Paytm installed on the user's phone via Deep Linking (UPI Intent).

6. AI / Vibe Coding Prompts

Building with AI? Use these pre-written prompts to let your AI coding assistant (Cursor, GitHub Copilot, etc.) integrate Payflux for you in seconds.

Master Integration Prompt

Copy this single prompt and paste it into your AI assistant to generate the complete end-to-to integration at once.

I want to integrate the Payflux payment gateway into my project. Here are the complete details:

## Payflux API Details
- Base URL: https://fampay-merchant-api.onrender.com
- Payment Flow: Server-side order creation → Redirect to hosted checkout → UPI QR payment → Auto-verification via IMAP → Webhook notification

## Complete Integration Steps:

### 1. Create Payment Order (Server-Side)
POST https://fampay-merchant-api.onrender.com/api/v1/orders
Body: { apiKey: "YOUR_API_KEY", amount: 500, currency: "INR", customerEmail: "user@email.com", customerName: "User Name", returnUrl: "https://your-site.com/success" }
Response: { success: true, data: { id: "order_id", checkoutUrl: "https://..." } }

### 2. Redirect User to Checkout
Take checkoutUrl from response and redirect browser: window.location.href = data.data.checkoutUrl
The checkout page shows UPI QR code. Payment is auto-verified.

### 3. Verify Payment (Server-Side)
POST https://fampay-merchant-api.onrender.com/api/v1/payments/verify
Body: { apiKey: "YOUR_API_KEY", orderId: "order_id_from_step1" }
Response: { success: true, data: { status: "SUCCESS" | "PENDING" | "FAILED" } }

### 4. Webhook (Optional but Recommended)
Set webhook URL in Dashboard > Webhooks
We POST to your URL with: { event: "payment.success", payload: { order: {...}, transaction: {...} } }
Verify signature using x-payflux-signature header with HMAC-SHA256

## Important Rules:
- Never expose API key in frontend code, always call from backend
- Use TEST keys during development, LIVE keys in production
- Always verify payment server-side before granting access
- Set up webhooks as backup for redirect failures
- In Test Mode (when using sk_test_ keys), the checkout page will show a "Simulate Success" button instead of a QR code. Click it to simulate a successful payment.

Step-by-Step Prompts

If you prefer to build step-by-step, use these individual prompts:

Step 1: Set up Backend Route

"Create a backend API route that calls POST https://fampay-merchant-api.onrender.com/api/v1/orders with my Payflux API key. Accept amount from frontend, create order, and return the checkoutUrl to redirect the user."

Step 2: Frontend Checkout Button

"Create a "Pay Now" button on my frontend. When clicked, call my backend route from Step 1, get the checkoutUrl, and redirect the user to it using window.location.href."

Step 3: Payment Success Page

"Create a success page at /payment-success. When user lands here after payment, extract orderId from URL params, call POST https://fampay-merchant-api.onrender.com/api/v1/payments/verify from my backend to verify the payment, and show success or failure message."

Step 4: Webhook Handler

"Create a webhook endpoint at /api/webhook. It receives POST requests from Payflux with payment events. Verify the x-payflux-signature header using HMAC-SHA256, then process the payment.success event to fulfill orders in my database."

Need Help Integrating?

Our support team and founders are available 24/7 to help you get started.

Contact Support