@quantaroute/checkout 1.4.4 → 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.
@@ -18,6 +18,7 @@ import {
18
18
  pincodeHasDeliveryOffice,
19
19
  type AddressComponents,
20
20
  } from '../core/api';
21
+ import { checkServiceability, type ServiceabilityResult } from '../core/checkout-api';
21
22
  import type {
22
23
  AddressFormProps,
23
24
  AddressLabel,
@@ -50,6 +51,7 @@ type FormState =
50
51
  fields: ManualFields;
51
52
  submitting: boolean;
52
53
  pincodeHasDelivery: boolean;
54
+ serviceabilityResult: ServiceabilityResult | null;
53
55
  };
54
56
 
55
57
  type FormAction =
@@ -60,6 +62,7 @@ type FormAction =
60
62
  alternatives: LocationAlternative[];
61
63
  addressComponents: AddressComponents;
62
64
  pincodeHasDelivery: boolean;
65
+ serviceabilityResult: ServiceabilityResult | null;
63
66
  }
64
67
  | { type: 'LOAD_ERROR'; message: string }
65
68
  | { type: 'SET_FIELD'; key: keyof ManualFields; value: string }
@@ -113,6 +116,7 @@ function reducer(state: FormState, action: FormAction): FormState {
113
116
  fields: { ...INITIAL_FIELDS, ...preFilled },
114
117
  submitting: false,
115
118
  pincodeHasDelivery: action.pincodeHasDelivery,
119
+ serviceabilityResult: action.serviceabilityResult,
116
120
  };
117
121
  }
118
122
  case 'LOAD_ERROR':
@@ -161,6 +165,12 @@ const AddressForm: React.FC<AddressFormProps> = ({
161
165
  onBack,
162
166
  onError,
163
167
  theme = 'light',
168
+ checkoutConfig,
169
+ serviceabilitySessionToken,
170
+ enableServiceabilityCheck = false,
171
+ showIndiaPostDeliveryWarning = false,
172
+ serviceabilityBlockCheckout,
173
+ onServiceabilityResult,
164
174
  }) => {
165
175
  const [state, dispatch] = useReducer(reducer, { status: 'loading' });
166
176
  const [showLocalityPicker, setShowLocalityPicker] = useState(false);
@@ -202,6 +212,26 @@ const AddressForm: React.FC<AddressFormProps> = ({
202
212
  }
203
213
 
204
214
  const hasDelivery = pincodeHasDeliveryOffice(pinValidation.offices);
215
+ let serviceabilityResult: ServiceabilityResult | null = null;
216
+
217
+ if (
218
+ enableServiceabilityCheck
219
+ && checkoutConfig?.functionBaseUrl
220
+ && checkoutConfig.merchantId
221
+ && serviceabilitySessionToken
222
+ ) {
223
+ try {
224
+ serviceabilityResult = await checkServiceability(
225
+ checkoutConfig,
226
+ serviceabilitySessionToken,
227
+ pincode,
228
+ { lat, lng }
229
+ );
230
+ onServiceabilityResult?.(serviceabilityResult);
231
+ } catch {
232
+ // Fail open if the platform serviceability check itself is unavailable.
233
+ }
234
+ }
205
235
 
206
236
  dispatch({
207
237
  type: 'LOAD_SUCCESS',
@@ -209,13 +239,25 @@ const AddressForm: React.FC<AddressFormProps> = ({
209
239
  alternatives: adminRes.data.alternatives || [],
210
240
  addressComponents: reverseRes.data.addressComponents,
211
241
  pincodeHasDelivery: hasDelivery,
242
+ serviceabilityResult,
212
243
  });
213
244
  } catch (err) {
214
245
  const msg = err instanceof Error ? err.message : 'Failed to fetch address data.';
215
246
  dispatch({ type: 'LOAD_ERROR', message: msg });
216
247
  onError?.(err instanceof Error ? err : new Error(msg));
217
248
  }
218
- }, [digipin, lat, lng, apiKey, apiBaseUrl, onError]);
249
+ }, [
250
+ digipin,
251
+ lat,
252
+ lng,
253
+ apiKey,
254
+ apiBaseUrl,
255
+ onError,
256
+ checkoutConfig,
257
+ serviceabilitySessionToken,
258
+ enableServiceabilityCheck,
259
+ onServiceabilityResult,
260
+ ]);
219
261
 
