Shipping
India Post consignments for GoCommerce
A Go package that records a parcel you booked at the post office counter or in the Department of Posts’ portal, and refuses a consignment number India Post did not issue. It books nothing, and its own documentation says so.
- Shipping module
- 1 setting
- 6 tests
- ext/fulfill-indiapost
What it does
Registering the module adds “india-post” as a fulfillment provider. An operator ships the usual way — the admin’s ship dialog, or POST /api/admin/create-fulfillment with "provider": "india-post" and the consignment number from the receipt — and the module checks the number, records the carrier as India Post and hands the shipment to the engine.
The package doc is candid about why it stops there. Every other fulfillment module calls an API and gets a waybill back; India Post has no such API that a store can sign up for. The Department of Posts integrates bulk customers one at a time, under an agreement, with no public sandbox and no documented request body — so a module that claimed to book a shipment would be guessing at somebody else’s contract.
What it does instead is the part that can be done correctly: take the number, check that it is an India Post article number before the order is marked shipped — which catches the transposed digit that would otherwise surface a week later as a customer with a dead link — and record the carrier, so the number is never attributed to anyone else.
Configuration
One setting, and nothing required. Because it needs no credentials, the module starts switched on as soon as it is installed; the setting lives in Config or under Settings › Shipping providers.
| Setting | Environment variable | Required | What it does |
|---|---|---|---|
AcceptAnyNumberAccept any consignment number | — | No | Turns off the S10 check, for an India Post product that numbers differently. Off by default: the number must be a 13-character S10 barcode. |
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
- Book at the counterHand the parcel over at a post office, or book it in the Department of Posts’ own portal, and keep the consignment number from the receipt.
- Install the moduleImport it and pass indiapost.New to gocommerce.New, as below — or run the reference binary with -carriers. It needs no keys, so it starts switched on.
- Record the parcelChoose India Post in the admin’s ship dialog and type the number, or POST /api/admin/create-fulfillment with "provider": "india-post" and the tracking number.
- Let the check workA number that is not an S10 article number — EE123456789IN for Speed Post — is refused, and the order stays unshipped until the right one is entered.
main.go
import (
"github.com/itswadesh/gocommerce/core"
indiapost "github.com/itswadesh/gocommerce/ext/fulfill-indiapost"
)
app, err := gocommerce.New(cfg, indiapost.New(indiapost.Config{})) The package doc’s own example, with its imports; cfg is your gocommerce.Config. An empty Config is the normal case. Import path github.com/itswadesh/gocommerce/ext/fulfill-indiapost.
How it works
-
Cleaned, then checked
Spaces, hyphens and lower case are stripped from what was typed, then the number is matched against the UPU S10 pattern India Post issues under: two letters, nine digits, IN.
-
Refused before it ships
A missing number, or one that fails the check, is an error returned before the engine records anything, so the order is not marked shipped.
-
The carrier is stated
The shipment is recorded with the carrier india-post rather than leaving the engine to work it out from the number.
-
The engine’s own rule
The S10 pattern is the one the engine’s carrier detection uses to recognise an India Post number, so a number this module accepts is one the engine will recognise too.
-
Speed Post and the rest
EE… for Speed Post, RX… for registered and CX… for business parcels all fit the pattern. A product outside S10 needs AcceptAnyNumber.
-
No calls, no tables
The module makes no network calls and keeps no state of its own. It logs each consignment it records; the engine stores the shipment.
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.
- It books nothingNo label, no waybill, no pickup. The booking is made at the counter or in the Department of Posts’ portal; this module records it.
- No tracking updatesNo webhook and no polling. Marking an order delivered is a separate step, in the admin or through the API.
- Shape, not existenceThe check confirms a number looks like one India Post issues. It cannot confirm that the article was actually booked.
- Unchecked with AcceptAnyNumberWith the check off, any number is recorded as typed, cleaned of spaces and hyphens. The typo it exists to catch is caught no longer.
- Better than manual, narrowlyThe package doc’s own verdict: it is better than the built-in manual provider only in that it refuses a number India Post did not issue.
- An agreement needs its own moduleA store with a Department of Posts integration agreement should, the doc says, write a module against the endpoints in that agreement.
FAQ
Questions about the India Post module
Why does it not book shipments like the other carrier modules?
Because there is nothing public to book against. The package doc explains that India Post has no API a store can sign up for: the Department of Posts integrates bulk customers one at a time, and the endpoint, credentials and payload are issued under that agreement rather than published.
What does a valid consignment number look like?
Thirteen characters on the UPU S10 standard: two letters, nine digits and IN — EE123456789IN for Speed Post, RX… for registered, CX… for business parcels. Spaces, hyphens and lower case are cleaned up before the check.
My product’s number does not match. What now?
Switch on Accept any consignment number (AcceptAnyNumber in Config). The number is then recorded as typed, cleaned of spaces and hyphens, without the check.
Does it need credentials?
None. Its one setting is optional, so it starts switched on as soon as it is installed, and it makes no network calls.
Is India Post involved?
No. The module calls no India Post system and records numbers you type. India Post 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-indiapost in the GoCommerce repository, MIT licensed. When this page and the code disagree, the code is right and this page is out of date.India Post is named here only to identify the carrier; this module calls no India Post system 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.