@gerbergpt/medusa-fulfillment-4px
v1.0.1
Published
4PX fulfillment service for Medusa V2
Downloads
8
Maintainers
Readme
Compatibility
This plugin is compatible with versions >= 2.11.x of @medusajs/medusa.
Table of Contents
Prerequisites
- Node.js v20 or higher
- Medusa server v2.11.3 or higher
- Get your own API Key and API Secret from 4PX API
- Note: To use this plugin with the 4PX API, you must have registered your 4PX account as a merchant. Developer or other service-provider account types are not supported.
Installation
yarn add @gerbergpt/medusa-fulfillment-sfexpressConfiguration
Add the provider module in your medusa-config.ts file:
module.exports = defineConfig({
projectConfig: {
// ...
},
modules: [
// ... other modules
{
key: Modules.FULFILLMENT,
resolve: "@medusajs/fulfillment",
options: {
providers: [
{
id: "4px",
resolve: "@gerbergpt/medusa-fulfillment-4px/providers/fulfillment-4px",
options: {
api_key: process.env.FOURPX_API_KEY,
api_secret: process.env.FOURPX_API_SECRET,
sandbox: process.env.FOURPX_ENV === "sandbox",
//source_country_code: 'CN',
//language: 'en',
//default_transport_mode: 2
},
},
],
},
},
],
...,
plugins: [
{
resolve: "@gerbergpt/medusa-fulfillment-4px",
options: {},
},
],
})Environment Variables
Create or update your .env file with the following variables:
FOURPX_API_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
FOURPX_API_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
FOURPX_ENV="sandbox | production"Development
The following steps guide you through setting up the plugin locally using yalc, a tool that allows you to publish local packages and test them in other projects without pushing them to a registry.
- Prepare the plugin for local development Install dependencies, build the project, and publish it to your local yalc store:
yarn install
yarn run build
yarn run publish- Navigate to your Medusa backend application and install the plugin:
npx medusa plugin:add @gerbergpt/medusa-fulfillment-4px- After installation, you should see an entry pointing to the local yalc package:
"dependencies": {
...,
"@gerbergpt/medusa-fulfillment-4px": "file:.yalc/@gerbergpt/medusa-fulfillment-4px",
...
}- Follow the steps in the configuration section
- You can now begin development by running the
yarn run devcommand. The Medusa backend server will automatically restart whenever you make changes to this plugin. - When you have completed development and testing, remove the local published yalc package:
yalc remove @gerbergpt/medusa-fulfillment-4px