@quantaroute/checkout 1.3.1 → 1.4.0
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/README.md +345 -0
- package/dist/lib/index.d.ts +481 -8
- package/dist/lib/quantaroute-checkout.es.js +238 -1285
- package/dist/lib/quantaroute-checkout.umd.js +211 -64
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/components/AddressForm.native.tsx +56 -1
- package/src/components/AddressForm.tsx +55 -1
- package/src/components/CheckoutWidget.native.tsx +88 -21
- package/src/components/CheckoutWidget.tsx +579 -47
- package/src/components/CodAvailabilityBanner.native.tsx +108 -0
- package/src/components/CodAvailabilityBanner.tsx +104 -0
- package/src/components/EmailOtpStep.tsx +198 -0
- package/src/components/EmailStep.tsx +108 -0
- package/src/components/MapPinSelector.native.tsx +37 -25
- package/src/components/MapPinSelector.tsx +10 -5
- package/src/components/OtpStep.tsx +227 -0
- package/src/components/PaymentStep.tsx +162 -0
- package/src/components/PhoneStep.tsx +124 -0
- package/src/components/PrepaidNudge.tsx +31 -0
- package/src/components/SavedAddressStep.tsx +281 -0
- package/src/core/api.ts +86 -0
- package/src/core/checkout-api.ts +458 -0
- package/src/core/device.ts +47 -0
- package/src/core/types.ts +217 -3
- package/src/core/utm.ts +29 -0
- package/src/index.ts +65 -1
- package/src/styles/checkout.css +614 -0
- package/src/styles/checkout.native.ts +144 -0
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Address components from Nominatim/OpenStreetMap (via reverse geocoding).
|
|
@@ -43,9 +44,6 @@ export declare interface AdministrativeInfo {
|
|
|
43
44
|
pincode: string;
|
|
44
45
|
delivery: string;
|
|
45
46
|
district: string;
|
|
46
|
-
mean_population_density?: number;
|
|
47
|
-
min_population_density?: number;
|
|
48
|
-
max_population_density?: number;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
declare type AnyStyle = any;
|
|
@@ -89,15 +87,70 @@ export declare interface AutocompleteSuggestion {
|
|
|
89
87
|
};
|
|
90
88
|
}
|
|
91
89
|
|
|
90
|
+
/** Read UTM params from the current page URL (web). Returns {} on native or SSR. */
|
|
91
|
+
export declare function captureUtmFromUrl(href?: string): UtmParams;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Check COD availability for a delivery pincode (Edge: `cod_eligibility`).
|
|
95
|
+
* Respects `checkout.merchants.enable_cod` (C4), `cod_blocked_pincodes` / `cod_max_cart_value_paise` (D1/D2).
|
|
96
|
+
* Pass `cartTotalPaise` in paise (e.g. ₹499 → 49900) to enforce the cart cap when set.
|
|
97
|
+
*/
|
|
98
|
+
export declare function checkCodEligibility(config: CheckoutApiConfig, sessionToken: string, pincode: string, cartTotalPaise?: number): Promise<CodEligibilityResult>;
|
|
99
|
+
|
|
100
|
+
export declare interface CheckoutApiConfig {
|
|
101
|
+
/** Supabase Edge Function base URL, e.g. https://<project>.supabase.co/functions/v1 */
|
|
102
|
+
functionBaseUrl: string;
|
|
103
|
+
/** UUID of the merchant from checkout.merchants */
|
|
104
|
+
merchantId: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Payload delivered to `onCheckoutEvent` on every step transition.
|
|
109
|
+
* Forward this to MoEngage, Clevertap, GTM, or your own analytics.
|
|
110
|
+
*/
|
|
111
|
+
export declare interface CheckoutEvent {
|
|
112
|
+
/** The event that just occurred. */
|
|
113
|
+
type: CheckoutEventType;
|
|
114
|
+
/** The step the widget moved INTO. */
|
|
115
|
+
step: string;
|
|
116
|
+
/** Buyer's phone number (E.164) or email. Available after OTP sent. */
|
|
117
|
+
mobile?: string;
|
|
118
|
+
/** Internal buyer UUID. Available after auth verification. */
|
|
119
|
+
buyerId?: string;
|
|
120
|
+
/** Checkout session UUID. Available after auth verification. */
|
|
121
|
+
sessionId?: string;
|
|
122
|
+
/** Auth channel used in this session. */
|
|
123
|
+
authChannel?: 'phone' | 'email' | 'none';
|
|
124
|
+
/** Device class: mobile | tablet | desktop */
|
|
125
|
+
deviceType?: 'mobile' | 'tablet' | 'desktop';
|
|
126
|
+
/** Platform: web | ios | android */
|
|
127
|
+
platform?: 'web' | 'ios' | 'android';
|
|
128
|
+
/** Truncated user agent (web). */
|
|
129
|
+
userAgent?: string;
|
|
130
|
+
/** Payment method when selected: cod | prepaid | upi | card | … */
|
|
131
|
+
paymentMethod?: string;
|
|
132
|
+
/** A/B experiment variant label from `variant` prop. */
|
|
133
|
+
experimentVariant?: string;
|
|
134
|
+
/** DigiPin of the confirmed location. Available after `location_confirmed` and `address_completed`. */
|
|
135
|
+
digipin?: string;
|
|
136
|
+
/** ISO timestamp of when the event fired. */
|
|
137
|
+
timestamp: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** All step-transition event types emitted by the widget. */
|
|
141
|
+
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' | 'map_step_viewed' | 'location_confirmed' | 'form_step_viewed' | 'address_completed' | 'widget_reset' | 'payment_step_viewed' | 'payment_method_selected' | 'session_abandoned';
|
|
142
|
+
|
|
143
|
+
declare type CheckoutPlatform = 'web' | 'ios' | 'android';
|
|
144
|
+
|
|
92
145
|
/**
|
|
93
146
|
* QuantaRoute Checkout Widget
|
|
94
147
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* Step 2 – Form: auto-filled address + manual flat/building details
|
|
148
|
+
* Default (enablePhoneAuth = false):
|
|
149
|
+
* map → form → done
|
|
98
150
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
151
|
+
* With phone auth (enablePhoneAuth = true):
|
|
152
|
+
* phone → otp → saved → map → form → done
|
|
153
|
+
* (buyer can skip phone auth to go straight to map)
|
|
101
154
|
*/
|
|
102
155
|
declare const CheckoutWidget: default_2.FC<CheckoutWidgetProps>;
|
|
103
156
|
export { CheckoutWidget }
|
|
@@ -143,6 +196,126 @@ export declare interface CheckoutWidgetProps {
|
|
|
143
196
|
* and the map instantly flies to their ~4m × 4m location — zero API cost.
|
|
144
197
|
*/
|
|
145
198
|
enableSearch?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Enable phone OTP authentication for saved addresses (default: false).
|
|
201
|
+
* When true, the widget starts with a phone entry step so returning buyers
|
|
202
|
+
* can access their previously saved addresses — reducing re-entry friction.
|
|
203
|
+
* Requires merchantId and supabaseFunctionBaseUrl to be set.
|
|
204
|
+
* Takes precedence over enableEmailAuth if both are set.
|
|
205
|
+
*/
|
|
206
|
+
enablePhoneAuth?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Enable email OTP authentication via Resend (default: false).
|
|
209
|
+
* When true (and enablePhoneAuth is false), the widget starts with an email
|
|
210
|
+
* entry step. Requires merchantId and supabaseFunctionBaseUrl to be set.
|
|
211
|
+
* Needs RESEND_API_KEY + RESEND_FROM_EMAIL on the checkout-email-otp Edge Function.
|
|
212
|
+
*/
|
|
213
|
+
enableEmailAuth?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* UUID of your merchant record in checkout.merchants.
|
|
216
|
+
* Required when enablePhoneAuth or enableEmailAuth is true.
|
|
217
|
+
*/
|
|
218
|
+
merchantId?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Base URL of your Supabase Edge Functions deployment.
|
|
221
|
+
* Example: "https://ikfiewesidedxozotmrl.supabase.co/functions/v1"
|
|
222
|
+
* Required when enablePhoneAuth or enableEmailAuth is true.
|
|
223
|
+
*/
|
|
224
|
+
supabaseFunctionBaseUrl?: string;
|
|
225
|
+
/**
|
|
226
|
+
* When true, shows a Cash on Delivery availability strip on the success screen
|
|
227
|
+
* (calls `cod_eligibility`). Requires `merchantId`, `supabaseFunctionBaseUrl`, and a
|
|
228
|
+
* session token from phone auth or `codSessionToken`. On the server, set
|
|
229
|
+
* `checkout.merchants.enable_cod` and optional D1/D2 columns.
|
|
230
|
+
*/
|
|
231
|
+
enableCod?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Cart total in paise for the COD cart cap (D2). Omit if the cart total is unknown.
|
|
234
|
+
*/
|
|
235
|
+
codCartTotalPaise?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Session token for the COD check when your app manages auth outside the widget’s phone flow.
|
|
238
|
+
*/
|
|
239
|
+
codSessionToken?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Brand accent colour (hex, e.g. `#7c3aed`). On web, sets `--qr-primary` on the root; on native, passed to the map pin and header accents.
|
|
242
|
+
*/
|
|
243
|
+
brandColor?: string;
|
|
244
|
+
/**
|
|
245
|
+
* Merchant logo URL shown in the widget header (replaces default map icon when set).
|
|
246
|
+
*/
|
|
247
|
+
logoUrl?: string;
|
|
248
|
+
/**
|
|
249
|
+
* Optional slot below the header row for trust badges, free-shipping strip, or any custom JSX.
|
|
250
|
+
*/
|
|
251
|
+
headerBanner?: ReactNode;
|
|
252
|
+
/**
|
|
253
|
+
* Client-side analytics hook. Called on every step transition so you can
|
|
254
|
+
* forward events to MoEngage, Clevertap, GTM, or your own backend.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* onCheckoutEvent={(event) => {
|
|
258
|
+
* Moengage.track_event(event.type, { step: event.step, buyerId: event.buyerId });
|
|
259
|
+
* }}
|
|
260
|
+
*/
|
|
261
|
+
onCheckoutEvent?: (event: CheckoutEvent) => void;
|
|
262
|
+
/**
|
|
263
|
+
* A/B experiment variant label — included on every `onCheckoutEvent` payload
|
|
264
|
+
* and stored on the checkout session for funnel breakdowns.
|
|
265
|
+
*/
|
|
266
|
+
variant?: string;
|
|
267
|
+
/**
|
|
268
|
+
* UTM params captured from the page URL at widget mount (web).
|
|
269
|
+
* Stored on the session when the buyer verifies OTP.
|
|
270
|
+
*/
|
|
271
|
+
utmParams?: UtmParams;
|
|
272
|
+
/**
|
|
273
|
+
* Enable Razorpay payment step after address completion (requires merchant Razorpay keys).
|
|
274
|
+
*/
|
|
275
|
+
enablePayment?: boolean;
|
|
276
|
+
/** Cart total in paise for Razorpay order creation. Required when enablePayment is true. */
|
|
277
|
+
paymentAmountPaise?: number;
|
|
278
|
+
/** Called when payment completes (prepaid or COD). */
|
|
279
|
+
onPaymentComplete?: (result: {
|
|
280
|
+
paymentMethod: string;
|
|
281
|
+
sessionId?: string;
|
|
282
|
+
}) => void;
|
|
283
|
+
/**
|
|
284
|
+
* Show prepaid conversion nudge when COD is eligible (merchant `prepaid_nudge_copy` or prop override).
|
|
285
|
+
*/
|
|
286
|
+
enablePrepaidNudge?: boolean;
|
|
287
|
+
/** Override merchant prepaid nudge copy. */
|
|
288
|
+
prepaidNudgeCopy?: string;
|
|
289
|
+
/** Override merchant prepaid nudge CTA URL. */
|
|
290
|
+
prepaidNudgeCtaUrl?: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Shows COD availability after checkout using `cod_eligibility` (merchant `enable_cod` + D1/D2).
|
|
295
|
+
*/
|
|
296
|
+
export declare const CodAvailabilityBanner: default_2.FC<CodAvailabilityBannerProps>;
|
|
297
|
+
|
|
298
|
+
declare interface CodAvailabilityBannerProps {
|
|
299
|
+
checkoutConfig: CheckoutApiConfig;
|
|
300
|
+
sessionToken: string;
|
|
301
|
+
pincode: string;
|
|
302
|
+
cartTotalPaise?: number;
|
|
303
|
+
theme?: 'light' | 'dark';
|
|
304
|
+
/** Called when COD eligibility is resolved (for prepaid nudge gating). */
|
|
305
|
+
onCodAllowedChange?: (allowed: boolean) => void;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export declare interface CodEligibilityResult {
|
|
309
|
+
/** Whether COD is allowed for this pincode for the session merchant. */
|
|
310
|
+
cod_allowed: boolean;
|
|
311
|
+
/** Normalized 6-digit pincode when valid; otherwise the trimmed input. */
|
|
312
|
+
pincode: string;
|
|
313
|
+
/** Present when COD is not allowed or the pincode could not be normalized. */
|
|
314
|
+
reason?: 'cod_disabled' | 'pincode_blocked' | 'invalid_pincode' | 'cart_value_exceeded';
|
|
315
|
+
/** Merchant COD cart cap in paise; null when unlimited. */
|
|
316
|
+
cod_max_cart_value_paise?: number | null;
|
|
317
|
+
/** Echo of `cartTotalPaise` when sent. */
|
|
318
|
+
cart_total_paise?: number;
|
|
146
319
|
}
|
|
147
320
|
|
|
148
321
|
export declare interface CompleteAddress {
|
|
@@ -183,6 +356,36 @@ export declare interface Coordinates {
|
|
|
183
356
|
lng: number;
|
|
184
357
|
}
|
|
185
358
|
|
|
359
|
+
/** Save a new address for the authenticated buyer. */
|
|
360
|
+
export declare function createAddress(config: CheckoutApiConfig, sessionToken: string, address: SavedAddressPayload): Promise<SavedAddress>;
|
|
361
|
+
|
|
362
|
+
export declare function createPaymentOrder(config: CheckoutApiConfig, sessionToken: string, amountPaise: number): Promise<CreatePaymentOrderResult>;
|
|
363
|
+
|
|
364
|
+
export declare interface CreatePaymentOrderResult {
|
|
365
|
+
razorpay_order_id: string;
|
|
366
|
+
razorpay_key_id: string;
|
|
367
|
+
amount_paise: number;
|
|
368
|
+
currency: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** Soft-delete a saved address. */
|
|
372
|
+
export declare function deleteAddress(config: CheckoutApiConfig, sessionToken: string, addressId: string): Promise<void>;
|
|
373
|
+
|
|
374
|
+
/** Detect coarse device class from viewport / user agent (web only). */
|
|
375
|
+
export declare function detectDeviceType(userAgent?: string): DeviceType;
|
|
376
|
+
|
|
377
|
+
/** Web checkout platform; native widgets pass platform explicitly. */
|
|
378
|
+
export declare function detectPlatform(): CheckoutPlatform;
|
|
379
|
+
|
|
380
|
+
declare interface DeviceContext {
|
|
381
|
+
deviceType: DeviceType;
|
|
382
|
+
platform: CheckoutPlatform;
|
|
383
|
+
userAgent?: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** Device / platform metadata attached to checkout analytics events. */
|
|
387
|
+
declare type DeviceType = 'mobile' | 'tablet' | 'desktop';
|
|
388
|
+
|
|
186
389
|
/** Geographic bounds for India */
|
|
187
390
|
export declare const DIGIPIN_BOUNDS: {
|
|
188
391
|
minLat: number;
|
|
@@ -196,6 +399,46 @@ declare interface DigiPinCoordinates {
|
|
|
196
399
|
longitude: string;
|
|
197
400
|
}
|
|
198
401
|
|
|
402
|
+
export declare const EmailOtpStep: default_2.FC<EmailOtpStepProps>;
|
|
403
|
+
|
|
404
|
+
export declare interface EmailOtpStepProps {
|
|
405
|
+
email: string;
|
|
406
|
+
onVerified: (sessionToken: string, buyerId: string, sessionId?: string) => void;
|
|
407
|
+
onBack: () => void;
|
|
408
|
+
functionBaseUrl: string;
|
|
409
|
+
merchantId: string;
|
|
410
|
+
sessionContext?: SessionContextPayload;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export declare const EmailStep: default_2.FC<EmailStepProps>;
|
|
414
|
+
|
|
415
|
+
export declare interface EmailStepProps {
|
|
416
|
+
/** Called with the normalised (lowercased) email once OTP is dispatched. */
|
|
417
|
+
onOtpSent: (email: string) => void;
|
|
418
|
+
onSkip: () => void;
|
|
419
|
+
functionBaseUrl: string;
|
|
420
|
+
merchantId: string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Fetch merchant prepaid nudge copy via Admin API (optional; use props to avoid). */
|
|
424
|
+
export declare function fetchPrepaidNudgeConfig(functionBaseUrl: string, adminApiKey: string): Promise<PrepaidNudgeConfig | null>;
|
|
425
|
+
|
|
426
|
+
/** Fetch UTM-matched offer banner for the current session. */
|
|
427
|
+
export declare function fetchSessionOffer(config: CheckoutApiConfig, sessionToken: string): Promise<SessionOffer | null>;
|
|
428
|
+
|
|
429
|
+
export declare interface FunnelEventPayload {
|
|
430
|
+
event_type: string;
|
|
431
|
+
step?: string;
|
|
432
|
+
session_token?: string;
|
|
433
|
+
buyer_id?: string;
|
|
434
|
+
auth_channel?: string;
|
|
435
|
+
device_type?: string;
|
|
436
|
+
platform?: string;
|
|
437
|
+
user_agent?: string;
|
|
438
|
+
payment_method?: string;
|
|
439
|
+
experiment_variant?: string;
|
|
440
|
+
}
|
|
441
|
+
|
|
199
442
|
/**
|
|
200
443
|
* Convert lat/lng coordinates to a DigiPin code.
|
|
201
444
|
* @throws if coordinates are outside India's bounds
|
|
@@ -208,6 +451,12 @@ export declare function getDigiPin(lat: number, lon: number): string;
|
|
|
208
451
|
*/
|
|
209
452
|
export declare function getLatLngFromDigiPin(digiPin: string): DigiPinCoordinates;
|
|
210
453
|
|
|
454
|
+
/** Build device context for web embeds. */
|
|
455
|
+
export declare function getWebDeviceContext(): DeviceContext;
|
|
456
|
+
|
|
457
|
+
/** True when at least one UTM field is set. */
|
|
458
|
+
export declare function hasUtmParams(utm: UtmParams): boolean;
|
|
459
|
+
|
|
211
460
|
/**
|
|
212
461
|
* Validate a DigiPin string (format + character check).
|
|
213
462
|
*/
|
|
@@ -218,6 +467,9 @@ export declare function isValidDigiPin(digiPin: string): boolean;
|
|
|
218
467
|
*/
|
|
219
468
|
export declare function isWithinIndia(lat: number, lon: number): boolean;
|
|
220
469
|
|
|
470
|
+
/** Fetch all saved addresses for the authenticated buyer. */
|
|
471
|
+
export declare function listAddresses(config: CheckoutApiConfig, sessionToken: string): Promise<SavedAddress[]>;
|
|
472
|
+
|
|
221
473
|
export declare interface LocationAlternative {
|
|
222
474
|
pincode: string;
|
|
223
475
|
name: string;
|
|
@@ -246,6 +498,9 @@ export declare interface LocationLookupResponse {
|
|
|
246
498
|
message?: string;
|
|
247
499
|
}
|
|
248
500
|
|
|
501
|
+
/** Log a checkout funnel event to the server (fire-and-forget). */
|
|
502
|
+
export declare function logFunnelEvent(config: CheckoutApiConfig, payload: FunnelEventPayload, sessionToken?: string): Promise<void>;
|
|
503
|
+
|
|
249
504
|
/**
|
|
250
505
|
* Returns true if the trimmed input looks like a complete DigiPin code.
|
|
251
506
|
* Used to skip the API call and resolve offline instead.
|
|
@@ -287,8 +542,107 @@ export declare interface MapPinSelectorProps {
|
|
|
287
542
|
apiKey?: string;
|
|
288
543
|
/** API base URL for autocomplete. Defaults to https://api.quantaroute.com */
|
|
289
544
|
apiBaseUrl?: string;
|
|
545
|
+
/**
|
|
546
|
+
* Brand accent colour (hex, e.g. `#7c3aed`). Sets map pin, buttons, focus rings via `--qr-primary` on web.
|
|
547
|
+
*/
|
|
548
|
+
brandColor?: string;
|
|
290
549
|
}
|
|
291
550
|
|
|
551
|
+
/**
|
|
552
|
+
* Notify the server that the buyer has confirmed their delivery address.
|
|
553
|
+
* Triggers `session.address_completed` webhook on the merchant's configured URL.
|
|
554
|
+
* Call this once `onComplete` fires in the widget (or from your own checkout page).
|
|
555
|
+
*/
|
|
556
|
+
export declare function notifyAddressCompleted(config: CheckoutApiConfig, sessionToken: string, address: {
|
|
557
|
+
pincode: string;
|
|
558
|
+
digipin: string;
|
|
559
|
+
state: string;
|
|
560
|
+
district: string;
|
|
561
|
+
locality: string;
|
|
562
|
+
}): Promise<void>;
|
|
563
|
+
|
|
564
|
+
/** Signal explicit session abandonment (page exit). */
|
|
565
|
+
export declare function notifySessionAbandoned(config: CheckoutApiConfig, sessionToken: string, lastStep: string): Promise<void>;
|
|
566
|
+
|
|
567
|
+
export declare const OtpStep: default_2.FC<OtpStepProps>;
|
|
568
|
+
|
|
569
|
+
export declare interface OtpStepProps {
|
|
570
|
+
mobile: string;
|
|
571
|
+
onVerified: (sessionToken: string, buyerId: string, sessionId?: string) => void;
|
|
572
|
+
onBack: () => void;
|
|
573
|
+
functionBaseUrl: string;
|
|
574
|
+
merchantId: string;
|
|
575
|
+
sessionContext?: SessionContextPayload;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export declare const PaymentStep: default_2.FC<PaymentStepProps>;
|
|
579
|
+
|
|
580
|
+
export declare interface PaymentStepProps {
|
|
581
|
+
checkoutConfig: CheckoutApiConfig;
|
|
582
|
+
sessionToken: string;
|
|
583
|
+
sessionId?: string;
|
|
584
|
+
amountPaise: number;
|
|
585
|
+
enableCod?: boolean;
|
|
586
|
+
codAllowed?: boolean;
|
|
587
|
+
theme?: 'light' | 'dark';
|
|
588
|
+
onComplete: (paymentMethod: string) => void;
|
|
589
|
+
onBack?: () => void;
|
|
590
|
+
onEvent?: (type: CheckoutEventType, paymentMethod?: string) => void;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export declare const PhoneStep: default_2.FC<PhoneStepProps>;
|
|
594
|
+
|
|
595
|
+
export declare interface PhoneStepProps {
|
|
596
|
+
onOtpSent: (mobile: string) => void;
|
|
597
|
+
onSkip: () => void;
|
|
598
|
+
functionBaseUrl: string;
|
|
599
|
+
merchantId: string;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Whether this pincode has at least one post office with India Post "Delivery" status
|
|
604
|
+
* (vs "Non Delivery" only — e.g. remote or PO-box-only areas).
|
|
605
|
+
*/
|
|
606
|
+
export declare function pincodeHasDeliveryOffice(offices: PincodeOffice[]): boolean;
|
|
607
|
+
|
|
608
|
+
/** One office row from /v1/pincode/validate/:pincode */
|
|
609
|
+
export declare interface PincodeOffice {
|
|
610
|
+
office_name: string;
|
|
611
|
+
delivery: string | null;
|
|
612
|
+
district: string | null;
|
|
613
|
+
state: string | null;
|
|
614
|
+
circle: string | null;
|
|
615
|
+
region: string | null;
|
|
616
|
+
division: string | null;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export declare interface PincodeValidateData {
|
|
620
|
+
isValid: boolean;
|
|
621
|
+
pincode: string;
|
|
622
|
+
count: number;
|
|
623
|
+
offices: PincodeOffice[];
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* C5 prepaid nudge — shown when COD is eligible to encourage prepaid checkout.
|
|
628
|
+
*/
|
|
629
|
+
export declare const PrepaidNudge: default_2.FC<PrepaidNudgeProps>;
|
|
630
|
+
|
|
631
|
+
export declare interface PrepaidNudgeConfig {
|
|
632
|
+
prepaid_nudge_copy: string | null;
|
|
633
|
+
prepaid_nudge_cta_url: string | null;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
export declare interface PrepaidNudgeProps {
|
|
637
|
+
copy: string;
|
|
638
|
+
ctaUrl?: string;
|
|
639
|
+
theme?: 'light' | 'dark';
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
export declare function recordCodPayment(config: CheckoutApiConfig, sessionToken: string): Promise<{
|
|
643
|
+
payment_method: string;
|
|
644
|
+
}>;
|
|
645
|
+
|
|
292
646
|
/**
|
|
293
647
|
* Call QuantaRoute's Reverse Geocoding API.
|
|
294
648
|
* Converts DigiPin → address components from Nominatim/OpenStreetMap.
|
|
@@ -315,6 +669,83 @@ export declare interface ReverseGeocodeResponse {
|
|
|
315
669
|
message?: string;
|
|
316
670
|
}
|
|
317
671
|
|
|
672
|
+
export declare interface SavedAddress {
|
|
673
|
+
id: string;
|
|
674
|
+
digipin: string;
|
|
675
|
+
lat: number;
|
|
676
|
+
lng: number;
|
|
677
|
+
state: string;
|
|
678
|
+
district: string;
|
|
679
|
+
locality: string;
|
|
680
|
+
pincode: string;
|
|
681
|
+
delivery_status: string;
|
|
682
|
+
flat_number: string;
|
|
683
|
+
floor_number: string;
|
|
684
|
+
building_name: string;
|
|
685
|
+
street_name: string;
|
|
686
|
+
label: string;
|
|
687
|
+
is_default: boolean;
|
|
688
|
+
created_at: string;
|
|
689
|
+
updated_at: string;
|
|
690
|
+
/** Brand name of the merchant where this address was first saved. Null if unknown. */
|
|
691
|
+
saved_at_brand: string | null;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
export declare interface SavedAddressPayload {
|
|
695
|
+
digipin: string;
|
|
696
|
+
lat: number;
|
|
697
|
+
lng: number;
|
|
698
|
+
state?: string;
|
|
699
|
+
district?: string;
|
|
700
|
+
locality?: string;
|
|
701
|
+
pincode?: string;
|
|
702
|
+
delivery_status?: string;
|
|
703
|
+
flat_number?: string;
|
|
704
|
+
floor_number?: string;
|
|
705
|
+
building_name?: string;
|
|
706
|
+
street_name?: string;
|
|
707
|
+
full_address_json?: Record<string, unknown>;
|
|
708
|
+
label?: string;
|
|
709
|
+
is_default?: boolean;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export declare const SavedAddressStep: default_2.FC<SavedAddressStepProps>;
|
|
713
|
+
|
|
714
|
+
export declare interface SavedAddressStepProps {
|
|
715
|
+
sessionToken: string;
|
|
716
|
+
functionBaseUrl: string;
|
|
717
|
+
merchantId: string;
|
|
718
|
+
onSelectAddress: (address: SavedAddress) => void;
|
|
719
|
+
onAddNew: () => void;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/** Send a 6-digit OTP to the given email via Resend (Edge: `checkout-email-otp`). */
|
|
723
|
+
export declare function sendEmailOtp(config: CheckoutApiConfig, email: string): Promise<void>;
|
|
724
|
+
|
|
725
|
+
/** Send OTP to the given mobile number. Throws on failure. */
|
|
726
|
+
export declare function sendOtp(config: CheckoutApiConfig, mobile: string): Promise<void>;
|
|
727
|
+
|
|
728
|
+
/** Device + UTM context sent with OTP verify to enrich checkout sessions. */
|
|
729
|
+
export declare interface SessionContextPayload {
|
|
730
|
+
utm_source?: string;
|
|
731
|
+
utm_medium?: string;
|
|
732
|
+
utm_campaign?: string;
|
|
733
|
+
device_type?: string;
|
|
734
|
+
platform?: string;
|
|
735
|
+
user_agent?: string;
|
|
736
|
+
experiment_variant?: string;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export declare interface SessionOffer {
|
|
740
|
+
offer_id: string;
|
|
741
|
+
name: string;
|
|
742
|
+
banner_copy: string;
|
|
743
|
+
banner_cta_url: string | null;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Set an address as the default. */
|
|
747
|
+
export declare function setDefaultAddress(config: CheckoutApiConfig, sessionToken: string, addressId: string): Promise<void>;
|
|
748
|
+
|
|
318
749
|
/**
|
|
319
750
|
* Compute a DigiPin code from lat/lng entirely offline (no API call).
|
|
320
751
|
* Returns null if coordinates are outside India's bounds.
|
|
@@ -335,4 +766,46 @@ export declare function useGeolocation(): {
|
|
|
335
766
|
error: string | null;
|
|
336
767
|
};
|
|
337
768
|
|
|
769
|
+
/** UTM parameters captured from the storefront URL at checkout start. */
|
|
770
|
+
export declare interface UtmParams {
|
|
771
|
+
utm_source?: string;
|
|
772
|
+
utm_medium?: string;
|
|
773
|
+
utm_campaign?: string;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Validate a 6-digit Indian pincode against QuantaRoute's postal database.
|
|
778
|
+
* Rejects fake codes (e.g. 123456) that are not in India Post records.
|
|
779
|
+
*/
|
|
780
|
+
export declare function validatePincode(pincode: string, apiKey: string, baseUrl?: string): Promise<PincodeValidateData>;
|
|
781
|
+
|
|
782
|
+
/** Verify a 6-digit email OTP. Returns a session token on success. */
|
|
783
|
+
export declare function verifyEmailOtp(config: CheckoutApiConfig, email: string, code: string, context?: SessionContextPayload): Promise<VerifyEmailOtpResult>;
|
|
784
|
+
|
|
785
|
+
export declare interface VerifyEmailOtpResult {
|
|
786
|
+
session_token: string;
|
|
787
|
+
session_id: string;
|
|
788
|
+
expires_at: string;
|
|
789
|
+
buyer_id: string;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/** Verify OTP and return a session token. Throws on invalid OTP. */
|
|
793
|
+
export declare function verifyOtp(config: CheckoutApiConfig, mobile: string, otp: string, context?: SessionContextPayload): Promise<VerifyOtpResult>;
|
|
794
|
+
|
|
795
|
+
export declare interface VerifyOtpResult {
|
|
796
|
+
session_token: string;
|
|
797
|
+
session_id: string;
|
|
798
|
+
expires_at: string;
|
|
799
|
+
buyer_id: string;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export declare function verifyPayment(config: CheckoutApiConfig, sessionToken: string, params: {
|
|
803
|
+
razorpay_order_id: string;
|
|
804
|
+
razorpay_payment_id: string;
|
|
805
|
+
razorpay_signature: string;
|
|
806
|
+
payment_method?: string;
|
|
807
|
+
}): Promise<{
|
|
808
|
+
payment_method: string;
|
|
809
|
+
}>;
|
|
810
|
+
|
|
338
811
|
export { }
|