@flopay/vue 1.20.15 → 2.0.1

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 (39) hide show
  1. package/README.md +56 -57
  2. package/dist/card-setup-entry.cjs +184 -569
  3. package/dist/card-setup-entry.d.ts +2 -2
  4. package/dist/card-setup-entry.mjs +3 -7
  5. package/dist/chunk-2VPPDVV7.mjs +218 -0
  6. package/dist/chunk-OCVTEXQA.mjs +20 -0
  7. package/dist/flopay-runtime-checkout.d.ts +11 -0
  8. package/dist/hosted-runtime-components.d.ts +587 -0
  9. package/dist/index.cjs +298 -5402
  10. package/dist/index.d.ts +3 -21
  11. package/dist/index.mjs +250 -3728
  12. package/dist/payment-method-setup-entry.cjs +194 -1852
  13. package/dist/payment-method-setup-entry.d.ts +2 -2
  14. package/dist/payment-method-setup-entry.mjs +4 -4
  15. package/dist/runtime-context.d.ts +11 -0
  16. package/package.json +3 -5
  17. package/dist/automatic-payment-button.d.ts +0 -296
  18. package/dist/buyer-identity-fallback.d.ts +0 -82
  19. package/dist/chunk-2USKULEH.mjs +0 -530
  20. package/dist/chunk-HH25IC76.mjs +0 -98
  21. package/dist/chunk-IJKGJSHH.mjs +0 -333
  22. package/dist/chunk-RAGPQWRA.mjs +0 -923
  23. package/dist/context.d.ts +0 -56
  24. package/dist/direct-paypal-button.d.ts +0 -325
  25. package/dist/flopay-card-setup.d.ts +0 -158
  26. package/dist/flopay-checkout.d.ts +0 -517
  27. package/dist/flopay-payment-method-setup-main.d.ts +0 -152
  28. package/dist/hooks.d.ts +0 -22
  29. package/dist/hosted-setup.d.ts +0 -116
  30. package/dist/payment-method-setup-paypal-D6FEQQJY.mjs +0 -151
  31. package/dist/payment-method-setup-paypal.d.ts +0 -108
  32. package/dist/processing-overlay.d.ts +0 -82
  33. package/dist/provider.d.ts +0 -76
  34. package/dist/saved-payment.d.ts +0 -44
  35. package/dist/split-card-form.d.ts +0 -777
  36. package/dist/stripe-elements-SI2PI6EO.mjs +0 -6
  37. package/dist/stripe-elements.d.ts +0 -280
  38. package/dist/stripe-paypal-continuation.d.ts +0 -28
  39. package/dist/vault-card-fields.d.ts +0 -129
@@ -1,2 +1,2 @@
1
- export type { FloPayCardSetupCancelEvent, FloPayCardSetupCompleteEvent, FloPayCardSetupDeclineEvent, FloPayCardSetupProps, } from './flopay-card-setup.js';
2
- export { FloPayCardSetup, FloPayCardSetupError } from './flopay-card-setup.js';
1
+ export type { FloPayRuntimeCardSetupProps as FloPayCardSetupProps } from './flopay-runtime-card-setup.js';
2
+ export { FloPayRuntimeCardSetup as FloPayCardSetup } from './flopay-runtime-card-setup.js';
@@ -1,10 +1,6 @@
1
1
  import {
2
- FloPayCardSetup
3
- } from "./chunk-HH25IC76.mjs";
4
- import {
5
- FloPayCardSetupError
6
- } from "./chunk-2USKULEH.mjs";
2
+ FloPayRuntimeCardSetup
3
+ } from "./chunk-2VPPDVV7.mjs";
7
4
  export {
8
- FloPayCardSetup,
9
- FloPayCardSetupError
5
+ FloPayRuntimeCardSetup as FloPayCardSetup
10
6
  };
