@forgeroute/ui 0.5.0 → 0.5.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.
@@ -1,6 +1,6 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { DestroyRef, InjectionToken, Provider, TemplateRef, WritableSignal } from "@angular/core";
3
- import { HostResult, PaymentAllocation, PaymentMethodBodyContext, PaymentMethodPlugin, PaymentPluginMethod, UiLabelsService } from "@forgeroute/ui";
3
+ import { CheckPaymentStatusFn, HostResult, PaymentAllocation, PaymentAttempt, PaymentAttemptControls, PaymentAttemptOutcome, PaymentMethodBodyContext, PaymentMethodPlugin, PaymentPluginMethod, PaymentReadiness, PaymentReadinessResult, ReadinessCheckFn, UiLabelsService, isDarkPage } from "@forgeroute/ui";
4
4
  import { Observable } from "rxjs";
5
5
  /**
6
6
  * The small part of Stripe.js the library calls, written as plain structural types so the library has NO compile-time or run-time
@@ -54,12 +54,33 @@ interface StripeConfirmResult<I> {
54
54
  paymentIntent?: I;
55
55
  setupIntent?: I;
56
56
  }
57
+ /** A ConfirmationToken as `stripe.createConfirmationToken` answers it (only the fields the library reads). */
58
+ interface StripeConfirmationTokenLike {
59
+ id: string;
60
+ payment_method_preview?: {
61
+ type?: string;
62
+ card?: {
63
+ brand?: string;
64
+ funding?: string;
65
+ last4?: string;
66
+ country?: string;
67
+ wallet?: {
68
+ type?: string;
69
+ } | null;
70
+ } | null;
71
+ } | null;
72
+ }
57
73
  /** The Stripe.js object (`Stripe`). Methods the library calls only in some flows are optional so a fake can leave them out. */
