@flopay/vue 1.20.6 → 1.20.8

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,4 +1,4 @@
1
- import type { CheckoutRuntimeEvent } from '@flopay/js';
1
+ import type { CheckoutRuntimeAutomaticPayment, CheckoutRuntimeEvent } from '@flopay/js';
2
2
  import type { PaymentMethodLayoutRules } from '@flopay/shared';
3
3
  import { FloPayError } from '@flopay/shared';
4
4
  import type { PropType } from 'vue';
@@ -22,11 +22,25 @@ export interface FloPayRuntimeCheckoutProps {
22
22
  * "More payment options"; without them the checkout keeps the 1.x default layout.
23
23
  */
24
24
  paymentMethodLayout?: PaymentMethodLayoutRules;
25
+ /**
26
+ * The checkout layout, as in 1.x: `default` (the card form in view) or `buttons`. The runtime
27
+ * lays out the payment methods for it; left out, the runtime keeps the 1.x default.
28
+ */
29
+ layout?: CheckoutLayout;
30
+ /**
31
+ * Automatic or confirm saved payment, as the 1.x automatic payment button: the runtime shows
32
+ * the pay control and runs the whole saved payment when the buyer clicks it. `getSession` is
33
+ * called in this page at click time; the runtime always calls the current prop's function.
34
+ * A new `mode`, or adding or removing `getSession`, mounts the checkout again.
35
+ */
36
+ automaticPayment?: CheckoutRuntimeAutomaticPayment;
25
37
  /** The Flo-origin runtime script. */
26
38
  runtimeUrl: string;
27
39
  /** How long the runtime has to load before the `error` emit. Defaults to 10 seconds. */
28
40
  runtimeTimeoutMs?: number;
29
41
  }