@@ -0,0 +1,218 @@
1
+ // src/flopay-runtime-card-setup.ts
2
+ import { loadCheckoutRuntime } from "@flopay/js";
3
+ import { FloPayError } from "@flopay/shared";
4
+ import {
5
+ defineComponent,
6
+ getCurrentInstance,
7
+ h,
8
+ onBeforeUnmount,
9
+ onMounted,
10
+ ref,
11
+ watch
12
+ } from "vue";
13
+ var SETUP_CONTRACT_VERSION = "2.4.0";
14
+ function isRecord(value) {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+ var ERROR_TYPES = /* @__PURE__ */ new Set([
18
+ "validation_error",
19
+ "api_error",
20
+ "authentication_error",
21
+ "rate_limit_error",
22
+ "network_error"
23
+ ]);
24
+ function setupError(message, type, retryable, options = {}) {
25
+ return Object.assign(new FloPayError(message, type, options), { retryable });
26
+ }
27
+ function errorFromPayload(payload) {
28
+ const record = isRecord(payload) ? payload : {};
29
+ const type = typeof record.type === "string" && ERROR_TYPES.has(record.type) ? record.type : "";
30
+ return setupError(
31
+ typeof record.message === "string" ? record.message : "The setup failed.",
32
+ type || "api_error",
33
+ record.retryable === true,
34
+ {
35
+ ...typeof record.code === "string" ? { code: record.code } : {},
36
+ ...typeof record.param === "string" ? { param: record.param } : {},
37
+ ...typeof record.statusCode === "number" ? { statusCode: record.statusCode } : {}
38
+ }
39
+ );
40
+ }
41
+ function loadError(caught) {
42
+ if (caught instanceof FloPayError) {
43
+ return setupError(caught.message, caught.type, true, {
44
+ code: caught.code ?? "runtime_load_failed",
45
+ cause: caught
46
+ });
47
+ }
48
+ return setupError("The checkout runtime failed to load.", "network_error", true, {
49
+ code: "runtime_load_failed",
50
+ cause: caught
51
+ });
52
+ }
53
+ function setupConfig(props) {
54
+ return {
55
+ ...props.theme === void 0 ? {} : { theme: props.theme },
56
+ ...props.appearance === void 0 ? {} : { appearance: props.appearance },
57
+ ...props.buttonsStyles === void 0 ? {} : { buttonsStyles: props.buttonsStyles },
58
+ ...props.containerStyle === void 0 ? {} : { containerStyle: props.containerStyle },
59
+ ...props.strings === void 0 ? {} : { strings: props.strings }
60
+ };
61
+ }
62
+ var setupProps = {
63
+ sessionId: { type: String, required: true },
64
+ nonce: { type: String, required: true },
65
+ theme: {
66
+ type: [String, Object],
67
+ default: void 0
68
+ },
69
+ appearance: { type: Object, default: void 0 },
70
+ buttonsStyles: { type: Object, default: void 0 },
71
+ containerStyle: {
72
+ type: Object,
73
+ default: void 0
74
+ },
75
+ strings: { type: Object, default: void 0 },
76
+ runtimeUrl: { type: String, required: true },
77
+ runtimeTimeoutMs: { type: Number, default: void 0 }
78
+ };
79
+ var setupEmits = {
80
+ ready: () => true,
81
+ validation: (_message) => true,
82
+ complete: (_event) => true,
83
+ decline: (_event) => true,
84
+ cancel: (_event) => true,
85
+ error: (_error) => true
86
+ };
87
+ var LISTENERS = {
88
+ ready: "onReady",
89
+ validation: "onValidation",
90
+ complete: "onComplete",
91
+ decline: "onDecline",
92
+ cancel: "onCancel",
93
+ error: "onError"
94
+ };
95
+ function setupRuntimeSetup(kind, props, emit) {
96
+ const instance = getCurrentInstance();
97
+ const container = ref(null);
98
+ let handle = null;
99
+ let generation = 0;
100
+ const deliver = (name, argument) => {
101
+ try {
102
+ if (instance?.isUnmounted) {
103
+ const listener = instance.vnode.props?.[LISTENERS[name]];
104
+ if (typeof listener === "function") listener(argument);
105
+ return;
106
+ }
107
+ emit(
108
+ name,
109
+ ...argument === void 0 ? [] : [argument]
110
+ );
111
+ } catch {
112
+ }
113
+ };
114
+ const onEvent = (event) => {
115
+ const payload = event.payload;
116
+ switch (event.name) {
117
+ case "setupReady":
118
+ deliver("ready");
119
+ return;
120
+ case "setupValidation":
121
+ deliver(
122
+ "validation",
123
+ isRecord(payload) && typeof payload.message === "string" ? payload.message : null
124
+ );
125
+ return;
126
+ case "complete":
127
+ case "decline":
128
+ case "cancel":
129
+ deliver(event.name, payload);
130
+ return;
131
+ case "error":
132
+ deliver("error", errorFromPayload(payload));
133
+ return;
134
+ default:
135
+ return;
136
+ }
137
+ };
138
+ const stop = () => {
139
+ generation += 1;
140
+ const current = handle;
141
+ handle = null;
142
+ current?.unmount();
143
+ };
144
+ const start = () => {
145
+ const element = container.value;
146
+ if (!element) return;
147
+ generation += 1;
148
+ const current = generation;
149
+ loadCheckoutRuntime({
150
+ runtimeUrl: props.runtimeUrl,
151
+ ...props.runtimeTimeoutMs === void 0 ? {} : { timeoutMs: props.runtimeTimeoutMs }
152
+ }).then(
153
+ (runtime) => {
154
+ if (current !== generation) return;
155
+ if (typeof runtime.mountSetup !== "function") {
156
+ deliver(
157
+ "error",
158
+ setupError(
159
+ "The checkout runtime on this page is too old to run setup.",
160
+ "api_error",
161
+ false,
162
+ { code: "runtime_setup_unsupported" }
163
+ )
164
+ );
165
+ return;
166
+ }
167
+ handle = runtime.mountSetup(element, {
168
+ setup: kind,
169
+ sessionId: props.sessionId,
170
+ nonce: props.nonce,
171
+ contractVersion: SETUP_CONTRACT_VERSION,
172
+ ...setupConfig(props),
173
+ onEvent
174
+ });
175
+ },
176
+ (caught) => {
177
+ if (current === generation) deliver("error", loadError(caught));
178
+ }
179
+ );
180
+ };
181
+ onMounted(start);
182
+ watch(
183
+ () => [props.sessionId, props.nonce, props.runtimeUrl, props.runtimeTimeoutMs],
184
+ () => {
185
+ stop();
186
+ start();
187
+ }
188
+ );
189
+ watch(
190
+ () => JSON.stringify(setupConfig(props)),
191
+ () => {
192
+ handle?.update({
193
+ theme: props.theme,
194
+ appearance: props.appearance,
195
+ buttonsStyles: props.buttonsStyles,
196
+ containerStyle: props.containerStyle,
197
+ strings: props.strings
198
+ });
199
+ }
200
+ );
201
+ onBeforeUnmount(stop);
202
+ return () => h("div", { ref: container });
203
+ }
204
+ var FloPayRuntimeCardSetup = defineComponent({
205
+ name: "FloPayRuntimeCardSetup",
206
+ props: setupProps,
207
+ emits: setupEmits,
208
+ setup(props, { emit }) {
209
+ return setupRuntimeSetup("card", props, emit);
210
+ }
211
+ });
212
+
213
+ export {
214
+ setupProps,
215
+ setupEmits,
216
+ setupRuntimeSetup,
217
+ FloPayRuntimeCardSetup
218
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ setupEmits,
3
+ setupProps,
4
+ setupRuntimeSetup
5
+ } from "./chunk-2VPPDVV7.mjs";
6
+
7
+ // src/flopay-runtime-payment-method-setup.ts
8
+ import { defineComponent } from "vue";
9
+ var FloPayRuntimePaymentMethodSetup = defineComponent({
10
+ name: "FloPayRuntimePaymentMethodSetup",
11
+ props: setupProps,
12
+ emits: setupEmits,
13
+ setup(props, { emit }) {
14
+ return setupRuntimeSetup("payment_method", props, emit);
15
+ }
16
+ });
17
+
18
+ export {
19
+ FloPayRuntimePaymentMethodSetup
20
+ };
@@ -38,6 +38,8 @@ export interface FloPayRuntimeCheckoutProps {
38
38
  runtimeUrl: string;
39
39
  /** How long the runtime has to load before the `error` emit. Defaults to 10 seconds. */
40
40
  runtimeTimeoutMs?: number;
41
+ /** Further mount options, passed to the runtime as given (by value). A change mounts again. */
42
+ extraMountOptions?: Record<string, unknown>;
41
43
  }
42
44
  /** The checkout layouts a merchant chooses from, as in 1.x. */
43
45
  type CheckoutLayout = 'default' | 'buttons';
@@ -94,6 +96,10 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
94
96
  type: NumberConstructor;
95
97
  default: undefined;
96
98
  };
99
+ extraMountOptions: {
100
+ type: PropType<Record<string, unknown>>;
101
+ default: undefined;
102
+ };
97
103
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
98
104
  [key: string]: any;
99
105
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -144,6 +150,10 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
144
150
  type: NumberConstructor;
145
151
  default: undefined;
146
152
  };
153
+ extraMountOptions: {
154
+ type: PropType<Record<string, unknown>>;
155
+ default: undefined;
156
+ };
147
157
  }>> & Readonly<{
148
158
  onError?: ((_error: FloPayError) => any) | undefined;
149
159
  onEvent?: ((_event: CheckoutRuntimeEvent) => any) | undefined;
@@ -157,5 +167,6 @@ export declare const FloPayRuntimeCheckout: import("vue").DefineComponent<import
157
167
  layout: CheckoutLayout;
158
168
  automaticPayment: CheckoutRuntimeAutomaticPayment;
159
169
  runtimeTimeoutMs: number;
170
+ extraMountOptions: Record<string, unknown>;
160
171
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
161
172
  export {};