storkplus / sylius-bosta-shipping-plugin
Bosta (Egypt) shipping for Sylius: shipping calculator, automatic delivery creation, webhooks, tracking and retries.
Package info
github.com/Storkplus/SyliusBostaShippingPlugin
Type:sylius-plugin
pkg:composer/storkplus/sylius-bosta-shipping-plugin
Requires
- php: ^8.2
- sylius/sylius: ^2.1
- symfony/http-client: ^6.4 || ^7.0
Requires (Dev)
- behat/behat: ^3.16
- dbrekelmans/bdi: ^1.4
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6
- friends-of-behat/variadic-extension: ^1.6
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- sylius-labs/coding-standard: ^4.4
- sylius-labs/suite-tags-extension: ~0.2
- sylius/sylius-rector: ^2.0
- sylius/test-application: ^2.0.0@alpha
- symfony/browser-kit: ^6.4 || ^7.4
- symfony/debug-bundle: ^6.4 || ^7.4
- symfony/dotenv: ^6.4 || ^7.4
- symfony/intl: ^6.4 || ^7.4
- symfony/runtime: ^6.4 || ^7.4
- symfony/web-profiler-bundle: ^6.4 || ^7.4
- symfony/webpack-encore-bundle: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-02 16:24:26 UTC
README
Bosta (Egypt) shipping for Sylius 2.1+:
bostashipping calculator: flat fee per channel, or Bosta's fee estimate for the customer's city with the flat fee as fallback. Configured on the shipping method (API key, pickup city, package size, COD payment methods...).- Automatic delivery creation: at checkout for cash-on-delivery orders, when the order is paid for online payments. Runs after the response is sent, so checkout never waits on Bosta and a Bosta outage never breaks it.
- Same tracking number everywhere: the Sylius shipment tracking code is the Bosta tracking number.
- Webhooks on a static per-store URL keep the order in step: picked up / in transit → shipment shipped, delivered → cash-on-delivery payment completed → order fulfilled. Exceptions, returns, loss are shown to the merchant.
- Fault tolerant: every failure is stored with its reason; the admin can Retry, Recreate (cancels the
pending Bosta delivery and creates a new one), Refresh status and print the Airway bill from the order page.
Retries never create duplicates (stable
uniqueBusinessReference; a lost response is recovered by reference). - Bosta logo on the checkout shipping step; Bosta links on the admin order page (merchant view) and the customer order pages (public tracking).
- English and Arabic.
Requirements
PHP 8.2+, Sylius 2.1 to 2.3, MySQL/MariaDB.
Installation
composer config repositories.sylius-bosta-shipping-plugin vcs https://github.com/Storkplus/SyliusBostaShippingPlugin composer require storkplus/sylius-bosta-shipping-plugin
// config/bundles.php Storkplus\SyliusBostaShippingPlugin\StorkplusSyliusBostaShippingPlugin::class => ['all' => true],
# config/packages/storkplus_sylius_bosta_shipping.yaml imports: - { resource: "@StorkplusSyliusBostaShippingPlugin/config/config.yaml" } # config/routes/storkplus_sylius_bosta_shipping.yaml storkplus_sylius_bosta_shipping: resource: "@StorkplusSyliusBostaShippingPlugin/config/routes.yaml"
Database: bin/console doctrine:migrations:migrate (adds storkplus_bosta_delivery). The SQL is also available as
Storkplus\SyliusBostaShippingPlugin\Migrations\Version20261005000000::CREATE_TABLE for setups that manage schemas
by hand.
Optional safety net, e.g. every 15 minutes: bin/console storkplus:bosta:sync retries failed creations and
refreshes deliveries whose webhook never arrived.
Setting up the shipping method
- In Bosta: Settings → API Integration → Create API key with Read/Write access.
- In Sylius admin: Configuration → Shipping methods → Create, calculator Bosta, a zone covering Egypt.
The form shows the store's webhook URL,
https://<store>/shipping/bosta/webhook, and a generated secret. - Fill in the API key, pickup city, the flat amount per channel and which payment methods are cash on delivery.
- Optional: in Bosta API Integration → Webhook, add the webhook URL with key name
X-Bosta-Secretand the secret as value. Not required for deliveries created by the store: each one is created with that URL and header.
Addresses: Bosta needs one of its governorates (city) and, ideally, a district. The plugin reads the governorate
from the address province (name, Arabic name or ISO EG-* code) or city, and the district from the city/street
(e.g. "Nasr City", "Maadi", "6th of October"). If Bosta still refuses an address, the delivery is marked failed with
Bosta's message; fix the address and click Retry.
How a shipment flows
order placed (COD) / order paid (online)
└─ kernel.terminate → POST /deliveries (uniqueBusinessReference = <STORE>-<order>-<shipment>)
ok → tracking number on the shipment, Bosta card shows "Sent to Bosta"
failed → reason stored, admin Retry / bin/console storkplus:bosta:sync
Bosta webhook POST /shipping/bosta/webhook (X-Bosta-Secret)
21/24/30/41 picked up, in transit → shipment "ship" (customer gets the shipping email with tracking)
45 delivered → COD payment "complete" → order fulfilled
46/48/49/100/101 → shown in red on the order for the merchant
Development
composer install
vendor/bin/phpunit --testsuite unit
vendor/bin/phpstan analyse -c phpstan.neon
vendor/bin/ecs check
# End to end (Docker): test application + MySQL + a mock Bosta API playing webhooks.
tests/E2E/run.sh
Logs: Monolog channel bosta.