Developer Docs

Integration Guide

Connect your store to PakkOrder in minutes. Choose the method that fits your setup.

How PakkOrder Works

When a buyer places a COD order on your store, you send the order details to PakkOrder. We immediately send them a WhatsApp message and email asking them to confirm or cancel. It takes about 30 seconds to set up.

Recommended

Auto Snippet

Paste one line of code. Works with most stores automatically.

🧩

Manual JS

Call our function yourself. For custom JS checkout flows.

🖥️

Backend API

Send orders from your server. Maximum control.

🔑

You need your License Key — find it in your PakkOrder dashboard under Settings. It looks like PAKK-XXXX-XXXX-XXXX.

Auto Snippet — Easiest

One line of code in your store's HTML. The snippet automatically detects your order form, reads the buyer's details, and sends them to PakkOrder when they submit.

Works with: WooCommerce, custom PHP stores, simple HTML checkout forms, most ecommerce platforms that render a form on the checkout page.

Step 1 — Paste the snippet

Copy this line and paste it just before the </body> tag on your checkout page. Replace YOUR_LICENSE_KEY with your actual key.

HTML
<script src="https://pakkorder.com/snippet.js"
        data-key="YOUR_LICENSE_KEY"></script>

Step 2 — That's it

The snippet will automatically find the order form on your page and start capturing orders. No other configuration needed.

💡

The snippet looks for these field names in your form: phone fields (phone, buyer_phone, mobile), name, address, city, and more. If your form fields have different names, use Method 2.

Optional — Force-enable on a specific form

If the snippet doesn't auto-detect your form, add data-pakkorder="true" to your form element:

HTML
<form data-pakkorder="true" action="/checkout" method="post">
  <!-- your form fields -->
</form>

Manual JS Call — Custom Checkouts

If your checkout is built with JavaScript (React, Vue, custom AJAX), the auto snippet may not detect the order. Use this method to call PakkOrder directly from your own JavaScript.

⚠️

Call this after the order is successfully placed — not on form submit, but after you get a success response from your own server. This avoids sending verification messages for failed orders.

Ready-to-use function

Paste this function into your JavaScript. Call sendToPakkOrder() after your order is confirmed.

JavaScript
function sendToPakkOrder(orderData) {
  var LICENSE_KEY = 'YOUR_LICENSE_KEY'; // ← replace this

  var payload = {
    buyer_phone:   orderData.phone,           // required
    order_details: orderData.details,         // required — product name(s)
    buyer_name:    orderData.name    || null, // optional
    buyer_email:   orderData.email   || null, // optional
    buyer_address: orderData.address || null, // optional
    buyer_city:    orderData.city    || null, // optional
    order_id:      orderData.orderId || null, // optional — auto-generated if missing
    order_amount:  orderData.amount  || null, // optional — e.g. "3800"
  };

  // Remove null values
  Object.keys(payload).forEach(function(k) {
    if (payload[k] === null) delete payload[k];
  });

  fetch('https://pakkorder.com/new-order', {
    method:  'POST',
    headers: {
      'Content-Type':  'application/json',
      'X-License-Key': LICENSE_KEY,
    },
    body: JSON.stringify(payload),
  }).catch(function() {}); // fire-and-forget, never block checkout
}

Usage example

JavaScript
// After your checkout API returns success:
placeOrder(formData).then(function(response) {
  // Your normal success handling...
  showThankYouPage(response);

  // Send to PakkOrder for COD verification:
  sendToPakkOrder({
    phone:   formData.phone,
    details: formData.productName,
    name:    formData.fullName,
    email:   formData.email,
    address: formData.address,
    city:    formData.city,
    orderId: response.orderId,
    amount:  response.total,
  });
});

Backend API Call — Server-Side

Send orders directly from your server. This is the most reliable method — ideal when you want to trigger verification from your order management system, after payment confirmation, or from any backend language.

🔒

Your License Key stays private on your server and is never exposed in the browser. This is the most secure integration method.

API Endpoint

