Shipping

Delhivery shipping for GoCommerce

A Go package that manifests a parcel with Delhivery and takes the waybill Delhivery assigns, from the engine’s own fulfillment call. An API token, a registered warehouse and a seller name are what it needs.

What it does

Registering the module adds “delhivery” as a fulfillment provider. An operator ships the usual way — the admin’s ship dialog, or POST /api/admin/create-fulfillment with "provider": "delhivery" — and the module manifests the parcel with Delhivery and returns the waybill as the tracking number, with the carrier recorded as Delhivery. The engine stores the shipment and moves the order on; the module only talks to Delhivery.

In the admin it describes itself as “Manifests parcels with Delhivery and takes the waybill it assigns.” It sends the parcel’s own lines, weight, size and value — the engine has already worked out what goes in this box — plus the seller details printed on the label.

Delhivery’s manifestation endpoint is not a JSON API: it takes a form whose data field holds the whole payload as a JSON string. The package doc records that sending JSON as the body returns a bare 400 with no explanation, which is why this module encodes twice and looks unlike its neighbours.

Configuration

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

Delhivery module settings — 10 settings, 3 required
SettingEnvironment variableRequiredWhat it does
Token
API token
DELHIVERY_TOKEN Yes Sent as Authorization: Token <token>. The staging host takes a different token from production.
PickupLocation
Pickup location
— Yes The warehouse nickname registered with Delhivery, matched case-sensitively on their side.
SellerName
Seller name
— Yes Printed on the label. Required because, in the code’s words, an unnamed seller is a parcel nobody can return.
SellerAddress
Seller address
— No Printed on the label.
SellerGSTIN
Seller GSTIN
— No Sent as seller_gst_tin when set. Optional here, because whether Delhivery requires it depends on what the store sells.
HSNCode
HSN code
— No Sent with every parcel when set. One code for the whole store.
DefaultWeightGrams
Default weight (grams)
— No Per unit, for a parcel the engine could not weigh. 500 g when unset.
DefaultLengthCM, DefaultWidthCM, DefaultHeightCM — No The box used for any parcel of more than one unit, where the engine has no single size. 15 × 15 × 10 cm when unset. Go only.
BaseURL
API base URL
— No Defaults to production, https://track.delhivery.com. Staging is https://staging-express.delhivery.com.
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. Register the warehouseIn Delhivery, register the pickup warehouse and note its nickname exactly — it is matched case-sensitively — and copy the API token.
  2. Install the moduleImport it and pass delhivery.New to gocommerce.New, as below — or run the reference binary with -carriers, which installs every carrier module idle.
  3. Configure itToken, pickup location and seller name, in Config or under Settings › Shipping providers. Add the GSTIN and HSN code if your goods need them.
  4. Ship an orderChoose Delhivery in the admin’s ship dialog, or POST /api/admin/create-fulfillment with "provider": "delhivery". The waybill becomes the tracking number.

main.go

import (
	"os"

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

app, err := gocommerce.New(cfg,
	delhivery.New(delhivery.Config{
		Token:          os.Getenv("DELHIVERY_TOKEN"),
		PickupLocation: "Primary",
		SellerName:     "Acme Retail",
	}),
)

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

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 Delhivery module

Does it need a GSTIN?

Not to be installed. The module sends seller_gst_tin and hsn_code only when they are set, because — as its own comment puts it — whether they are mandatory depends on what the store sells, and Delhivery is the one entitled to refuse.

Can I test against Delhivery’s staging?

Yes. Set BaseURL to https://staging-express.delhivery.com and use a staging token; the two hosts take different tokens. Left empty, BaseURL is production.

Why does a shipment fail with a reason from Delhivery?

Because Delhivery refused it. It can answer HTTP 200 with a refusal per package, and the module reports that package’s remarks rather than letting the engine mark the order shipped. Fix what the remark names and ship again.

Does the order update when the parcel is delivered?

No. The module manifests 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 Delhivery a partner?

No. The module calls Delhivery’s API with a token you supply. Delhivery 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-delhivery in the GoCommerce repository, MIT licensed. When this page and the code disagree, the code is right and this page is out of date.Delhivery 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