@flopay/js 1.20.3 → 1.20.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.
@@ -0,0 +1,25 @@
1
+ import type { CheckoutRuntimeContract } from './contract-manifest.js';
2
+ export interface ContractCompatibility {
3
+ compatible: boolean;
4
+ /** One entry per breaking change, each naming the member path, e.g. `options.sessionId`. */
5
+ breaking: string[];
6
+ }
7
+ export interface ContractNeutrality {
8
+ ok: boolean;
9
+ /** One entry per member that is processor-specific or unclassified, naming its path. */
10
+ violations: string[];
11
+ }
12
+ /**
13
+ * Whether `candidate` still honours every member of the `baseline` contract. Only additive,
14
+ * optional changes are compatible within 2.x: removing or renaming a member, making an optional
15
+ * one required, adding a required one, changing what a member means, dropping a lifecycle step
16
+ * or leaving the baseline's major version breaks it.
17
+ */
18
+ export declare function checkContractCompatibility(baseline: CheckoutRuntimeContract, candidate: CheckoutRuntimeContract): ContractCompatibility;
19
+ /**
20
+ * Whether every member of `contract`, nested fields included, has a neutral classification and
21
+ * none exists for one processor only. It holds no list of processors: a member is accepted only
22
+ * when its meaning is one of the closed {@link CONTRACT_SEMANTICS}, so a processor nobody listed
23
+ * fails as unclassified.
24
+ */
25
+ export declare function checkContractNeutrality(contract: CheckoutRuntimeContract): ContractNeutrality;
@@ -0,0 +1,50 @@
1
+ /** One option, message, message field or event of the public contract. */
2
+ export interface CheckoutRuntimeContractMember {
3
+ name: string;
4
+ /** True when a wrapper has to supply it. Within 2.x only the 2.0.0 baseline's are required. */
5
+ required: boolean;
6
+ /**
7
+ * What the member means, from the closed {@link CONTRACT_SEMANTICS} set: always a payment
8
+ * method or an outcome (or another neutral meaning), never a processor.
9
+ */
10
+ semantic: string;
11
+ /** The one processor a member exists for. The public contract has no such member. */
12
+ onlyFor?: string;
13
+ /** The fields of a message, or the declared parts of an event payload. */
14
+ fields?: CheckoutRuntimeContractMember[];
15
+ }
16
+ export interface CheckoutRuntimeContract {
17
+ version: string;
18
+ /** The steps of a mounted checkout's life, in order: mount, update, unmount. */
19
+ lifecycle: string[];
20
+ /** Options a wrapper hands the runtime to mount a checkout. */
21
+ options: CheckoutRuntimeContractMember[];
22
+ /** Options a mounted checkout accepts after it is mounted. */
23
+ updateOptions: CheckoutRuntimeContractMember[];
24
+ /** Messages the checkout frame sends the runtime. */
25
+ messagesFromFrame: CheckoutRuntimeContractMember[];
26
+ /** Messages the runtime sends the checkout frame. */
27
+ messagesToFrame: CheckoutRuntimeContractMember[];
28
+ /** Events the runtime relays to the wrapper. */
29
+ events: CheckoutRuntimeContractMember[];
30
+ }
31
+ /**
32
+ * The version of the contract below. It is not the npm or runtime build version: it starts at
33
+ * 2.0.0 and takes a minor bump with each additive change (see .gitea/README.md, "Runtime
34
+ * compatibility"), and each released version keeps a frozen copy in ./baselines.
35
+ */
36
+ export declare const CHECKOUT_RUNTIME_CONTRACT_VERSION: string;
37
+ /**
38
+ * The first released contract version: the one a wrapper that declares no `contractVersion`
39
+ * (one built before versions existed) runs under.
40
+ */
41
+ export declare const CHECKOUT_RUNTIME_BASELINE_CONTRACT_VERSION: string;
42
+ /**
43
+ * The closed set of neutral meanings a contract member may have. Every member names what it is
44
+ * for (a payment method, an outcome, the session, the page's wording, ...), never the processor
45
+ * behind it. A new member that fits none of these needs a new neutral meaning, added here by
46
+ * review, not a processor's name.
47
+ */
48
+ export declare const CONTRACT_SEMANTICS: readonly string[];
49
+ /** The contract this runtime build accepts. */
50
+ export declare const checkoutRuntimeContract: CheckoutRuntimeContract;
@@ -1,3 +1,4 @@
1
+ import type { PaymentMethodLayoutRules } from '@flopay/shared';
1
2
  /** The events the runtime relays to the wrapper, with the payloads the 1.x checkout emitted. */
2
3
  export type CheckoutRuntimeEventName = 'complete' | 'decline' | 'error' | 'cancel' | 'instruments' | 'cardFieldsReady' | 'cardFieldsFailed';
3
4
  export interface CheckoutRuntimeEvent {
@@ -25,9 +26,25 @@ export interface CheckoutRuntimeMountOptions {
25
26
  /** Merchant wording overrides, applied over the strings the API returns. */
26
27
  strings?: Record<string, string>;
27
28
  onEvent?: (event: CheckoutRuntimeEvent) => void;
29
+ /**
30
+ * The contract version this wrapper was built against. Optional: a wrapper that omits it is
31
+ * read as the 2.0.0 baseline.
32
+ */
33
+ contractVersion?: string;
34
+ /**
35
+ * The merchant's payment method layout rules (contract 2.1.0). The runtime sends them to the
36
+ * billing API, which picks the buyer's rule, and hands the frame the layout it answers.
37
+ * Without rules, or when the API cannot answer, the frame keeps the 1.x default
38
+ * presentation. The runtime never sends or looks up a buyer country.
39
+ */
40
+ paymentMethodLayout?: PaymentMethodLayoutRules;
28
41
  }
29
- /** The options a mounted checkout accepts after it is mounted. */
30
- export type CheckoutRuntimeUpdateOptions = Partial<Pick<CheckoutRuntimeMountOptions, 'appearance' | 'strings' | 'onEvent'>>;
42
+ /**
43
+ * The options a mounted checkout accepts after it is mounted. As with `appearance` and
44
+ * `strings`, leaving `paymentMethodLayout` out (or `undefined`) keeps the current layout; new
45
+ * rules are resolved again by the API and the frame gets the new layout in the same frame.
46
+ */
47
+ export type CheckoutRuntimeUpdateOptions = Partial<Pick<CheckoutRuntimeMountOptions, 'appearance' | 'strings' | 'onEvent' | 'paymentMethodLayout'>>;
31
48
  export interface CheckoutRuntimeHandle {
32
49
  update(options: CheckoutRuntimeUpdateOptions): void;
33
50
  unmount(): void;
@@ -43,6 +60,8 @@ export interface CheckoutRuntimeTelemetryEvent {
43
60
  /** The session's card gateway, exactly as the API names it, known to the runtime or not. */
44
61
  cardGateway?: string;
45
62
  reason?: string;
63
+ /** The contract version in force for this mount: the wrapper's, or 2.0.0 when it declared none. */
64
+ contractVersion?: string;
46
65
  }
47
66
  /** The runtime's own configuration. Wrappers never supply any of it. */
48
67
  export interface CheckoutRuntimeConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/js",
3
- "version": "1.20.3",
3
+ "version": "1.20.5",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@flopay/shared": "1.20.3",
34
+ "@flopay/shared": "1.20.5",
35
35
  "@stripe/stripe-js": "^10.3.0"
36
36
  },
37
37
  "devDependencies": {