Shipping

Shiprocket shipping for GoCommerce

A Go package that books a parcel with Shiprocket, has a waybill assigned and asks for a label — all from the engine’s own fulfillment call. An API user, a pickup location and your variants’ weights are what it needs.

What it does

Registering the module adds “shiprocket” as a fulfillment provider. An operator ships the usual way — the admin’s ship dialog, or POST /api/admin/create-fulfillment with "provider": "shiprocket" — and the module creates the order in Shiprocket, has a waybill assigned and asks for a label. The engine then stores the shipment, moves the order to shipped or partial, and writes the event; the module only talks to Shiprocket.

In the admin it describes itself as “Books shipments and waybills through Shiprocket, India’s aggregator: one login across its couriers.” Shiprocket assigns the courier unless the request names one.

What is declared is what is in the box. The engine works out which lines go in this parcel before the module is called, so the items, the declared value and whether the courier collects cash are this parcel’s, not the whole order’s.

Configuration

Three settings are required: the API user’s email and password, and the pickup location’s nickname. Set them in Config from your own main(), or leave Config empty and fill them in under Settings › Shipping providers.

Shiprocket module settings — 7 settings, 3 required
SettingEnvironment variableRequiredWhat it does
Email
API user email
SHIPROCKET_EMAIL Yes The login of the Shiprocket API user — the panel’s own note says the API user’s, not the account owner’s.
Password
API user password
SHIPROCKET_PASSWORD Yes Exchanged for a bearer token, which the module caches for nine days; Shiprocket’s tokens last ten.
PickupLocation
Pickup location
— Yes The nickname of the pickup address registered in Shiprocket. The package’s example uses “Primary”.
DefaultWeightKg
Default weight (kg)
— No Per unit, for a parcel holding a variant with no weight recorded. 0.5 kg when unset; a fully weighed catalogue never reaches it.
DefaultLengthCm, DefaultBreadthCm, DefaultHeightCm — No The box used when the engine has no single size — any parcel of more than one unit. 15 × 15 × 10 cm when unset. Go only.
BaseURL
API base URL
— No Overrides https://apiv2.shiprocket.in, for tests. Empty for production.
Client — No Replaces the HTTP client, which otherwise times out after 30 seconds. Go only; not in the panel.

The module reads its Config struct, not the environment. The variable names are the ones the package’s own example or the reference binary uses; in your own main() you choose where each value comes from. Where a setting has a panel label, the admin’s settings drawer can hold it too, and a value typed there wins over Config.

Setting it up

  1. Create an API userIn Shiprocket, set up the API user the module will log in as, and note the nickname of the pickup address it should collect from.
  2. Install the moduleImport it and pass shiprocket.New to gocommerce.New, as below — or run the reference binary with -carriers, which installs every carrier module idle.
  3. Configure itEmail, password and pickup location, in Config or under Settings › Shipping providers. Record weights on your variants; the default is only a fallback.
  4. Ship an orderChoose Shiprocket in the admin’s ship dialog, or POST /api/admin/create-fulfillment with "provider": "shiprocket". The waybill becomes the tracking number.

main.go

import (
	"os"

	"github.com/itswadesh/gocommerce/core"
	shiprocket "github.com/itswadesh/gocommerce/ext/fulfill-shiprocket"
)

app, err := gocommerce.New(cfg,
	shiprocket.New(shiprocket.Config{
		Email:          os.Getenv("SHIPROCKET_EMAIL"),
		Password:       os.Getenv("SHIPROCKET_PASSWORD"),
		PickupLocation: "Primary",
	}),
)

The package doc’s own example, with its imports; cfg is your gocommerce.Config. With an empty shiprocket.Config the module installs idle and waits for the panel. Import path github.com/itswadesh/gocommerce/ext/fulfill-shiprocket.

How it works

What it does not do

Read these before an order depends on it. No store is known to run GoCommerce in production yet, so these come from the code, not from anyone’s experience.

FAQ

Questions about the Shiprocket module

Who chooses the courier?

Shiprocket, unless you do. Without a courier_id in the request’s meta the module asks Shiprocket to assign a waybill and Shiprocket picks; with one, it asks for that courier. The admin’s ship dialog sends no meta, so naming a courier is an API call.

Which credentials does it need?

An API user’s email and password — the module’s own note says the API user’s login, not the account owner’s — and the nickname of a pickup location registered in Shiprocket.

What about cash-on-delivery orders?

An order not marked paid is booked as COD, so the courier collects; a paid one is booked as Prepaid. Cash on delivery is GoCommerce’s default payment method, so an order taken without a gateway ships as COD.

Does the order update when the parcel arrives?

No. The module books and returns; it has no webhook and polls nothing. Mark the order delivered from the admin or with POST /api/admin/orders/{id}/deliver.

Is Shiprocket a partner?

No. The module calls Shiprocket’s public API with credentials you supply. Shiprocket does not endorse GoCommerce, and no store is known to run this module in production yet.

Source

Everything on this page is read from ext/fulfill-shiprocket in the GoCommerce repository, MIT licensed. When this page and the code disagree, the code is right and this page is out of date.Shiprocket is a trademark of its owner; this module talks to its public API and implies no endorsement. See trademarks.

Try it against a store of your own

The one-command stack gives you GoCommerce’s API and admin on your own machine in minutes. Add this module to it and try it on test orders before a real one depends on it.

Chat on WhatsApp