sunrice / commerce-biteship
Biteship shipping for Sunrice Commerce: live rates from Indonesian couriers (JNE, J&T, SiCepat, GoSend, Grab…), automatic pickup booking and tracking.
Package info
github.com/Digital-Citra-Kreatif/sunrice-commerce-biteship
pkg:composer/sunrice/commerce-biteship
Requires
- php: ^8.4
- illuminate/contracts: ^13.0
- illuminate/http: ^13.0
- illuminate/support: ^13.0
- spatie/laravel-package-tools: ^1.93
- sunrice/admin: ^0.8
- sunrice/commerce: ^0.4
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-26 15:27:28 UTC
README
Biteship shipping for Sunrice Commerce:
- Live rates at checkout from the couriers you choose (JNE, J&T, SiCepat, AnterAja, POS, TIKI, Ninja, Lion, ID Express, SAP, JDL, Wahana, GoSend, GrabExpress, Lalamove, Borzo, Paxel…).
- Pickup booking: when an order is paid (cash on delivery: when it is placed), or with one click on the order page. The courier comes to your address and the order is marked shipped with the waybill as its tracking number.
- Tracking: Biteship's webhooks (and commerce's hourly check) move the shipment to in transit and delivered.
- Shipping labels: a printable A6 label drawn by the store, with the waybill barcode, routing code, both addresses, weight, contents and the COD amount. Or Biteship's own label, from its Shipping Label API (Biteship's Grow plan or higher).
Contents
- Setup checklist
- Installation
- Configuration
- Setting up the shipping method
- Booking, cancelling and labels
- Tracking and webhooks
- Testing Mode
- Going live
- Instant couriers (GoSend, GrabExpress)
- How it fits into commerce
- Development
Setup checklist
Biteship has no API for webhooks or for activating bookings, so a few steps happen in its dashboard. In order:
In the store
composer require sunrice/commerce-biteship, addBiteshipPlugin::make()after commerce in your panel provider and publish the panel's script (php artisan sunrice:assets, also on every deploy).- Set the store address with its postal code and the store phone (Settings → Store → General). Biteship needs a phone number for the courier at pickup.
- Add a Biteship method to a shipping zone and choose the couriers, the booking moment, the hand-over and what you ship (details).
- Run a queue worker (automatic bookings) and the scheduler (
commerce:tick). - Check the store health check: it lists anything missing.
In Biteship, Testing Mode
- Turn on Mode Testing in the dashboard sidebar and create a test key (Integrations → API →
Tambah Kunci API). Put it in
BITESHIP_API_KEY. - Add the webhook: Integrations → Pengaturan → Webhook → Tambah Webhook, URL
https://your-store.example/biteship/webhook?token=…(HTTPS, reachable from the internet; use a random string and set the same one inBITESHIP_WEBHOOK_TOKEN), eventsorder.status,order.priceandorder.waybill_id. Biteship calls it once when you save; the package answers 200. - Place a test order in the store, book it (Book pickup on the order page, or pay it with automatic booking on) and print its label.
- In Biteship's order list, use the yellow Play Webhook buttons on that order to walk it through picked up, in transit and delivered, and watch the order page follow.
Going live
- Integrations → API → Aktivasi Order API: choose the live key and couriers, paste the test order's Biteship id (the panel's "Booking"), say you use your own label and upload a label printed from the test order, and submit. Wait for the status Aktif.
- Put the
biteship_live.key inBITESHIP_API_KEYand add the webhook again with Testing Mode off: each mode has its own webhooks. - Top up the Biteship balance: bookings are paid from it.
- For cash on delivery, ask Biteship to enable COD for your account and couriers; until then COD bookings are refused.
Remember: in Testing Mode bookings are simulated (no courier comes, nothing is charged), but rates, areas and tracking are real data that Biteship counts as paid usage.
Installation
composer require sunrice/commerce-biteship
Add its plugin after commerce's in your panel provider: it adds the order page's booking routes and its Biteship panel.
use Sunrice\CommerceBiteship\BiteshipPlugin; return $panel->plugin(CmsPlugin::make())->plugin(CommercePlugin::make())->plugin(BiteshipPlugin::make());
php artisan sunrice:assets publishes the panel's script with the other plugins' (so does
composer update, through the laravel-assets tag). The shipping method, rates, webhooks and
booking register themselves; switch them off with the Biteship feature in Settings → Store →
Features.
Configuration
.env:
| Key | ||
|---|---|---|
BITESHIP_API_KEY |
required | Biteship dashboard → Integrations → API. biteship_test.… is Testing Mode |
BITESHIP_ORIGIN_POSTAL_CODE |
Where parcels leave from; empty uses the store address's postal code (Settings → Store → General) | |
BITESHIP_ORIGIN_LATITUDE, BITESHIP_ORIGIN_LONGITUDE |
The store's coordinates, for instant couriers | |
BITESHIP_ORIGIN_CONTACT_NAME, BITESHIP_ORIGIN_CONTACT_PHONE |
Who the courier asks for at pickup; empty uses the store's name and phone | |
BITESHIP_ORIGIN_NOTE |
A note for the courier ("ring the bell at the side door") | |
BITESHIP_WEBHOOK_PATH |
biteship/webhook |
See Tracking and webhooks |
BITESHIP_WEBHOOK_TOKEN |
Recommended: a random string the webhook URL must carry as ?token=…. Empty accepts webhooks without it (the health check warns in production) |
|
BITESHIP_QUEUE |
The queue for automatic bookings (null: the default) |
Publish config/commerce-biteship.php with php artisan vendor:publish --tag=commerce-biteship-config
for the rest (base URL, timeout). The key stays in .env: it is never shown in the admin.
The store health check (Shop dashboard, php artisan commerce:doctor) tells you when the key is
missing, the origin can't be found, a test key is used or the webhook has no token in production, or
the panel isn't published.
Setting up the shipping method
Settings → Store → Shipping → a zone → add a method of the type Biteship (live courier rates):
| Setting | |
|---|---|
| Couriers | Which couriers checkout quotes (default JNE, J&T, SiCepat, AnterAja, POS) |
| Book the pickup | From the order page, or When the order is paid (cash on delivery: when it is placed; with a deposit, once the balance is paid too) |
| Hand over | The courier picks up at the store, or you drop parcels off at the courier |
| Insure parcels for their value | Adds Biteship's insurance to rates and bookings |
| Shipping label | The store's label (A6, drawn by the package; the default) or Biteship's label (see Booking, cancelling and labels) |
| Biteship label paper | For Biteship's label: 10 × 15 cm (Biteship's default), 8 × 10 cm or A4 |
| What you ship | Biteship's item category (fashion, food and drink, electronics…); food and drink gets instant couriers assigned faster |
The usual method settings (title, minimum subtotal, maximum weight…) apply too.
Checkout shows one rate per courier service, e.g. "JNE Reguler · 2 - 3 days". Rates are quoted by postal code: the customer's, or their village's from commerce's region list, or, when neither is known, Biteship's area for the district (looked up once and remembered for 30 days). Weights are the variants' weights in grams and sizes their dimensions in centimetres, so fill those in on your products. Cash on delivery orders only see couriers that collect cash, priced with the COD fee, and none above Biteship's COD limit of Rp15.000.000. When a route has no courier, checkout simply shows no Biteship rate.
Rates are cached for ten minutes per cart and address by commerce.
Booking, cancelling and labels
A booking sends everything left to ship in the order as one parcel, with the order number as Biteship's reference (so Biteship refuses a second booking for the same order). When it succeeds, commerce gets a shipment with the courier, the waybill as tracking number, Biteship's tracking link and the price you pay; the order is marked shipped and the customer gets commerce's "shipped" email.
The Biteship panel on the order page (permission commerce.shipments.manage; with commerce's
order scopes, Commerce::scopeAdminOrders(), only for orders the staff member may see) shows the
booking (status, courier, waybill, driver, price, live tracking) and has the buttons:
- Book pickup: for orders whose method books from the order page, or when an automatic booking failed. Failures (no balance, an address Biteship can't find) are on the order's timeline and on the panel.
- Print label: the shipping label PDF.
- The store's label (default): the sender is where the pickup was booked (the order's branch
when an extension chose one, else the store). Override the template with
resources/views/vendor/commerce-biteship/label.blade.php. - Biteship's label (method setting Shipping label): the button opens the PDF Biteship makes for the booking, on the chosen paper. Biteship's other label options (what it shows or hides) come from your Biteship dashboard's label settings. It needs Biteship's Grow plan or higher: if Biteship refuses (plan, booking not found), the store's label is printed instead and the error is reported to the application log. Biteship's label is a snapshot of the booking when it was first made.
- Neither replaces commerce's packing slip (Documents), which stays as it is.
- The store's label (default): the sender is where the pickup was booked (the order's branch
when an extension chose one, else the store). Override the template with
- Refresh: fetches the booking now.
- Cancel booking: until the courier has picked the parcel up (Biteship's rule), cancels it at
Biteship; the shipment is marked cancelled and Book again books it anew on the same shipment
(reference
ORDER-NUMBER-2).
Bookings are paid from your Biteship balance, so keep it topped up. A booking that gets no courier
(courier_not_found) or is rejected also marks the shipment cancelled: book it again.
Automatic bookings run on the queue (three tries for network errors; Biteship's own refusals aren't retried). Run a queue worker. If Biteship already has a booking for the reference (the answer to an earlier try was lost), that booking is taken over rather than refused.
The hand-over follows the method's setting when the courier offers it on the route, otherwise the way it does offer (pickup or drop-off, from Biteship's rates). Items go to Biteship with their name, variant, SKU, price, weight and size, and the method's category.
Tracking and webhooks
Biteship has no API for webhooks: add it in the dashboard.
- Biteship dashboard → Integrations → Pengaturan (Settings) → Webhook → Tambah Webhook.
- URL:
https://your-store.example/biteship/webhook?token=…, with a random string as the token, and the same string inBITESHIP_WEBHOOK_TOKEN. It must be HTTPS and reachable from the internet; Biteship calls it once when you save, and the package answers 200. On a store that already receives webhooks, change the URL in Biteship first and set the variable after: a token in.envthat Biteship doesn't send yet answers 403. - Events:
order.status,order.priceandorder.waybill_id. - Add it once in Testing Mode and once in live mode: each mode has its own webhooks.
In Testing Mode, Biteship's order list has a yellow button on each order to fire its webhooks (Play Webhook): use it to walk a test booking through picked up, in transit and delivered.
Biteship doesn't sign webhooks, so the package only reads which booking changed from them and
then fetches that booking from Biteship's API before it changes anything. A forged webhook can at
most make the store ask Biteship again; with BITESHIP_WEBHOOK_TOKEN set, webhooks without the
token are refused (403) before that. Statuses move the shipment:
| Biteship | Shipment |
|---|---|
| confirmed, scheduled, allocated, picking_up | shipped |
| picked, in_transit, dropping_off, on_hold, return_in_transit | in transit |
| delivered | delivered (ShipmentDelivered) |
| returned | returned |
| cancelled, rejected, courier_not_found, disposed | cancelled (book again from the order page) |
Every change is on the order's timeline, including a new price when the courier weighs the parcel
differently at pickup (order.price; the shipment's cost follows). Some couriers issue the
waybill only after pickup; it arrives with the order.waybill_id webhook. Without webhooks,
commerce:tick still asks Biteship about each open booking once an hour and applies the answer as
a webhook would (status, waybill, price and the timeline), so a missed webhook doesn't leave a
cancelled or returned booking looking active.
Tracking reads the booking from the Order API (GET /v1/orders/{id}, its courier history), not
Biteship's Tracking API (GET /v1/trackings/{id}), which counts against the monthly Tracking quota
on live keys. Shipments with a waybill you entered yourself (not booked through Biteship) aren't
tracked by this package.
Testing Mode
Turn on Mode Testing in Biteship's dashboard and create a key there: it starts with
biteship_test.. With it:
- bookings are simulated: no courier comes and nothing is taken from your balance; the panel and the label say "testing mode";
- rates, areas and tracking are real data, and Biteship counts them as paid usage even in Testing Mode.
The health check warns about a test key in production.
Going live
Biteship activates the Order API for live keys only after reviewing a test integration (dashboard → Integrations → API → Aktivasi Order API):
- In Testing Mode, place an order in the store and book it (Book pickup on the order page). Copy its Biteship order id from the panel ("Booking"): the form asks for a Test Order ID.
- Choose the live key and the couriers to activate.
- The form asks whether you use your own shipping label: you do. Upload a sample made with Print label on the test order.
- Submit ("Kirim Data Aktivasi API") and wait for the status to read Aktif.
- Put the
biteship_live.key inBITESHIP_API_KEY, add the live webhook, and top up the Biteship balance (bookings are paid from it). - For cash on delivery, ask Biteship to enable COD for your account and couriers; until then bookings of COD orders are refused ("not available for COD feature").
Rates and tracking work with a live key before activation; only bookings wait for it.
Instant couriers (GoSend, GrabExpress)
GoSend, GrabExpress, Lalamove, Borzo and Paxel price by distance, so Biteship needs the
coordinates of both ends. Set the store's in BITESHIP_ORIGIN_LATITUDE and
BITESHIP_ORIGIN_LONGITUDE. Commerce's checkout doesn't ask customers for a map pin yet, so these
couriers aren't quoted at checkout for now, even when chosen on the method. The package uses an
address's latitude and longitude as soon as commerce stores them.
How it fits into commerce
Only commerce's public extension points:
- the shipping method type
biteship(ShippingMethodType,TracksShipments,BooksShipments); - the feature
biteship(requiresshipping); - an order panel, a health check and courier presets;
- listeners on
OrderPaidandOrderPlaced; - commerce's
CreateShipmentandUpdateShipmentactions.
Bookings live on commerce shipments, in meta.biteship (Biteship order id, tracking id, waybill,
status, driver, price), so the package has no tables of its own.
Development
composer install composer test # Pest, with Biteship's API faked composer lint # Pint composer analyse # Larastan
sunrice/admin, sunrice/cms and sunrice/commerce come from Packagist. To work against local checkouts next to this one, copy composer.json to
composer.local.json, point its repositories at ../sunrice/packages/admin, ../sunrice/packages/cms and ../sunrice-commerce as
path repositories, and run COMPOSER=composer.local.json composer install.
License
MIT