@primer-io/primer-js 1.7.0 → 1.9.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/chunks/ar.E4O36EC6.js +1 -0
  3. package/dist/chunks/bg.PK6JKEHS.js +1 -0
  4. package/dist/chunks/ca.OTUBI37X.js +1 -0
  5. package/dist/chunks/chunk.MBXVVM2T.js +2 -0
  6. package/dist/chunks/cs.THPV6MYZ.js +1 -0
  7. package/dist/chunks/da.T6YM33IA.js +1 -0
  8. package/dist/chunks/de.5OGX2NED.js +1 -0
  9. package/dist/chunks/el.YRAV7ELP.js +1 -0
  10. package/dist/chunks/en-GB.6IEVRFTK.js +1 -0
  11. package/dist/chunks/en.OBBZZ45H.js +1 -0
  12. package/dist/chunks/es-AR.KUNVD6SX.js +1 -0
  13. package/dist/chunks/es-MX.YIGVIDM6.js +1 -0
  14. package/dist/chunks/es.CJZT56YE.js +1 -0
  15. package/dist/chunks/et-EE.HWMKJWNX.js +1 -0
  16. package/dist/chunks/fi-FI.7NJH7P3A.js +1 -0
  17. package/dist/chunks/fr.KRF4Y57O.js +1 -0
  18. package/dist/chunks/he.XI3WARES.js +1 -0
  19. package/dist/chunks/hr.XYKILVHU.js +1 -0
  20. package/dist/chunks/hu.UDGJJAFE.js +1 -0
  21. package/dist/chunks/id.7ZN2WKC2.js +1 -0
  22. package/dist/chunks/it.VOYA3KT5.js +1 -0
  23. package/dist/chunks/ja.POQ2E2L3.js +1 -0
  24. package/dist/chunks/ko.MSGGDR35.js +1 -0
  25. package/dist/chunks/lt-LT.QPDWC7EL.js +1 -0
  26. package/dist/chunks/lt.PGXRTZVX.js +1 -0
  27. package/dist/chunks/lv-LV.MPIETXH7.js +1 -0
  28. package/dist/chunks/lv.K76XV5XK.js +1 -0
  29. package/dist/chunks/ms.TLDQ5MRG.js +1 -0
  30. package/dist/chunks/nb.5C4GCSHD.js +1 -0
  31. package/dist/chunks/nl.MPB5NUZQ.js +1 -0
  32. package/dist/chunks/nl_NL.MEGWQA4L.js +1 -0
  33. package/dist/chunks/pl.G5NUFTFJ.js +3 -0
  34. package/dist/chunks/pt-BR.YUAN3GE5.js +1 -0
  35. package/dist/chunks/pt.U7KK23LM.js +1 -0
  36. package/dist/chunks/ro.V5C7DKLQ.js +1 -0
  37. package/dist/chunks/ru.L7XTNV7J.js +1 -0
  38. package/dist/chunks/sk.B5NKJNWF.js +1 -0
  39. package/dist/chunks/sl.PO5G6BSL.js +1 -0
  40. package/dist/chunks/sr-RS.5T2KJ2PK.js +1 -0
  41. package/dist/chunks/sv.XXKSWUSH.js +1 -0
  42. package/dist/chunks/th.7HQVVBDC.js +1 -0
  43. package/dist/chunks/tr.XK3UIRBK.js +1 -0
  44. package/dist/chunks/uk-UA.PJMQMEKE.js +1 -0
  45. package/dist/chunks/vi.KQNTEEX5.js +1 -0
  46. package/dist/chunks/zh-CN.5YAD67HK.js +1 -0
  47. package/dist/chunks/zh-HK.I5LZOTED.js +1 -0
  48. package/dist/chunks/zh-TW.UWEXAFT4.js +1 -0
  49. package/dist/custom-elements.json +364 -305
  50. package/dist/jsx/index.d.ts +0 -2
  51. package/dist/primer-loader.d.ts +249 -60
  52. package/dist/primer-loader.js +16 -14
  53. package/dist/web-types.json +1 -2
  54. package/package.json +1 -1
  55. package/dist/chunks/ar.BIHRX5RF.js +0 -1
  56. package/dist/chunks/bg.FGU6YCAF.js +0 -1
  57. package/dist/chunks/ca.IKG75KNP.js +0 -1
  58. package/dist/chunks/chunk.B7X364D6.js +0 -2
  59. package/dist/chunks/cs.MILBDWY6.js +0 -1
  60. package/dist/chunks/da.JTASZFYV.js +0 -1
  61. package/dist/chunks/de.DXQD6OEP.js +0 -1
  62. package/dist/chunks/el.EFHFPB3R.js +0 -1
  63. package/dist/chunks/en-GB.SXPN4WN6.js +0 -1
  64. package/dist/chunks/en.NNAZENAS.js +0 -1
  65. package/dist/chunks/es-AR.PGD5Q57R.js +0 -1
  66. package/dist/chunks/es-MX.PTII2RTJ.js +0 -1
  67. package/dist/chunks/es.AKW6WGRC.js +0 -1
  68. package/dist/chunks/et-EE.LHI2XOXI.js +0 -1
  69. package/dist/chunks/fi-FI.IPGRD7WF.js +0 -1
  70. package/dist/chunks/fr.PDUWBPKF.js +0 -1
  71. package/dist/chunks/he.5SDFV353.js +0 -1
  72. package/dist/chunks/hr.LXFZTJMG.js +0 -1
  73. package/dist/chunks/hu.VXISLOF3.js +0 -1
  74. package/dist/chunks/id.UCNPGRJA.js +0 -1
  75. package/dist/chunks/it.F7GBFWC2.js +0 -1
  76. package/dist/chunks/ja.BHTV4F5V.js +0 -1
  77. package/dist/chunks/ko.L4TUG67I.js +0 -1
  78. package/dist/chunks/lt-LT.ULLOOI4H.js +0 -1
  79. package/dist/chunks/lt.WAZLYIAI.js +0 -1
  80. package/dist/chunks/lv-LV.TEXPN3ZR.js +0 -1
  81. package/dist/chunks/lv.TQJGMNOY.js +0 -1
  82. package/dist/chunks/ms.Q2C5ZFHD.js +0 -1
  83. package/dist/chunks/nb.KCZ6D34T.js +0 -1
  84. package/dist/chunks/nl.2CTHY5J7.js +0 -1
  85. package/dist/chunks/nl_NL.SYW24NKO.js +0 -1
  86. package/dist/chunks/pl.AI5CECVT.js +0 -3
  87. package/dist/chunks/pt-BR.OWKVFNRL.js +0 -1
  88. package/dist/chunks/pt.LVBHJFXR.js +0 -1
  89. package/dist/chunks/ro.SJYNCSI5.js +0 -1
  90. package/dist/chunks/ru.3HE2B7ZT.js +0 -1
  91. package/dist/chunks/sk.YAEVPIZD.js +0 -1
  92. package/dist/chunks/sl.BA3GBVRO.js +0 -1
  93. package/dist/chunks/sr-RS.3C6VVYBB.js +0 -1
  94. package/dist/chunks/sv.2VDFAELX.js +0 -1
  95. package/dist/chunks/th.J7ZUQIZS.js +0 -1
  96. package/dist/chunks/tr.E2CHOIPA.js +0 -1
  97. package/dist/chunks/uk-UA.QYJJIGTW.js +0 -1
  98. package/dist/chunks/vi.YGBNA3NJ.js +0 -1
  99. package/dist/chunks/zh-CN.SRN7TXMD.js +0 -1
  100. package/dist/chunks/zh-HK.3JAKYZ5N.js +0 -1
  101. package/dist/chunks/zh-TW.WTNQLAHV.js +0 -1
