Medusa v2 fulfillment provider for Mondial Relay shipping
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-mondialrelay
// medusa-config.tsimport { defineConfig, loadEnv } from "@medusajs/framework/utils"loadEnv(process.env.NODE_ENV || "development", process.cwd())module.exports = defineConfig({projectConfig: {databaseUrl: process.env.DATABASE_URL,http: {storeCors: process.env.STORE_CORS!,adminCors: process.env.ADMIN_CORS!,authCors: process.env.AUTH_CORS!,jwtSecret: process.env.JWT_SECRET || "supersecret",cookieSecret: process.env.COOKIE_SECRET || "supersecret",},},// Register the pluginplugins: [{resolve: "medusa-mondialrelay",options: {},},],// Configure the fulfillment module with the providermodules: [{resolve: "@medusajs/medusa/fulfillment",options: {providers: [// Default manual provider (optional){resolve: "@medusajs/medusa/fulfillment-manual",id: "manual",},// Mondial Relay provider{resolve: "medusa-mondialrelay",id: "mondialrelay",options: {apiBaseUrl: process.env.MONDIAL_RELAY_API_BASE_URL,culture: process.env.MONDIAL_RELAY_CULTURE || "fr-FR",login: process.env.MONDIAL_RELAY_LOGIN,password: process.env.MONDIAL_RELAY_PASSWORD,customerId: process.env.MONDIAL_RELAY_CUSTOMER_ID,businessAddress: {title: "Mr",firstname: process.env.BUSINESS_FIRSTNAME,lastname: process.env.BUSINESS_LASTNAME,streetname: process.env.BUSINESS_STREET,countryCode: process.env.BUSINESS_COUNTRY || "FR",postCode: process.env.BUSINESS_POSTCODE,city: process.env.BUSINESS_CITY,addressAdd1: "",addressAdd2: "",mobileNo: process.env.BUSINESS_PHONE,email: process.env.BUSINESS_EMAIL,returnLocation: process.env.MONDIAL_RELAY_RETURN_LOCATION || "",},// Optional: Free shipping when cart total >= this amount (in euros)freeShippingThreshold: 50,// Optional: Which delivery types get free shipping ("all" | "pickup" | "home")freeShippingAppliesTo: "all",},},],},},],})
Important: You need to register the plugin in both (for admin extensions) and (for the fulfillment provider).
Create or update your file:
# Mondial Relay API CredentialsMONDIAL_RELAY_LOGIN=your_loginMONDIAL_RELAY_PASSWORD=your_passwordMONDIAL_RELAY_CUSTOMER_ID=your_customer_idMONDIAL_RELAY_CULTURE=fr-FRMONDIAL_RELAY_API_URL=https://api.mondialrelay.com/Web_Services.asmx# Business Address (sender)BUSINESS_FIRSTNAME=JohnBUSINESS_LASTNAME=DoeBUSINESS_STREET=123 Main StreetBUSINESS_POSTCODE=75001BUSINESS_CITY=ParisBUSINESS_COUNTRY=FRBUSINESS_EMAIL=contact@yourstore.comBUSINESS_PHONE=0612345678
In 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:
// In medusa-config.ts, provider options:options: {// ... other optionsfreeShippingThreshold: 50, // Free shipping when cart >= 50€freeShippingAppliesTo: "all", // "all" | "pickup" | "home"}
| Option | Type | Default | Description |
|---|---|---|---|
| Cart total (in euros) above which shipping is free | |||
| Which delivery types get free shipping |
// Free shipping for ALL delivery types when cart >= 50€options: {freeShippingThreshold: 50,freeShippingAppliesTo: "all", // or omit (default)}// Free shipping ONLY for Point Relais when cart >= 50€// Home delivery still has normal pricingoptions: {freeShippingThreshold: 50,freeShippingAppliesTo: "pickup",}// Free shipping ONLY for Home Delivery when cart >= 100€// Point Relais still has normal pricingoptions: {freeShippingThreshold: 100,freeShippingAppliesTo: "home",}
Pass the cart total when setting the shipping method:
await setShippingMethod({cartId: cart.id,shippingMethodId: selectedOptionId,data: {shipping_option_name: "Mondial Relay - Point Relais",cart_total: cart.total / 100, // Convert from cents to euros// ... other data}})
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:
await setShippingMethod({cartId: cart.id,shippingMethodId: selectedOptionId,data: {shipping_option_name: "Mondial Relay - Point Relais",parcel_shop_id: "020340",parcel_shop_name: "Relay Shop Name",parcel_shop_address: "123 Shop Street",parcel_shop_city: "Paris",parcel_shop_postcode: "75001",}})
npm install @frontboi/mondial-relay
import { ParcelShopSelector } from "@frontboi/mondial-relay"<ParcelShopSelectorpostalCode="75001"countryCode="FR"brandIdAPI={process.env.NEXT_PUBLIC_MONDIAL_RELAY_BRAND_ID}onParcelShopSelected={(shop) => {// Handle selection}}/>
await setShippingMethod({cartId: cart.id,shippingMethodId: selectedOptionId,data: {shipping_option_name: "Mondial Relay - Livraison à Domicile",}})
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