kiora/sylius-mondial-relay-plugin

Mondial Relay pickup point shipping integration for Sylius 2

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

Type:sylius-plugin

pkg:composer/kiora/sylius-mondial-relay-plugin

v1.1.0 2025-12-15 09:53 UTC

This package is auto-updated.

Last update: 2025-12-15 10:41:30 UTC


README

PHP Version Sylius Version License

A comprehensive Mondial Relay integration plugin for Sylius 2.x, providing pickup point shipping functionality for French and European e-commerce stores.

Features

  • πŸ—ΊοΈ Pickup Point Selection: Interactive widget for customers to choose relay points during checkout
  • πŸ“¦ Dual API Support:
    • REST API v2 (Connect): For shipment creation, label generation with Basic Auth
    • SOAP API v1: For relay point search (WSI4_PointRelais_Recherche)
  • 🎫 Label & QR Code Generation: Automatic shipping labels with QR codes for drop-off
  • πŸ“Š Admin Interface:
    • Configuration page for API credentials
    • Relay point details in order view
    • QR code generation from admin panel
  • πŸ”Œ Sylius 2 Twig Hooks: Native integration with Sylius 2 hook system
  • ⚑ Performance: Built-in caching for API responses
  • πŸ§ͺ Sandbox Mode: Test integration without affecting production
  • πŸ”’ Type Safety: PHP 8.2+ with readonly classes and strict typing
  • πŸ“ Well Documented: Complete API documentation and usage examples

Requirements

  • PHP 8.2 or higher
  • Sylius 2.0 or higher
  • Symfony 7.0 or higher
  • MySQL 8.0+ or PostgreSQL 13+
  • A valid Mondial Relay merchant account

Installation

1. Install via Composer

composer require kiora/sylius-mondial-relay-plugin

2. Register the Bundle

The bundle is automatically registered via Symfony Flex. If not, add it manually to config/bundles.php:

<?php

return [
    // ...
    Kiora\SyliusMondialRelayPlugin\KioraSyliusMondialRelayPlugin::class => ['all' => true],
];

3. Import Routes

Create config/routes/kiora_mondial_relay.yaml:

# Admin routes (configuration, shipment actions)
kiora_mondial_relay_admin:
    resource: '@KioraSyliusMondialRelayPlugin/config/routes/admin.yaml'

# Shop routes (relay point search/select during checkout)
kiora_mondial_relay_shop:
    resource: '@KioraSyliusMondialRelayPlugin/config/routes/shop.yaml'

4. Extend Shipment Entity (optional)

To store pickup point selections, extend Sylius Shipment entity with the provided trait:

<?php
// src/Entity/Shipping/Shipment.php

namespace App\Entity\Shipping;

use Doctrine\ORM\Mapping as ORM;
use Kiora\SyliusMondialRelayPlugin\Entity\MondialRelayShipmentInterface;
use Kiora\SyliusMondialRelayPlugin\Entity\MondialRelayShipmentTrait;
use Sylius\Component\Core\Model\Shipment as BaseShipment;

#[ORM\Entity]
#[ORM\Table(name: 'sylius_shipment')]
class Shipment extends BaseShipment implements MondialRelayShipmentInterface
{
    use MondialRelayShipmentTrait;
}

Then run migrations:

bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate

5. Clear Cache

bin/console cache:clear

6. Configure API Credentials

Navigate to Admin > Configuration > Mondial Relay to configure:

  • REST API v2 (Connect): API Key, API Secret, Brand ID for shipment creation and labels
  • SOAP API v1: Enseigne code and Private Key for relay point search
  • Sandbox Mode: Enable/disable test environment

The configuration is stored in config/mondial_relay.json and can be tested directly from the admin interface.

Usage

Quick Start with API Client

The plugin provides a complete HTTP client for interacting with the Mondial Relay API:

<?php

use Kiora\SyliusMondialRelayPlugin\Api\Client\MondialRelayApiClientInterface;
use Kiora\SyliusMondialRelayPlugin\Api\DTO\RelayPointSearchCriteria;

class MyService
{
    public function __construct(
        private readonly MondialRelayApiClientInterface $apiClient
    ) {}

    public function searchRelayPoints(string $postalCode): void
    {
        // Search by postal code
        $criteria = RelayPointSearchCriteria::fromPostalCode(
            postalCode: $postalCode,
            countryCode: 'FR',
            radius: 10,
            limit: 20
        );

        $collection = $this->apiClient->findRelayPoints($criteria);

        foreach ($collection as $relayPoint) {
            echo sprintf(
                "%s - %s (%s km)\n",
                $relayPoint->name,
                $relayPoint->getFullAddress(),
                $relayPoint->getDistanceKm()
            );
        }
    }
}