@@ -71,8 +71,6 @@ export type PrimerCheckoutComponentProps = {
71
71
  This is used to control the CSS-only loader visibility */
72
72
  "js-initialized"?: boolean;
73
73
  /** */
74
- jsInitialized?: boolean;
75
- /** */
76
74
  primerJS?: PrimerJS | undefined;
77
75
  /** */
78
76
  options?: PrimerCheckoutOptions;
@@ -1,7 +1,6 @@
1
1
  import { ContextProvider } from '@lit/context';
2
2
  import { Task, initialState } from '@lit/task';
3
- import { PayPalButtonStyle } from '@paypal/paypal-js';
4
- import { FUNDING_SOURCE } from '@paypal/paypal-js/types/components/funding-eligibility';
3
+ import { FUNDING_SOURCE, PayPalButtonStyle } from '@paypal/paypal-js';
5
4
  import { CSSResult, LitElement, PropertyValues, ReactiveController, ReactiveControllerHost, SVGTemplateResult, TemplateResult, nothing } from 'lit';
6
5
 
7
6
  declare global {
@@ -268,7 +267,9 @@ export interface GooglePayClientOptions {
268
267
  */
269
268
  captureBillingAddress?: boolean;
270
269
  /**
271
- * When true, requests shipping address from Google Pay and updates client session.
270
+ * When true, requests shipping address from Google Pay and updates client
271
+ * session. Register `onShippingAddressChange` to supply shipping options
272
+ * for display in the sheet.
272
273
  */
273
274
  captureShippingAddress?: boolean;
274
275
  /**
@@ -281,10 +282,9 @@ export interface GooglePayClientOptions {
281
282
  */
282
283
  emailRequired?: boolean;
283
284
  /**
284
- * When true, enables shipping method selection in the Google Pay payment sheet.
285
- * Shipping methods are read from the SHIPPING checkout module in the client configuration.
286
- * When the user selects a shipping option, the SDK will call selectShippingMethod()
287
- * on the client session API to update the order on the backend.
285
+ * When true, enables shipping method selection in the Google Pay payment
286
+ * sheet. Register `onShippingAddressChange` to supply the option list and
287
+ * `onShippingOptionChange` to commit the shopper's selection.
288
288
  */
289
289
  requireShippingMethod?: boolean;
290
290
  /**
@@ -371,29 +371,15 @@ export interface BillingAddressCheckoutModule {
371
371
  type: "BILLING_ADDRESS";
372
372
  options: BillingAddressModuleOptions;
373
373
  }
374
- /**
375
- * Shipping method for express checkout flows (Google Pay, Apple Pay).
376
- */
377
- export interface ShippingMethod {
378
- /** Unique identifier for the shipping method */
379
- id: string;
380
- /** Display name for the shipping method */
381
- name: string;
382
- /** Description (e.g., "5-7 business days") */
383
- description: string;
384
- /** Shipping cost in minor units */
385
- amount: number;
386
- /** Type of shipping method */
387
- type?: "shipping" | "pickup";
388
- }
389
374
  /**
390
375
  * Shipping checkout module options
391
376
  */
392
377
  export interface ShippingModuleOptions {
393
- /** Available shipping methods */
394
- shippingMethods: ShippingMethod[];
378
+ /** Available shipping methods (legacy `shippingMethodsUrl` path only) */
379
+ shippingMethods: ShippingOption[];
395
380
  /** Currently selected shipping method ID */
396
381
  selectedShippingMethod?: string;
382
+ callbackMode?: boolean;
397
383
  }
398
384
  /**
399
385
  * Shipping checkout module
@@ -407,6 +393,20 @@ export interface ShippingCheckoutModule {
407
393
  * Supports billing address and shipping modules
408
394
  */
409
395
  export type CheckoutModuleConfig = BillingAddressCheckoutModule | ShippingCheckoutModule;
396
+ /**
397
+ * A shipping option offered to the shopper inside an Express Checkout
398
+ * (Apple Pay / Google Pay) payment sheet — either the legacy
399
+ * `shippingMethodsUrl`-resolved list (read from `ShippingCheckoutModule`),
400
+ * or merchant-supplied via the newer event-driven flow: returned via the
401
+ * `setShippingOptions` handler on `onShippingAddressChange`, and passed back
402
+ * via `onShippingOptionChange` once the shopper selects one.
403
+ */
404
+ export interface ShippingOption {
405
+ amount: number;
406
+ id: string;
407
+ name: string;
408
+ description: string;
409
+ }
410
410
  export type ApprovalMode = "AUTO" | "MANUAL";
411
411
  export interface ClientSession {
412
412
  clientSessionId: string;
@@ -661,8 +661,6 @@ export interface TelemetryClient {
661
661
  sdkVersion: string;
662
662
  clientSessionToken?: string;
663
663
  userAgent: string;
664
- /** Timestamp (ms) when the first backend call (/configuration) started */
665
- sdkInitStartTime?: number;
666
664
  };
667
665
  readonly analytics: {
668
666
  sendEvent(event: {
@@ -675,8 +673,13 @@ export interface TelemetryClient {
675
673
  metadata?: Record<string, unknown>;
676
674
  status?: "error" | "warn" | "info";
677
675
  }): void;
678
- checkoutInitialized(initDurationMs?: number): void;
679
676
  };
677
+ /**
678
+ * Merge checkout-flow context into every subsequent remote log's metadata
679
+ * (e.g. `selected_payment_method`, `payment_id`). Setting a key to `undefined`
680
+ * removes it.
681
+ */
682
+ setLogContext(patch: Record<string, unknown>): void;
680
683
  /**
681
684
  * Console error + Datadog report for unexpected technical errors, exactly
682
685
  * once per error. Do NOT use for expected operational errors (payment
@@ -686,8 +689,6 @@ export interface TelemetryClient {
686
689
  reportSdkError(error: unknown, options?: {
687
690
  message?: string;
688
691
  }): void;
689
- setSdkInitStartTime(timestamp: number): void;
690
- getSdkInitStartTime(): number | undefined;
691
692
  dispose(): void;
692
693
  }
693
694
  declare enum HeadlessManagerType {
@@ -722,6 +723,51 @@ export interface PayPalOptionsWithPaypalJsTypes {
722
723
  enableFunding?: FUNDING_SOURCE[];
723
724
  integrationDate?: string;
724
725
  debug?: boolean;
726
+ /**
727
+ * PayPal App Switch configuration.
728
+ *
729
+ * When enabled, tapping the PayPal button attempts to open the PayPal app
730
+ * (falling back to the web flow when unavailable), and the buyer is
731
+ * returned to complete checkout. The SDK uses your `returnUrl` as the PayPal
732
+ * order/billing-agreement return and cancel URLs, and resumes the pending
733
+ * session on return.
734
+ */
735
+ appSwitch?: {
736
+ /**
737
+ * Whether App Switch is enabled.
738
+ * @default false
739
+ */
740
+ enabled?: boolean;
741
+ /**
742
+ * The full URL PayPal returns and cancels to after the app switch.
743
+ * **Required when App Switch is enabled**, and PayPal requires it to be the
744
+ * same URL the SDK was initialized on. The SDK appends `?clientToken=…` so
745
+ * that page can resume the pending session.
746
+ */
747
+ returnUrl?: string;
748
+ /**
749
+ * Host-app bridge for checkout embedded in a native app's webview, where
750
+ * PayPal's in-browser App Switch cannot return. The SDK hands the approval
751
+ * deep link to the host app, which opens it and calls `resumeAppSwitch()`
752
+ * on the native return.
753
+ */
754
+ hostApp?: {
755
+ /** Return the host native app's return deep link, OS, and OS version. */
756
+ getContext: () => Promise<{
757
+ appUrl: string;
758
+ osType: "IOS" | "ANDROID" | "OTHER";
759
+ /** Host OS version, e.g. "14". */
760
+ osVersion?: string;
761
+ }>;
762
+ /**
763
+ * Open the PayPal approval deep link. The native return appends
764
+ * `/success` or `/cancel` to the return URL and carries the `token`
765
+ * (order id) on both — route by path: `resumeAppSwitch(token)` on
766
+ * success, `cancelAppSwitch()` on cancel.
767
+ */
768
+ openApprovalUrl: (approvalUrl: string) => void | Promise<void>;
769
+ };
770
+ };
725
771
  }
726
772
  export interface LegacyApplePayOptions {
727
773
  /**
@@ -769,6 +815,11 @@ export interface ApplePayClientOptions {
769
815
  * @see https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields
770
816
  */
771
817
  requiredShippingContactFields?: ("postalAddress" | "name" | "phoneticName" | "phone" | "email")[];
818
+ /**
819
+ * When true, enables shipping method selection in the Apple Pay sheet.
820
+ * Register `onShippingAddressChange` to supply the option list and
821
+ * `onShippingOptionChange` to commit the shopper's selection.
822
+ */
772
823
  requireShippingMethod?: boolean;
773
824
  };
774
825
  }
@@ -1145,8 +1196,11 @@ export interface BlikPaymentMethod {
1145
1196
  */
1146
1197
  start(): Promise<void>;
1147
1198
  }
1199
+ /**
1200
+ * A payment method rendered as a branded button by an external SDK.
1201
+ */
1148
1202
  export interface NativePaymentMethod {
1149
- type: typeof PaymentMethodType.APPLE_PAY | typeof PaymentMethodType.GOOGLE_PAY | typeof PaymentMethodType.PAYPAL;
1203
+ type: typeof PaymentMethodType.APPLE_PAY | typeof PaymentMethodType.GOOGLE_PAY;
1150
1204
  managerType: HeadlessManagerType.NATIVE;
1151
1205
  /**
1152
1206
  * Initialize the payment method (e.g. load the external SDK)
@@ -1158,6 +1212,22 @@ export interface NativePaymentMethod {
1158
1212
  render(container: HTMLElement, buttonOptions?: PaymentRenderButtonOptions): Promise<void>;
1159
1213
  setDisabled(disabled: boolean): Promise<void>;
1160
1214
  }
1215
+ /**
1216
+ * PayPal renders like the other native methods, plus the host-app App Switch
1217
+ * entry points. Both warn and do nothing unless `paypal.appSwitch.hostApp` is
1218
+ * configured.
1219
+ */
1220
+ export interface PayPalPaymentMethod {
1221
+ type: typeof PaymentMethodType.PAYPAL;
1222
+ managerType: HeadlessManagerType.NATIVE;
1223
+ start(): Promise<void>;
1224
+ render(container: HTMLElement, buttonOptions?: PaymentRenderButtonOptions): Promise<void>;
1225
+ setDisabled(disabled: boolean): Promise<void>;
1226
+ /** Finishes the payment after the buyer returns, with the `orderId` the host app captured. */
1227
+ resumeAppSwitch(orderId: string): Promise<void>;
1228
+ /** Propagates a user cancellation when the buyer returns without approving. */
1229
+ cancelAppSwitch(): Promise<void>;
1230
+ }
1161
1231
  /**
1162
1232
  * Payment method types that have a surface of their own. Everything else is
1163
1233
  * driven generically — by a redirect, or by the backend.
@@ -1411,6 +1481,16 @@ export interface CreateHeadlessOptions {
1411
1481
  */
1412
1482
  resumePaymentOnPopupClosure?: boolean;
1413
1483
  };
1484
+ /**
1485
+ * Vault options
1486
+ */
1487
+ vault?: {
1488
+ /**
1489
+ * Restricts the payment method types returned.
1490
+ * Vaulted payment methods of any other type are filtered out.
1491
+ */
1492
+ enabledPaymentMethods?: PaymentMethodType[];
1493
+ };
1414
1494
  /**
1415
1495
  * Fires once at SDK init with the initial set of available payment methods.
1416
1496
  */
@@ -1459,12 +1539,67 @@ export interface CreateHeadlessOptions {
1459
1539
  * is resolved. Not fired for a fresh checkout (no attempt in flight).
1460
1540
  */
1461
1541
  onCheckoutResume?: () => void;
1542
+ /**
1543
+ * Express Checkout (Apple Pay / Google Pay): invoked when the shopper
1544
+ * changes/enters their shipping address inside the native payment sheet.
1545
+ * The merchant computes shipping options for that address and calls
1546
+ * `setShippingOptions` with the result; the SDK displays them in the
1547
+ * sheet. Display-only — the SDK does not persist the list.
1548
+ *
1549
+ * Required for `captureShippingAddress`/`requireShippingMethod` (Google
1550
+ * Pay) or `shippingOptions.requireShippingMethod` (Apple Pay) to show any
1551
+ * shipping options. If not registered, no options are shown and a warning
1552
+ * is logged.
1553
+ *
1554
+ * Must call `setShippingOptions` within 20 seconds or the payment attempt
1555
+ * fails with a `REQUEST_TIMEOUT` error. If integrating via
1556
+ * `addEventListener('primer:shipping-address-change', ...)` instead of
1557
+ * this callback, call `event.preventDefault()` synchronously to signal you
1558
+ * will respond asynchronously — otherwise the SDK assumes nothing is
1559
+ * listening, logs a warning, and your later response is ignored.
1560
+ *
1561
+ * Not invoked at all if a legacy `shippingMethodsUrl`-configured `SHIPPING`
1562
+ * checkout module is present on the client session — that legacy,
1563
+ * server-resolved flow takes priority silently (a warning is logged, but
1564
+ * this callback is simply never called). The two are mutually exclusive;
1565
+ * remove the `shippingMethodsUrl` configuration to use this callback.
1566
+ */
1567
+ onShippingAddressChange?: (data: {
1568
+ paymentMethodType: PaymentMethodType;
1569
+ shippingAddress: NullableAddress;
1570
+ }, handler: {
1571
+ setShippingOptions: (options: ShippingOption[]) => void;
1572
+ }) => void;
1573
+ /**
1574
+ * Express Checkout (Apple Pay / Google Pay): invoked when the shopper
1575
+ * selects one of the shipping options supplied via
1576
+ * `onShippingAddressChange`. The merchant's backend should PATCH the
1577
+ * client session with the authoritative shipping amount (+ tax) before
1578
+ * calling `continue()` to acknowledge. Payment authorization is gated on
1579
+ * this ack.
1580
+ *
1581
+ * Must call `continue()` within 20 seconds or the payment attempt fails
1582
+ * with a `REQUEST_TIMEOUT` error. If integrating via
1583
+ * `addEventListener('primer:shipping-option-change', ...)` instead of
1584
+ * this callback, call `event.preventDefault()` synchronously to signal you
1585
+ * will respond asynchronously — otherwise the SDK assumes nothing is
1586
+ * listening, logs a warning, and your later response is ignored.
1587
+ *
1588
+ * Not invoked at all if a legacy `shippingMethodsUrl`-configured `SHIPPING`
1589
+ * checkout module is present — see `onShippingAddressChange`.
1590
+ */
1591
+ onShippingOptionChange?: (data: {
1592
+ paymentMethodType: PaymentMethodType;
1593
+ selectedShippingOption: ShippingOption;
1594
+ }, handler: {
1595
+ continue: () => void;
1596
+ }) => void;
1462
1597
  onBinDataAvailable?: (event: BinDataAvailableEvent) => void;
1463
1598
  onBinDataLoadingChange?: (loading: boolean) => void;
1464
1599
  onCardNetworksChange?: (event: CardNetworkChangeEvent) => void;
1465
1600
  onCardNetworksLoading?: () => void;
1466
1601
  }
1467
- export type InitializedPaymentMethod = CardPaymentMethod | KlarnaPaymentMethod | AdyenKlarnaPaymentMethod | QRCodePaymentMethod | BlikPaymentMethod | MbwayPaymentMethod | RedirectPaymentMethod | BackendDrivenPaymentMethod | NativePaymentMethod;
1602
+ export type InitializedPaymentMethod = CardPaymentMethod | KlarnaPaymentMethod | AdyenKlarnaPaymentMethod | QRCodePaymentMethod | BlikPaymentMethod | MbwayPaymentMethod | RedirectPaymentMethod | BackendDrivenPaymentMethod | NativePaymentMethod | PayPalPaymentMethod;
1468
1603
  export interface CardSecurityCodeInputOptions {
1469
1604
  ariaLabel?: string;
1470
1605
  container: string | Element | HTMLElement;
@@ -1485,7 +1620,7 @@ export interface InputMetadata {
1485
1620
  touched: boolean;
1486
1621
  submitted: boolean;
1487
1622
  }
1488
- export interface PrimerCheckoutOptions extends Omit<CreateHeadlessOptions, "dialogProvider"> {
1623
+ export interface PrimerCheckoutOptions extends Omit<CreateHeadlessOptions, "dialogProvider" | "onShippingAddressChange" | "onShippingOptionChange"> {
1489
1624
  giftCard?: {
1490
1625
  logoSrc: string;
1491
1626
  background: string;
@@ -1596,7 +1731,7 @@ export interface PrimerCheckoutOptions extends Omit<CreateHeadlessOptions, "dial
1596
1731
  * ```
1597
1732
  */
1598
1733
  headless?: boolean;
1599
- };
1734
+ } & CreateHeadlessOptions["vault"];
1600
1735
  /**
1601
1736
  * Globally disables all payment method interactions in drop-in mode.
1602
1737
  *
@@ -1680,11 +1815,17 @@ export type SdkState = {
1680
1815
  */
1681
1816
  isProcessing: boolean;
1682
1817
  /**
1683
- * SDK/component initialization errors.
1684
- * This represents errors from the Primer JS layer itself (e.g., configuration errors,
1685
- * component initialization failures), not payment processing errors.
1686
- */
1687
- primerJsError: Error | null;
1818
+ * SDK initialization errors — never payment-processing failures (those go
1819
+ * to `paymentFailure`). The error thrown during initialization is kept
1820
+ * as-is; common codes:
1821
+ * - `INVALID_CLIENT_TOKEN`: the client token is malformed, expired, or was
1822
+ * rejected generate a new one
1823
+ * - `INITIALIZATION_ERROR`: any other initialization failure (e.g. the
1824
+ * configuration failed to load)
1825
+ * `origin` says who should act on it ('network' marks retryable failures);
1826
+ * the underlying cause is nested in `error`.
1827
+ */
1828
+ primerJsError: SdkError | null;
1688
1829
  isLoading: boolean;
1689
1830
  /**
1690
1831
  * Payment processing failure information.
@@ -2115,13 +2256,6 @@ export declare class PrimerJS {
2115
2256
  * Returns the cached list of payment methods.
2116
2257
  */
2117
2258
  getPaymentMethods(): InitializedPaymentMethod[];
2118
- /**
2119
- * Internal accessor that returns the initialized payment methods (with their
2120
- * managers), used by the refresh path to preserve manager identity across
2121
- * client-session refreshes.
2122
- * @internal
2123
- */
2124
- getInitializedPaymentMethods(): InitializedPaymentMethod[];
2125
2259
  /**
2126
2260
  * Internal method to handle the onPaymentStart callback
2127
2261
  * @internal - This is only used internally by the SDK
@@ -2150,6 +2284,29 @@ export declare class PrimerJS {
2150
2284
  * ```
2151
2285
  */
2152
2286
  setCardholderName(cardholderName: string): void;
2287
+ /**
2288
+ * PayPal host-app App Switch: finishes the payment after the buyer returns
2289
+ * from the PayPal app, with the `orderId` the host app read from the return
2290
+ * deep link's `token` param. The outcome arrives through the usual
2291
+ * onCheckoutComplete/onCheckoutFail callbacks.
2292
+ *
2293
+ * Does not need the PayPal button to have rendered.
2294
+ *
2295
+ * @example
2296
+ * ```typescript
2297
+ * const checkout = document.querySelector('primer-checkout');
2298
+ * await checkout.primerJS?.resumeAppSwitch(orderIdFromDeepLink);
2299
+ * ```
2300
+ */
2301
+ resumeAppSwitch(orderId: string): Promise<void>;
2302
+ /** PayPal host-app App Switch: cancels when the buyer returns without approving. */
2303
+ cancelAppSwitch(): Promise<void>;
2304
+ /**
2305
+ * Warns rather than throwing when PayPal is absent: the host app calls these
2306
+ * on a deep-link return, where whether PayPal is in the session is not its
2307
+ * business.
2308
+ */
2309
+ private findPayPalMethod;
2153
2310
  }
2154
2311
  export interface CardSubmitResult {
2155
2312
  success?: boolean;
@@ -2223,6 +2380,18 @@ export interface PrimerEvents {
2223
2380
  "primer:payment-approval-required": CustomEvent<PaymentApprovalRequiredData & {
2224
2381
  timestamp: number;
2225
2382
  }>;
2383
+ "primer:shipping-address-change": CustomEvent<{
2384
+ paymentMethodType: PaymentMethodType;
2385
+ shippingAddress: NullableAddress;
2386
+ setShippingOptions: (options: ShippingOption[]) => void;
2387
+ timestamp: number;
2388
+ }>;
2389
+ "primer:shipping-option-change": CustomEvent<{
2390
+ paymentMethodType: PaymentMethodType;
2391
+ selectedShippingOption: ShippingOption;
2392
+ continue: () => void;
2393
+ timestamp: number;
2394
+ }>;
2226
2395
  "primer:vault-methods-update": CustomEvent<{
2227
2396
  vaultedPayments: VaultedPaymentMethodSummary[];
2228
2397
  cvvRecapture: boolean;
@@ -2302,6 +2471,26 @@ declare class PrimerEventsController {
2302
2471
  * backend to call /approve or /abort, and continueFlow() to resume the SDK.
2303
2472
  */
2304
2473
  dispatchPaymentApprovalRequired(detail: PaymentApprovalRequiredData): void;
2474
+ /**
2475
+ * @returns true if a listener called `preventDefault()` or
2476
+ * `setShippingOptions` synchronously; false if nothing is listening, so
2477
+ * the caller can resolve on its own rather than waiting out its timeout.
2478
+ */
2479
+ dispatchShippingAddressChange(detail: {
2480
+ paymentMethodType: PaymentMethodType;
2481
+ shippingAddress: NullableAddress;
2482
+ setShippingOptions: (options: ShippingOption[]) => void;
2483
+ }): boolean;
2484
+ /**
2485
+ * @returns true if a listener called `preventDefault()` or `continue()`
2486
+ * synchronously; false if nothing is listening, so the caller can resolve
2487
+ * on its own rather than waiting out its timeout.
2488
+ */
2489
+ dispatchShippingOptionChange(detail: {
2490
+ paymentMethodType: PaymentMethodType;
2491
+ selectedShippingOption: ShippingOption;
2492
+ continue: () => void;
2493
+ }): boolean;
2305
2494
  /**
2306
2495
  * Dispatch vault methods update event.
2307
2496
  * Called when vaulted payment methods are loaded or updated.
@@ -2460,8 +2649,6 @@ declare class HeadlessSdkController implements ReactiveController {
2460
2649
  host: PrimerCheckoutType;
2461
2650
  private currentSdkInstance;
2462
2651
  private primerJS;
2463
- private loadingTimeout;
2464
- private isDisconnected;
2465
2652
  /**
2466
2653
  * Session-bound telemetry of the current SDK instance. Held here (in
2467
2654
  * addition to the Lit context) so teardown paths can still emit
@@ -2472,8 +2659,6 @@ declare class HeadlessSdkController implements ReactiveController {
2472
2659
  get primerJSInstance(): PrimerJS | null;
2473
2660
  hostConnected(): void;
2474
2661
  hostDisconnected(): void;
2475
- private setupLoadingTimeout;
2476
- private clearLoadingTimeout;
2477
2662
  private cleanupResources;
2478
2663
  /**
2479
2664
  * Datadog error reporting that works across the whole lifecycle: uses the
@@ -2489,6 +2674,19 @@ declare class HeadlessSdkController implements ReactiveController {
2489
2674
  * synchronously read state see `isProcessing: true`.
2490
2675
  */
2491
2676
  private handlePaymentApprovalRequired;
2677
+ /**
2678
+ * Bridges sdk-core's shipping-address-change callback to the
2679
+ * primer:shipping-address-change DOM event, auto-resolving with no
2680
+ * options so sdk-core's promise doesn't time out if nothing responds.
2681
+ */
2682
+ private handleShippingAddressChange;
2683
+ /**
2684
+ * Express Checkout (Apple Pay / Google Pay): sdk-core invokes this when the
2685
+ * shopper selects one of the shipping options previously supplied via
2686
+ * onShippingAddressChange. Same bridge/auto-resolve shape as
2687
+ * handleShippingAddressChange above.
2688
+ */
2689
+ private handleShippingOptionChange;
2492
2690
  initializeHeadless(): ([clientToken, options]: readonly [
2493
2691
  string | null,
2494
2692
  PrimerCheckoutOptions | null
@@ -2512,8 +2710,6 @@ declare class HeadlessSdkController implements ReactiveController {
2512
2710
  * 2. Setting the CSS custom property --primer-loader-disabled: 1
2513
2711
  */
2514
2712
  export declare class PrimerCheckoutComponent extends LitElement implements PrimerCheckoutType {
2515
- set jsInitialized(value: boolean);
2516
- get jsInitialized(): boolean;
2517
2713
  get primerJS(): PrimerJS | undefined;
2518
2714
  static styles: CSSResult[];
2519
2715
  customStyles: string;
@@ -2525,11 +2721,9 @@ export declare class PrimerCheckoutComponent extends LitElement implements Prime
2525
2721
  * This is used to control the CSS-only loader visibility
2526
2722
  * @private
2527
2723
  */
2528
- private _jsInitialized;
2724
+ private jsInitialized;
2529
2725
  defaultSlot: HTMLSlotElement;
2530
- private previousLoadingState;
2531
2726
  private hasAssignedContent;
2532
- private _loadingTimeoutId;
2533
2727
  private _eventListenerController;
2534
2728
  private _classObserver;
2535
2729
  locale: LocaleCode;
@@ -2541,7 +2735,7 @@ export declare class PrimerCheckoutComponent extends LitElement implements Prime
2541
2735
  headlessSdkController: HeadlessSdkController;
2542
2736
  constructor();
2543
2737
  connectedCallback(): void;
2544
- attributeChangedCallback(attrName: string, oldVal: string, newVal: string): void;
2738
+ attributeChangedCallback(attrName: "custom-styles" | (string & {}), oldVal: string, newVal: string): void;
2545
2739
  disconnectedCallback(): void;
2546
2740
  willUpdate(changedProperties: PropertyValues): void;
2547
2741
  updated(): void;
@@ -2560,11 +2754,6 @@ export declare class PrimerCheckoutComponent extends LitElement implements Prime
2560
2754
  * Uses AbortController signal to prevent circular event loops more safely
2561
2755
  */
2562
2756
  private handleExternalShowOtherPaymentsToggle;
2563
- /**
2564
- * Check if the loading state has changed and update the CSS loader visibility accordingly.
2565
- * This method is called after each update cycle to detect when loading is complete.
2566
- */
2567
- private checkLoadingStateChange;
2568
2757
  render(): TemplateResult;
2569
2758
  addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: PrimerCheckoutComponent, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
2570
2759
  addEventListener<K extends keyof ShadowRootEventMap>(type: K, listener: (this: PrimerCheckoutComponent, ev: ShadowRootEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;