Доставляйте заказы с Mondial Relay
A Medusa v2 fulfillment provider plugin for Mondial Relay shipping services. Supports both Point Relais (pickup point) and Home Delivery options with real-time pricing via @frontboi/mondial-relay.
npm install medusa-mondialrelay1// medusa-config.ts2import { defineConfig, loadEnv } from "@medusajs/framework/utils"3
4loadEnv(process.env.NODE_ENV || "development", process.cwd())5
6module.exports = defineConfig({7 projectConfig: {8 databaseUrl: process.env.DATABASE_URL,9 http: {10 storeCors: process.env.STORE_CORS!,11 adminCors: process.env.ADMIN_CORS!,12 authCors: process.env.AUTH_CORS!,13 jwtSecret: process.env.JWT_SECRET || "supersecret",14 cookieSecret: process.env.COOKIE_SECRET || "supersecret",15 },16 },17
18 // Register the plugin19 plugins: [20 {21 resolve: "medusa-mondialrelay",22 options: {},23 },24 ],25
26 // Configure the fulfillment module with the provider27 modules: [28 {29 resolve: "@medusajs/medusa/fulfillment",30 options: {31 providers: [32 // Default manual provider (optional)33 {34 resolve: "@medusajs/medusa/fulfillment-manual",35 id: "manual",36 },37 // Mondial Relay provider38 {39 resolve: "medusa-mondialrelay",40 id: "mondialrelay",41 options: {42 apiBaseUrl: process.env.MONDIAL_RELAY_API_BASE_URL,43 culture: process.env.MONDIAL_RELAY_CULTURE || "fr-FR",44 login: process.env.MONDIAL_RELAY_LOGIN,45 password: process.env.MONDIAL_RELAY_PASSWORD,46 customerId: process.env.MONDIAL_RELAY_CUSTOMER_ID,47 businessAddress: {48 title: "Mr",49 firstname: process.env.BUSINESS_FIRSTNAME,50 lastname: process.env.BUSINESS_LASTNAME,51 streetname: process.env.BUSINESS_STREET,52 countryCode: process.env.BUSINESS_COUNTRY || "FR",53 postCode: process.env.BUSINESS_POSTCODE,54 city: process.env.BUSINESS_CITY,55 addressAdd1: "",56 addressAdd2: "",57 mobileNo: process.env.BUSINESS_PHONE,58 email: process.env.BUSINESS_EMAIL,59 returnLocation: process.env.MONDIAL_RELAY_RETURN_LOCATION || "",60 },61 // Optional: Free shipping when cart total >= this amount (in euros)62 freeShippingThreshold: 50,63 // Optional: Which delivery types get free shipping ("all" | "pickup" | "home")64 freeShippingAppliesTo: "all",65 },66 },67 ],68 },69 },70 ],71})Important: You need to register the plugin in both (for admin extensions) and (for the fulfillment provider).
Create or update your file:
1# Mondial Relay API Credentials2MONDIAL_RELAY_LOGIN=your_login3MONDIAL_RELAY_PASSWORD=your_password4MONDIAL_RELAY_CUSTOMER_ID=your_customer_id5MONDIAL_RELAY_CULTURE=fr-FR6MONDIAL_RELAY_API_URL=https://api.mondialrelay.com/Web_Services.asmx7
8# Business Address (sender)9BUSINESS_FIRSTNAME=John10BUSINESS_LASTNAME=Doe11BUSINESS_STREET=123 Main Street12BUSINESS_POSTCODE=7500113BUSINESS_CITY=Paris14BUSINESS_COUNTRY=FR15BUSINESS_EMAIL=contact@yourstore.com16BUSINESS_PHONE=0612345678In the Medusa Admin, create shipping options:
Note: The plugin automatically applies +3€ surcharge for home delivery options.
You can configure a cart total threshold above which shipping becomes free:
1// In medusa-config.ts, provider options:2options: {3 // ... other options4 freeShippingThreshold: 50, // Free shipping when cart >= 50€5 freeShippingAppliesTo: "all", // "all" | "pickup" | "home"6}| Option | Type | Default | Description |
|---|---|---|---|
| Cart total (in euros) above which shipping is free | |||
| Which delivery types get free shipping |
1// Free shipping for ALL delivery types when cart >= 50€2options: {3 freeShippingThreshold: 50,4 freeShippingAppliesTo: "all", // or omit (default)5}6
7// Free shipping ONLY for Point Relais when cart >= 50€8// Home delivery still has normal pricing9options: {10 freeShippingThreshold: 50,11 freeShippingAppliesTo: "pickup",12}13
14// Free shipping ONLY for Home Delivery when cart >= 100€15// Point Relais still has normal pricing16options: {17 freeShippingThreshold: 100,18 freeShippingAppliesTo: "home",19}Pass the cart total when setting the shipping method:
1await setShippingMethod({2 cartId: cart.id,3 shippingMethodId: selectedOptionId,4 data: {5 shipping_option_name: "Mondial Relay - Point Relais",6 cart_total: cart.total / 100, // Convert from cents to euros7 // ... other data8 }9})When and the delivery type matches , the shipping cost will be 0€.
The plugin uses for official Mondial Relay pricing based on:
Home delivery options automatically add a +3€ surcharge to the base Point Relais price.
| Weight | Point Relais | Home Delivery |
|---|---|---|
| 500g | ~3.99€ | ~6.99€ |
| 1kg | ~4.49€ | ~7.49€ |
| 2kg | ~5.49€ | ~8.49€ |
| 5kg | ~7.99€ | ~10.99€ |
Prices are fetched in real-time from Mondial Relay's official pricing grid.
For Point Relais delivery, integrate a pickup point selector. The plugin expects:
1await setShippingMethod({2 cartId: cart.id,3 shippingMethodId: selectedOptionId,4 data: {5 shipping_option_name: "Mondial Relay - Point Relais",6 parcel_shop_id: "020340",7 parcel_shop_name: "Relay Shop Name",8 parcel_shop_address: "123 Shop Street",9 parcel_shop_city: "Paris",10 parcel_shop_postcode: "75001",11 }12})npm install @frontboi/mondial-relay1import { ParcelShopSelector } from "@frontboi/mondial-relay"2
3<ParcelShopSelector4 postalCode="75001"5 countryCode="FR"6 brandIdAPI={process.env.NEXT_PUBLIC_MONDIAL_RELAY_BRAND_ID}7 onParcelShopSelected={(shop) => {8 // Handle selection9 }}10/>1await setShippingMethod({2 cartId: cart.id,3 shippingMethodId: selectedOptionId,4 data: {5 shipping_option_name: "Mondial Relay - Livraison à Domicile",6 }7})The plugin adds a widget to the order details page for:
| Code | Country |
|---|---|
| FR | France |
| BE | Belgium |
| LU | Luxembourg |
| NL | Netherlands |
| ES | Spain |
| PT | Portugal |
| DE | Germany |
| IT | Italy |
| AT | Austria |
MIT © Théo Daguier