npm package: @piranhastudios/parcels2go
Description: A starter for Medusa plugins.
Author: Medusa
Latest version: 0.0.3

# @piranhastudios/parcels2go

Parcels2Go fulfillment provider plugin for [Medusa v2](https://medusajs.com). Adds Parcels2Go as a fulfillment option in your Medusa store, with OAuth credential management and an Admin UI for connecting your account.

## Features

- Parcels2Go fulfillment provider (rate quoting, shipment creation, cancellation, returns, label retrieval)
- OAuth credential storage and management
- Admin UI page for connecting/disconnecting your Parcels2Go account
- Sandbox and production mode support

## Requirements

- Node.js >= 20
- Medusa >= 2.12.4
- A [Parcels2Go](https://www.parcel2go.com) account with an OAuth application (Client ID + Client Secret)

## Installation

In your Medusa backend, run:

```bash
npx medusa plugin:add @piranhastudios/parcels2go
```

Then run migrations to create the OAuth credentials table:

```bash
npx medusa db:migrate
```

## Configuration

Add the following to your `medusa-config.ts`:

```ts
import { loadEnv, defineConfig, Modules } from "@medusajs/framework/utils";
import { PARCELS2GO_CREDENTIALS_MODULE } from "@piranhastudios/parcels2go/modules/parcels2go/credentials-index";

module.exports = defineConfig({
  modules: {
    // Register the credentials storage module
    parcels2goCredentials: {
      resolve: "@piranhastudios/parcels2go/modules/parcels2go/credentials-index",
    },

    // Add the fulfillment provider
    [Modules.FULFILLMENT]: {
      resolve: "@medusajs/medusa/fulfillment",
      dependencies: [PARCELS2GO_CREDENTIALS_MODULE],
      options: {
        providers: [
          // ... your other providers
          {
            resolve: "@piranhastudios/parcels2go/modules/parcels2go",
            id: "parcels2go",
            options: {
              // Set to false (or remove) for production
              sandbox: true,
            },
          },
        ],
      },
    },
  },
});
```

## Connecting Your Account

1. In the Medusa Admin, go to **Extensions → Parcels2Go**
2. Enter your **Client ID** and **Client Secret** from your Parcels2Go OAuth application
3. Click **Connect to Parcels2Go**

Once connected, the status will show as active and the provider will be ready to use in your shipping options.

To create a Parcels2Go OAuth application:
1. Log in to your [Parcels2Go account](https://www.parcel2go.com)
2. Navigate to your API / Developer settings and create a new OAuth client
3. Copy the Client ID and Client Secret into the Admin UI form
![integration page](integration-page.png)
## Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `PARCELS2GO_SANDBOX` | Set to `"true"` to use the sandbox API | `"false"` |

## API Routes

The plugin registers the following admin API endpoints:

| Method | Path | Description |
|--------|------|-------------|
| `POST` | `/admin/parcels2go/connect` | Authenticate with Client ID & Secret and store the OAuth token |
| `GET` | `/admin/parcels2go/status` | Check connection status and token expiry |
| `POST` | `/admin/parcels2go/disconnect` | Remove stored credentials |

## Compatibility

Compatible with Medusa >= 2.12.4.