waaz / sylius-fedex-plugin
This FedEx plugin enables you to easily print shipping labels and show available pickup locations for customers to choose from.
Package info
github.com/StudioWaaz/SyliusFedexPlugin
Type:sylius-plugin
pkg:composer/waaz/sylius-fedex-plugin
Requires
- php: ^8.1
- bitbag/shipping-export-plugin: ^3.0
- giggsey/libphonenumber-for-php-lite: ^8.9 || ^9.0
- nyholm/psr7: ^1.8
- setono/sylius-pickup-point-plugin: ^1.1
- sylius/sylius: ^1.11|^1.12|^1.13|^1.14
- symfony/http-client: ^5.4|^6.0
Requires (Dev)
- ext-json: *
- behat/behat: ^3.7
- behat/mink: ^1.9
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.8
- friends-of-behat/mink: ^1.9
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- phpstan/extension-installer: ^1.2
- phpstan/phpstan-doctrine: ^1
- phpstan/phpstan-strict-rules: ^1
- phpstan/phpstan-webmozart-assert: ^1
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^5.4|^6.0
- symfony/debug-bundle: ^5.4|^6.0
- symfony/dotenv: ^5.4|^6.0
- symfony/http-client: ^5.4|^6.0
- symfony/intl: ^5.4|^6.0
- symfony/runtime: ^5.4|^6.0
- symfony/web-profiler-bundle: ^5.4|^6.0
- symfony/webpack-encore-bundle: ^1.16
- vimeo/psalm: ^4|^5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
WaazSyliusFedexPlugin
This plugin allows you to integrate FedEx REST API into your Sylius store for shipping labels generation and pickup points / drop-off locations.
Features
- FedEx Shipping Labels Export (via
bitbag/shipping-export-plugin)- Integration with FedEx REST API v1 (
/ship/v1/shipments) - Generates labels in PDF or PNG format
- Automatically retrieves and assigns master tracking numbers
- Integration with FedEx REST API v1 (
- FedEx Pickup Points / Drop-off Locations (via
setono/sylius-pickup-point-plugin)- Searches nearest FedEx locations and drop-off points (
/location/v1/locations)
- Searches nearest FedEx locations and drop-off points (
- Recipient Notifications (optional, sent by FedEx)
emailNotificationDetailin the Ship API payload (ON_DELIVERY,ON_EXCEPTION,ON_ESTIMATED_DELIVERY, ...)- Email (
EMAIL) and/or SMS (SMS_TEXT_MESSAGE) recipients - Configurable format (
HTML/TEXT), locale and personal message
- Phone Number Normalization (
giggsey/libphonenumber-for-php-lite)- Local formats (
06 12 34 56 78) become FedEx-ready digits with dialing code (33612345678) - Unparseable numbers are omitted instead of being replaced by a placeholder
- Local formats (
- OAuth2 Token Handling with automatic caching
- Sylius 1.11, 1.12 & 1.13 compatible with native Symfony HTTP client (
symfony/http-client)
Requirements
- PHP 8.1+ (the lite libphonenumber build requires it)
- Sylius 1.11 to 1.14
Installation
1. Install via Composer
composer require waaz/sylius-fedex-plugin
2. Enable the Plugin
Add the plugin to your config/bundles.php:
return [ // ... BitBag\SyliusShippingExportPlugin\BitBagSyliusShippingExportPlugin::class => ['all' => true], Setono\SyliusPickupPointPlugin\SetonoSyliusPickupPointPlugin::class => ['all' => true], Waaz\SyliusFedexPlugin\WaazSyliusFedexPlugin::class => ['all' => true], ];
3. Plugin Configuration
Create config/packages/waaz_sylius_fedex_plugin.yaml:
waaz_sylius_fedex: sandbox: true # true for sandbox/testing, false for production weight_unit: 'KG' # 'KG' or 'LB'
4. Enable FedEx Pickup Point Provider (Optional)
In config/packages/setono_sylius_pickup_point.yaml:
setono_sylius_pickup_point: providers: fedex: true
Shipping Gateway Configuration (Admin)
In Sylius Admin panel:
- Go to Shipping > Shipping gateways (
/admin/shipping-gateways/new/fedex). - Fill in your FedEx credentials:
- FedEx API Key (Client ID)
- FedEx Secret Key
- FedEx Account Number
- Environment (
sandboxorproduction) - Default Shipping Service (
FEDEX_GROUND,FEDEX_EXPRESS_SAVER,INTERNATIONAL_PRIORITY, etc.) - Drop-off Type (
REGULAR_PICKUP,BUSINESS_SERVICE_CENTER,DROP_BOX, etc.) - Packaging Type (
YOUR_PACKAGING,FEDEX_BOX,FEDEX_ENVELOPE, etc.) - Label format:
PDF/PNGfor laser,ZPLIIfor Zebra thermal,EPL2for Eltron thermal - Stock type: laser (
PAPER_*) or thermal (STOCK_*), including Doc-Tab variants - Shipper Contact and Address details
- Recipient notifications (optional): enable email and/or SMS, choose the events
(
ON_DELIVERY,ON_ESTIMATED_DELIVERY,ON_SHIPMENT,ON_TENDER,ON_EXCEPTION,ON_PICKUP), the email format (HTML/TEXT), the locale (e.g.fr_FR) and an optional personal message
Recipient notifications: what FedEx can and cannot do
The notification emails and SMS are sent by FedEx, not by Sylius, and use FedEx's own content.
The personal message is the only customizable part (500 characters in HTML, 120 in TEXT).
SMS uses the phone number of the shipping address. It is normalized with
giggsey/libphonenumber-for-php-lite:
Input (Sylius, country FR) |
Sent to FedEx |
|---|---|
06 12 34 56 78 |
33612345678 |
+33 6 12 34 56 78 |
33612345678 |
0000000000 |
field omitted |
not a phone |
field omitted |
- FedEx requires 10 to 15 digits. US/CA numbers are sent as exactly 10 digits, without prefix.
- No made-up fallback is sent anymore: an unusable number is omitted rather than replaced by
0000000000. - SMS still requires a valid customer email in the payload, because FedEx expects an email address on every notification recipient.
- Check SMS availability for your destination country/account with FedEx, and make sure the customer consented to SMS notifications (GDPR).
There is no FedEx notification event for “parcel arrived at the pickup point”. The closest options are:
ON_ESTIMATED_DELIVERY— estimated delivery date updatesON_DELIVERY— the shipment reached its final destinationON_EXCEPTION— delivery exception
⚠️ For a shop-branded “your parcel is ready at the pickup point” email, the FedEx Advanced Integrated Visibility webhooks (tracking events pushed to your own HTTPS endpoint) are required instead. Those webhooks are currently limited to US-based shipping/billing accounts.
⚠️ This plugin also does not forward the pickup point selected with
setono/sylius-pickup-point-plugin (shipment.pickupPointId) to FedEx: the recipient address in the
payload is always the order shipping address. Make sure the delivery address matches the pickup
point before relying on ON_DELIVERY as an “arrived at pickup point” signal.
Running Tests
- PHPUnit (Unit Tests):
vendor/bin/phpunit
- Behat (non-JS scenarios):
vendor/bin/behat --strict --tags="~@javascript"
- Behat (JS scenarios):
# 1. Start Chrome headless google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 & # 2. Start test application web server APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon # 3. Run Behat vendor/bin/behat --strict --tags="@javascript"
- PHPStan:
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
- Coding Standard (ECS):
vendor/bin/ecs check src
Author
- @ehibes for Studio Waaz
License
This plugin's source code is completely free and released under the terms of the MIT license.
