@quantaroute/checkout 1.7.0 → 1.7.2
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 +27 -0
- package/dist/lib/index.d.ts +122 -1
- package/dist/lib/quantaroute-checkout.es.js +201 -183
- package/dist/lib/quantaroute-checkout.umd.js +138 -120
- package/dist/style.css +1 -1
- package/package.json +6 -6
- package/src/components/CheckoutWidget.tsx +62 -11
- package/src/components/MapPinSelector.tsx +251 -167
- package/src/components/PaymentStep.tsx +17 -1
- package/src/core/checkout-api.ts +79 -0
- package/src/core/map-runtime.ts +100 -0
- package/src/core/types.ts +40 -1
- package/src/index.ts +19 -0
- package/src/styles/checkout.css +47 -28
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,33 @@ Release dates are from git history where available; earlier versions are estimat
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.7.2](https://github.com/quantaroute/checkout/compare/v1.7.1...v1.7.2) — 2026-07-06
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`mapStyle` prop** on `MapPinSelector` and `CheckoutWidget` — override the MapLibre basemap URL (e.g. `OPENFREEMAP_POSITRON_STYLE_URL` when Carto credentials are unavailable)
|
|
15
|
+
- **`embedMode` prop** (`bundled` | `external`) — `external` waits for `window.maplibregl` from a CDN script before initialising the map (Shopify theme extensions, script-tag embeds)
|
|
16
|
+
- **`MapRuntime` interface** and helpers (`getExternalMapRuntime`, `waitForExternalMapRuntime`, `DEFAULT_MAP_STYLE_URL`, `OPENFREEMAP_POSITRON_STYLE_URL`) exported from the package
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **MapPinSelector (web)** — loading/unavailable/error states when MapLibre is slow or missing; confirm and locate buttons disabled until the map is ready
|
|
21
|
+
|
|
22
|
+
## [1.7.1](https://github.com/quantaroute/checkout/compare/v1.7.0...v1.7.1) — 2026-07-06
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **Map locate button** — stays in the top-right on mobile (no overlap with attribution toggle); matches MapLibre zoom control size (29×29px) and alignment on all viewports
|
|
27
|
+
- **Map attribution** — compact attribution starts collapsed (icon only); full credits expand on click
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Address Intelligence (opt-in)** — `enableAddressIntelligence` prop, `scoreAddressRisk()` helper, payment-step risk banner, and optional COD restriction for high-risk addresses (requires deployed `checkout-addresses` backend; defaults off)
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- `CompleteAddress` now includes saved `addressId` after `createAddress` completes
|
|
36
|
+
|
|
10
37
|
## [1.7.0](https://github.com/quantaroute/checkout/compare/v1.6.0...v1.7.0) — 2026-06-28
|
|
11
38
|
|
|
12
39
|
### Added
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { AttributionControl } from 'maplibre-gl';
|
|
1
2
|
import { default as default_2 } from 'react';
|
|
3
|
+
import { Map as MapLibreMap } from 'maplibre-gl';
|
|
4
|
+
import { Marker as MapLibreMarker } from 'maplibre-gl';
|
|
5
|
+
import { MapMouseEvent } from 'maplibre-gl';
|
|
6
|
+
import { NavigationControl } from 'maplibre-gl';
|
|
2
7
|
import { ReactNode } from 'react';
|
|
3
8
|
|
|
4
9
|
export declare const ADDRESS_LABELS: AddressLabel[];
|
|
@@ -24,6 +29,8 @@ export declare interface AddressComponents {
|
|
|
24
29
|
[key: string]: string | undefined;
|
|
25
30
|
}
|
|
26
31
|
|
|
32
|
+
export declare type AddressConfidenceState = 'new_source_collected' | 'buyer_reconfirmed' | 'merchant_successful' | 'courier_corrected' | 'rto_associated' | 'trusted_repeat';
|
|
33
|
+
|
|
27
34
|
export declare const AddressForm: default_2.FC<AddressFormProps>;
|
|
28
35
|
|
|
29
36
|
/** Pre-fill manual fields when verifying an imported saved address. */
|
|
@@ -65,9 +72,54 @@ export declare interface AddressFormProps {
|
|
|
65
72
|
onServiceabilityResult?: (result: ServiceabilityResult) => void;
|
|
66
73
|
}
|
|
67
74
|
|
|
75
|
+
export declare type AddressIntervention = 'none' | 'request_missing_details' | 'reconfirm_pin' | 'prepaid_nudge' | 'hide_cod' | 'manual_review' | 'delivery_instruction';
|
|
76
|
+
|
|
68
77
|
/** Label for a saved buyer address — stored in checkout-addresses API. */
|
|
69
78
|
export declare type AddressLabel = 'home' | 'work' | 'other';
|
|
70
79
|
|
|
80
|
+
export declare type AddressRiskLevel = 'low' | 'medium' | 'high';
|
|
81
|
+
|
|
82
|
+
export declare interface AddressRiskPayload {
|
|
83
|
+
address_id?: string;
|
|
84
|
+
digipin?: string;
|
|
85
|
+
lat?: number;
|
|
86
|
+
lng?: number;
|
|
87
|
+
pincode?: string;
|
|
88
|
+
state?: string;
|
|
89
|
+
district?: string;
|
|
90
|
+
locality?: string;
|
|
91
|
+
delivery_status?: string;
|
|
92
|
+
flat_number?: string;
|
|
93
|
+
floor_number?: string;
|
|
94
|
+
building_name?: string;
|
|
95
|
+
street_name?: string;
|
|
96
|
+
payment_method?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export declare interface AddressRiskScore {
|
|
100
|
+
level: AddressRiskLevel;
|
|
101
|
+
score: number;
|
|
102
|
+
reasons: string[];
|
|
103
|
+
interventions: AddressIntervention[];
|
|
104
|
+
confidence_state: AddressConfidenceState;
|
|
105
|
+
signals: AddressRiskSignals;
|
|
106
|
+
scored_at: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare interface AddressRiskSignals {
|
|
110
|
+
merchant_history_records: number;
|
|
111
|
+
buyer_successful_deliveries: number;
|
|
112
|
+
buyer_rto_orders: number;
|
|
113
|
+
pincode_successful_deliveries: number;
|
|
114
|
+
pincode_rto_orders: number;
|
|
115
|
+
digipin_cell_successful_deliveries: number;
|
|
116
|
+
digipin_cell_rto_orders: number;
|
|
117
|
+
repeat_verified_address: boolean;
|
|
118
|
+
imported_address_pending_digipin: boolean;
|
|
119
|
+
cod_requested: boolean;
|
|
120
|
+
address_edit_count: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
71
123
|
export declare interface AdministrativeInfo {
|
|
72
124
|
country?: string;
|
|
73
125
|
state: string;
|
|
@@ -165,12 +217,16 @@ export declare interface CheckoutEvent {
|
|
|
165
217
|
experimentVariant?: string;
|
|
166
218
|
/** DigiPin of the confirmed location. Available after `location_confirmed` and `address_completed`. */
|
|
167
219
|
digipin?: string;
|
|
220
|
+
/** Address risk level when `address_risk_scored` fires. */
|
|
221
|
+
addressRiskLevel?: AddressRiskScore['level'];
|
|
222
|
+
/** Address risk score (0-100) when address intelligence is enabled. */
|
|
223
|
+
addressRiskScore?: number;
|
|
168
224
|
/** ISO timestamp of when the event fired. */
|
|
169
225
|
timestamp: string;
|
|
170
226
|
}
|
|
171
227
|
|
|
172
228
|
/** All step-transition event types emitted by the widget. */
|
|
173
|
-
export declare type CheckoutEventType = 'phone_step_viewed' | 'otp_sent' | 'phone_verified' | 'email_step_viewed' | 'email_otp_sent' | 'email_verified' | 'auth_skipped' | 'saved_addresses_viewed' | 'saved_address_selected' | 'verify_address_step_viewed' | 'map_step_viewed' | 'location_confirmed' | 'form_step_viewed' | 'address_completed' | 'widget_reset' | 'payment_step_viewed' | 'payment_method_selected' | 'session_abandoned';
|
|
229
|
+
export declare type CheckoutEventType = 'phone_step_viewed' | 'otp_sent' | 'phone_verified' | 'email_step_viewed' | 'email_otp_sent' | 'email_verified' | 'auth_skipped' | 'saved_addresses_viewed' | 'saved_address_selected' | 'verify_address_step_viewed' | 'map_step_viewed' | 'location_confirmed' | 'form_step_viewed' | 'address_completed' | 'address_risk_scored' | 'widget_reset' | 'payment_step_viewed' | 'payment_method_selected' | 'session_abandoned';
|
|
174
230
|
|
|
175
231
|
export declare type CheckoutMobilePresentation = 'auto' | 'sheet' | 'card';
|
|
176
232
|
|
|
@@ -243,6 +299,16 @@ export declare interface CheckoutWidgetProps {
|
|
|
243
299
|
* Example: indiaBoundaryUrl="/geojson/india.geojson"
|
|
244
300
|
*/
|
|
245
301
|
indiaBoundaryUrl?: string;
|
|
302
|
+
/**
|
|
303
|
+
* MapLibre style URL for the map step. Defaults to Carto Positron.
|
|
304
|
+
* Pass `OPENFREEMAP_POSITRON_STYLE_URL` when Carto basemaps require credentials.
|
|
305
|
+
*/
|
|
306
|
+
mapStyle?: string;
|
|
307
|
+
/**
|
|
308
|
+
* How MapLibre GL JS is loaded on web. `external` waits for `window.maplibregl`
|
|
309
|
+
* when the host loads MapLibre from a CDN (e.g. Shopify theme extensions).
|
|
310
|
+
*/
|
|
311
|
+
embedMode?: MapEmbedMode;
|
|
246
312
|
/**
|
|
247
313
|
* Show the smart search bar on the map step (default: true).
|
|
248
314
|
* Supports address search (API) and DigiPin lookup (100% offline).
|
|
@@ -288,6 +354,11 @@ export declare interface CheckoutWidgetProps {
|
|
|
288
354
|
* Requires `merchantId`, `supabaseFunctionBaseUrl`, and an authenticated checkout session.
|
|
289
355
|
*/
|
|
290
356
|
enableServiceabilityCheck?: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Score address-discrepancy-led RTO risk after address completion.
|
|
359
|
+
* Requires `merchantId`, `supabaseFunctionBaseUrl`, and phone/email auth or `codSessionToken`.
|
|
360
|
+
*/
|
|
361
|
+
enableAddressIntelligence?: boolean;
|
|
291
362
|
/**
|
|
292
363
|
* Opt-in fallback banner for India Post "Non Delivery" pincodes.
|
|
293
364
|
* Defaults off because courier partners may still deliver.
|
|
@@ -447,6 +518,8 @@ export declare interface CompleteAddress {
|
|
|
447
518
|
labelText?: string;
|
|
448
519
|
/** Set when the buyer re-selected an existing saved row (skip createAddress). */
|
|
449
520
|
addressId?: string;
|
|
521
|
+
/** Explainable checkout-time address discrepancy risk, when enabled. */
|
|
522
|
+
addressRisk?: AddressRiskScore;
|
|
450
523
|
}
|
|
451
524
|
|
|
452
525
|
export declare interface Coordinates {
|
|
@@ -472,6 +545,9 @@ export declare interface CreatePaymentOrderResult {
|
|
|
472
545
|
currency: string;
|
|
473
546
|
}
|
|
474
547
|
|
|
548
|
+
/** Carto Positron — default basemap for standard web embeds. */
|
|
549
|
+
export declare const DEFAULT_MAP_STYLE_URL = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json";
|
|
550
|
+
|
|
475
551
|
/** Soft-delete a saved address. */
|
|
476
552
|
export declare function deleteAddress(config: CheckoutApiConfig, sessionToken: string, addressId: string): Promise<void>;
|
|
477
553
|
|
|
@@ -556,6 +632,8 @@ export declare interface FunnelEventPayload {
|
|
|
556
632
|
*/
|
|
557
633
|
export declare function getDigiPin(lat: number, lon: number): string;
|
|
558
634
|
|
|
635
|
+
export declare function getExternalMapRuntime(): MapRuntime | null;
|
|
636
|
+
|
|
559
637
|
/**
|
|
560
638
|
* Decode a DigiPin code back to center-point coordinates.
|
|
561
639
|
* @throws if the DigiPin format is invalid
|
|
@@ -630,6 +708,19 @@ export declare function looksLikeDigiPin(input: string): boolean;
|
|
|
630
708
|
*/
|
|
631
709
|
export declare function lookupLocation(lat: number, lng: number, apiKey: string, baseUrl?: string): Promise<LocationLookupResponse>;
|
|
632
710
|
|
|
711
|
+
/**
|
|
712
|
+
* How the host provides MapLibre GL JS.
|
|
713
|
+
* - `bundled`: import from `maplibre-gl` (default — Next.js, Vite apps with the peer installed)
|
|
714
|
+
* - `external`: read from `window.maplibregl` (CDN script loaded before the widget, e.g. Shopify)
|
|
715
|
+
*/
|
|
716
|
+
export declare type MapEmbedMode = 'bundled' | 'external';
|
|
717
|
+
|
|
718
|
+
export { MapLibreMap }
|
|
719
|
+
|
|
720
|
+
export { MapLibreMarker }
|
|
721
|
+
|
|
722
|
+
export { MapMouseEvent }
|
|
723
|
+
|
|
633
724
|
export declare const MapPinSelector: default_2.FC<MapPinSelectorProps>;
|
|
634
725
|
|
|
635
726
|
export declare interface MapPinSelectorProps {
|
|
@@ -663,6 +754,24 @@ export declare interface MapPinSelectorProps {
|
|
|
663
754
|
* Brand accent colour (hex, e.g. `#7c3aed`). Sets map pin, buttons, focus rings via `--qr-primary` on web.
|
|
664
755
|
*/
|
|
665
756
|
brandColor?: string;
|
|
757
|
+
/**
|
|
758
|
+
* MapLibre style URL for the basemap. Defaults to Carto Positron.
|
|
759
|
+
* Use `OPENFREEMAP_POSITRON_STYLE_URL` when Carto credentials are unavailable.
|
|
760
|
+
*/
|
|
761
|
+
mapStyle?: string;
|
|
762
|
+
/**
|
|
763
|
+
* How MapLibre GL JS is loaded on web. `bundled` imports the peer dependency;
|
|
764
|
+
* `external` waits for `window.maplibregl` (CDN script loaded by the host).
|
|
765
|
+
*/
|
|
766
|
+
embedMode?: MapEmbedMode;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/** Subset of maplibre-gl used by the web MapPinSelector. */
|
|
770
|
+
export declare interface MapRuntime {
|
|
771
|
+
Map: new (options: ConstructorParameters<MapLibreMap>[0]) => MapLibreMap;
|
|
772
|
+
Marker: new (options?: ConstructorParameters<MapLibreMarker>[0]) => MapLibreMarker;
|
|
773
|
+
AttributionControl?: new (options?: ConstructorParameters<NonNullable<AttributionControl>>[0]) => AttributionControl;
|
|
774
|
+
NavigationControl?: new (options?: ConstructorParameters<NonNullable<NavigationControl>>[0]) => NavigationControl;
|
|
666
775
|
}
|
|
667
776
|
|
|
668
777
|
/**
|
|
@@ -687,6 +796,9 @@ export declare function notifyAddressCompleted(config: CheckoutApiConfig, sessio
|
|
|
687
796
|
/** Signal explicit session abandonment (page exit). */
|
|
688
797
|
export declare function notifySessionAbandoned(config: CheckoutApiConfig, sessionToken: string, lastStep: string): Promise<void>;
|
|
689
798
|
|
|
799
|
+
/** OpenFreeMap Positron — free, no API key (used when Carto credentials are unavailable). */
|
|
800
|
+
export declare const OPENFREEMAP_POSITRON_STYLE_URL = "https://tiles.openfreemap.org/styles/positron";
|
|
801
|
+
|
|
690
802
|
export declare const OtpStep: default_2.FC<OtpStepProps>;
|
|
691
803
|
|
|
692
804
|
export declare interface OtpStepProps {
|
|
@@ -707,6 +819,7 @@ export declare interface PaymentStepProps {
|
|
|
707
819
|
amountPaise: number;
|
|
708
820
|
enableCod?: boolean;
|
|
709
821
|
codAllowed?: boolean;
|
|
822
|
+
addressRisk?: AddressRiskScore | null;
|
|
710
823
|
theme?: 'light' | 'dark';
|
|
711
824
|
onComplete: (result: {
|
|
712
825
|
paymentMethod: string;
|
|
@@ -851,6 +964,8 @@ export declare interface SavedAddressStepProps {
|
|
|
851
964
|
onAddNew: () => void;
|
|
852
965
|
}
|
|
853
966
|
|
|
967
|
+
export declare function scoreAddressRisk(config: CheckoutApiConfig, sessionToken: string, payload: AddressRiskPayload): Promise<AddressRiskScore>;
|
|
968
|
+
|
|
854
969
|
/** Record the buyer's address choice for the current checkout session. */
|
|
855
970
|
export declare function selectAddress(config: CheckoutApiConfig, sessionToken: string, addressId: string): Promise<void>;
|
|
856
971
|
|
|
@@ -990,4 +1105,10 @@ export declare function verifyPayment(config: CheckoutApiConfig, sessionToken: s
|
|
|
990
1105
|
razorpay_payment_id: string;
|
|
991
1106
|
}>;
|
|
992
1107
|
|
|
1108
|
+
/**
|
|
1109
|
+
* Poll `window.maplibregl` until available or timeout (for async CDN loads).
|
|
1110
|
+
* Returns a cancel function for useEffect cleanup.
|
|
1111
|
+
*/
|
|
1112
|
+
export declare function waitForExternalMapRuntime(onReady: (runtime: MapRuntime) => void, onUnavailable: () => void, waitMs?: number, retryMs?: number): () => void;
|
|
1113
|
+
|
|
993
1114
|
export { }
|