@flopay/vue 1.20.7 → 1.20.9

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';
@@ -27,6 +27,13 @@ export interface FloPayRuntimeCheckoutProps {
27
27
  * lays out the payment methods for it; left out, the runtime keeps the 1.x default.
28
28
  */
29
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;
30
37
  /** The Flo-origin runtime script. */
31
38
  runtimeUrl: string;
32
39
  /** How long the runtime has to load before the `error` emit. Defaults to 10 seconds. */
@@ -75,6 +82,10 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
75
82
  type: PropType<CheckoutLayout>;
76
83
  default: undefined;
77
84
  };
85
+ automaticPayment: {
86
+ type: PropType<CheckoutRuntimeAutomaticPayment>;
87
+ default: undefined;
88
+ };
78
89
  runtimeUrl: {
79
90
  type: StringConstructor;
80
91
  required: true;
@@ -121,6 +132,10 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
121
132
  type: PropType<CheckoutLayout>;
122
133
  default: undefined;
123
134
  };
135
+ automaticPayment: {
136
+ type: PropType<CheckoutRuntimeAutomaticPayment>;
137
+ default: undefined;
138
+ };
124
139
  runtimeUrl: {
125
140
  type: StringConstructor;
126
141
  required: true;
@@ -140,6 +155,7 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
140
155
  strings: Record<string, string>;
141
156
  paymentMethodLayout: PaymentMethodLayoutRules;
142
157
  layout: CheckoutLayout;
158
+ automaticPayment: CheckoutRuntimeAutomaticPayment;
143
159
  runtimeTimeoutMs: number;
144
160
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
145
161
  export {};
package/dist/index.cjs CHANGED
@@ -5354,6 +5354,12 @@ function asFloPayError(caught) {
5354
5354
  });
5355
5355
  }
5356
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
  }
@@ -5374,6 +5380,10 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5374
5380
  default: void 0
5375
5381
  },
5376
5382
  layout: { type: String, default: void 0 },
5383
+ automaticPayment: {
5384
+ type: Object,
5385
+ default: void 0
5386
+ },
5377
5387
  runtimeUrl: { type: String, required: true },
5378
5388
  runtimeTimeoutMs: { type: Number, default: void 0 }
5379
5389
  },
@@ -5398,8 +5408,15 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5398
5408
  (runtime) => {
5399
5409
  if (current !== run || !container.value) return;
5400
5410
  mountedLayoutRules = rulesKey(props.paymentMethodLayout);
5411
+ const mode = props.automaticPayment?.mode;
5401
5412
  handle = runtime.mount(container.value, {
5402
- 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
+ } : {},
5403
5420
  publishableKey: props.publishableKey,
5404
5421
  sessionId: props.sessionId,
5405
5422
  nonce: props.nonce,
@@ -5427,7 +5444,10 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
5427
5444
  () => props.runtimeUrl,
5428
5445
  () => props.runtimeTimeoutMs,
5429
5446
  // The runtime lays out its payment methods at mount, so a new layout mounts again.
5430
- () => props.layout
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
5431
5451
  ],
5432
5452
  () => start()
5433
5453
  );
package/dist/index.mjs CHANGED
@@ -3488,6 +3488,12 @@ function asFloPayError(caught) {
3488
3488
  });
3489
3489
  }
3490
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
  }
@@ -3508,6 +3514,10 @@ var FloPayRuntimeCheckout = defineComponent6({
3508
3514
  default: void 0
3509
3515
  },
3510
3516
  layout: { type: String, default: void 0 },
3517
+ automaticPayment: {
3518
+ type: Object,
3519
+ default: void 0
3520
+ },
3511
3521
  runtimeUrl: { type: String, required: true },
3512
3522
  runtimeTimeoutMs: { type: Number, default: void 0 }
3513
3523
  },
@@ -3532,8 +3542,15 @@ var FloPayRuntimeCheckout = defineComponent6({
3532
3542
  (runtime) => {
3533
3543
  if (current !== run || !container.value) return;
3534
3544
  mountedLayoutRules = rulesKey(props.paymentMethodLayout);
3545
+ const mode = props.automaticPayment?.mode;
3535
3546
  handle = runtime.mount(container.value, {
3536
- 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
+ } : {},
3537
3554
  publishableKey: props.publishableKey,
3538
3555
  sessionId: props.sessionId,
3539
3556
  nonce: props.nonce,
@@ -3561,7 +3578,10 @@ var FloPayRuntimeCheckout = defineComponent6({
3561
3578
  () => props.runtimeUrl,
3562
3579
  () => props.runtimeTimeoutMs,
3563
3580
  // The runtime lays out its payment methods at mount, so a new layout mounts again.
3564
- () => props.layout
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
3565
3585
  ],
3566
3586
  () => start()
3567
3587
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/vue",
3
- "version": "1.20.7",
3
+ "version": "1.20.9",
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.7",
40
- "@flopay/shared": "1.20.7",
39
+ "@flopay/js": "1.20.9",
40
+ "@flopay/shared": "1.20.9",
41
41
  "@paypal/paypal-js": "^11.3.0",
42
42
  "@stripe/stripe-js": "^10.3.0"
43
43
  },