58
74
  interface StripeLike {
59
75
  elements(options?: Record<string, unknown>): StripeElementsLike;
60
76
  confirmPayment(params: Record<string, unknown>): Promise<StripeConfirmResult<StripeIntentLike>>;
61
77
  confirmSetup(params: Record<string, unknown>): Promise<StripeConfirmResult<StripeIntentLike>>;
62
78
  handleCardAction?(clientSecret: string): Promise<StripeConfirmResult<StripeIntentLike>>;
79
+ /** Creates a ConfirmationToken from the Elements (call `elements.submit()` first): the funding of a typed card is known BEFORE any intent exists. */
80
+ createConfirmationToken?(params: Record<string, unknown>): Promise<{
81
+ confirmationToken?: StripeConfirmationTokenLike;
82
+ error?: StripeErrorLike;
83
+ }>;
63
84
  retrievePaymentIntent?(clientSecret: string): Promise<StripeConfirmResult<StripeIntentLike>>;
64
85
  retrieveSetupIntent?(clientSecret: string): Promise<StripeConfirmResult<StripeIntentLike>>;
65
86
  verifyMicrodepositsForPayment?(clientSecret: string, data?: Record<string, unknown>): Promise<StripeConfirmResult<StripeIntentLike>>;
@@ -181,6 +202,28 @@ interface StripeConfirmedEvent {
181
202
  /** The 3D Secure step (`stripe.handleCardAction`) ran before this result (`autoHandleCardAction` / `handleNextAction`). Hosts use it for their post-3DS wording. */
182
203
  actionHandled: boolean;
183
204
  }
205
+ /** The funding of a card as Stripe reports it in a ConfirmationToken's `payment_method_preview.card.funding`. */
206
+ type StripeCardFunding = 'credit' | 'debit' | 'prepaid' | 'unknown';
207
+ /**
208
+ * A ConfirmationToken made from the typed form (`createConfirmationToken()` / `collectConfirmationToken`), with what Stripe shows about the payment method BEFORE any
209
+ * intent exists. `funding` is only for display and for hosts that estimate a fee; a backend that charges by it must read the funding itself from the token id
210
+ * (`stripe.confirmationTokens.retrieve`), never trust the browser.
211
+ */
212
+ interface StripeConfirmationTokenEvent {
213
+ /** `ctoken_...`: send it to your backend with the request that creates the intent. */
214
+ id: string;
215
+ /** The preview's payment method type (`'card'`, `'us_bank_account'`, `'link'`, ...), `null` when Stripe sent none. */
216
+ paymentMethodType: string | null;
217
+ /** The card's funding; `null` when the payment method is not a card, `'unknown'` when Stripe did not say. */
218
+ funding: StripeCardFunding | null;
219
+ brand: string | null;
220
+ last4: string | null;
221
+ country: string | null;
222
+ /** `'apple_pay'` / `'google_pay'` / ... when a wallet card was used. */
223
+ wallet: string | null;
224
+ }
225
+ /** The normalised {@link StripeConfirmationTokenEvent} of a ConfirmationToken. */
226
+ declare function confirmationTokenEventOf(token: StripeConfirmationTokenLike): StripeConfirmationTokenEvent;
184
227
  /** Why a flow stopped. */
185
228
  type StripeFailureStage = 'load' | 'submit' | 'intent' | 'confirm' | 'action' | 'result' | 'verify' | 'return';
186
229
  /** A failure: `message` is what to show the customer; `stripeMessage` is Stripe's own text. */
@@ -216,6 +259,7 @@ declare const MSG_AUTH_FAILED = "Payment authentication failed";
216
259
  declare const MSG_AUTH_NOT_COMPLETED = "Payment authentication was not completed";
217
260
  declare const MSG_KEY_MISSING = "A Stripe publishable key is required";
218
261
  declare const MSG_LOAD_FAILED = "Failed to load Stripe";
262
+ declare const MSG_TOKEN_FAILED = "The card details could not be checked. Please try again.";
219
263
  export declare function paymentMethodIdOf(intent: StripeIntentLike | null | undefined): string | null;
220
264
  /** The micro-deposit verification of an intent whose `next_action` is `verify_with_microdeposits`, else `null`. */
221
265
  export declare function verificationOf(intent: StripeIntentLike | null | undefined): StripeVerification | null;
@@ -319,8 +363,6 @@ interface StripeAppearance {
319
363
  labels?: 'above' | 'floating';
320
364
  disableAnimations?: boolean;
321
365
  }
322
- /** True when the page is in dark mode: `data-theme="dark"` on the root, or the system prefers dark and the root is not forced to `light`. */
323
- export declare function isDarkPage(doc: Document): boolean;
324
366
  /** Builds the appearance from the tokens in effect on `element` (default: the document root). */
325
367
  export declare function readStripeAppearance(doc: Document, element?: Element): StripeAppearance;
326
368
  /** The texts of the screen-reader status region. */
@@ -356,6 +398,9 @@ interface StripeDeferredIntent {
356
398
  /** Called on submit in deferred mode: create the intent on your backend and resolve its client secret (or `{ clientSecret }`). */
357
399
  type StripeCreateIntentFn = (context: {
358
400
  mode: StripeIntentKind;
401
+ confirmationToken?: StripeConfirmationTokenEvent | null;
402
+ attemptKey?: string;
403
+ payableRef?: string | null;
359
404
  }) => Promise<string | {
360
405
  clientSecret: string;
361
406
  }>;
@@ -449,6 +494,60 @@ export declare class StripePaymentComponent {
449
494
  readonly submitBeforeConfirm: import("@angular/core").InputSignal<boolean | null>;
450
495
  /** After a payment comes back `requires_action` (not a bank verification), run `stripe.handleCardAction` (3D Secure) before reporting. */
451
496
  readonly autoHandleCardAction: import("@angular/core").InputSignal<boolean>;
497
+ /**
498
+ * Opt-in (default off, nothing changes): when `confirm()` runs for a CARD, create a ConfirmationToken from the Elements (`stripe.createConfirmationToken({ elements })`, after
499
+ * `elements.submit()`) before the intent is created. The token is emitted as `(confirmationToken)` and handed to `createIntent({ mode, confirmationToken })`, so the host's backend
500
+ * can read the card funding (credit / debit / prepaid) from Stripe BEFORE it creates the intent. A token that cannot be made never stops the payment (the `createIntent`
501
+ * context then has no token). Only made for a DEFERRED intent (`[deferred]`, no `clientSecret`: Stripe requires deferred Elements for `createConfirmationToken`); never for a bank account, Link or a wallet tab, nor for `confirm({ useExistingIntent: true })`.
502
+ */
503
+ readonly collectConfirmationToken: import("@angular/core").InputSignal<boolean>;
504
+ /**
505
+ * Turns on the duplicate-charge protection (docs: "Duplicate-payment protection") and the readiness gate ("Readiness gate"): the synchronous in-flight lock for the button, Enter and `confirm()`,
506
+ * the attempt key, the UNKNOWN outcome (timeout, offline mid-flight) with the host's `checkStatus`, offline refusal, the paid lock and the readiness reasons. Default OFF: `confirm()` behaves
507
+ * exactly as it always did and `createIntent` receives the same context.
508
+ */
509
+ readonly duplicateProtection: import("@angular/core").InputSignal<boolean>;
510
+ /**
511
+ * The amount of the attempt in MAJOR units (the base amount the payer typed): it goes into the attempt marker, the derived key and the host's records. Default: the deferred amount / 100. A caller whose deferred
512
+ * amount includes fees (the Stripe payment-panel plugin) passes the base amount here, so a payment recorded after an unknown outcome is the base amount, not the fee-inclusive charge.
513
+ */
514
+ readonly attemptAmount: import("@angular/core").InputSignal<number | null>;
515
+ /**
516
+ * The method of the attempt as the HOST names it (marker, derived key, `succeeded` outcome / tombstone). Default: the Stripe payment method type (`'card'`, `'us_bank_account'`). The payment-panel plugin passes the
517
+ * panel's own method (`'CARD'`, `'ACH'`), so an attempt adopted by a reload or another tab is recorded with the method the panel knows, not with a Stripe type.
518
+ */
519
+ readonly attemptMethod: import("@angular/core").InputSignal<string | null>;
520
+ /**
521
+ * The payable this is for (an invoice, a balance, a payment link). While an attempt is undecided its opaque marker (key, amount, method) is stored under it in `localStorage`, so a RELOAD or a
522
+ * SECOND TAB of the same payable starts locked (unknown) with the same attempt key. Without it the protection covers this page instance only. Nothing else is stored.
523
+ */
524
+ readonly payableRef: import("@angular/core").InputSignal<string | null>;
525
+ /** A key the host supplies; empty = generated per payment attempt session. It reaches `createIntent({ attemptKey })`. */
526
+ readonly attemptKey: import("@angular/core").InputSignal<string | null>;
527
+ /** The host's status check by attempt key: resolves an UNKNOWN outcome. */
528
+ readonly checkStatus: import("@angular/core").InputSignal<CheckPaymentStatusFn | null>;
529
+ /** The payable is paid (host re-render, back navigation): every confirm is refused for good. */
530
+ readonly paid: import("@angular/core").InputSignal<boolean>;
531
+ /** The host reports an ambiguous result of ITS charge call: "Checking your payment..." while true. */
532
+ readonly hostPending: import("@angular/core").InputSignal<boolean>;
533
+ readonly statusPollMs: import("@angular/core").InputSignal<number>;
534
+ readonly statusPollMaxMs: import("@angular/core").InputSignal<number>;
535
+ /** A status check slower than this counts as unknown (ms). */
536
+ readonly statusCheckTimeoutMs: import("@angular/core").InputSignal<number>;
537
+ /** While the attempt's own request is unsettled, a status answer `failed` is ignored for this long (ms). */
538
+ readonly statusFailGraceMs: import("@angular/core").InputSignal<number>;
539
+ /** Offer "Start over" after the status polling window (a new attempt with a NEW key). Turn it on ONLY when your backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key: that rule is what makes it safe. */
540
+ readonly allowStartOver: import("@angular/core").InputSignal<boolean>;
541
+ /** Managed environments where `navigator.onLine === false` is a false negative (captive portal, VPN): do not refuse a payment because of the browser's offline flag (default false). */
542
+ readonly offlineOverride: import("@angular/core").InputSignal<boolean>;
543
+ /** The request timeout is replaced by this while a 3-D Secure challenge or the bank window is open (ms). */
544
+ readonly authTimeoutMs: import("@angular/core").InputSignal<number>;
545
+ /** How long ONE `confirm()` (intent creation + Stripe confirmation) may take before the outcome counts as unknown (ms). */
546
+ readonly confirmTimeoutMs: import("@angular/core").InputSignal<number>;
547
+ /** The host's readiness endpoint (`GET /api/payments/ready`): `{ ready, reasons[] }`. */
548
+ readonly readinessCheck: import("@angular/core").InputSignal<ReadinessCheckFn | null>;
549
+ readonly readinessTimeoutMs: import("@angular/core").InputSignal<number>;
550
+ readonly readinessEveryMs: import("@angular/core").InputSignal<number>;
452
551
  readonly submitLabel: import("@angular/core").InputSignal<string>;
453
552
  /** Show the built-in submit button; turn off to use your own and call `confirm()`. */
454
553
  readonly showSubmit: import("@angular/core").InputSignal<boolean>;
@@ -500,12 +599,22 @@ export declare class StripePaymentComponent {
500
599
  readonly paymentMethodTypeChange: import("@angular/core").OutputEmitterRef<string>;
501
600
  /** Every change of the form: completeness and the selected type. */
502
601
  readonly elementChange: import("@angular/core").OutputEmitterRef<StripeElementChange>;
602
+ /** A ConfirmationToken of the typed card was created (`collectConfirmationToken` during `confirm()`, or `createConfirmationToken()`). Only emitted for a card. */
603
+ readonly confirmationToken: import("@angular/core").OutputEmitterRef<StripeConfirmationTokenEvent>;
503
604
  /** The intent was confirmed (succeeded, processing, needs bank verification, or needs a further action). */
504
605
  readonly confirmed: import("@angular/core").OutputEmitterRef<StripeConfirmedEvent>;
505
606
  /** A step failed (validation, intent creation, confirmation). `message` is ready to show. */
506
607
  readonly failed: import("@angular/core").OutputEmitterRef<StripeFailure>;
507
608
  /** Stripe.js or the Payment Element could not be loaded. */
508
609
  readonly loadError: import("@angular/core").OutputEmitterRef<StripeFailure>;
610
+ /** A confirm started / ended (the synchronous lock; only with `duplicateProtection`). */
611
+ readonly inFlightChange: import("@angular/core").OutputEmitterRef<boolean>;
612
+ /** Unified outcome of a payment attempt: `succeeded`, `failed`, `unknown`, `refused` (with `reason`), `pending` (only with `duplicateProtection`). */
613
+ readonly outcome: import("@angular/core").OutputEmitterRef<PaymentAttemptOutcome>;
614
+ /** The attempt key in effect (only with `duplicateProtection`). */
615
+ readonly attemptKeyChange: import("@angular/core").OutputEmitterRef<string>;
616
+ /** The readiness gate changed (only with `duplicateProtection`). */
617
+ readonly readinessChange: import("@angular/core").OutputEmitterRef<PaymentReadinessResult>;
509
618
  readonly loading: import("@angular/core").WritableSignal<boolean>;
510
619
  readonly isReady: import("@angular/core").WritableSignal<boolean>;
511
620
  readonly submitting: import("@angular/core").WritableSignal<boolean>;
@@ -538,9 +647,19 @@ export declare class StripePaymentComponent {
538
647
  private lastAmount;
539
648
  private lastFailure;
540
649
  private destroyed;
650
+ /** Counts the confirms: only the NEWEST one may clear `submitting` (a late, older confirm must not unlock the newer one's screen). */
651
+ private confirmSeq;
541
652
  /** What the element was last given, so a change made while it loaded is applied once it is ready. */
542
653
  private appliedDefaultValues;
543
654
  private appliedDisabled;
655
+ /** The protection applies to PAYMENTS only: saving a card (`mode="setup"`) moves no money, so there is nothing to double-charge and the flag is ignored there. */
656
+ protected readonly protectionOn: import("@angular/core").Signal<boolean>;
657
+ /** The duplicate-payment protection (only active with `duplicateProtection` in payment mode). */
658
+ readonly attempt: PaymentAttempt;
659
+ readonly readiness: PaymentReadiness;
660
+ /** The key of the attempt that is running (passed to `createIntent`); `null` with protection off. */
661
+ /** Bumped by "Retry loading": the init effect runs again. */
662
+ private readonly retryTick;
544
663
  constructor();
545
664
  /**
546
665
  * Submits the form: `elements.submit()` (when required), the deferred intent, then `confirmSetup` / `confirmPayment`.
@@ -554,6 +673,35 @@ export declare class StripePaymentComponent {
554
673
  useExistingIntent?: boolean;
555
674
  clientSecret?: string;
556
675
  }): Promise<StripeConfirmedEvent | null>;
676
+ /**
677
+ * `confirm()` under the duplicate-payment protection: the gate (paid / unknown / not ready / offline: nothing is sent), then ONE attempt under the synchronous lock, raced against
678
+ * `confirmTimeoutMs`. A timeout, going offline, a thrown error, a connection error or an abandoned 3-D Secure challenge make the outcome UNKNOWN (locked, status check by key); only
679
+ * a definitive Stripe refusal unlocks with a new key. Never retries by itself.
680
+ */
681
+ private confirmProtected;
682
+ /** What the result of the core confirm means for the attempt (see {@link confirmProtected}). */
683
+ private classifyConfirm;
684
+ /** "Retry loading" of a blocked Stripe.js / Payment Element: builds the form again. */
685
+ protected reload(): void;
686
+ /** The host reports that ITS charge call timed out or is ambiguous (only with `duplicateProtection`). */
687
+ markUnknown(): void;
688
+ /** The host reports that the payment succeeded (locks the form for this payable). */
689
+ markSucceeded(): void;
690
+ /** The host reports a DEFINITIVE failure (declined): unlock with a NEW key. */
691
+ markFailed(): void;
692
+ /** The host did not use the payment and nothing reached Stripe: unlock, the attempt key is KEPT. */
693
+ markNotCharged(): void;
694
+ /** The host starts a deliberate SECOND payment of this payable (an explicit "pay again" flow): forgets the paid state this form saw, removes the succeeded record and moves the epoch so the next attempt has a NEW key. Does nothing against the host's own `paid` input. */
695
+ resetPaid(): void;
696
+ private confirmCore;
697
+ /**
698
+ * Creates a ConfirmationToken from the typed form (`elements.submit()`, then `stripe.createConfirmationToken({ elements })`) so a host can learn the card's funding before it
699
+ * creates any intent (a fee that depends on credit / debit). Resolves the token event (also emitted as `(confirmationToken)` when it is a card), or the failure (returned only,
700
+ * not emitted, and nothing is shown: Stripe's own form already marks an incomplete field). `null` when nothing was started (already submitting, or disabled).
701
+ */
702
+ createConfirmationToken(): Promise<StripeConfirmationTokenEvent | StripeFailure | null>;
703
+ /** `stripe.createConfirmationToken({ elements })` (with the billing details as `params` when given); the event, or the failure. Never throws. */
704
+ private makeConfirmationToken;
557
705
  /**
558
706
  * Runs `stripe.handleCardAction(clientSecret)` (3D Secure) for a payment that came back `requires_action`, and reports the result like `confirm()`.
559
707
  * Use it when `autoHandleCardAction` is off and the host handles `outcome: 'requires_action'` itself.
@@ -588,6 +736,8 @@ export declare class StripePaymentComponent {
588
736
  private thrownFailure;
589
737
  private buildConfirmParams;
590
738
  private fail;
739
+ /** Shows and emits a failure (what `fail()` always did). */
740
+ private publishFailure;
591
741
  private finish;
592
742
  private announce;
593
743
  private runCardAction;
@@ -736,6 +886,106 @@ export declare class StripePaymentComponent {
736
886
  "required": false;
737
887
  "isSignal": true;
738
888
  };
889
+ "collectConfirmationToken": {
890
+ "alias": "collectConfirmationToken";
891
+ "required": false;
892
+ "isSignal": true;
893
+ };
894
+ "duplicateProtection": {
895
+ "alias": "duplicateProtection";
896
+ "required": false;
897
+ "isSignal": true;
898
+ };
899
+ "attemptAmount": {
900
+ "alias": "attemptAmount";
901
+ "required": false;
902
+ "isSignal": true;
903
+ };
904
+ "attemptMethod": {
905
+ "alias": "attemptMethod";
906
+ "required": false;
907
+ "isSignal": true;
908
+ };
909
+ "payableRef": {
910
+ "alias": "payableRef";
911
+ "required": false;
912
+ "isSignal": true;
913
+ };
914
+ "attemptKey": {
915
+ "alias": "attemptKey";
916
+ "required": false;
917
+ "isSignal": true;
918
+ };
919
+ "checkStatus": {
920
+ "alias": "checkStatus";
921
+ "required": false;
922
+ "isSignal": true;
923
+ };
924
+ "paid": {
925
+ "alias": "paid";
926
+ "required": false;
927
+ "isSignal": true;
928
+ };
929
+ "hostPending": {
930
+ "alias": "hostPending";
931
+ "required": false;
932
+ "isSignal": true;
933
+ };
934
+ "statusPollMs": {
935
+ "alias": "statusPollMs";
936
+ "required": false;
937
+ "isSignal": true;
938
+ };
939
+ "statusPollMaxMs": {
940
+ "alias": "statusPollMaxMs";
941
+ "required": false;
942
+ "isSignal": true;
943
+ };
944
+ "statusCheckTimeoutMs": {
945
+ "alias": "statusCheckTimeoutMs";
946
+ "required": false;
947
+ "isSignal": true;
948
+ };
949
+ "statusFailGraceMs": {
950
+ "alias": "statusFailGraceMs";
951
+ "required": false;
952
+ "isSignal": true;
953
+ };
954
+ "allowStartOver": {
955
+ "alias": "allowStartOver";
956
+ "required": false;
957
+ "isSignal": true;
958
+ };
959
+ "offlineOverride": {
960
+ "alias": "offlineOverride";
961
+ "required": false;
962
+ "isSignal": true;
963
+ };
964
+ "authTimeoutMs": {
965
+ "alias": "authTimeoutMs";
966
+ "required": false;
967
+ "isSignal": true;
968
+ };
969
+ "confirmTimeoutMs": {
970
+ "alias": "confirmTimeoutMs";
971
+ "required": false;
972
+ "isSignal": true;
973
+ };
974
+ "readinessCheck": {
975
+ "alias": "readinessCheck";
976
+ "required": false;
977
+ "isSignal": true;
978
+ };
979
+ "readinessTimeoutMs": {
980
+ "alias": "readinessTimeoutMs";
981
+ "required": false;
982
+ "isSignal": true;
983
+ };
984
+ "readinessEveryMs": {
985
+ "alias": "readinessEveryMs";
986
+ "required": false;
987
+ "isSignal": true;
988
+ };
739
989
  "submitLabel": {
740
990
  "alias": "submitLabel";
741
991
  "required": false;
@@ -841,9 +1091,14 @@ export declare class StripePaymentComponent {
841
1091
  "ready": "ready";
842
1092
  "paymentMethodTypeChange": "paymentMethodTypeChange";
843
1093
  "elementChange": "elementChange";
1094
+ "confirmationToken": "confirmationToken";
844
1095
  "confirmed": "confirmed";
845
1096
  "failed": "failed";
846
1097
  "loadError": "loadError";
1098
+ "inFlightChange": "inFlightChange";
1099
+ "outcome": "outcome";
1100
+ "attemptKeyChange": "attemptKeyChange";
1101
+ "readinessChange": "readinessChange";
847
1102
  }, never, never, true, never>;
848
1103
  }
849
1104
  /** How a bank account added with micro-deposits is verified: two deposit amounts, the code of one deposit, or the bank is still confirming it. */
@@ -1434,6 +1689,17 @@ interface StripeIntentContext extends PaymentAllocation {
1434
1689
  paymentMethodType: 'card' | 'us_bank_account';
1435
1690
  receivedDate: string;
1436
1691
  notes: string | null;
1692
+ /** Only with `[fundingPreview]="true"` on the plugin and a card: the ConfirmationToken (`ctoken_...`) created from the typed card, so the backend can read the card funding from Stripe before it creates the intent. */
1693
+ confirmationTokenId?: string | null;
1694
+ /** Only with `[fundingPreview]="true"` and a card: Stripe's funding of the typed card (display only; a backend that charges by it reads it from the token). */
1695
+ funding?: StripeCardFunding | null;
1696
+ /**
1697
+ * Only with `[duplicateProtection]="true"` on the plugin: the key of this PAYMENT ATTEMPT (stable across retries after a timeout / offline loss, a reload and a second tab; renewed only after
1698
+ * a definitive failure or success). Send it to your backend, which creates the PaymentIntent with it as Stripe's `Idempotency-Key` and answers `checkStatus(attemptKey)` with it.
1699
+ */
1700
+ attemptKey?: string;
1701
+ /** Only with `[duplicateProtection]="true"`: the payable of this attempt (`payableRef` at the click): the backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key. */
1702
+ payableRef?: string | null;
1437
1703
  }
1438
1704
  /** What the host's `createIntent` answers. Fees are optional; when given they are shown as rows under the form. */
1439
1705
  interface StripeIntentInfo {
@@ -1461,6 +1727,13 @@ interface StripeFeeContext {
1461
1727
  amount: number;
1462
1728
  paymentMethod: string;
1463
1729
  paymentMethodType: 'card' | 'us_bank_account';
1730
+ /**
1731
+ * Only with `[fundingPreview]="true"` on the plugin: the funding of the typed card once the card form is complete (`'credit'`, `'debit'`, `'prepaid'`, `'unknown'`), `null` while it is
1732
+ * not known (no card yet, a bank account). A credit-only fee schedule answers the credit fee while it is `null` or `'credit'` and no platform fee for `'debit'` / ACH.
1733
+ */
1734
+ funding?: StripeCardFunding | null;
1735
+ /** Only with `[fundingPreview]="true"` once the card is complete: the ConfirmationToken of the typed card, for a backend-side funding lookup in `estimateFees`. */
1736
+ confirmationTokenId?: string | null;
1464
1737
  }
1465
1738
  export declare const STRIPE_PAYMENT_METHODS: readonly [{
1466
1739
  readonly value: "CARD";
@@ -1518,9 +1791,63 @@ export declare class StripePaymentMethodComponent extends PaymentMethodPlugin {
1518
1791
  readonly estimateTimeoutMs: import("@angular/core").InputSignal<number>;
1519
1792
  /** The payer covers fees, so the intent amount is payment + fees: a rejected or empty estimate keeps Pay off (with "Try again") instead of falling back to the base amount, which Stripe would reject as a mismatch. */
1520
1793
  readonly feesRequired: import("@angular/core").InputSignal<boolean>;
1794
+ /**
1795
+ * Opt-in (default off: the estimate and the intent request are exactly as before). For a fee schedule that depends on the card's funding (a platform fee on credit cards only):
1796
+ * once the typed card is complete a ConfirmationToken is made from the Payment Element, its funding is passed to `estimateFees` (`ctx.funding`, `ctx.confirmationTokenId`) so
1797
+ * the fee rows and the total update (credit vs debit vs bank account), and `createIntent` gets `confirmationTokenId` + `funding` for the backend's own lookup. Needs `[estimateFees]`.
1798
+ */
1799
+ readonly fundingPreview: import("@angular/core").InputSignal<boolean>;
1800
+ /** Turns on the duplicate-charge protection and the readiness gate of the Payment Element (docs: "Duplicate-payment protection", "Readiness gate"). Default off. */
1801
+ readonly duplicateProtection: import("@angular/core").InputSignal<boolean>;
1802
+ /**
1803
+ * The payable this is for (an invoice, a balance, a payment link). While an attempt is undecided its opaque marker (key, amount, method) is stored under it in `localStorage`, so a RELOAD or a
1804
+ * SECOND TAB of the same payable starts locked (unknown) with the same attempt key. Without it the protection covers this page instance only. Nothing else is stored.
1805
+ */
1806
+ readonly payableRef: import("@angular/core").InputSignal<string | null>;
1807
+ /** A key the host supplies; empty = generated per payment attempt session (it arrives in `createIntent(ctx).attemptKey`). */
1808
+ readonly attemptKey: import("@angular/core").InputSignal<string | null>;
1809
+ /** The host's status check by attempt key: resolves an UNKNOWN outcome (timeout, offline mid-flight, abandoned 3-D Secure challenge). */
1810
+ readonly checkStatus: import("@angular/core").InputSignal<CheckPaymentStatusFn | null>;
1811
+ /** The payable is paid (host re-render, back navigation): Pay stays locked for good. */
1812
+ readonly paid: import("@angular/core").InputSignal<boolean>;
1813
+ /** The host reports an ambiguous result of ITS charge call: "Checking your payment..." while true. */
1814
+ readonly hostPending: import("@angular/core").InputSignal<boolean>;
1815
+ readonly statusPollMs: import("@angular/core").InputSignal<number>;
1816
+ readonly statusPollMaxMs: import("@angular/core").InputSignal<number>;
1817
+ /** A status check slower than this counts as unknown (ms). */
1818
+ readonly statusCheckTimeoutMs: import("@angular/core").InputSignal<number>;
1819
+ /** While the attempt's own request is unsettled, a status answer `failed` is ignored for this long (ms). */
1820
+ readonly statusFailGraceMs: import("@angular/core").InputSignal<number>;
1821
+ /** Offer "Start over" after the status polling window (a new attempt with a NEW key). Turn it on ONLY when your backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key: that rule is what makes it safe. */
1822
+ readonly allowStartOver: import("@angular/core").InputSignal<boolean>;
1823
+ /** Managed environments where `navigator.onLine === false` is a false negative (captive portal, VPN): do not refuse a payment because of the browser's offline flag (default false). */
1824
+ readonly offlineOverride: import("@angular/core").InputSignal<boolean>;
1825
+ /** The request timeout is replaced by this while a 3-D Secure challenge or the bank window is open (ms). */
1826
+ readonly authTimeoutMs: import("@angular/core").InputSignal<number>;
1827
+ /** How long ONE confirmation (intent creation + Stripe confirmation) may take before the outcome counts as unknown (ms). */
1828
+ readonly confirmTimeoutMs: import("@angular/core").InputSignal<number>;
1829
+ /** The host's readiness endpoint (`GET /api/payments/ready`): `{ ready, reasons[] }`. */
1830
+ readonly readinessCheck: import("@angular/core").InputSignal<ReadinessCheckFn | null>;
1831
+ readonly readinessTimeoutMs: import("@angular/core").InputSignal<number>;
1832
+ readonly readinessEveryMs: import("@angular/core").InputSignal<number>;
1521
1833
  readonly receiptNoteInput: import("@angular/core").InputSignal<string | null>;
1522
1834
  readonly receiptNote: import("@angular/core").Signal<string>;
1523
1835
  private readonly body;
1836
+ private readonly controls;
1837
+ /** @internal The body registers itself. */
1838
+ attachControls(controls: PaymentAttemptControls): void;
1839
+ /** @internal The body leaves. */
1840
+ detachControls(controls: PaymentAttemptControls): void;
1841
+ /** The host's charge of this payment is ambiguous (its call timed out): the plugin shows "Checking your payment..." and stays locked (see `checkStatus`). */
1842
+ markUnknown(): void;
1843
+ /** The host's charge succeeded: the plugin records it (paid + complete) and locks the payable. */
1844
+ markSucceeded(): void;
1845
+ /** The host's charge was DEFINITIVELY refused: the plugin unlocks with a NEW attempt key. */
1846
+ markFailed(): void;
1847
+ /** NOTHING was sent to the processor: the plugin unlocks and the attempt key is KEPT (the backend must still answer the state of an attempt it already holds for that key). */
1848
+ markNotCharged(): void;
1849
+ /** The host starts a deliberate SECOND payment of this payable (an explicit "pay again" flow): forgets the paid state this form saw, removes the succeeded record and moves the epoch so the next attempt has a NEW key. Does nothing against the host's own `paid` input. */
1850
+ resetPaid(): void;
1524
1851
  readonly methods: import("@angular/core").Signal<readonly PaymentPluginMethod[]>;
1525
1852
  readonly template: import("@angular/core").Signal<TemplateRef<PaymentMethodBodyContext> | undefined>;
1526
1853
  static ɵfac: i0.ɵɵFactoryDeclaration<StripePaymentMethodComponent, never>;
@@ -1580,6 +1907,96 @@ export declare class StripePaymentMethodComponent extends PaymentMethodPlugin {
1580
1907
  "required": false;
1581
1908
  "isSignal": true;
1582
1909
  };
1910
+ "fundingPreview": {
1911
+ "alias": "fundingPreview";
1912
+ "required": false;
1913
+ "isSignal": true;
1914
+ };
1915
+ "duplicateProtection": {
1916
+ "alias": "duplicateProtection";
1917
+ "required": false;
1918
+ "isSignal": true;
1919
+ };
1920
+ "payableRef": {
1921
+ "alias": "payableRef";
1922
+ "required": false;
1923
+ "isSignal": true;
1924
+ };
1925
+ "attemptKey": {
1926
+ "alias": "attemptKey";
1927
+ "required": false;
1928
+ "isSignal": true;
1929
+ };
1930
+ "checkStatus": {
1931
+ "alias": "checkStatus";
1932
+ "required": false;
1933
+ "isSignal": true;
1934
+ };
1935
+ "paid": {
1936
+ "alias": "paid";
1937
+ "required": false;
1938
+ "isSignal": true;
1939
+ };
1940
+ "hostPending": {
1941
+ "alias": "hostPending";
1942
+ "required": false;
1943
+ "isSignal": true;
1944
+ };
1945
+ "statusPollMs": {
1946
+ "alias": "statusPollMs";
1947
+ "required": false;
1948
+ "isSignal": true;
1949
+ };
1950
+ "statusPollMaxMs": {
1951
+ "alias": "statusPollMaxMs";
1952
+ "required": false;
1953
+ "isSignal": true;
1954
+ };
1955
+ "statusCheckTimeoutMs": {
1956
+ "alias": "statusCheckTimeoutMs";
1957
+ "required": false;
1958
+ "isSignal": true;
1959
+ };
1960
+ "statusFailGraceMs": {
1961
+ "alias": "statusFailGraceMs";
1962
+ "required": false;
1963
+ "isSignal": true;
1964
+ };
1965
+ "allowStartOver": {
1966
+ "alias": "allowStartOver";
1967
+ "required": false;
1968
+ "isSignal": true;
1969
+ };
1970
+ "offlineOverride": {
1971
+ "alias": "offlineOverride";
1972
+ "required": false;
1973
+ "isSignal": true;
1974
+ };
1975
+ "authTimeoutMs": {
1976
+ "alias": "authTimeoutMs";
1977
+ "required": false;
1978
+ "isSignal": true;
1979
+ };
1980
+ "confirmTimeoutMs": {
1981
+ "alias": "confirmTimeoutMs";
1982
+ "required": false;
1983
+ "isSignal": true;
1984
+ };
1985
+ "readinessCheck": {
1986
+ "alias": "readinessCheck";
1987
+ "required": false;
1988
+ "isSignal": true;
1989
+ };
1990
+ "readinessTimeoutMs": {
1991
+ "alias": "readinessTimeoutMs";
1992
+ "required": false;
1993
+ "isSignal": true;
1994
+ };
1995
+ "readinessEveryMs": {
1996
+ "alias": "readinessEveryMs";
1997
+ "required": false;
1998
+ "isSignal": true;
1999
+ };
1583
2000
  "receiptNoteInput": {
1584
2001
  "alias": "receiptNote";
1585
2002
  "required": false;
@@ -1587,4 +2004,4 @@ export declare class StripePaymentMethodComponent extends PaymentMethodPlugin {
1587
2004
  };
1588
2005
  }, {}, never, never, true, never>;
1589
2006
  }
1590
- export type { HandleReturnOptions, MicrodepositStartedBy, MicrodepositStepsContext, MicrodepositType, MicrodepositVerifyData, MicrodepositVerifyEvent, ProvideStripePaymentOptions, StripeA11yMessages, StripeAppearance, StripeBillingDetails, StripeConfirmResult, StripeConfirmedEvent, StripeConnectAccount, StripeConnectFlowOptions, StripeConnectOutcome, StripeConnectState, StripeConnectStatus, StripeConnection, StripeCreateIntentFn, StripeDeferredIntent, StripeElementChange, StripeElementsLike, StripeErrorDisplay, StripeErrorLike, StripeErrorMessageOptions, StripeFailure, StripeFailureStage, StripeFeeContext, StripeFees, StripeIntentContext, StripeIntentInfo, StripeIntentKind, StripeIntentLike, StripeLike, StripeLikeWithBankSetup, StripeLoadOptions, StripeLoaderFn, StripeMicrodepositNextAction, StripeMicrodepositResult, StripeOutcome, StripePaymentDefaults, StripePaymentElementLike, StripeReadyEvent, StripeReturnParams, StripeReturnResult, StripeVerification };
2007
+ export { type HandleReturnOptions, type MicrodepositStartedBy, type MicrodepositStepsContext, type MicrodepositType, type MicrodepositVerifyData, type MicrodepositVerifyEvent, type ProvideStripePaymentOptions, type StripeA11yMessages, type StripeAppearance, type StripeBillingDetails, type StripeCardFunding, type StripeConfirmResult, type StripeConfirmationTokenEvent, type StripeConfirmationTokenLike, type StripeConfirmedEvent, type StripeConnectAccount, type StripeConnectFlowOptions, type StripeConnectOutcome, type StripeConnectState, type StripeConnectStatus, type StripeConnection, type StripeCreateIntentFn, type StripeDeferredIntent, type StripeElementChange, type StripeElementsLike, type StripeErrorDisplay, type StripeErrorLike, type StripeErrorMessageOptions, type StripeFailure, type StripeFailureStage, type StripeFeeContext, type StripeFees, type StripeIntentContext, type StripeIntentInfo, type StripeIntentKind, type StripeIntentLike, type StripeLike, type StripeLikeWithBankSetup, type StripeLoadOptions, type StripeLoaderFn, type StripeMicrodepositNextAction, type StripeMicrodepositResult, type StripeOutcome, type StripePaymentDefaults, type StripePaymentElementLike, type StripeReadyEvent, type StripeReturnParams, type StripeReturnResult, type StripeVerification, isDarkPage };