Connect Your Own Website (Laravel or PHP)
Last updated 2026-10-02
Connect Your Own Website (Laravel or PHP)
Bangla: আপনার নিজের বানানো ওয়েবসাইট (Laravel বা PHP) রেখেই Omnikyo ব্যবহার করুন। ওয়েবসাইটের প্রতিটা অর্ডার, আর কাস্টমার কোন Facebook অ্যাড বা লিংক থেকে এসেছে, সরাসরি Omnikyo-তে চলে আসবে। স্টক Omnikyo-তেই থাকবে।
Keep the website you already have and run everything behind it in Omnikyo: orders, customers, couriers, stock, reports and Meta ads. Your website sends two things:
- Each new order, from its server, the moment the customer checks out.
- Where the customer came from: the Facebook ad, campaign or link. A script tag on your pages remembers it; the order carries it along.
Nothing is sent back to the website. Omnikyo keeps your stock: each order reserves it here, like any other order.
What you need
- A product in Omnikyo for everything your website sells, with the same SKU on both. Orders are matched to products by SKU; an order with a SKU Omnikyo doesn't have is not created (it waits under Recent orders until you fix it).
- Ten minutes of your developer's time, or an AI coding assistant.
Step 1: create your keys
Go to Settings → Sales channels → Your website and press Create keys. You get:
- a public key (
pk_live_…) that goes in the script tag on your pages, and - a secret key (
sk_live_…) your website's server sends orders with. Keep it private: never put it in a page or in JavaScript.
Type your website's address (for example yourshop.com) in step 1 on the same page and save. Tracking only counts from that domain.
Step 2: the fastest way, with an AI assistant
Most developers use Cursor, Claude, ChatGPT or Copilot. On the Setup tab press Copy prompt, open your website's code in the assistant, and paste. The prompt already contains your keys and the exact code; the assistant makes the changes and tells you which files it edited and how it mapped your order fields.
Step 2, by hand (Laravel)
The Setup tab shows each piece with your keys already filled in and a copy button. In short:
1. The script tag. Just before </head> in the layout every page uses (usually resources/views/layouts/app.blade.php):
<script async src="https://omnikyo.com/connect.js?key=pk_live_YOUR_PUBLIC_KEY"></script>
If your Meta pixel is set up in Omnikyo, this tag runs it: remove the old Meta pixel code from the page, or Meta counts every visit twice.
2. The secret key, in .env:
OMNIKYO_KEY=sk_live_YOUR_SECRET_KEY
3. The helper file. Create app/Support/Omnikyo.php with the file from Settings (copy or download it). It needs no package and works on Laravel 5.5 and later. It never throws an error, never slows checkout (it sends after the page is returned to the customer) and retries if Omnikyo can't be reached.
4. Send each order, right after your checkout saves it. Change the right-hand side to your own field names:
$items = [];
foreach ($order->items as $item) {
$items[] = [
'sku' => $item->sku,
'quantity' => $item->quantity,
'price' => $item->price,
];
}
\App\Support\Omnikyo::sendOrder([
'order_number' => $order->id,
'customer' => [
'name' => $order->customer_name,
'phone' => $order->phone,
'address' => $order->address,
'city' => $order->city,
],
'items' => $items,
'shipping_fee' => $order->shipping_charge,
'discount' => $order->discount,
'total' => $order->total,
'payment_method' => $order->payment_method,
]);
5. Test it. Place an order on your website. It appears under Recent orders in a few seconds, and in Orders like any other order.
Plain PHP (no framework)
Choose Plain PHP on the Setup tab. The helper file is omnikyo.php with your secret key already inside; put it next to your checkout file and call Omnikyo::sendOrder([...]) after require_once __DIR__ . '/omnikyo.php';. The script tag is the same.
What each field means
| Field | Required | Notes |
|---|---|---|
order_number | yes | Your website's own order id. Sending the same number twice never makes a second order. |
customer.name | yes | |
customer.phone | yes | Any Bangladeshi format: 017…, +88017…, 88017…. |
customer.address | yes | Couriers need it. |
customer.city | no | Helps pick the delivery zone. |
customer.email | no | |
items[].sku | yes | Must match the product's SKU in Omnikyo (capital letters don't matter). |
items[].quantity | no | Defaults to 1. qty also works. |
items[].price | no | Price of one. Defaults to the product's price in Omnikyo. |
shipping_fee, discount | no | |
total | no | What the customer pays. Worked out from the items when missing. |
payment_method | no | cod (default), bkash, nagad, card… Anything other than cash on delivery counts as paid in full unless you also send paid_amount. |
paid_amount | no | Money already paid online. |
note | no | Shown on the order. |
test | no | true checks everything and creates nothing. |
What happens to an order
- Created: it's in Orders as New (Confirmed if it was fully paid online), with its campaign source.
- On hold: low stock: Omnikyo didn't have enough stock, so the order is created on Hold instead of being lost. Restock and confirm it.
- Already received: the same order number was sent again; nothing changed.
- Not created: something has to be fixed first, usually a SKU Omnikyo doesn't have or a phone number that isn't Bangladeshi. The reason is shown in plain words. Fix it (for a SKU: add it to the product in Omnikyo) and press Retry.
Each order also reports the sale to Meta (the Purchase event, from Omnikyo's server), matched to the ad click when the customer came from an ad.
Tracking extra Meta events (optional)
The script tag sends PageView on every page by itself. To send product events too, call these from your pages:
Omnikyo.track('ViewContent', { sku: 'TSH-RED-M', price: 650 });
Omnikyo.track('AddToCart', { sku: 'TSH-RED-M', price: 650, quantity: 1 });
Omnikyo.track('InitiateCheckout', { value: 1360 });
Don't send Purchase from the page: Omnikyo sends it when the order arrives.
Troubleshooting
- Orders don't arrive: look in
storage/logs/laravel.log(plain PHP: the PHP error log) for lines starting withOmnikyo. A missing or wrong key says so there. - "This secret key is not valid": the keys were replaced in Settings. Copy the new secret key into
.env. - Class
App\Support\Omnikyonot found: runcomposer dump-autoload. - Campaign source is empty: the script tag must be on every page, including the product page the ad opens, and the order must be sent from the checkout request itself (not from a queued job), so the visitor's cookie goes with it.
- Meta events don't show: add your website's address under Keys and domain, check the Meta pixel is connected in Settings → Ads and tracking, and make sure there's no second Meta pixel on the page (the browser console says so).
For developers: the API
POST https://omnikyo.com/api/v1/orders with Authorization: Bearer sk_live_… and a JSON body with the fields above. The helper also adds tracking (the _okyo cookie, as is) and client (ip, user_agent, page_url) from the checkout request.
Answers: 201 created or held, 200 already received or test, 401 key, 422 something in the order to fix (error.fields names the field, error.skus lists unknown SKUs), 402 plan's order limit reached, 429 too many at once, 500 our side (safe to retry: the order number keeps it from being created twice).