# medusa-plugin-brightpearl

> Brightpearl plugin for Medusa Commerce

Latest version **1.3.14** (published 2024-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install medusa-plugin-brightpearl
pnpm add medusa-plugin-brightpearl
yarn add medusa-plugin-brightpearl
bun add medusa-plugin-brightpearl
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score; popular repo.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.14 |
| Published | 2024-07-18 |
| First published | 2020-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 6 |
| Unpacked size | 310.7 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 36678 |
| Author | Sebastian Rindom |
| Maintainers | sebrindom, oliverjuhl |
| Keywords | medusa-plugin, medusa-plugin-erp |

## Links

- npm: https://www.npmjs.com/package/medusa-plugin-brightpearl
- Repository: https://github.com/medusajs/medusa
- Homepage: https://github.com/medusajs/medusa#readme
- Issues: https://github.com/medusajs/medusa/issues
- npm.io page: https://npm.io/package/medusa-plugin-brightpearl

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^0.19.2
- [express](https://npm.io/package/express.md) ^4.17.1
- [randomatic](https://npm.io/package/randomatic.md) ^3.1.1
- [@medusajs/utils](https://npm.io/package/@medusajs/utils.md) ^1.11.10
- [axios-rate-limit](https://npm.io/package/axios-rate-limit.md) ^1.2.1
- [medusa-core-utils](https://npm.io/package/medusa-core-utils.md) ^1.2.3

## Recent versions

- 1.3.14 (latest) — 2024-07-18
- 1.3.14-snapshot-20240718083016 (snapshot) — 2024-07-18
- 1.3.14-next-20240430121402 (next) — 2024-04-30
- 1.3.10-beta-20230705211101 (beta) — 2023-07-05
- 1.3.7-rc.0 (rc) — 2023-03-24
- 2.0.0-20230320210331 (canary) — 2023-03-20
- 1.3.3-staging-20221220110309 (staging) — 2022-12-20
- 1.3.3-alpha.0 (alpha) — 2022-12-13
- 1.3.2-alp.0 (alp) — 2022-10-05
- 1.3.2-test-release.0 (test-release) — 2022-08-25
- 1.3.2-test.0 (test) — 2022-08-25
- 1.3.2-nxt.0 (nxt) — 2022-08-25
- 1.3.2-next-1-3-6.0 (next-1-3-6) — 2022-08-25
- 1.3.1-dev-c76e23.237 (dev-c76e23) — 2022-07-04
- 1.3.1-fix-1749.225 (fix-1749) — 2022-06-29
- … 534 more at https://npm.io/package/medusa-plugin-brightpearl/versions

## README

# Brightpearl

Manage and streamline your business processes using Brightpearl.

[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)

## Features

- Send and sync orders with Brightpearl.
- Listen for inventory and stock movements in Brightpearl.
- Handle order returns through Brightpearl.

---

## Prerequisites

- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Brightpearl account](https://www.brightpearl.com)

---

## How to Install

1\. Run the following command in the directory of the Medusa backend:

  ```bash
  npm install medusa-plugin-brightpearl
  ```

2\. Set the following environment variables in `.env`:

  ```bash
  BRIGHTPEARL_ACCOUNT=<YOUR_ACCOUNT>
  BRIGHTPEARL_CHANNEL_ID=<YOUR_CHANNEL_ID>
  BRIGHTPEARL_BACKEND_URL=<YOUR_BACKEND_URL>
  BRIGHTPEARL_EVENT_OWNER=<YOUR_EVENT_OWNER>
  BRIGHTPEARL_WAREHOUSE=<YOUR_WAREHOUSE>
  BRIGHTPEARL_DEFAULT_STATUS_ID=<YOUR_DEFAULT_STATUS_ID>
  BRIGHTPEARL_SWAP_STATUS_ID=<YOUR_SWAP_STATUS_ID>
  BRIGHTPEARL_CLAIM_STATUS_ID=<YOUR_CLAIM_STATUS_ID>
  BRIGHTPEARL_PAYMENT_METHOD_CODE=<YOUR_PAYMENT_METHOD_CODE>
  BRIGHTPEARL_SALES_ACCOUNT_CODE=<YOUR_SALES_ACCOUNT_CODE>
  BRIGHTPEARL_SHIPPING_ACCOUNT_CODE=<YOUR_SHIPPING_ACCOUNT_CODE>
  BRIGHTPEARL_DISCOUNT_ACCOUNT_CODE=<YOUR_DISCOUNT_ACCOUNT_CODE>
  BRIGHTPEARL_GIFT_CARD_ACCOUNT_CODE=<YOUR_GIFT_CARD_ACCOUNT_CODE>
  BRIGHTPEARL_INVENTORY_SYNC_CRON=<YOUR_INVENTORY_SYNC_CRON>
  BRIGHTPEARL_COST_PRICE_LIST=<YOUR_COST_PRICE_LIST>
  BRIGHTPEARL_BASE_CURRENCY=<YOUR_BASE_CURRENCY>
  ```

3\. In `medusa-config.js` add the following at the end of the `plugins` array:

  ```js
  const plugins = [
    // ...
    {
      resolve: `medusa-plugin-brightpearl`,
      options: {
        account: process.env.BRIGHTPEARL_ACCOUNT, // required, the Brightpearl account
        channel_id: process.env.BRIGHTPEARL_CHANNEL_ID, // required, channel id to map sales and credits to
        backend_url: process.env.BRIGHTPEARL_BACKEND_URL, // required, the url where the Medusa server is running, needed for webhooks
        event_owner: process.env.BRIGHTPEARL_EVENT_OWNER, // required, the id of the user who will own goods out events]
        warehouse: process.env.BRIGHTPEARL_WAREHOUSE, // required, the warehouse id to allocate orders from
        default_status_id: process.env.BRIGHTPEARL_DEFAULT_STATUS_ID, // (default: `3`), the status id to assign new orders with
        swap_status_id: process.env.BRIGHTPEARL_SWAP_STATUS_ID, // (default: `3`), the status id to assign new swaps
        claim_status_id: process.env.BRIGHTPEARL_CLAIM_STATUS_ID, // (default: `3`), the status id to assign new claims
        payment_method_code: process.env.BRIGHTPEARL_PAYMENT_METHOD_CODE, // (default: `1220`), the method code to register payments with
        sales_account_code: process.env.BRIGHTPEARL_SALES_ACCOUNT_CODE, // (defaults: `4000`), nominal code to assign line items to
        shipping_account_code: process.env.BRIGHTPEARL_SHIPPING_ACCOUNT_CODE, // (default: `4040`), nominal code to assign shipping line to
        discount_account_code: process.env.BRIGHTPEARL_DISCOUNT_ACCOUNT_CODE, // optional, nominal code to use for Discount-type refunds
        gift_card_account_code: process.env.BRIGHTPEARL_GIFT_CARD_ACCOUNT_CODE, // (default: `4000`), nominal code to use for gift card products and redeems
        inventory_sync_cron: process.env.BRIGHTPEARL_INVENTORY_SYNC_CRON, // optional, cron pattern for inventory sync, if left out the job will not be created
        cost_price_list: process.env.BRIGHTPEARL_COST_PRICE_LIST, // (default: `1`) the ID of the price list to assign to created claims
        base_currency: process.env.BRIGHTPEARL_BASE_CURRENCY, // (default: `EUR`) the ISO 3 character code of the currency to assign to created claims.
      },
    },
  ]
  ```

---

## Test the Plugin

1\. Run the following command in the directory of the Medusa backend to run the backend:

  ```bash
  npm run start
  ```

2\. On placing an order, you should see that order appear on Brightpearl.

---

## Additional Information

### Orders

When an order is created in Medusa it will automatically be sent to Brightpearl and allocated there. Once allocated it is up to Brightpearl to figure out how the order is to be fulfilled - the plugin listens for goods out notes and tries to map each of these to a Medusa order, if the matching succeeds Medusa will send the order to the fulfillment provider associated with the shipping method selected by the Customer.

When line items on an order are returned the plugin will generate a sales credit in Brightpearl.

### Products

The plugin doesn't automatically create products in Medusa, but listens for inventory changes in Brightpearl. The plugin updates each product variant to reflect the inventory quantity listed in Brightpearl, thereby ensuring that the inventory levels in Medusa are always in sync with Brightpearl.

### OAuth

The plugin registers an OAuth app in Medusa allowing installation at https://medusa-commerce.com/a/settings/apps. The OAuth tokens are refreshed every hour to prevent unauthorized requests.

---
_Source: https://npm.io/package/medusa-plugin-brightpearl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
