Demo mode: nothing is sent anywhere. Every step below is simulated so you can see the flow.

Checkout

A minimal store page. Clicking “Pay” starts the integration on the right.

PRO
Pro plan — 1 month
Example product
Total

What happens

  1. 1
    Your server → PayerFox API

    Create a payment

    POST /payments with the amount, order ID and return URLs.
  2. 2
    Customer → hosted checkout

    Customer pays

    Send the customer to checkout_url. PayerFox shows the payment methods and handles the payment.
  3. 3
    PayerFox → your server

    Confirm the payment

    Mark the order paid when the webhook arrives. This demo also polls the status so you can watch it change.

Move to production

Keep the store page; move step 1 to your server and confirm orders with the webhook.

Node.js (Express) — create the payment on your server
// npm install express
import express from 'express';
const app = express();
app.use(express.json());

const API_URL = process.env.PAYERFOX_API_URL; // e.g. https://api.example.com/api/v1
const API_KEY = process.env.PAYERFOX_API_KEY; // pd_live_… (keep it on the server)

app.post('/checkout', async (req, res) => {
  const order = await createOrderInYourDatabase(req.body); // your code

  const r = await fetch(`${API_URL}/payments`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      'Content-Type': 'application/json',
      'Idempotency-Key': order.id,          // safe to retry
    },
    body: JSON.stringify({
      amount: order.total,                  // "499.00"
      currency: 'INR',
      merchantOrderId: order.id,
      customerEmail: order.email,
      successUrl: 'https://yourstore.com/order/success',
      cancelUrl: 'https://yourstore.com/order/cancel',
      ipnUrl: 'https://yourstore.com/webhooks/payerfox',
    }),
  });
  const { success, data, message } = await r.json();
  if (!success) return res.status(400).json({ error: message });
  res.json({ checkoutUrl: data.checkout_url }); // frontend redirects here
});

// Webhook: mark the order paid (respond 2xx quickly).
app.post('/webhooks/payerfox', express.json(), async (req, res) => {
  const { event, data } = req.body;
  if (event === 'payment.paid') await markOrderPaid(data.merchant_order_id, data);
  res.sendStatus(200);
});

app.listen(3000);
PHP — create the payment on your server
<?php
$apiUrl = getenv('PAYERFOX_API_URL'); // e.g. https://api.example.com/api/v1
$apiKey = getenv('PAYERFOX_API_KEY'); // pd_live_… (keep it on the server)

$payload = [
  'amount'          => '499.00',
  'currency'        => 'INR',
  'merchantOrderId' => 'ORDER-1001',
  'customerEmail'   => 'asha@example.com',
  'successUrl'      => 'https://yourstore.com/order/success',
  'cancelUrl'       => 'https://yourstore.com/order/cancel',
  'ipnUrl'          => 'https://yourstore.com/webhooks/payerfox',
];

$ch = curl_init("$apiUrl/payments");
curl_setopt_array($ch, [
  CURLOPT_POST           => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer $apiKey",
    'Content-Type: application/json',
    'Idempotency-Key: ORDER-1001',
  ],
  CURLOPT_POSTFIELDS     => json_encode($payload),
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);

if (!empty($res['success'])) {
  header('Location: ' . $res['data']['checkout_url']); // send the customer to checkout
  exit;
}
http_response_code(400);
echo $res['message'] ?? 'Could not start the payment';