@quantaroute/checkout 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +70 -2
- package/dist/lib/index.d.ts +69 -0
- package/dist/lib/quantaroute-checkout.es.js +165 -147
- package/dist/lib/quantaroute-checkout.umd.js +159 -141
- package/dist/style.css +1 -1
- package/package.json +3 -2
- package/src/components/AddressForm.native.tsx +184 -23
- package/src/components/AddressForm.tsx +152 -20
- package/src/components/AddressLabelIcons.native.tsx +144 -0
- package/src/components/AddressLabelIcons.tsx +46 -0
- package/src/components/CheckoutWidget.native.tsx +8 -0
- package/src/components/CheckoutWidget.tsx +11 -0
- package/src/components/MapPinSelector.native.tsx +8 -1
- package/src/components/MapPinSelector.tsx +9 -1
- package/src/components/SavedAddressStep.tsx +7 -1
- package/src/core/api.ts +9 -1
- package/src/core/checkout-api.ts +56 -0
- package/src/core/digipin.ts +10 -1
- package/src/core/types.ts +30 -1
- package/src/index.ts +4 -0
- package/src/styles/checkout.css +115 -20
- package/src/styles/checkout.native.ts +50 -15
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,34 @@ All notable changes to `@quantaroute/checkout` are documented here.
|
|
|
5
5
|
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
Release dates are from git history where available; earlier versions are estimated from the first public commit.
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.4.5](https://github.com/quantaroute/checkout/compare/v1.4.4...v1.4.5) — 2026-06-13
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Merchant courier serviceability checks via `checkout-addresses` `serviceability_check`, signed webhook configuration on `checkout.merchants`, and `checkServiceability()` client helper
|
|
15
|
+
- `enableServiceabilityCheck`, `showIndiaPostDeliveryWarning`, and `serviceabilityBlockCheckout` widget props
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- India Post "Non Delivery" is now an opt-in informational fallback instead of the default buyer-facing warning; merchant courier serviceability takes precedence
|
|
20
|
+
|
|
21
|
+
## [1.4.4](https://github.com/quantaroute/checkout/compare/v1.4.3...v1.4.4) — 2026-06-16
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **Custom "Other" address label** — text input when Other is selected; persisted as `label_text` while `label` stays `other`
|
|
26
|
+
- `CompleteAddress.labelText` — returned on completion and when re-selecting saved addresses
|
|
27
|
+
- `couldBeDigiPinInput` and `isPotentialDigiPinInput` — partial DigiPin typing no longer triggers address autocomplete
|
|
28
|
+
- `npm run verify:digipin` — regression script for dashed, spaced, and compact DigiPin input
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- **Address label picker** — compact pill chips with stroke SVG icons (web) and View-drawn icons (native); selected state uses primary tint instead of heavy borders
|
|
33
|
+
- **Native address form** — vector map-pin section icon replaces emoji in "Your details" header
|
|
34
|
+
- Saved address cards show custom `label_text` (e.g. "Friend's home") instead of generic "Other"
|
|
35
|
+
|
|
8
36
|
## [1.4.3](https://github.com/quantaroute/checkout/compare/v1.4.2...v1.4.3) — 2026-06-16
|
|
9
37
|
|
|
10
38
|
### Added
|
package/README.md
CHANGED
|
@@ -380,6 +380,74 @@ When `enableEmailAuth` is true the widget starts with an email-entry step. The b
|
|
|
380
380
|
|
|
381
381
|
---
|
|
382
382
|
|
|
383
|
+
### Merchant courier serviceability
|
|
384
|
+
|
|
385
|
+
QuantaRoute still validates that a pincode exists in the India Post database, but India Post "Non Delivery" is treated as **reference data**, not the final merchant delivery decision. Most D2C stores ship through Shiprocket, Delhivery, ClickPost, or direct courier contracts, so the buyer-facing serviceability check should come from the merchant.
|
|
386
|
+
|
|
387
|
+
| Prop | Type | Default | Platform |
|
|
388
|
+
|---|---|---|---|
|
|
389
|
+
| `enableServiceabilityCheck` | `boolean` | `false` | all |
|
|
390
|
+
| `showIndiaPostDeliveryWarning` | `boolean` | `false` | all |
|
|
391
|
+
| `serviceabilityBlockCheckout` | `boolean` | merchant setting | all |
|
|
392
|
+
|
|
393
|
+
When `enableServiceabilityCheck` is true and the buyer has a checkout session, the widget calls `checkout-addresses` with `action: "serviceability_check"`. The Edge Function calls the merchant's configured courier endpoint server-side and fails open if that endpoint is unavailable.
|
|
394
|
+
|
|
395
|
+
```tsx
|
|
396
|
+
<CheckoutWidget
|
|
397
|
+
apiKey={process.env.NEXT_PUBLIC_QUANTAROUTE_KEY!}
|
|
398
|
+
merchantId={process.env.NEXT_PUBLIC_MERCHANT_ID!}
|
|
399
|
+
supabaseFunctionBaseUrl={process.env.NEXT_PUBLIC_SUPABASE_FUNCTION_URL!}
|
|
400
|
+
enableEmailAuth={true}
|
|
401
|
+
enableServiceabilityCheck={true}
|
|
402
|
+
onComplete={(addr) => console.log(addr)}
|
|
403
|
+
/>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Merchant configuration lives on `checkout.merchants`:
|
|
407
|
+
|
|
408
|
+
| Column | Meaning |
|
|
409
|
+
|---|---|
|
|
410
|
+
| `serviceability_enabled` | Enables the merchant courier check |
|
|
411
|
+
| `serviceability_webhook_url` | Merchant endpoint called by QuantaRoute |
|
|
412
|
+
| `serviceability_webhook_secret` | Shared HMAC secret for outbound calls |
|
|
413
|
+
| `serviceability_block_checkout` | If true, `serviceable: false` blocks address save |
|
|
414
|
+
| `show_india_post_delivery_warning` | Optional soft India Post info banner fallback |
|
|
415
|
+
|
|
416
|
+
Merchant endpoint contract:
|
|
417
|
+
|
|
418
|
+
```http
|
|
419
|
+
POST /checkout/serviceability
|
|
420
|
+
Content-Type: application/json
|
|
421
|
+
X-QuantaRoute-Timestamp: 1782000000000
|
|
422
|
+
X-QuantaRoute-Signature: v1=<hmac_sha256(timestamp + "." + body)>
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
```json
|
|
426
|
+
{
|
|
427
|
+
"merchant_id": "merchant-uuid",
|
|
428
|
+
"pincode": "110011",
|
|
429
|
+
"lat": 28.6139,
|
|
430
|
+
"lng": 77.209,
|
|
431
|
+
"requested_at": "2026-06-21T00:00:00.000Z"
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Expected response:
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{ "serviceable": true, "message": "Delivery available in 3-5 days" }
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
or:
|
|
442
|
+
|
|
443
|
+
```json
|
|
444
|
+
{ "serviceable": false, "message": "We do not currently ship to this pincode" }
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
If the merchant endpoint errors, times out, or returns an invalid response, checkout **fails open** and the buyer can continue. `showIndiaPostDeliveryWarning` is opt-in and only shows a soft informational banner: "Courier partners may still deliver to this pincode."
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
383
451
|
#### Setting up Resend (required for `enableEmailAuth`)
|
|
384
452
|
|
|
385
453
|
> **Hosted merchants (recommended):** If you onboarded at [developers.quantaroute.com](https://developers.quantaroute.com), QuantaRoute already runs Resend on shared infrastructure. Skip steps 1–5 below — just set `enableEmailAuth={true}` and register your domain in the portal. The steps below apply only when **self-hosting** the `checkout-email-otp` Edge Function in your own Supabase project.
|
|
@@ -845,7 +913,7 @@ When publishing a new version to npm (maintainers only):
|
|
|
845
913
|
2. Run `npm run type-check && npm run build:lib && npm pack --dry-run` — confirm tarball contents.
|
|
846
914
|
3. Confirm no `.env`, `.pem`, or `supabase/` paths in the pack list.
|
|
847
915
|
4. Publish from a **clean git tag** with provenance: `npm publish --provenance --access public`.
|
|
848
|
-
5. Do **not** bump version in the same change unless releasing; current version is `1.4.
|
|
916
|
+
5. Do **not** bump version in the same change unless releasing; current version is `1.4.5`.
|
|
849
917
|
|
|
850
918
|
---
|
|
851
919
|
|
|
@@ -881,7 +949,7 @@ npx expo run:android # requires Android Studio
|
|
|
881
949
|
|
|
882
950
|
## Changelog
|
|
883
951
|
|
|
884
|
-
See [CHANGELOG.md](./CHANGELOG.md) for version history. Current release: **v1.4.
|
|
952
|
+
See [CHANGELOG.md](./CHANGELOG.md) for version history. Current release: **v1.4.5**.
|
|
885
953
|
|
|
886
954
|
---
|
|
887
955
|
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -36,6 +36,18 @@ export declare interface AddressFormProps {
|
|
|
36
36
|
onBack: () => void;
|
|
37
37
|
onError?: (error: Error) => void;
|
|
38
38
|
theme?: 'light' | 'dark';
|
|
39
|
+
/** Checkout API config for merchant serviceability checks. */
|
|
40
|
+
checkoutConfig?: CheckoutApiConfig;
|
|
41
|
+
/** Buyer session token used by checkout-addresses serviceability_check. */
|
|
42
|
+
serviceabilitySessionToken?: string;
|
|
43
|
+
/** When true, calls the merchant courier serviceability endpoint after pincode validation. */
|
|
44
|
+
enableServiceabilityCheck?: boolean;
|
|
45
|
+
/** Shows a soft India Post home-delivery info banner when merchant check is absent/failed. */
|
|
46
|
+
showIndiaPostDeliveryWarning?: boolean;
|
|
47
|
+
/** Optional client override for blocking address save when merchant says not serviceable. */
|
|
48
|
+
serviceabilityBlockCheckout?: boolean;
|
|
49
|
+
/** Optional observer for the merchant serviceability result. */
|
|
50
|
+
onServiceabilityResult?: (result: ServiceabilityResult) => void;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
/** Label for a saved buyer address — stored in checkout-addresses API. */
|
|
@@ -241,6 +253,21 @@ export declare interface CheckoutWidgetProps {
|
|
|
241
253
|
* `checkout.merchants.enable_cod` and optional D1/D2 columns.
|
|
242
254
|
*/
|
|
243
255
|
enableCod?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Call the merchant's courier serviceability webhook for the resolved pincode.
|
|
258
|
+
* Requires `merchantId`, `supabaseFunctionBaseUrl`, and an authenticated checkout session.
|
|
259
|
+
*/
|
|
260
|
+
enableServiceabilityCheck?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Opt-in fallback banner for India Post "Non Delivery" pincodes.
|
|
263
|
+
* Defaults off because courier partners may still deliver.
|
|
264
|
+
*/
|
|
265
|
+
showIndiaPostDeliveryWarning?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Client override: block address save when merchant serviceability says not deliverable.
|
|
268
|
+
* If omitted, the server result from checkout.merchants.serviceability_block_checkout is used.
|
|
269
|
+
*/
|
|
270
|
+
serviceabilityBlockCheckout?: boolean;
|
|
244
271
|
/**
|
|
245
272
|
* Cart total in paise for the COD cart cap (D2). Omit if the cart total is unknown.
|
|
246
273
|
*/
|
|
@@ -307,6 +334,15 @@ export declare interface CheckoutWidgetProps {
|
|
|
307
334
|
registerController?: (controller: CheckoutWidgetController) => void;
|
|
308
335
|
}
|
|
309
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Check merchant courier serviceability for a pincode.
|
|
339
|
+
* Uses the merchant's configured webhook on checkout.merchants and fails open.
|
|
340
|
+
*/
|
|
341
|
+
export declare function checkServiceability(config: CheckoutApiConfig, sessionToken: string, pincode: string, coords?: {
|
|
342
|
+
lat?: number;
|
|
343
|
+
lng?: number;
|
|
344
|
+
}): Promise<ServiceabilityResult>;
|
|
345
|
+
|
|
310
346
|
/**
|
|
311
347
|
* Shows COD availability after checkout using `cod_eligibility` (merchant `enable_cod` + D1/D2).
|
|
312
348
|
*/
|
|
@@ -368,6 +404,8 @@ export declare interface CompleteAddress {
|
|
|
368
404
|
formattedAddress: string;
|
|
369
405
|
/** Buyer-chosen label for saved-address book (defaults to home) */
|
|
370
406
|
label?: AddressLabel;
|
|
407
|
+
/** Custom label text when `label` is `other` (e.g. "Friend's home") */
|
|
408
|
+
labelText?: string;
|
|
371
409
|
/** Set when the buyer re-selected an existing saved row (skip createAddress). */
|
|
372
410
|
addressId?: string;
|
|
373
411
|
}
|
|
@@ -377,6 +415,12 @@ export declare interface Coordinates {
|
|
|
377
415
|
lng: number;
|
|
378
416
|
}
|
|
379
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Returns true while the user is typing a DigiPin (compact, dashed, or spaced).
|
|
420
|
+
* Used to suppress address autocomplete until the code is complete or abandoned.
|
|
421
|
+
*/
|
|
422
|
+
export declare function couldBeDigiPinInput(input: string): boolean;
|
|
423
|
+
|
|
380
424
|
/** Save a new address for the authenticated buyer. */
|
|
381
425
|
export declare function createAddress(config: CheckoutApiConfig, sessionToken: string, address: SavedAddressPayload): Promise<SavedAddress>;
|
|
382
426
|
|
|
@@ -488,6 +532,9 @@ export declare function hasUtmParams(utm: UtmParams): boolean;
|
|
|
488
532
|
/** True when input is a complete 10-character DigiPin (any common separator style). */
|
|
489
533
|
export declare function isCompleteDigiPinInput(input: string): boolean;
|
|
490
534
|
|
|
535
|
+
/** True when normalised input is a non-empty prefix of a DigiPin (still being typed). */
|
|
536
|
+
export declare function isPotentialDigiPinInput(input: string): boolean;
|
|
537
|
+
|
|
491
538
|
/**
|
|
492
539
|
* Validate a DigiPin string (format + character check).
|
|
493
540
|
*/
|
|
@@ -721,6 +768,8 @@ export declare interface SavedAddress {
|
|
|
721
768
|
building_name: string;
|
|
722
769
|
street_name: string;
|
|
723
770
|
label: string;
|
|
771
|
+
/** Custom display text when label is `other` */
|
|
772
|
+
label_text: string | null;
|
|
724
773
|
is_default: boolean;
|
|
725
774
|
created_at: string;
|
|
726
775
|
updated_at: string;
|
|
@@ -743,6 +792,7 @@ export declare interface SavedAddressPayload {
|
|
|
743
792
|
street_name?: string;
|
|
744
793
|
full_address_json?: Record<string, unknown>;
|
|
745
794
|
label?: string;
|
|
795
|
+
label_text?: string | null;
|
|
746
796
|
is_default?: boolean;
|
|
747
797
|
}
|
|
748
798
|
|
|
@@ -767,6 +817,25 @@ export declare interface SendEmailOtpResult {
|
|
|
767
817
|
/** Send OTP to the given mobile number. Throws on failure. */
|
|
768
818
|
export declare function sendOtp(config: CheckoutApiConfig, mobile: string): Promise<void>;
|
|
769
819
|
|
|
820
|
+
export declare interface ServiceabilityResult {
|
|
821
|
+
/** Whether a merchant serviceability endpoint was configured and enabled. */
|
|
822
|
+
enabled: boolean;
|
|
823
|
+
/** Whether the merchant endpoint returned a definitive response. */
|
|
824
|
+
checked: boolean;
|
|
825
|
+
/** true/false when checked, null when disabled or failed open. */
|
|
826
|
+
serviceable: boolean | null;
|
|
827
|
+
/** Normalized 6-digit pincode when valid; otherwise the trimmed input. */
|
|
828
|
+
pincode: string;
|
|
829
|
+
/** Buyer-facing merchant message, when supplied by the merchant endpoint. */
|
|
830
|
+
message?: string;
|
|
831
|
+
/** Whether the widget should block address submission when not serviceable. */
|
|
832
|
+
block_checkout: boolean;
|
|
833
|
+
/** Whether the merchant wants the soft India Post info banner as fallback. */
|
|
834
|
+
show_india_post_delivery_warning: boolean;
|
|
835
|
+
/** Present when the endpoint was skipped or failed open. */
|
|
836
|
+
reason?: 'not_configured' | 'invalid_pincode' | 'merchant_error' | 'merchant_unreachable' | 'invalid_response';
|
|
837
|
+
}
|
|
838
|
+
|
|
770
839
|
/** Device + UTM context sent with OTP verify to enrich checkout sessions. */
|
|
771
840
|
export declare interface SessionContextPayload {
|
|
772
841
|
utm_source?: string;
|