42
+ /** The checkout layouts a merchant chooses from, as in 1.x. */
43
+ type CheckoutLayout = 'default' | 'buttons';
30
44
  /**
31
45
  * A card checkout that runs from the Flo-hosted runtime. The component holds no checkout
32
46
  * logic: it loads the runtime, mounts it in a container, passes its props through, relays the
@@ -64,6 +78,14 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
64
78
  type: PropType<PaymentMethodLayoutRules>;
65
79
  default: undefined;
66
80
  };
81
+ layout: {
82
+ type: PropType<CheckoutLayout>;
83
+ default: undefined;
84
+ };
85
+ automaticPayment: {
86
+ type: PropType<CheckoutRuntimeAutomaticPayment>;
87
+ default: undefined;
88
+ };
67
89
  runtimeUrl: {
68
90
  type: StringConstructor;
69
91
  required: true;
@@ -106,6 +128,14 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
106
128
  type: PropType<PaymentMethodLayoutRules>;
107
129
  default: undefined;
108
130
  };
131
+ layout: {
132
+ type: PropType<CheckoutLayout>;
133
+ default: undefined;
134
+ };
135
+ automaticPayment: {
136
+ type: PropType<CheckoutRuntimeAutomaticPayment>;
137
+ default: undefined;
138
+ };
109
139
  runtimeUrl: {
110
140
  type: StringConstructor;
111
141
  required: true;
@@ -124,5 +154,8 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
124
154
  appearance: Record<string, unknown>;
125
155
  strings: Record<string, string>;
126
156
  paymentMethodLayout: PaymentMethodLayoutRules;
157
+ layout: CheckoutLayout;
158
+ automaticPayment: CheckoutRuntimeAutomaticPayment;
127
159
  runtimeTimeoutMs: number;
128
160
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
161
+ export {};
package/dist/index.cjs CHANGED
@@ -5353,7 +5353,13 @@ function asFloPayError(caught) {
5353
5353
  cause: caught
5354
5354
  });
5355
5355
  }
5356
- var RUNTIME_CONTRACT_VERSION = "2.1.0";
5356
+ var RUNTIME_CONTRACT_VERSION = "2.2.0";
5357
+ var SAVED_PAYMENT_CONTRACT_VERSION = "2.3.0";
5358
+ function savedPaymentSetting(mode, supplier) {
5359
+ const setting = { mode };
5360
+ if (supplier) Object.defineProperty(setting, "getSession", { enumerable: true, get: supplier });
5361
+ return setting;
5362
+ }
5357
5363
  function rulesKey(rules) {
5358
5364
  return rules === void 0 ? void 0 : JSON.stringify(rules);
5359
5365
  }
@@ -5373,6 +5379,11 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5373
5379
  type: Object,
5374
5380
  default: void 0
5375
5381
  },
5382
+ layout: { type: String, default: void 0 },
5383
+ automaticPayment: {
5384
+ type: Object,
5385
+ default: void 0
5386
+ },
5376
5387
  runtimeUrl: { type: String, required: true },
5377
5388
  runtimeTimeoutMs: { type: Number, default: void 0 }
5378
5389
  },
@@ -5397,8 +5408,15 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5397
5408
  (runtime) => {
5398
5409
  if (current !== run || !container.value) return;
5399
5410
  mountedLayoutRules = rulesKey(props.paymentMethodLayout);
5411
+ const mode = props.automaticPayment?.mode;
5400
5412
  handle = runtime.mount(container.value, {
5401
- contractVersion: RUNTIME_CONTRACT_VERSION,
5413
+ contractVersion: mode ? SAVED_PAYMENT_CONTRACT_VERSION : RUNTIME_CONTRACT_VERSION,
5414
+ ...mode ? {
5415
+ automaticPayment: savedPaymentSetting(
5416
+ mode,
5417
+ props.automaticPayment?.getSession ? () => props.automaticPayment?.getSession : void 0
5418
+ )
5419
+ } : {},
5402
5420
  publishableKey: props.publishableKey,
5403
5421
  sessionId: props.sessionId,
5404
5422
  nonce: props.nonce,
@@ -5406,6 +5424,7 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5406
5424
  appearance: props.appearance,
5407
5425
  strings: props.strings,
5408
5426
  paymentMethodLayout: rulesFromKey(mountedLayoutRules),
5427
+ ...props.layout ? { layout: props.layout } : {},
5409
5428
  onEvent: (event) => emit("event", event)
5410
5429
  });
5411
5430
  },
@@ -5423,7 +5442,12 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5423
5442
  // By value, so a new object with the same session does not mount again.
5424
5443
  () => props.createSession === void 0 ? void 0 : JSON.stringify(props.createSession),
5425
5444
  () => props.runtimeUrl,
5426
- () => props.runtimeTimeoutMs
5445
+ () => props.runtimeTimeoutMs,
5446
+ // The runtime lays out its payment methods at mount, so a new layout mounts again.
5447
+ () => props.layout,
5448
+ // By value: an equal saved-payment setting in a new object does not mount again.
5449
+ () => props.automaticPayment?.mode,
5450
+ () => props.automaticPayment?.getSession !== void 0
5427
5451
  ],
5428
5452
  () => start()
5429
5453
  );
package/dist/index.mjs CHANGED
@@ -3487,7 +3487,13 @@ function asFloPayError(caught) {
3487
3487
  cause: caught
3488
3488
  });
3489
3489
  }
3490
- var RUNTIME_CONTRACT_VERSION = "2.1.0";
3490
+ var RUNTIME_CONTRACT_VERSION = "2.2.0";
3491
+ var SAVED_PAYMENT_CONTRACT_VERSION = "2.3.0";
3492
+ function savedPaymentSetting(mode, supplier) {
3493
+ const setting = { mode };
3494
+ if (supplier) Object.defineProperty(setting, "getSession", { enumerable: true, get: supplier });
3495
+ return setting;
3496
+ }
3491
3497
  function rulesKey(rules) {
3492
3498
  return rules === void 0 ? void 0 : JSON.stringify(rules);
3493
3499
  }
@@ -3507,6 +3513,11 @@ var FloPayRuntimeCheckout = defineComponent6({
3507
3513
  type: Object,
3508
3514
  default: void 0
3509
3515
  },
3516
+ layout: { type: String, default: void 0 },
3517
+ automaticPayment: {
3518
+ type: Object,
3519
+ default: void 0
3520
+ },
3510
3521
  runtimeUrl: { type: String, required: true },
3511
3522
  runtimeTimeoutMs: { type: Number, default: void 0 }
3512
3523
  },
@@ -3531,8 +3542,15 @@ var FloPayRuntimeCheckout = defineComponent6({
3531
3542
  (runtime) => {
3532
3543
  if (current !== run || !container.value) return;
3533
3544
  mountedLayoutRules = rulesKey(props.paymentMethodLayout);
3545
+ const mode = props.automaticPayment?.mode;
3534
3546
  handle = runtime.mount(container.value, {
3535
- contractVersion: RUNTIME_CONTRACT_VERSION,
3547
+ contractVersion: mode ? SAVED_PAYMENT_CONTRACT_VERSION : RUNTIME_CONTRACT_VERSION,
3548
+ ...mode ? {
3549
+ automaticPayment: savedPaymentSetting(
3550
+ mode,
3551
+ props.automaticPayment?.getSession ? () => props.automaticPayment?.getSession : void 0
3552
+ )
3553
+ } : {},
3536
3554
  publishableKey: props.publishableKey,
3537
3555
  sessionId: props.sessionId,
3538
3556
  nonce: props.nonce,
@@ -3540,6 +3558,7 @@ var FloPayRuntimeCheckout = defineComponent6({
3540
3558
  appearance: props.appearance,
3541
3559
  strings: props.strings,
3542
3560
  paymentMethodLayout: rulesFromKey(mountedLayoutRules),
3561
+ ...props.layout ? { layout: props.layout } : {},
3543
3562
  onEvent: (event) => emit("event", event)
3544
3563
  });
3545
3564
  },
@@ -3557,7 +3576,12 @@ var FloPayRuntimeCheckout = defineComponent6({
3557
3576
  // By value, so a new object with the same session does not mount again.
3558
3577
  () => props.createSession === void 0 ? void 0 : JSON.stringify(props.createSession),
3559
3578
  () => props.runtimeUrl,
3560
- () => props.runtimeTimeoutMs
3579
+ () => props.runtimeTimeoutMs,
3580
+ // The runtime lays out its payment methods at mount, so a new layout mounts again.
3581
+ () => props.layout,
3582
+ // By value: an equal saved-payment setting in a new object does not mount again.
3583
+ () => props.automaticPayment?.mode,
3584
+ () => props.automaticPayment?.getSession !== void 0
3561
3585
  ],
3562
3586
  () => start()
3563
3587
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/vue",
3
- "version": "1.20.6",
3
+ "version": "1.20.8",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -36,8 +36,8 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@flopay/js": "1.20.6",
40
- "@flopay/shared": "1.20.6",
39
+ "@flopay/js": "1.20.8",
40
+ "@flopay/shared": "1.20.8",
41
41
  "@paypal/paypal-js": "^11.3.0",
42
42
  "@stripe/stripe-js": "^10.3.0"
43
43
  },