220
262
  useEffect(() => {
221
263
  void fetchAdminInfo();
@@ -226,6 +268,11 @@ const AddressForm: React.FC<AddressFormProps> = ({
226
268
  if (state.status !== 'ready') return;
227
269
  if (!state.fields.flatNumber.trim()) return;
228
270
  if (state.selectedLabel === 'other' && !state.labelText.trim()) return;
271
+ const serviceabilityBlocked =
272
+ state.serviceabilityResult?.checked
273
+ && state.serviceabilityResult.serviceable === false
274
+ && (serviceabilityBlockCheckout ?? state.serviceabilityResult.block_checkout);
275
+ if (serviceabilityBlocked) return;
229
276
 
230
277
  const { adminInfo, selectedLocality, selectedLabel, labelText, fields } = state;
231
278
 
@@ -263,7 +310,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
263
310
  } finally {
264
311
  dispatch({ type: 'SUBMIT_END' });
265
312
  }
266
- }, [state, digipin, lat, lng, onAddressComplete]);
313
+ }, [state, digipin, lat, lng, onAddressComplete, serviceabilityBlockCheckout]);
267
314
 
268
315
  // ─── Field input helper ────────────────────────────────────────────────────
269
316
  const renderField = (
@@ -306,6 +353,24 @@ const AddressForm: React.FC<AddressFormProps> = ({
306
353
  </View>
307
354
  );
308
355
 
356
+ const serviceabilityBlocked =
357
+ state.status === 'ready'
358
+ && state.serviceabilityResult?.checked
359
+ && state.serviceabilityResult.serviceable === false
360
+ && (serviceabilityBlockCheckout ?? state.serviceabilityResult.block_checkout);
361
+
362
+ const showMerchantServiceability =
363
+ state.status === 'ready'
364
+ && state.serviceabilityResult?.checked
365
+ && state.serviceabilityResult.serviceable === false;
366
+
367
+ const showIndiaPostInfo =
368
+ state.status === 'ready'
369
+ && !state.pincodeHasDelivery
370
+ && state.serviceabilityResult?.serviceable !== true
371
+ && !showMerchantServiceability
372
+ && (state.serviceabilityResult?.show_india_post_delivery_warning ?? showIndiaPostDeliveryWarning);
373
+
309
374
  return (
310
375
  <KeyboardAvoidingView
311
376
  behavior={Platform.OS === 'ios' ? 'padding' : undefined}
@@ -449,20 +514,58 @@ const AddressForm: React.FC<AddressFormProps> = ({
449
514
  </View>
450
515
  </View>
451
516
 
452
- {!state.pincodeHasDelivery ? (
517
+ {showMerchantServiceability && state.serviceabilityResult ? (
453
518
  <View
454
- style={[styles.pincodeBanner, isDark && styles.pincodeBannerDark]}
519
+ style={[
520
+ styles.pincodeBanner,
521
+ serviceabilityBlocked
522
+ ? styles.pincodeBannerError
523
+ : styles.pincodeBannerWarning,
524
+ isDark && (
525
+ serviceabilityBlocked
526
+ ? styles.pincodeBannerErrorDark
527
+ : styles.pincodeBannerDark
528
+ ),
529
+ ]}
530
+ accessibilityRole="text"
531
+ accessibilityLabel={
532
+ serviceabilityBlocked
533
+ ? 'Delivery unavailable'
534
+ : 'Delivery may be limited'
535
+ }
536
+ >
537
+ <Text style={styles.pincodeBannerIcon}>{serviceabilityBlocked ? '!' : '⚠'}</Text>
538
+ <View style={{ flex: 1 }}>
539
+ <Text style={[styles.pincodeBannerTitle, isDark && styles.pincodeBannerTitleDark]}>
540
+ {serviceabilityBlocked ? 'Delivery unavailable' : 'Delivery may be limited'}
541
+ </Text>
542
+ <Text style={[styles.pincodeBannerBody, isDark && styles.pincodeBannerBodyDark]}>
543
+ {state.serviceabilityResult.message
544
+ ?? (serviceabilityBlocked
545
+ ? 'This seller does not currently deliver to this pincode.'
546
+ : 'This seller recommends confirming delivery availability for this pincode.')}
547
+ </Text>
548
+ </View>
549
+ </View>
550
+ ) : null}
551
+
552
+ {showIndiaPostInfo ? (
553
+ <View
554
+ style={[
555
+ styles.pincodeBanner,
556
+ styles.pincodeBannerInfo,
557
+ isDark && styles.pincodeBannerInfoDark,
558
+ ]}
455
559
  accessibilityRole="text"
456
- accessibilityLabel="Non-delivery area warning"
560
+ accessibilityLabel="India Post home-delivery information"
457
561
  >
458
- <Text style={styles.pincodeBannerIcon}>⚠</Text>
562
+ <Text style={styles.pincodeBannerIcon}>i</Text>
459
563
  <View style={{ flex: 1 }}>
460
564
  <Text style={[styles.pincodeBannerTitle, isDark && styles.pincodeBannerTitleDark]}>
461
- Non-delivery area
565
+ India Post: no home-delivery office
462
566
  </Text>
463
567
  <Text style={[styles.pincodeBannerBody, isDark && styles.pincodeBannerBodyDark]}>
464
- This pincode has no India Post home-delivery office. Courier delivery may be
465
- limited — confirm with your seller before placing the order.
568
+ Courier partners may still deliver to this pincode.
466
569
  </Text>
467
570
  </View>
468
571
  </View>
@@ -612,13 +715,15 @@ const AddressForm: React.FC<AddressFormProps> = ({
612
715
  styles.btnPrimary,
613
716
  { flex: 1 },
614
717
  (state.submitting || !state.fields.flatNumber.trim()
615
- || (state.selectedLabel === 'other' && !state.labelText.trim())) && styles.btnDisabled,
718
+ || (state.selectedLabel === 'other' && !state.labelText.trim())
719
+ || serviceabilityBlocked) && styles.btnDisabled,
616
720
  ]}
617
721
  onPress={handleSubmit}
618
722
  disabled={
619
723
  state.submitting
620
724
  || !state.fields.flatNumber.trim()
621
725
  || (state.selectedLabel === 'other' && !state.labelText.trim())
726
+ || Boolean(serviceabilityBlocked)
622
727
  }
623
728
  activeOpacity={0.8}
624
729
  accessibilityRole="button"
@@ -6,6 +6,7 @@ import {
6
6
  pincodeHasDeliveryOffice,
7
7
  type AddressComponents,
8
8
  } from '../core/api';
9
+ import { checkServiceability, type ServiceabilityResult } from '../core/checkout-api';
9
10
  import type {
10
11
  AddressFormProps,
11
12
  AddressLabel,
@@ -38,6 +39,7 @@ type FormState =
38
39
  submitting: boolean;
39
40
  /** At least one India Post office with "Delivery" (not only "Non Delivery") */
40
41
  pincodeHasDelivery: boolean;
42
+ serviceabilityResult: ServiceabilityResult | null;
41
43
  };
42
44
 
43
45
  type FormAction =
@@ -48,6 +50,7 @@ type FormAction =
48
50
  alternatives: LocationAlternative[];
49
51
  addressComponents: AddressComponents;
50
52
  pincodeHasDelivery: boolean;
53
+ serviceabilityResult: ServiceabilityResult | null;
51
54
  }
52
55
  | { type: 'LOAD_ERROR'; message: string }
53
56
  | { type: 'SET_FIELD'; key: keyof ManualFields; value: string }
@@ -114,6 +117,7 @@ function reducer(state: FormState, action: FormAction): FormState {
114
117
  fields: { ...INITIAL_FIELDS, ...preFilled },
115
118
  submitting: false,
116
119
  pincodeHasDelivery: action.pincodeHasDelivery,
120
+ serviceabilityResult: action.serviceabilityResult,
117
121
  };
118
122
  }
119
123
  case 'LOAD_ERROR':
@@ -156,6 +160,12 @@ const AddressForm: React.FC<AddressFormProps> = ({
156
160
  onAddressComplete,
157
161
  onBack,
158
162
  onError,
163
+ checkoutConfig,
164
+ serviceabilitySessionToken,
165
+ enableServiceabilityCheck = false,
166
+ showIndiaPostDeliveryWarning = false,
167
+ serviceabilityBlockCheckout,
168
+ onServiceabilityResult,
159
169
  }) => {
160
170
  const [state, dispatch] = useReducer(reducer, { status: 'loading' });
161
171
 
@@ -195,6 +205,27 @@ const AddressForm: React.FC<AddressFormProps> = ({
195
205
  }
196
206
 
197
207
  const hasDelivery = pincodeHasDeliveryOffice(pinValidation.offices);
208
+ let serviceabilityResult: ServiceabilityResult | null = null;
209
+
210
+ if (
211
+ enableServiceabilityCheck
212
+ && checkoutConfig?.functionBaseUrl
213
+ && checkoutConfig.merchantId
214
+ && serviceabilitySessionToken
215
+ ) {
216
+ try {
217
+ serviceabilityResult = await checkServiceability(
218
+ checkoutConfig,
219
+ serviceabilitySessionToken,
220
+ pincode,
221
+ { lat, lng }
222
+ );
223
+ onServiceabilityResult?.(serviceabilityResult);
224
+ } catch {
225
+ // Fail open: merchant serviceability should never block address entry
226
+ // when the checkout-addresses function itself is unreachable.
227
+ }
228
+ }
198
229
 
199
230
  dispatch({
200
231
  type: 'LOAD_SUCCESS',
@@ -202,13 +233,25 @@ const AddressForm: React.FC<AddressFormProps> = ({
202
233
  alternatives: adminRes.data.alternatives || [],
203
234
  addressComponents: reverseRes.data.addressComponents,
204
235
  pincodeHasDelivery: hasDelivery,
236
+ serviceabilityResult,
205
237
  });
206
238
  } catch (err) {
207
239
  const msg = err instanceof Error ? err.message : 'Failed to fetch address data.';
208
240
  dispatch({ type: 'LOAD_ERROR', message: msg });
209
241
  onError?.(err instanceof Error ? err : new Error(msg));
210
242
  }
211
- }, [digipin, lat, lng, apiKey, apiBaseUrl, onError]);
243
+ }, [
244
+ digipin,
245
+ lat,
246
+ lng,
247
+ apiKey,
248
+ apiBaseUrl,
249
+ onError,
250
+ checkoutConfig,
251
+ serviceabilitySessionToken,
252
+ enableServiceabilityCheck,
253
+ onServiceabilityResult,
254
+ ]);
212
255
 
213
256
  useEffect(() => {
214
257
  void fetchAdminInfo();
@@ -223,6 +266,11 @@ const AddressForm: React.FC<AddressFormProps> = ({
223
266
  const { adminInfo, selectedLocality, selectedLabel, labelText, fields } = state;
224
267
 
225
268
  if (selectedLabel === 'other' && !labelText.trim()) return;
269
+ const serviceabilityBlocked =
270
+ state.serviceabilityResult?.checked
271
+ && state.serviceabilityResult.serviceable === false
272
+ && (serviceabilityBlockCheckout ?? state.serviceabilityResult.block_checkout);
273
+ if (serviceabilityBlocked) return;
226
274
 
227
275
  const parts: string[] = [
228
276
  fields.flatNumber,
@@ -259,9 +307,27 @@ const AddressForm: React.FC<AddressFormProps> = ({
259
307
  dispatch({ type: 'SUBMIT_END' });
260
308
  }
261
309
  },
262
- [state, digipin, lat, lng, onAddressComplete]
310
+ [state, digipin, lat, lng, onAddressComplete, serviceabilityBlockCheckout]
263
311
  );
264
312
 
313
+ const serviceabilityBlocked =
314
+ state.status === 'ready'
315
+ && state.serviceabilityResult?.checked
316
+ && state.serviceabilityResult.serviceable === false
317
+ && (serviceabilityBlockCheckout ?? state.serviceabilityResult.block_checkout);
318
+
319
+ const showMerchantServiceability =
320
+ state.status === 'ready'
321
+ && state.serviceabilityResult?.checked
322
+ && state.serviceabilityResult.serviceable === false;
323
+
324
+ const showIndiaPostInfo =
325
+ state.status === 'ready'
326
+ && !state.pincodeHasDelivery
327
+ && state.serviceabilityResult?.serviceable !== true
328
+ && !showMerchantServiceability
329
+ && (state.serviceabilityResult?.show_india_post_delivery_warning ?? showIndiaPostDeliveryWarning);
330
+
265
331
  return (
266
332
  <div className="qr-form-wrapper">
267
333
  {/* ── Step header ── */}
@@ -391,19 +457,44 @@ const AddressForm: React.FC<AddressFormProps> = ({
391
457
  </div>
392
458
  </fieldset>
393
459
 
394
- {/* Serviceability: India Post "Non Delivery" only — warn (still allow save) */}
395
- {!state.pincodeHasDelivery && (
460
+ {showMerchantServiceability && state.serviceabilityResult && (
461
+ <div
462
+ className={`qr-pincode-banner ${
463
+ serviceabilityBlocked
464
+ ? 'qr-pincode-banner--error'
465
+ : 'qr-pincode-banner--warning'
466
+ }`}
467
+ role={serviceabilityBlocked ? 'alert' : 'status'}
468
+ aria-live="polite"
469
+ >
470
+ <span className="qr-pincode-banner__icon" aria-hidden="true">
471
+ {serviceabilityBlocked ? '!' : '⚠'}
472
+ </span>
473
+ <div className="qr-pincode-banner__text">
474
+ <strong>
475
+ {serviceabilityBlocked ? 'Delivery unavailable' : 'Delivery may be limited'}
476
+ </strong>
477
+ <span>
478
+ {state.serviceabilityResult.message
479
+ ?? (serviceabilityBlocked
480
+ ? 'This seller does not currently deliver to this pincode.'
481
+ : 'This seller recommends confirming delivery availability for this pincode.')}
482
+ </span>
483
+ </div>
484
+ </div>
485
+ )}
486
+
487
+ {showIndiaPostInfo && (
396
488
  <div
397
- className="qr-pincode-banner qr-pincode-banner--warning"
489
+ className="qr-pincode-banner qr-pincode-banner--info"
398
490
  role="status"
399
491
  aria-live="polite"
400
492
  >
401
- <span className="qr-pincode-banner__icon" aria-hidden="true">⚠</span>
493
+ <span className="qr-pincode-banner__icon" aria-hidden="true">i</span>
402
494
  <div className="qr-pincode-banner__text">
403
- <strong>Non-delivery area</strong>
495
+ <strong>India Post: no home-delivery office</strong>
404
496
  <span>
405
- This pincode has no India Post home-delivery office. Courier delivery may be limited —
406
- confirm with your seller before placing the order.
497
+ Courier partners may still deliver to this pincode.
407
498
  </span>
408
499
  </div>
409
500
  </div>
@@ -575,6 +666,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
575
666
  state.submitting
576
667
  || !state.fields.flatNumber.trim()
577
668
  || (state.selectedLabel === 'other' && !state.labelText.trim())
669
+ || Boolean(serviceabilityBlocked)
578
670
  }
579
671
  >
580
672
  {state.submitting ? (
@@ -97,6 +97,9 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
97
97
  merchantId = '',
98
98
  supabaseFunctionBaseUrl = '',
99
99
  enableCod = false,
100
+ enableServiceabilityCheck = false,
101
+ showIndiaPostDeliveryWarning = false,
102
+ serviceabilityBlockCheckout,
100
103
  codCartTotalPaise,
101
104
  codSessionToken = '',
102
105
  }) => {
@@ -243,6 +246,11 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
243
246
  onBack={handleBack}
244
247
  onError={onError}
245
248
  theme={theme}
249
+ checkoutConfig={checkoutConfig}
250
+ serviceabilitySessionToken={codSession}
251
+ enableServiceabilityCheck={enableServiceabilityCheck}
252
+ showIndiaPostDeliveryWarning={showIndiaPostDeliveryWarning}
253
+ serviceabilityBlockCheckout={serviceabilityBlockCheckout}
246
254
  />
247
255
  ) : null}
248
256
 
@@ -159,6 +159,9 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
159
159
  headerBanner,
160
160
  onCheckoutEvent,
161
161
  enableCod = false,
162
+ enableServiceabilityCheck = false,
163
+ showIndiaPostDeliveryWarning = false,
164
+ serviceabilityBlockCheckout,
162
165
  codCartTotalPaise,
163
166
  codSessionToken = '',
164
167
  enableEmailAuth = false,
@@ -718,6 +721,11 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
718
721
  onBack={handleBack}
719
722
  onError={onError}
720
723
  theme={theme}
724
+ checkoutConfig={checkoutConfig}
725
+ serviceabilitySessionToken={codSession}
726
+ enableServiceabilityCheck={enableServiceabilityCheck}
727
+ showIndiaPostDeliveryWarning={showIndiaPostDeliveryWarning}
728
+ serviceabilityBlockCheckout={serviceabilityBlockCheckout}
721
729
  />
722
730
  )}
723
731
 
@@ -305,6 +305,59 @@ export async function checkCodEligibility(
305
305
  return data.data as CodEligibilityResult;
306
306
  }
307
307
 
308
+ // ─── Merchant serviceability (courier / 3PL pincode check) ───────────────────
309
+
310
+ export interface ServiceabilityResult {
311
+ /** Whether a merchant serviceability endpoint was configured and enabled. */
312
+ enabled: boolean;
313
+ /** Whether the merchant endpoint returned a definitive response. */
314
+ checked: boolean;
315
+ /** true/false when checked, null when disabled or failed open. */
316
+ serviceable: boolean | null;
317
+ /** Normalized 6-digit pincode when valid; otherwise the trimmed input. */
318
+ pincode: string;
319
+ /** Buyer-facing merchant message, when supplied by the merchant endpoint. */
320
+ message?: string;
321
+ /** Whether the widget should block address submission when not serviceable. */
322
+ block_checkout: boolean;
323
+ /** Whether the merchant wants the soft India Post info banner as fallback. */
324
+ show_india_post_delivery_warning: boolean;
325
+ /** Present when the endpoint was skipped or failed open. */
326
+ reason?:
327
+ | 'not_configured'
328
+ | 'invalid_pincode'
329
+ | 'merchant_error'
330
+ | 'merchant_unreachable'
331
+ | 'invalid_response';
332
+ }
333
+
334
+ /**
335
+ * Check merchant courier serviceability for a pincode.
336
+ * Uses the merchant's configured webhook on checkout.merchants and fails open.
337
+ */
338
+ export async function checkServiceability(
339
+ config: CheckoutApiConfig,
340
+ sessionToken: string,
341
+ pincode: string,
342
+ coords?: { lat?: number; lng?: number }
343
+ ): Promise<ServiceabilityResult> {
344
+ const res = await fetch(`${config.functionBaseUrl}/checkout-addresses`, {
345
+ method: 'POST',
346
+ headers: addressHeaders(sessionToken),
347
+ body: JSON.stringify({
348
+ action: 'serviceability_check',
349
+ pincode,
350
+ ...(coords?.lat !== undefined ? { lat: coords.lat } : {}),
351
+ ...(coords?.lng !== undefined ? { lng: coords.lng } : {}),
352
+ }),
353
+ });
354
+ const data = await res.json().catch(() => ({}));
355
+ if (!res.ok || !data.success) {
356
+ throw new Error(data.error ?? 'Failed to check delivery serviceability.');
357
+ }
358
+ return data.data as ServiceabilityResult;
359
+ }
360
+
308
361
  // ─── Funnel events (server-side analytics) ────────────────────────────────────
309
362
 
310
363
  export interface FunnelEventPayload {
package/src/core/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { UtmParams } from './utm';
3
- import type { SessionContextPayload } from './checkout-api';
3
+ import type { CheckoutApiConfig, ServiceabilityResult, SessionContextPayload } from './checkout-api';
4
4
 
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
6
  type AnyStyle = any; // CSSProperties on web · StyleProp<ViewStyle> on native
@@ -207,6 +207,18 @@ export interface AddressFormProps {
207
207
  onBack: () => void;
208
208
  onError?: (error: Error) => void;
209
209
  theme?: 'light' | 'dark';
210
+ /** Checkout API config for merchant serviceability checks. */
211
+ checkoutConfig?: CheckoutApiConfig;
212
+ /** Buyer session token used by checkout-addresses serviceability_check. */
213
+ serviceabilitySessionToken?: string;
214
+ /** When true, calls the merchant courier serviceability endpoint after pincode validation. */
215
+ enableServiceabilityCheck?: boolean;
216
+ /** Shows a soft India Post home-delivery info banner when merchant check is absent/failed. */
217
+ showIndiaPostDeliveryWarning?: boolean;
218
+ /** Optional client override for blocking address save when merchant says not serviceable. */
219
+ serviceabilityBlockCheckout?: boolean;
220
+ /** Optional observer for the merchant serviceability result. */
221
+ onServiceabilityResult?: (result: ServiceabilityResult) => void;
210
222
  }
211
223
 
212
224
  export interface CheckoutWidgetProps {
@@ -282,6 +294,21 @@ export interface CheckoutWidgetProps {
282
294
  * `checkout.merchants.enable_cod` and optional D1/D2 columns.
283
295
  */
284
296
  enableCod?: boolean;
297
+ /**
298
+ * Call the merchant's courier serviceability webhook for the resolved pincode.
299
+ * Requires `merchantId`, `supabaseFunctionBaseUrl`, and an authenticated checkout session.
300
+ */
301
+ enableServiceabilityCheck?: boolean;
302
+ /**
303
+ * Opt-in fallback banner for India Post "Non Delivery" pincodes.
304
+ * Defaults off because courier partners may still deliver.
305
+ */
306
+ showIndiaPostDeliveryWarning?: boolean;
307
+ /**
308
+ * Client override: block address save when merchant serviceability says not deliverable.
309
+ * If omitted, the server result from checkout.merchants.serviceability_block_checkout is used.
310
+ */
311
+ serviceabilityBlockCheckout?: boolean;
285
312
  /**
286
313
  * Cart total in paise for the COD cart cap (D2). Omit if the cart total is unknown.
287
314
  */
package/src/index.ts CHANGED
@@ -72,6 +72,7 @@ export {
72
72
  deleteAddress,
73
73
  setDefaultAddress,
74
74
  checkCodEligibility,
75
+ checkServiceability,
75
76
  notifyAddressCompleted,
76
77
  logFunnelEvent,
77
78
  notifySessionAbandoned,
@@ -89,6 +90,7 @@ export type {
89
90
  SavedAddress,
90
91
  SavedAddressPayload,
91
92
  CodEligibilityResult,
93
+ ServiceabilityResult,
92
94
  SessionContextPayload,
93
95
  FunnelEventPayload,
94
96
  SessionOffer,
@@ -1923,10 +1923,39 @@
1923
1923
  border-color: rgba(245, 158, 11, 0.35);
1924
1924
  }
1925
1925
 
1926
+ .qr-pincode-banner--error {
1927
+ background: rgba(239, 68, 68, 0.1);
1928
+ border: 1px solid rgba(239, 68, 68, 0.38);
1929
+ color: var(--qr-text);
1930
+ }
1931
+
1932
+ .qr-checkout--dark .qr-pincode-banner--error {
1933
+ background: rgba(239, 68, 68, 0.14);
1934
+ border-color: rgba(239, 68, 68, 0.34);
1935
+ }
1936
+
1937
+ .qr-pincode-banner--info {
1938
+ background: color-mix(in srgb, var(--qr-primary) 9%, transparent);
1939
+ border: 1px solid color-mix(in srgb, var(--qr-primary) 28%, transparent);
1940
+ color: var(--qr-text);
1941
+ }
1942
+
1943
+ .qr-checkout--dark .qr-pincode-banner--info {
1944
+ background: color-mix(in srgb, var(--qr-primary) 13%, transparent);
1945
+ border-color: color-mix(in srgb, var(--qr-primary) 26%, transparent);
1946
+ }
1947
+
1926
1948
  .qr-pincode-banner__icon {
1927
1949
  flex-shrink: 0;
1950
+ display: inline-flex;
1951
+ align-items: center;
1952
+ justify-content: center;
1953
+ width: 18px;
1954
+ height: 18px;
1955
+ border-radius: 999px;
1928
1956
  font-size: 16px;
1929
1957
  line-height: 1.2;
1958
+ font-weight: 700;
1930
1959
  }
1931
1960
 
1932
1961
  .qr-pincode-banner__text {
@@ -519,13 +519,38 @@ export const styles = StyleSheet.create({
519
519
  borderWidth: 1,
520
520
  borderColor: 'rgba(245, 158, 11, 0.45)',
521
521
  },
522
+ pincodeBannerWarning: {
523
+ backgroundColor: 'rgba(245, 158, 11, 0.12)',
524
+ borderColor: 'rgba(245, 158, 11, 0.45)',
525
+ },
522
526
  pincodeBannerDark: {
523
527
  backgroundColor: 'rgba(245, 158, 11, 0.15)',
524
528
  borderColor: 'rgba(245, 158, 11, 0.35)',
525
529
  },
530
+ pincodeBannerError: {
531
+ backgroundColor: 'rgba(239, 68, 68, 0.1)',
532
+ borderColor: 'rgba(239, 68, 68, 0.38)',
533
+ },
534
+ pincodeBannerErrorDark: {
535
+ backgroundColor: 'rgba(239, 68, 68, 0.14)',
536
+ borderColor: 'rgba(239, 68, 68, 0.34)',
537
+ },
538
+ pincodeBannerInfo: {
539
+ backgroundColor: 'rgba(14, 165, 233, 0.09)',
540
+ borderColor: 'rgba(14, 165, 233, 0.28)',
541
+ },
542
+ pincodeBannerInfoDark: {
543
+ backgroundColor: 'rgba(14, 165, 233, 0.13)',
544
+ borderColor: 'rgba(14, 165, 233, 0.26)',
545
+ },
526
546
  pincodeBannerIcon: {
547
+ width: 18,
548
+ height: 18,
549
+ borderRadius: 9,
550
+ textAlign: 'center',
527
551
  fontSize: 16,
528
552
  lineHeight: 20,
553
+ fontWeight: '700',
529
554
  },
530
555
  pincodeBannerTitle: {
531
556
  fontSize: 13,