See complete documentation: API Client Documentation

See working examples: docs/examples/basic-usage.php

Testing the Integration

Use the provided Makefile commands for development:

# Install dependencies
make install

# Run tests
make test

# Run static analysis
make phpstan

# Fix code style
make cs-fix

# Run all quality checks
make check

Development

Project Structure

kiora-sylius-mondial-relay-plugin/
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ admin.yaml                 # Admin routes (configuration, shipments)
β”‚   β”‚   └── shop.yaml                  # Shop routes (relay point search/select)
β”‚   β”œβ”€β”€ services.yaml                  # Service definitions
β”‚   └── twig_hooks.yaml                # Sylius 2 Twig Hooks configuration
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Api/
β”‚   β”‚   β”œβ”€β”€ Client/
β”‚   β”‚   β”‚   β”œβ”€β”€ MondialRelayApiClient.php      # REST API v2 client
β”‚   β”‚   β”‚   β”œβ”€β”€ MondialRelayApiClientInterface.php
β”‚   β”‚   β”‚   └── MondialRelaySoapClient.php     # SOAP API v1 client
β”‚   β”‚   β”œβ”€β”€ DTO/
β”‚   β”‚   β”‚   β”œβ”€β”€ RelayPointSearchCriteria.php   # Search parameters
β”‚   β”‚   β”‚   β”œβ”€β”€ RelayPointDTO.php              # Relay point data
β”‚   β”‚   β”‚   β”œβ”€β”€ RelayPointCollection.php       # Iterable collection
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   └── Exception/
β”‚   β”‚       └── MondialRelayApiException.php   # API exceptions
β”‚   β”œβ”€β”€ Controller/
β”‚   β”‚   β”œβ”€β”€ Admin/
β”‚   β”‚   β”‚   β”œβ”€β”€ ConfigurationController.php    # API configuration page
β”‚   β”‚   β”‚   └── ShipmentController.php         # Label/QR code generation
β”‚   β”‚   └── Shop/
β”‚   β”‚       └── RelayPointController.php       # Relay point search/select
β”‚   β”œβ”€β”€ Entity/
β”‚   β”‚   β”œβ”€β”€ MondialRelayPickupPoint.php        # Pickup point entity
β”‚   β”‚   └── MondialRelayShipmentTrait.php      # Shipment extension trait
β”‚   β”œβ”€β”€ Service/
β”‚   β”‚   β”œβ”€β”€ MondialRelayLabelGenerator.php     # Shipping labels
β”‚   β”‚   └── MondialRelayQrCodeGenerator.php    # QR codes for drop-off
β”‚   β”œβ”€β”€ DependencyInjection/
β”‚   β”‚   β”œβ”€β”€ Configuration.php
β”‚   β”‚   └── KioraSyliusMondialRelayExtension.php
β”‚   └── KioraSyliusMondialRelayPlugin.php
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”œβ”€β”€ configuration/             # Admin configuration page templates
β”‚   β”‚   └── order/show/                # Order detail Mondial Relay info
β”‚   └── shop/
β”‚       └── checkout/                  # Relay point selector widget
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ composer.json
└── README.md

Running Tests

composer test

Static Analysis

composer phpstan

Code Style

composer cs-fix

Troubleshooting

API Authentication Errors

If you receive authentication errors:

  1. Verify your credentials in the Mondial Relay merchant portal
  2. Ensure you're using the correct environment (sandbox vs production)
  3. Check that the API secret is properly configured for request signing

Cache Issues

Clear the plugin cache:

bin/console cache:pool:clear kiora_sylius_mondial_relay.cache

Network Timeouts

Increase the HTTP timeout in your configuration:

kiora_sylius_mondial_relay:
    http:
        timeout: 30

Documentation

Plugin Documentation

External Documentation

Support

For bugs, feature requests, or questions:

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes with clear messages
  4. Add tests for new functionality
  5. Submit a pull request

License

This plugin is licensed under the MIT License. See LICENSE for details.

Credits

Developed by Kiora

Built for Sylius, the modern e-commerce framework for PHP.

Note: This plugin requires a valid Mondial Relay merchant account. Visit Mondial Relay Professional to register.