Endpoint
POST  https://pakkorder.com/new-order
Content-Type:  application/json
X-License-Key: YOUR_LICENSE_KEY

Code examples

Node.js (axios)
const axios = require('axios');

async function notifyPakkOrder(order) {
  try {
    await axios.post(
      'https://pakkorder.com/new-order',
      {
        buyer_phone:   order.phone,           // required
        order_details: order.details,         // required
        buyer_name:    order.name,            // optional
        buyer_email:   order.email,           // optional
        buyer_address: order.address,         // optional
        buyer_city:    order.city,            // optional
        order_id:      order.id,              // optional
        order_amount:  String(order.amount),  // optional, as string
      },
      {
        headers: {
          'X-License-Key': process.env.PAKKORDER_KEY,
        },
        timeout: 8000,
      }
    );
    console.log('PakkOrder: verification sent for order', order.id);
  } catch (err) {
    // Log but never crash your own order flow
    console.error('PakkOrder error:', err.message);
  }
}
PHP (cURL)
function notify_pakkorder($order) {
  $payload = json_encode([
    'buyer_phone'   => $order['phone'],      // required
    'order_details' => $order['details'],    // required
    'buyer_name'    => $order['name']    ?? null,
    'buyer_email'   => $order['email']   ?? null,
    'buyer_address' => $order['address'] ?? null,
    'buyer_city'    => $order['city']    ?? null,
    'order_id'      => $order['id']      ?? null,
    'order_amount'  => (string)($order['amount'] ?? ''),
  ]);

  $ch = curl_init('https://pakkorder.com/new-order');
  curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => $payload,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 8,
    CURLOPT_HTTPHEADER     => [
      'Content-Type: application/json',
      'X-License-Key: ' . getenv('PAKKORDER_KEY'),
    ],
  ]);

  $result = curl_exec($ch);
  curl_close($ch);
  // Never throw — PakkOrder should not crash your order flow
}
cURL (Terminal)
curl -X POST https://pakkorder.com/new-order \
  -H "Content-Type: application/json" \
  -H "X-License-Key: YOUR_LICENSE_KEY" \
  -d '{
    "buyer_phone":   "03001234567",
    "order_details": "Nike Shoes x1",
    "buyer_name":    "Ahmed Ali",
    "buyer_email":   "[email protected]",
    "buyer_address": "House 5, Block B, Gulshan",
    "buyer_city":    "Karachi",
    "order_id":      "ORD-1001",
    "order_amount":  "3800"
  }'

API Fields

All fields sent to POST /new-order.

Field Required Description Example
buyer_phone Required Buyer's Pakistani mobile number 03001234567
order_details Required Product name(s), shown in the WhatsApp message Nike Shoes x1
buyer_name Optional Buyer's full name — personalises the message Ahmed Ali
buyer_email Optional Buyer's email — used to send email confirmation [email protected]
buyer_address Optional Delivery address — shown in the message House 5, Block B
buyer_city Optional City name Karachi
order_id Optional Your internal order ID — auto-generated if not provided ORD-1001
order_amount Optional Order total as a string — shown in the message 3800

Response

On success, the API returns HTTP 200 with:

JSON Response
{
  "success": true,
  "orderId": "firebase-document-id",
  "message": "Order queued for verification"
}

On error: HTTP 400 (bad request), HTTP 401 (invalid key), HTTP 429 (order limit reached).

Test Your Integration

1

Place a test order on your store using your own phone number as the buyer number.

2

You should receive a WhatsApp message within 30 seconds asking you to confirm or cancel the order.

3

Check your PakkOrder dashboard — the order should appear with status Pending, then change to Confirmed after you reply.

4

Not working? Enable debug mode by opening your browser console and typing window.PAKKORDER_DEBUG = true before the form submits. You'll see detailed logs.

⚠️

Use your own number for testing. PakkOrder sends real WhatsApp messages. Do not use a customer's number for integration testing.

Need Help?

If you're stuck or your integration isn't working, we'll set it up for you — for free.

Response time: within a few hours, 9am–9pm PKT.