๐Ÿ” Pickbo API Authentication Documentation

This documentation explains the authentication mechanism used in auth.php, located at:

api/v1/utils/auth.php

โœ… Purpose

To verify and authorize API access using merchant credentials, domain validation, and IP whitelisting.

๐Ÿงช Required HTTP Headers

Header NameDescriptionRequired
API-USERNAMEYour unique API usernameโœ…
API-PASSWORDYour API passwordโœ…
API-APP-KEYApplication key for the integrationโœ…
API-SECRET-KEYSecret key to authenticate the requestโœ…

๐Ÿ—ƒ๏ธ Database Tables Used

๐Ÿ” Authentication Flow

  1. Read and normalize headers
  2. Validate API credentials
  3. Validate merchant account status, domain, and IP
  4. Compare normalized domains
  5. Check IP against whitelist
  6. Return success or 401 Unauthorized

๐Ÿ” Example Header Request (cURL)

curl -X POST https://pickbo.com/api/v1/initiate-payment.php \
  -H "API-USERNAME: merchant_user" \
  -H "API-PASSWORD: merchant_pass" \
  -H "API-APP-KEY: app_123" \
  -H "API-SECRET-KEY: secret_456" \
  -d '{ "amount": 100, "callback_url": "https://merchant.com/callback" }'

๐Ÿ” Unauthorized Responses

{
  "status": "error",
  "message": "Unauthorized IP address."
}

๐Ÿงผ Normalization Function

function normalizeDomain($domain) {
  if (!$domain) return null;
  $domain = strtolower(trim($domain));
  $domain = preg_replace('/^www\./', '', $domain);
  $domain = preg_replace('/^https?:\/\//', '', $domain);
  $domain = rtrim($domain, '/');
  return $domain;
}

๐Ÿ” Unauthorized Helper Function

function unauthorized($message) {
  http_response_code(401);
  echo json_encode([
    "status" => "error",
    "message" => $message
  ]);
  exit;
}

๐Ÿงช Developer Notes


๐Ÿ“ค Payment Initiation API Documentation

๐Ÿ“Œ Endpoint

POST https://pickbo.com/api/v1/initiate-payment.php

๐Ÿ” Authentication

Header NameTypeRequiredDescription
API-USERNAMEstringโœ…Your assigned API Username
API-KEYstringโœ…Your assigned API Key (secret)
Content-Typestringโœ…Must be application/json

๐Ÿ“ฅ Request Body

Required Fields:

FieldTypeDescription
amountfloatTotal payment amount
currencystringCurrency code (e.g., BDT)
customer_namestringCustomer's name
customer_emailstringCustomer's email
customer_mobilestringCustomer's mobile number
callback_urlstringYour callback URL (must be HTTPS)

๐Ÿ“ฆ Example Request

{
  "amount": 250.00,
  "currency": "BDT",
  "customer_name": "Tanvir Ahmed",
  "customer_email": "tanvir@example.com",
  "customer_mobile": "01712345678",
  "callback_url": "https://yourdomain.com/checkout/callback"
}

โœ… Success Response

{
  "status": "success",
  "message": "Payment initiated successfully.",
  "payment_id": "123",
  "invoice_id": "INV-1722946334128",
  "redirect_url": "https://payment.pickbo.com/checkout/INV-1722946334128"
}

โŒ Error Responses

{
  "status": "error",
  "message": "API-USERNAME header missing."
}

๐Ÿ” Next Step: Callback Handling

Pickbo will redirect to your callback_url with invoice, status, and paymentID as query parameters.


โœ… Payment Execution API Documentation

๐Ÿ“Œ API Endpoint

POST https://pickbo.com/api/v1/execute-payment.php

๐Ÿ” Authentication

Send API-USERNAME and API-KEY in the headers.

๐Ÿ“ฅ Request Payload

FieldTypeDescription
invoice_idstringInvoice ID from Pickbo
payment_idstringPayment ID from gateway
statusstringOne of: success, failed, cancel

๐Ÿ’ก Sample Callback Handling (PHP)

// payment-status.php
$status     = $_GET['status'] ?? 'unknown';
$invoice    = $_GET['invoice'] ?? '';
$payment_id = $_GET['paymentID'] ?? '';

if ($status === 'success') {
  echo "โœ… Payment Successful! Invoice: $invoice";
} else {
  echo "โŒ Payment Failed or Cancelled. Invoice: $invoice";
}

๐Ÿ“ž Support