Developer Documentation

Integrate ZeroPay into your website or application using our REST API.

How to Integrate ZeroPay

ZeroPay acts as a bridge between a personal Android phone and a business website. There are two distinct ways you can integrate our service into a website checkout flow:

Method 1: The Webhook System (Real-Time Push)

When a customer pays to a bKash/Nagad number, the Android app instantly sends the SMS to our server. We will immediately push that transaction to the website's configured Webhook URL. The website just needs to listen for it and mark the order as paid.

Example: webhook.php (On the merchant's website)

<?php // 1. Receive the JSON push from ZeroPay Server $payload = file_get_contents('php://input'); $data = json_decode($payload, true); // 2. Extract transaction details $txn_id = $data['txn_id']; $amount = $data['amount']; $sender = $data['sender']; // e.g., 'bKash' or 'NAGAD' // 3. Update the database // SELECT * FROM orders WHERE amount = $amount AND status = 'Pending' ... // UPDATE orders SET status = 'Paid' WHERE ... echo "Webhook processed successfully."; ?>

Method 2: The Invoice API (Checkout Pages)

If a highly structured checkout page is preferred, the backend can first Create an Invoice via our API. It will receive a unique checkout_url to redirect the customer to. It can then query our server later to check if it was paid.

Method 3: Native JS Drop-in Widget (Recommended)

Keep customers on your own domain. Use our Drop-in JavaScript SDK to generate a native checkout UI. It automatically pulls your brand colors and logos directly onto your website.

Step A: Create an Invoice

First, securely call the Create Invoice API from your backend (as shown below) to get an invoice_id.

Step B: Embed the Widget

Drop this snippet onto your checkout page where you want the payment box to appear:

<!-- The container where the widget will render --> <div id="zeropay-checkout"></div> <!-- Load the SDK --> <script src="https://pay.spin2taka.fun/public/zeropay.js"></script> <script> new ZeroPayWidget({ container: 'zeropay-checkout', invoiceId: 'INV_1234567890', // The ID you got from Step A apiUrl: 'https://pay.spin2taka.fun/api' }); </script>
Authentication

Include the merchant API key in every request using the Authorization header:

Authorization: Bearer YOUR_API_KEY
Endpoints
Method Endpoint Description Auth
POST /api/create-invoice.php Create a new payment invoice Required
GET /api/check-invoice.php Check invoice status and details Required
POST /api/create-invoice.php
Create a new payment invoice and receive a checkout URL.

Request Body (JSON)

"amount": 500.00, "customer_name": "John Doe", "redirect_url": "https://shop.com/thanks", "notes": "Order #1234", "expires_in": 3600 // seconds (optional)

Example Response

"success": true, "invoice_id": "INV-9XK2M", "checkout_url": "https://pay.spin2taka.fun/checkout.php?invoice=INV-9XK2M", "expires_at": "2026-06-24T15:00:00+06:00"

PHP Example

$ch = curl_init('https://pay.spin2taka.fun/api/create-invoice.php'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode([ 'amount' => 500.00, 'customer_name' => 'John Doe', 'expires_in' => 3600, ]), CURLOPT_HTTPHEADER => [ 'Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json', ], ]); $response = json_decode(curl_exec($ch), true); $checkout_url = $response['checkout_url'];
GET /api/check-invoice.php
Retrieve the current status of a payment invoice.

Query Parameters

invoice_id=INV-9XK2M api_key=YOUR_API_KEY

Example Response

"invoice_id": "INV-9XK2M", "status": "Paid", "amount": 500.00, "customer_name": "John Doe", "paid_at": "2026-06-24T14:22:00+06:00", "expires_at": null

PHP Example

<?php $url = "https://pay.spin2taka.fun/api/check-invoice.php?invoice_id=INV-9XK2M&api_key=YOUR_API_KEY"; $response = file_get_contents($url); $data = json_decode($response, true); if ($data['status'] === 'Paid') { echo "Payment Successful!"; } else { echo "Still Pending..."; } ?>