@getopenpay/openpay-js-react 0.1.6-alpha.7c15e03 → 0.1.7
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1053 -1585
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { z as
|
|
4
|
-
|
|
1
|
+
import rn, { createContext as on, useContext as sn, useRef as re, useCallback as Z, useEffect as q, useState as w, useMemo as Q } from "react";
|
|
2
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
3
|
+
import { z as n } from "zod";
|
|
4
|
+
import { v4 as st } from "uuid";
|
|
5
|
+
import { connectToChild as it } from "penpal";
|
|
6
|
+
import ae from "chalk";
|
|
7
|
+
const at = on({
|
|
5
8
|
formId: "",
|
|
6
9
|
formHeight: "",
|
|
7
10
|
referer: void 0,
|
|
@@ -9,42 +12,42 @@ const Nt = $n({
|
|
|
9
12
|
registerIframe: () => {
|
|
10
13
|
},
|
|
11
14
|
baseUrl: ""
|
|
12
|
-
}),
|
|
13
|
-
const e =
|
|
15
|
+
}), an = () => {
|
|
16
|
+
const e = sn(at);
|
|
14
17
|
if (!e)
|
|
15
18
|
throw new Error("useOpenPayElements must be used within an OpenPayElementsProvider");
|
|
16
19
|
return e;
|
|
17
|
-
},
|
|
18
|
-
type:
|
|
19
|
-
loc:
|
|
20
|
-
msg:
|
|
21
|
-
url:
|
|
22
|
-
}),
|
|
23
|
-
code:
|
|
24
|
-
message:
|
|
25
|
-
path:
|
|
26
|
-
}),
|
|
20
|
+
}, cn = "https://cde.getopenpay.com", ln = n.object({
|
|
21
|
+
type: n.string(),
|
|
22
|
+
loc: n.array(n.string()),
|
|
23
|
+
msg: n.string(),
|
|
24
|
+
url: n.string()
|
|
25
|
+
}), un = n.array(ln), dn = n.object({
|
|
26
|
+
code: n.string(),
|
|
27
|
+
message: n.string(),
|
|
28
|
+
path: n.array(n.string())
|
|
29
|
+
}), mn = n.array(dn), fn = {
|
|
27
30
|
"failed to fetch": "Connection error: please double check if you are connected to the internet, then try again"
|
|
28
|
-
},
|
|
31
|
+
}, je = (e) => {
|
|
29
32
|
const t = e.toLowerCase().trim();
|
|
30
|
-
return
|
|
31
|
-
},
|
|
33
|
+
return fn[t] ?? e;
|
|
34
|
+
}, pn = (e) => {
|
|
32
35
|
try {
|
|
33
36
|
return typeof JSON.parse(e) == "object";
|
|
34
37
|
} catch {
|
|
35
38
|
return !1;
|
|
36
39
|
}
|
|
37
|
-
},
|
|
38
|
-
${e.map((
|
|
39
|
-
`)}`,
|
|
40
|
-
${e.map((
|
|
41
|
-
`)}`,
|
|
40
|
+
}, yn = (e) => e.length === 1 ? je(e[0].msg) : `Please fix the following errors:
|
|
41
|
+
${e.map((r) => `• ${je(r.msg)}`).join(`
|
|
42
|
+
`)}`, _n = (e) => `Encountered the following errors:
|
|
43
|
+
${e.map((r) => `- ${r.path.join("/")}: ${r.message}`).join(`
|
|
44
|
+
`)}`, pe = (e) => {
|
|
42
45
|
if (e instanceof Error)
|
|
43
|
-
if (
|
|
46
|
+
if (pn(e.message)) {
|
|
44
47
|
const t = JSON.parse(e.message);
|
|
45
|
-
return
|
|
48
|
+
return un.safeParse(t).success ? yn(t) : mn.safeParse(t).success ? _n(t) : e.message;
|
|
46
49
|
} else
|
|
47
|
-
return
|
|
50
|
+
return je(e.message);
|
|
48
51
|
if (typeof e == "object")
|
|
49
52
|
try {
|
|
50
53
|
return JSON.stringify(e);
|
|
@@ -53,42 +56,42 @@ ${e.map((n) => `- ${n.path.join("/")}: ${n.message}`).join(`
|
|
|
53
56
|
}
|
|
54
57
|
else
|
|
55
58
|
return e + "";
|
|
56
|
-
},
|
|
59
|
+
}, te = (e, t) => (...r) => {
|
|
57
60
|
try {
|
|
58
|
-
return t(...
|
|
61
|
+
return t(...r);
|
|
59
62
|
} catch {
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
|
-
},
|
|
63
|
-
var
|
|
64
|
-
const
|
|
65
|
-
var
|
|
66
|
-
const
|
|
67
|
-
var
|
|
68
|
-
const
|
|
69
|
-
provider:
|
|
70
|
-
processor_name:
|
|
71
|
-
metadata:
|
|
72
|
-
}),
|
|
73
|
-
id:
|
|
65
|
+
}, O = n.string().trim().min(1, { message: "Cannot be blank" }), v = n.string().trim().optional(), de = (e) => n.nullable(e.optional());
|
|
66
|
+
var C = /* @__PURE__ */ ((e) => (e.FIRST_NAME = "firstName", e.LAST_NAME = "lastName", e.EMAIL = "email", e.ZIP_CODE = "zipCode", e.CITY = "city", e.STATE = "state", e.COUNTRY = "country", e.ADDRESS = "address", e.PHONE = "phone", e.PROMOTION_CODE = "promotionCode", e))(C || {});
|
|
67
|
+
const ct = n.nativeEnum(C);
|
|
68
|
+
var lt = /* @__PURE__ */ ((e) => (e.CARD_NUMBER = "cardNumber", e.CARD_EXPIRY = "cardExpiry", e.CARD_CVC = "cardCvc", e))(lt || {});
|
|
69
|
+
const ut = n.nativeEnum(lt), dt = n.union([ct, ut]);
|
|
70
|
+
var mt = /* @__PURE__ */ ((e) => (e.CARD = "card", e.CARD_NUMBER = "card-number", e.CARD_EXPIRY = "card-expiry", e.CARD_CVC = "card-cvc", e))(mt || {});
|
|
71
|
+
const gn = n.nativeEnum(mt), ye = n.object({
|
|
72
|
+
provider: n.string(),
|
|
73
|
+
processor_name: de(n.string()),
|
|
74
|
+
metadata: de(n.record(n.string(), n.any()))
|
|
75
|
+
}), hn = n.object({
|
|
76
|
+
id: n.string()
|
|
74
77
|
});
|
|
75
|
-
|
|
76
|
-
cardNumber:
|
|
77
|
-
expiry:
|
|
78
|
-
cvc:
|
|
78
|
+
n.object({
|
|
79
|
+
cardNumber: v,
|
|
80
|
+
expiry: v,
|
|
81
|
+
cvc: v
|
|
79
82
|
});
|
|
80
|
-
|
|
81
|
-
backgroundColor:
|
|
82
|
-
color:
|
|
83
|
-
fontFamily:
|
|
84
|
-
fontSize:
|
|
85
|
-
fontWeight:
|
|
86
|
-
margin:
|
|
87
|
-
padding:
|
|
88
|
-
letterSpacing:
|
|
89
|
-
lineHeight:
|
|
83
|
+
n.object({
|
|
84
|
+
backgroundColor: v,
|
|
85
|
+
color: v,
|
|
86
|
+
fontFamily: v,
|
|
87
|
+
fontSize: v,
|
|
88
|
+
fontWeight: v,
|
|
89
|
+
margin: v,
|
|
90
|
+
padding: v,
|
|
91
|
+
letterSpacing: v,
|
|
92
|
+
lineHeight: v
|
|
90
93
|
});
|
|
91
|
-
const
|
|
94
|
+
const f = n.enum([
|
|
92
95
|
// Element -> Form
|
|
93
96
|
"LAYOUT",
|
|
94
97
|
"LOADED",
|
|
@@ -109,163 +112,163 @@ const h = o.enum([
|
|
|
109
112
|
"TOKENIZE",
|
|
110
113
|
"CHECKOUT",
|
|
111
114
|
"START_PAYMENT_FLOW"
|
|
112
|
-
]),
|
|
113
|
-
type:
|
|
114
|
-
elementType:
|
|
115
|
-
errors:
|
|
116
|
-
}),
|
|
117
|
-
type:
|
|
118
|
-
message:
|
|
119
|
-
headers:
|
|
120
|
-
}),
|
|
121
|
-
type:
|
|
122
|
-
elementType:
|
|
123
|
-
errors:
|
|
124
|
-
}),
|
|
125
|
-
type:
|
|
126
|
-
height:
|
|
127
|
-
}),
|
|
128
|
-
type:
|
|
129
|
-
sessionId:
|
|
130
|
-
totalAmountAtoms:
|
|
131
|
-
currency:
|
|
132
|
-
checkoutPaymentMethods:
|
|
133
|
-
}),
|
|
134
|
-
type:
|
|
135
|
-
nextActionMetadata:
|
|
136
|
-
paymentFlowMetadata:
|
|
137
|
-
startPFMetadata:
|
|
138
|
-
}),
|
|
139
|
-
type:
|
|
140
|
-
paymentMethodId:
|
|
141
|
-
}),
|
|
142
|
-
firstName:
|
|
143
|
-
lastName:
|
|
144
|
-
email:
|
|
145
|
-
zipCode:
|
|
146
|
-
country:
|
|
147
|
-
promotionCode:
|
|
148
|
-
}),
|
|
149
|
-
email:
|
|
150
|
-
zipCode:
|
|
151
|
-
country:
|
|
152
|
-
promotionCode:
|
|
153
|
-
}),
|
|
154
|
-
type:
|
|
155
|
-
sessionId:
|
|
156
|
-
checkoutPaymentMethod:
|
|
157
|
-
paymentFlowMetadata:
|
|
158
|
-
doNotUseLegacyCCFlow:
|
|
159
|
-
existingCCPMId:
|
|
160
|
-
}).extend(
|
|
161
|
-
type:
|
|
162
|
-
isReadyForCheckout:
|
|
163
|
-
}),
|
|
164
|
-
type:
|
|
165
|
-
invoiceUrls:
|
|
166
|
-
subscriptionIds:
|
|
167
|
-
customerId:
|
|
168
|
-
}),
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
]),
|
|
181
|
-
payload:
|
|
182
|
-
nonce:
|
|
183
|
-
formId:
|
|
184
|
-
elementId:
|
|
115
|
+
]), wn = f.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), En = n.object({ type: wn }), Cn = f.extract(["BLUR", "FOCUS", "CHANGE"]), bn = n.object({
|
|
116
|
+
type: Cn,
|
|
117
|
+
elementType: ut,
|
|
118
|
+
errors: n.array(n.string()).optional()
|
|
119
|
+
}), Sn = f.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), Pn = n.object({
|
|
120
|
+
type: Sn,
|
|
121
|
+
message: O,
|
|
122
|
+
headers: n.record(n.string(), n.string()).optional()
|
|
123
|
+
}), vn = f.extract(["VALIDATION_ERROR"]), On = n.object({
|
|
124
|
+
type: vn,
|
|
125
|
+
elementType: dt,
|
|
126
|
+
errors: n.array(n.string())
|
|
127
|
+
}), Rn = n.object({
|
|
128
|
+
type: n.literal(f.enum.LAYOUT),
|
|
129
|
+
height: O
|
|
130
|
+
}), kn = n.object({
|
|
131
|
+
type: n.literal(f.enum.LOADED),
|
|
132
|
+
sessionId: O,
|
|
133
|
+
totalAmountAtoms: n.number(),
|
|
134
|
+
currency: v,
|
|
135
|
+
checkoutPaymentMethods: n.array(ye)
|
|
136
|
+
}), Tn = n.object({
|
|
137
|
+
type: n.literal(f.enum.PAYMENT_FLOW_STARTED),
|
|
138
|
+
nextActionMetadata: n.record(n.string(), n.any()),
|
|
139
|
+
paymentFlowMetadata: n.any().optional(),
|
|
140
|
+
startPFMetadata: n.optional(n.record(n.string(), n.any()))
|
|
141
|
+
}), An = n.object({
|
|
142
|
+
type: n.literal(f.enum.SETUP_PAYMENT_METHOD_SUCCESS),
|
|
143
|
+
paymentMethodId: n.string()
|
|
144
|
+
}), oe = n.object({
|
|
145
|
+
firstName: O,
|
|
146
|
+
lastName: O,
|
|
147
|
+
email: O,
|
|
148
|
+
zipCode: O,
|
|
149
|
+
country: O,
|
|
150
|
+
promotionCode: v
|
|
151
|
+
}), In = n.object({
|
|
152
|
+
email: O,
|
|
153
|
+
zipCode: O,
|
|
154
|
+
country: O,
|
|
155
|
+
promotionCode: v
|
|
156
|
+
}), jn = f.extract(["TOKENIZE", "CHECKOUT", "START_PAYMENT_FLOW"]), ft = n.object({
|
|
157
|
+
type: jn,
|
|
158
|
+
sessionId: O,
|
|
159
|
+
checkoutPaymentMethod: ye,
|
|
160
|
+
paymentFlowMetadata: n.any().optional(),
|
|
161
|
+
doNotUseLegacyCCFlow: n.boolean().optional(),
|
|
162
|
+
existingCCPMId: v
|
|
163
|
+
}).extend(oe.shape), Mn = n.object({
|
|
164
|
+
type: n.literal(f.enum.TOKENIZE_SUCCESS),
|
|
165
|
+
isReadyForCheckout: n.boolean()
|
|
166
|
+
}), Fn = n.object({
|
|
167
|
+
type: n.literal(f.enum.CHECKOUT_SUCCESS),
|
|
168
|
+
invoiceUrls: n.array(n.string()),
|
|
169
|
+
subscriptionIds: n.array(n.string()),
|
|
170
|
+
customerId: n.string()
|
|
171
|
+
}), Dn = n.discriminatedUnion("type", [
|
|
172
|
+
En,
|
|
173
|
+
bn,
|
|
174
|
+
Pn,
|
|
175
|
+
On,
|
|
176
|
+
Rn,
|
|
177
|
+
kn,
|
|
178
|
+
ft,
|
|
179
|
+
Mn,
|
|
180
|
+
Fn,
|
|
181
|
+
Tn,
|
|
182
|
+
An
|
|
183
|
+
]), Nn = n.object({
|
|
184
|
+
payload: Dn,
|
|
185
|
+
nonce: O,
|
|
186
|
+
formId: O,
|
|
187
|
+
elementId: O
|
|
185
188
|
});
|
|
186
|
-
|
|
187
|
-
amountAtom:
|
|
188
|
-
currency:
|
|
189
|
+
n.object({
|
|
190
|
+
amountAtom: n.number(),
|
|
191
|
+
currency: O
|
|
189
192
|
});
|
|
190
|
-
|
|
191
|
-
secure_token:
|
|
192
|
-
promotion_code:
|
|
193
|
+
n.object({
|
|
194
|
+
secure_token: n.string(),
|
|
195
|
+
promotion_code: n.string().optional()
|
|
193
196
|
});
|
|
194
|
-
|
|
195
|
-
secure_token:
|
|
196
|
-
existing_cc_pm_id:
|
|
197
|
+
n.object({
|
|
198
|
+
secure_token: n.string(),
|
|
199
|
+
existing_cc_pm_id: de(n.string())
|
|
197
200
|
});
|
|
198
|
-
const
|
|
199
|
-
payment_methods:
|
|
200
|
-
}),
|
|
201
|
-
elementType:
|
|
202
|
-
errors:
|
|
201
|
+
const xn = n.object({
|
|
202
|
+
payment_methods: n.array(hn)
|
|
203
|
+
}), Ln = n.object({
|
|
204
|
+
elementType: n.string(),
|
|
205
|
+
errors: n.array(n.string())
|
|
203
206
|
});
|
|
204
|
-
|
|
205
|
-
session_id:
|
|
207
|
+
n.object({
|
|
208
|
+
session_id: n.string()
|
|
206
209
|
});
|
|
207
|
-
const
|
|
208
|
-
success:
|
|
209
|
-
error_type:
|
|
210
|
-
errors:
|
|
211
|
-
}),
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
const $n = n.object({
|
|
211
|
+
success: n.literal(!1),
|
|
212
|
+
error_type: n.literal("validation_error"),
|
|
213
|
+
errors: n.array(Ln)
|
|
214
|
+
}), Un = n.discriminatedUnion("success", [
|
|
215
|
+
n.object({ success: n.literal(!0) }),
|
|
216
|
+
$n
|
|
214
217
|
]);
|
|
215
|
-
|
|
216
|
-
session_id:
|
|
217
|
-
checkout_payment_method:
|
|
218
|
-
non_cde_form_fields:
|
|
219
|
-
do_not_use_legacy_cc_flow:
|
|
220
|
-
existing_cc_pm_id:
|
|
218
|
+
n.object({
|
|
219
|
+
session_id: n.string(),
|
|
220
|
+
checkout_payment_method: ye,
|
|
221
|
+
non_cde_form_fields: oe,
|
|
222
|
+
do_not_use_legacy_cc_flow: n.boolean().optional(),
|
|
223
|
+
existing_cc_pm_id: de(n.string())
|
|
221
224
|
});
|
|
222
|
-
|
|
223
|
-
session_id:
|
|
224
|
-
checkout_payment_method:
|
|
225
|
-
non_cde_form_fields:
|
|
225
|
+
n.object({
|
|
226
|
+
session_id: n.string(),
|
|
227
|
+
checkout_payment_method: ye,
|
|
228
|
+
non_cde_form_fields: oe
|
|
226
229
|
});
|
|
227
|
-
var
|
|
228
|
-
const
|
|
229
|
-
status:
|
|
230
|
+
var me = /* @__PURE__ */ ((e) => (e.SUCCESS = "success", e.FAILURE = "failure", e.CANCELLED = "cancelled", e))(me || {});
|
|
231
|
+
const qn = n.object({
|
|
232
|
+
status: n.enum([
|
|
230
233
|
"success",
|
|
231
234
|
"failure",
|
|
232
235
|
"cancelled"
|
|
233
236
|
/* CANCELLED */
|
|
234
237
|
])
|
|
235
|
-
}),
|
|
236
|
-
type:
|
|
237
|
-
redirect_url:
|
|
238
|
-
initial_intent_id:
|
|
239
|
-
consent_id:
|
|
240
|
-
}),
|
|
238
|
+
}), zn = n.object({
|
|
239
|
+
type: n.string(),
|
|
240
|
+
redirect_url: n.string(),
|
|
241
|
+
initial_intent_id: n.string(),
|
|
242
|
+
consent_id: n.string()
|
|
243
|
+
}), pt = (e) => {
|
|
241
244
|
const t = {};
|
|
242
|
-
return Object.entries(e).forEach(([
|
|
245
|
+
return Object.entries(e).forEach(([r, o]) => {
|
|
243
246
|
try {
|
|
244
|
-
const s =
|
|
245
|
-
Array.isArray(
|
|
247
|
+
const s = ct.parse(r);
|
|
248
|
+
Array.isArray(o) ? t[s] = o : Array.isArray(o._errors) && (t[s] = o._errors);
|
|
246
249
|
} catch {
|
|
247
250
|
return;
|
|
248
251
|
}
|
|
249
252
|
}), t;
|
|
250
|
-
},
|
|
251
|
-
stripe_pk:
|
|
252
|
-
client_secret:
|
|
253
|
-
stripe_pm_id:
|
|
254
|
-
}),
|
|
255
|
-
type:
|
|
256
|
-
client_secret:
|
|
257
|
-
stripe_pk:
|
|
258
|
-
}),
|
|
253
|
+
}, yt = n.object({
|
|
254
|
+
stripe_pk: n.string(),
|
|
255
|
+
client_secret: n.string(),
|
|
256
|
+
stripe_pm_id: n.string()
|
|
257
|
+
}), Hn = n.object({
|
|
258
|
+
type: n.string(),
|
|
259
|
+
client_secret: n.string(),
|
|
260
|
+
stripe_pk: n.string()
|
|
261
|
+
}), Vn = {
|
|
259
262
|
usd: "usd",
|
|
260
263
|
brl: "brl"
|
|
261
|
-
},
|
|
262
|
-
for (let
|
|
263
|
-
|
|
264
|
-
if (!
|
|
264
|
+
}, _e = async (e) => {
|
|
265
|
+
for (let r = 0; r < 10; r++)
|
|
266
|
+
Be() || await _t(500);
|
|
267
|
+
if (!Be())
|
|
265
268
|
throw new Error("Stripe JS not found.");
|
|
266
269
|
return new Stripe(e);
|
|
267
|
-
},
|
|
268
|
-
const i = await
|
|
270
|
+
}, Kn = async (e, t, r, o, s) => {
|
|
271
|
+
const i = await _e(e), a = Vn[r.toLowerCase().trim()];
|
|
269
272
|
return i.paymentRequest({
|
|
270
273
|
// TODO: replace this with stripe account country as soon as we support it
|
|
271
274
|
country: "US",
|
|
@@ -273,538 +276,273 @@ const wr = o.object({
|
|
|
273
276
|
total: {
|
|
274
277
|
label: "Total",
|
|
275
278
|
amount: t,
|
|
276
|
-
pending:
|
|
279
|
+
pending: o
|
|
277
280
|
},
|
|
278
281
|
requestPayerName: !0,
|
|
279
282
|
requestPayerEmail: !0,
|
|
280
283
|
disableWallets: []
|
|
281
284
|
});
|
|
282
|
-
},
|
|
285
|
+
}, _t = (e) => new Promise((t) => {
|
|
283
286
|
setTimeout(t, e);
|
|
284
|
-
}),
|
|
287
|
+
}), Be = () => "Stripe" in window, Yn = async (e) => new Promise((t, r) => {
|
|
285
288
|
try {
|
|
286
|
-
e.on("paymentmethod", async (
|
|
287
|
-
t(
|
|
289
|
+
e.on("paymentmethod", async (o) => {
|
|
290
|
+
t(o);
|
|
288
291
|
}), e.on("cancel", () => {
|
|
289
|
-
|
|
292
|
+
r(new Error("Payment cancelled, please click Submit again to pay"));
|
|
290
293
|
});
|
|
291
|
-
} catch (
|
|
292
|
-
|
|
294
|
+
} catch (o) {
|
|
295
|
+
r(o);
|
|
293
296
|
}
|
|
294
|
-
}),
|
|
295
|
-
const
|
|
297
|
+
}), Zn = async (e, t) => {
|
|
298
|
+
const r = e.nextActionMetadata;
|
|
296
299
|
if (!e.paymentFlowMetadata || !e.paymentFlowMetadata.stripePmId)
|
|
297
300
|
throw new Error(`Invalid payment flow metadata format: ${JSON.stringify(e.paymentFlowMetadata)}`);
|
|
298
|
-
if (!
|
|
299
|
-
throw new Error(`Invalid next action metadata format: ${JSON.stringify(
|
|
301
|
+
if (!r.stripe_pk || !r.client_secret)
|
|
302
|
+
throw new Error(`Invalid next action metadata format: ${JSON.stringify(r)}`);
|
|
300
303
|
if (t.paymentMethod.id !== e.paymentFlowMetadata.stripePmId)
|
|
301
304
|
throw new Error(`PM ID mismatch: ${t.paymentMethod.id} != ${e.paymentFlowMetadata.stripePmId}`);
|
|
302
|
-
const s = await (await
|
|
305
|
+
const s = await (await _e(r.stripe_pk)).confirmCardSetup(r.client_secret, {
|
|
303
306
|
payment_method: e.paymentFlowMetadata.stripePmId
|
|
304
307
|
});
|
|
305
308
|
if (s.error)
|
|
306
309
|
throw t.complete("fail"), new Error(`Payment failed: ${s.error.message ?? "unknown"}`);
|
|
307
310
|
t.complete("success");
|
|
308
|
-
},
|
|
311
|
+
}, Jn = async (e, t) => {
|
|
309
312
|
if (!e.stripe_pk || !e.client_secret)
|
|
310
313
|
throw new Error(`Invalid next action metadata format: ${JSON.stringify(e)}`);
|
|
311
|
-
const
|
|
314
|
+
const o = await (await _e(e.stripe_pk)).confirmCardSetup(e.client_secret, {
|
|
312
315
|
payment_method: t.paymentMethod.id
|
|
313
316
|
});
|
|
314
|
-
if (
|
|
315
|
-
throw t.complete("fail"), new Error(`Payment failed: ${
|
|
316
|
-
t.complete("success");
|
|
317
|
-
},
|
|
318
|
-
const t =
|
|
319
|
-
await
|
|
320
|
-
},
|
|
317
|
+
if (o.error)
|
|
318
|
+
throw t.complete("fail"), new Error(`Payment failed: ${o.error.message ?? "unknown"}`);
|
|
319
|
+
return t.complete("success"), o;
|
|
320
|
+
}, Wn = async (e) => {
|
|
321
|
+
const t = yt.parse(e.nextActionMetadata);
|
|
322
|
+
await gt(t);
|
|
323
|
+
}, gt = async (e) => {
|
|
321
324
|
var s, i, a, c;
|
|
322
|
-
const
|
|
325
|
+
const r = await (await _e(e.stripe_pk)).confirmCardSetup(e.client_secret, {
|
|
323
326
|
payment_method: e.stripe_pm_id
|
|
324
|
-
}),
|
|
325
|
-
if (
|
|
326
|
-
`${((i =
|
|
327
|
+
}), o = (s = r.setupIntent) == null ? void 0 : s.status;
|
|
328
|
+
if (o !== "succeeded") throw o === "canceled" ? new Error("Payment cancelled, please click Submit again to pay") : new Error(
|
|
329
|
+
`${((i = r.error) == null ? void 0 : i.message) ?? ((c = (a = r.setupIntent) == null ? void 0 : a.last_setup_error) == null ? void 0 : c.message) ?? "Payment failed, please click submit again to pay."}`
|
|
327
330
|
);
|
|
328
|
-
},
|
|
329
|
-
var O = [];
|
|
330
|
-
for (var Ge = 0; Ge < 256; ++Ge)
|
|
331
|
-
O.push((Ge + 256).toString(16).slice(1));
|
|
332
|
-
function Ar(e, t = 0) {
|
|
333
|
-
return (O[e[t + 0]] + O[e[t + 1]] + O[e[t + 2]] + O[e[t + 3]] + "-" + O[e[t + 4]] + O[e[t + 5]] + "-" + O[e[t + 6]] + O[e[t + 7]] + "-" + O[e[t + 8]] + O[e[t + 9]] + "-" + O[e[t + 10]] + O[e[t + 11]] + O[e[t + 12]] + O[e[t + 13]] + O[e[t + 14]] + O[e[t + 15]]).toLowerCase();
|
|
334
|
-
}
|
|
335
|
-
var Pe, Tr = new Uint8Array(16);
|
|
336
|
-
function Ir() {
|
|
337
|
-
if (!Pe && (Pe = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Pe))
|
|
338
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
339
|
-
return Pe(Tr);
|
|
340
|
-
}
|
|
341
|
-
var Mr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
342
|
-
const Et = {
|
|
343
|
-
randomUUID: Mr
|
|
344
|
-
};
|
|
345
|
-
function Zt(e, t, n) {
|
|
346
|
-
if (Et.randomUUID && !t && !e)
|
|
347
|
-
return Et.randomUUID();
|
|
348
|
-
e = e || {};
|
|
349
|
-
var r = e.random || (e.rng || Ir)();
|
|
350
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Ar(r);
|
|
351
|
-
}
|
|
352
|
-
const et = (e, t) => Array.from(e.querySelectorAll("[data-opid]") ?? []).reduce((s, i) => {
|
|
331
|
+
}, Bn = (e) => JSON.stringify(e), Me = (e, t) => Array.from(e.querySelectorAll("[data-opid]") ?? []).reduce((s, i) => {
|
|
353
332
|
const a = i.getAttribute("data-opid");
|
|
354
333
|
return a ? { ...s, [a]: i.value } : s;
|
|
355
|
-
}, t ?? {}),
|
|
356
|
-
const c =
|
|
334
|
+
}, t ?? {}), Gn = (e, t, r, o, s, i, a) => {
|
|
335
|
+
const c = Me(r, {
|
|
357
336
|
type: e,
|
|
358
337
|
sessionId: t,
|
|
359
338
|
checkoutPaymentMethod: s,
|
|
360
339
|
paymentFlowMetadata: a,
|
|
361
340
|
doNotUseLegacyCCFlow: i
|
|
362
341
|
});
|
|
363
|
-
(s.provider === "apple_pay" || s.provider === "google_pay" || s.provider === "stripe_link") && (c[
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
return
|
|
342
|
+
(s.provider === "apple_pay" || s.provider === "google_pay" || s.provider === "stripe_link") && (c[C.ZIP_CODE] || (c[C.ZIP_CODE] = "00000"));
|
|
343
|
+
const l = ft.safeParse(c);
|
|
344
|
+
if (l.success)
|
|
345
|
+
return l.data;
|
|
367
346
|
{
|
|
368
|
-
const
|
|
369
|
-
for (const [
|
|
370
|
-
|
|
347
|
+
const d = l.error.format(), m = pt(d);
|
|
348
|
+
for (const [E, g] of Object.entries(m))
|
|
349
|
+
o(E, g, E);
|
|
371
350
|
return null;
|
|
372
351
|
}
|
|
373
|
-
},
|
|
352
|
+
}, Qn = (e) => {
|
|
374
353
|
try {
|
|
375
|
-
return
|
|
354
|
+
return Nn.parse(e);
|
|
376
355
|
} catch (t) {
|
|
377
356
|
throw t;
|
|
378
357
|
}
|
|
379
|
-
},
|
|
358
|
+
}, Te = (e, t, r, o, s) => {
|
|
380
359
|
const i = {
|
|
381
|
-
payload:
|
|
382
|
-
nonce:
|
|
360
|
+
payload: o,
|
|
361
|
+
nonce: st(),
|
|
383
362
|
formId: t,
|
|
384
|
-
elementId:
|
|
363
|
+
elementId: r
|
|
385
364
|
};
|
|
386
365
|
e.postMessage(JSON.stringify(i), s);
|
|
387
|
-
}
|
|
388
|
-
var V;
|
|
389
|
-
(function(e) {
|
|
390
|
-
e.Call = "call", e.Reply = "reply", e.Syn = "syn", e.SynAck = "synAck", e.Ack = "ack";
|
|
391
|
-
})(V || (V = {}));
|
|
392
|
-
var oe;
|
|
393
|
-
(function(e) {
|
|
394
|
-
e.Fulfilled = "fulfilled", e.Rejected = "rejected";
|
|
395
|
-
})(oe || (oe = {}));
|
|
396
|
-
var we;
|
|
397
|
-
(function(e) {
|
|
398
|
-
e.ConnectionDestroyed = "ConnectionDestroyed", e.ConnectionTimeout = "ConnectionTimeout", e.NoIframeSrc = "NoIframeSrc";
|
|
399
|
-
})(we || (we = {}));
|
|
400
|
-
var tt;
|
|
401
|
-
(function(e) {
|
|
402
|
-
e.DataCloneError = "DataCloneError";
|
|
403
|
-
})(tt || (tt = {}));
|
|
404
|
-
var ee;
|
|
405
|
-
(function(e) {
|
|
406
|
-
e.Message = "message";
|
|
407
|
-
})(ee || (ee = {}));
|
|
408
|
-
const Dr = (e, t) => {
|
|
409
|
-
const n = [];
|
|
410
|
-
let r = !1;
|
|
411
|
-
return {
|
|
412
|
-
destroy(s) {
|
|
413
|
-
r || (r = !0, t(`${e}: Destroying connection`), n.forEach((i) => {
|
|
414
|
-
i(s);
|
|
415
|
-
}));
|
|
416
|
-
},
|
|
417
|
-
onDestroy(s) {
|
|
418
|
-
r ? s() : n.push(s);
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
}, xr = (e) => (...t) => {
|
|
422
|
-
}, $r = {
|
|
423
|
-
"http:": "80",
|
|
424
|
-
"https:": "443"
|
|
425
|
-
}, Nr = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Lr = ["file:", "data:"], Ur = (e) => {
|
|
426
|
-
if (e && Lr.find((c) => e.startsWith(c)))
|
|
427
|
-
return "null";
|
|
428
|
-
const t = document.location, n = Nr.exec(e);
|
|
429
|
-
let r, s, i;
|
|
430
|
-
n ? (r = n[1] ? n[1] : t.protocol, s = n[2], i = n[4]) : (r = t.protocol, s = t.hostname, i = t.port);
|
|
431
|
-
const a = i && i !== $r[r] ? `:${i}` : "";
|
|
432
|
-
return `${r}//${s}${a}`;
|
|
433
|
-
}, Ct = ({ name: e, message: t, stack: n }) => ({
|
|
434
|
-
name: e,
|
|
435
|
-
message: t,
|
|
436
|
-
stack: n
|
|
437
|
-
}), Br = (e) => {
|
|
438
|
-
const t = new Error();
|
|
439
|
-
return Object.keys(e).forEach((n) => t[n] = e[n]), t;
|
|
440
|
-
}, qr = (e, t, n) => {
|
|
441
|
-
const { localName: r, local: s, remote: i, originForSending: a, originForReceiving: c } = e;
|
|
442
|
-
let d = !1;
|
|
443
|
-
const l = (u) => {
|
|
444
|
-
if (u.source !== i || u.data.penpal !== V.Call)
|
|
445
|
-
return;
|
|
446
|
-
if (c !== "*" && u.origin !== c) {
|
|
447
|
-
n(`${r} received message from origin ${u.origin} which did not match expected origin ${c}`);
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
const y = u.data, { methodName: f, args: m, id: g } = y;
|
|
451
|
-
n(`${r}: Received ${f}() call`);
|
|
452
|
-
const v = (C) => (x) => {
|
|
453
|
-
if (n(`${r}: Sending ${f}() reply`), d) {
|
|
454
|
-
n(`${r}: Unable to send ${f}() reply due to destroyed connection`);
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
const $ = {
|
|
458
|
-
penpal: V.Reply,
|
|
459
|
-
id: g,
|
|
460
|
-
resolution: C,
|
|
461
|
-
returnValue: x
|
|
462
|
-
};
|
|
463
|
-
C === oe.Rejected && x instanceof Error && ($.returnValue = Ct(x), $.returnValueIsError = !0);
|
|
464
|
-
try {
|
|
465
|
-
i.postMessage($, a);
|
|
466
|
-
} catch (S) {
|
|
467
|
-
if (S.name === tt.DataCloneError) {
|
|
468
|
-
const Z = {
|
|
469
|
-
penpal: V.Reply,
|
|
470
|
-
id: g,
|
|
471
|
-
resolution: oe.Rejected,
|
|
472
|
-
returnValue: Ct(S),
|
|
473
|
-
returnValueIsError: !0
|
|
474
|
-
};
|
|
475
|
-
i.postMessage(Z, a);
|
|
476
|
-
}
|
|
477
|
-
throw S;
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
new Promise((C) => C(t[f].apply(t, m))).then(v(oe.Fulfilled), v(oe.Rejected));
|
|
481
|
-
};
|
|
482
|
-
return s.addEventListener(ee.Message, l), () => {
|
|
483
|
-
d = !0, s.removeEventListener(ee.Message, l);
|
|
484
|
-
};
|
|
485
|
-
};
|
|
486
|
-
let zr = 0;
|
|
487
|
-
const Vr = () => ++zr, Wt = ".", Jt = (e) => e ? e.split(Wt) : [], Hr = (e) => e.join(Wt), Kr = (e, t) => {
|
|
488
|
-
const n = Jt(t || "");
|
|
489
|
-
return n.push(e), Hr(n);
|
|
490
|
-
}, Yr = (e, t, n) => {
|
|
491
|
-
const r = Jt(t);
|
|
492
|
-
return r.reduce((s, i, a) => (typeof s[i] > "u" && (s[i] = {}), a === r.length - 1 && (s[i] = n), s[i]), e), e;
|
|
493
|
-
}, Qt = (e, t) => {
|
|
494
|
-
const n = {};
|
|
495
|
-
return Object.keys(e).forEach((r) => {
|
|
496
|
-
const s = e[r], i = Kr(r, t);
|
|
497
|
-
typeof s == "object" && Object.assign(n, Qt(s, i)), typeof s == "function" && (n[i] = s);
|
|
498
|
-
}), n;
|
|
499
|
-
}, Gr = (e) => {
|
|
500
|
-
const t = {};
|
|
501
|
-
for (const n in e)
|
|
502
|
-
Yr(t, n, e[n]);
|
|
503
|
-
return t;
|
|
504
|
-
}, Zr = (e, t, n, r, s) => {
|
|
505
|
-
const { localName: i, local: a, remote: c, originForSending: d, originForReceiving: l } = t;
|
|
506
|
-
let u = !1;
|
|
507
|
-
s(`${i}: Connecting call sender`);
|
|
508
|
-
const y = (m) => (...g) => {
|
|
509
|
-
s(`${i}: Sending ${m}() call`);
|
|
510
|
-
let v;
|
|
511
|
-
try {
|
|
512
|
-
c.closed && (v = !0);
|
|
513
|
-
} catch {
|
|
514
|
-
v = !0;
|
|
515
|
-
}
|
|
516
|
-
if (v && r(), u) {
|
|
517
|
-
const C = new Error(`Unable to send ${m}() call due to destroyed connection`);
|
|
518
|
-
throw C.code = we.ConnectionDestroyed, C;
|
|
519
|
-
}
|
|
520
|
-
return new Promise((C, x) => {
|
|
521
|
-
const $ = Vr(), S = (W) => {
|
|
522
|
-
if (W.source !== c || W.data.penpal !== V.Reply || W.data.id !== $)
|
|
523
|
-
return;
|
|
524
|
-
if (l !== "*" && W.origin !== l) {
|
|
525
|
-
s(`${i} received message from origin ${W.origin} which did not match expected origin ${l}`);
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
const pe = W.data;
|
|
529
|
-
s(`${i}: Received ${m}() reply`), a.removeEventListener(ee.Message, S);
|
|
530
|
-
let te = pe.returnValue;
|
|
531
|
-
pe.returnValueIsError && (te = Br(te)), (pe.resolution === oe.Fulfilled ? C : x)(te);
|
|
532
|
-
};
|
|
533
|
-
a.addEventListener(ee.Message, S);
|
|
534
|
-
const Z = {
|
|
535
|
-
penpal: V.Call,
|
|
536
|
-
id: $,
|
|
537
|
-
methodName: m,
|
|
538
|
-
args: g
|
|
539
|
-
};
|
|
540
|
-
c.postMessage(Z, d);
|
|
541
|
-
});
|
|
542
|
-
}, f = n.reduce((m, g) => (m[g] = y(g), m), {});
|
|
543
|
-
return Object.assign(e, Gr(f)), () => {
|
|
544
|
-
u = !0;
|
|
545
|
-
};
|
|
546
|
-
}, Wr = (e, t, n, r, s) => {
|
|
547
|
-
const { destroy: i, onDestroy: a } = r;
|
|
548
|
-
let c, d;
|
|
549
|
-
const l = {};
|
|
550
|
-
return (u) => {
|
|
551
|
-
if (t !== "*" && u.origin !== t) {
|
|
552
|
-
s(`Parent: Handshake - Received ACK message from origin ${u.origin} which did not match expected origin ${t}`);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
s("Parent: Handshake - Received ACK");
|
|
556
|
-
const y = {
|
|
557
|
-
localName: "Parent",
|
|
558
|
-
local: window,
|
|
559
|
-
remote: u.source,
|
|
560
|
-
originForSending: n,
|
|
561
|
-
originForReceiving: t
|
|
562
|
-
};
|
|
563
|
-
c && c(), c = qr(y, e, s), a(c), d && d.forEach((m) => {
|
|
564
|
-
delete l[m];
|
|
565
|
-
}), d = u.data.methodNames;
|
|
566
|
-
const f = Zr(l, y, d, i, s);
|
|
567
|
-
return a(f), l;
|
|
568
|
-
};
|
|
569
|
-
}, Jr = (e, t, n, r) => (s) => {
|
|
570
|
-
if (!s.source)
|
|
571
|
-
return;
|
|
572
|
-
if (n !== "*" && s.origin !== n) {
|
|
573
|
-
e(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${n}`);
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
e("Parent: Handshake - Received SYN, responding with SYN-ACK");
|
|
577
|
-
const i = {
|
|
578
|
-
penpal: V.SynAck,
|
|
579
|
-
methodNames: Object.keys(t)
|
|
580
|
-
};
|
|
581
|
-
s.source.postMessage(i, r);
|
|
582
|
-
}, Qr = 6e4, Xr = (e, t) => {
|
|
583
|
-
const { destroy: n, onDestroy: r } = t, s = setInterval(() => {
|
|
584
|
-
e.isConnected || (clearInterval(s), n());
|
|
585
|
-
}, Qr);
|
|
586
|
-
r(() => {
|
|
587
|
-
clearInterval(s);
|
|
588
|
-
});
|
|
589
|
-
}, eo = (e, t) => {
|
|
590
|
-
let n;
|
|
591
|
-
return e !== void 0 && (n = window.setTimeout(() => {
|
|
592
|
-
const r = new Error(`Connection timed out after ${e}ms`);
|
|
593
|
-
r.code = we.ConnectionTimeout, t(r);
|
|
594
|
-
}, e)), () => {
|
|
595
|
-
clearTimeout(n);
|
|
596
|
-
};
|
|
597
|
-
}, to = (e) => {
|
|
598
|
-
if (!e.src && !e.srcdoc) {
|
|
599
|
-
const t = new Error("Iframe must have src or srcdoc property defined.");
|
|
600
|
-
throw t.code = we.NoIframeSrc, t;
|
|
601
|
-
}
|
|
602
|
-
}, Xt = (e) => {
|
|
603
|
-
let { iframe: t, methods: n = {}, childOrigin: r, timeout: s, debug: i = !1 } = e;
|
|
604
|
-
const a = xr(i), c = Dr("Parent", a), { onDestroy: d, destroy: l } = c;
|
|
605
|
-
r || (to(t), r = Ur(t.src));
|
|
606
|
-
const u = r === "null" ? "*" : r, y = Qt(n), f = Jr(a, y, r, u), m = Wr(y, r, u, c, a);
|
|
607
|
-
return {
|
|
608
|
-
promise: new Promise((v, C) => {
|
|
609
|
-
const x = eo(s, l), $ = (S) => {
|
|
610
|
-
if (!(S.source !== t.contentWindow || !S.data)) {
|
|
611
|
-
if (S.data.penpal === V.Syn) {
|
|
612
|
-
f(S);
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
if (S.data.penpal === V.Ack) {
|
|
616
|
-
const Z = m(S);
|
|
617
|
-
Z && (x(), v(Z));
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
window.addEventListener(ee.Message, $), a("Parent: Awaiting handshake"), Xr(t, c), d((S) => {
|
|
623
|
-
window.removeEventListener(ee.Message, $), S && C(S);
|
|
624
|
-
});
|
|
625
|
-
}),
|
|
626
|
-
destroy() {
|
|
627
|
-
l();
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
}, no = async (e) => {
|
|
366
|
+
}, Xn = async (e) => {
|
|
631
367
|
if (typeof e != "object" || !e) return !1;
|
|
632
368
|
try {
|
|
633
|
-
const t = { type: "ping" },
|
|
634
|
-
if (
|
|
635
|
-
throw new Error(`Expected 'true' after ping, got ${JSON.stringify(
|
|
369
|
+
const t = { type: "ping" }, r = await e.send(t);
|
|
370
|
+
if (r !== !0)
|
|
371
|
+
throw new Error(`Expected 'true' after ping, got ${JSON.stringify(r)}`);
|
|
636
372
|
return !0;
|
|
637
373
|
} catch {
|
|
638
374
|
return !1;
|
|
639
375
|
}
|
|
640
|
-
},
|
|
641
|
-
async function
|
|
642
|
-
const
|
|
376
|
+
}, er = (e, t) => !!e && t;
|
|
377
|
+
async function tr(e) {
|
|
378
|
+
const r = await it({
|
|
643
379
|
iframe: e,
|
|
644
380
|
debug: !0
|
|
645
|
-
}).promise,
|
|
646
|
-
if (!
|
|
381
|
+
}).promise, o = await Xn(r);
|
|
382
|
+
if (!er(r, o))
|
|
647
383
|
throw new Error("Got invalid CDE connection object");
|
|
648
|
-
return
|
|
384
|
+
return r;
|
|
649
385
|
}
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
const
|
|
653
|
-
cde_response_type:
|
|
654
|
-
message:
|
|
655
|
-
headers:
|
|
656
|
-
})
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}),
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}),
|
|
691
|
-
amount_atom:
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}),
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
386
|
+
const b = (e) => n.nullable(e.optional());
|
|
387
|
+
n.string().trim().min(1, { message: "Cannot be blank" });
|
|
388
|
+
const nr = n.object({
|
|
389
|
+
cde_response_type: n.literal("error"),
|
|
390
|
+
message: n.string(),
|
|
391
|
+
headers: n.record(n.string(), n.string()).optional()
|
|
392
|
+
});
|
|
393
|
+
n.enum(["usd", "brl"]);
|
|
394
|
+
const ht = n.object({
|
|
395
|
+
name: n.string(),
|
|
396
|
+
amount_atom_off: b(n.number()),
|
|
397
|
+
percent_off: b(n.number()),
|
|
398
|
+
currency: b(n.string()),
|
|
399
|
+
duration: n.string(),
|
|
400
|
+
duration_in_months: b(n.number())
|
|
401
|
+
}), wt = n.object({
|
|
402
|
+
amount_subtotal_atom: n.number().int(),
|
|
403
|
+
amount_total_atom: n.number().int(),
|
|
404
|
+
currency: n.string(),
|
|
405
|
+
description: b(n.string()),
|
|
406
|
+
price_id: n.string(),
|
|
407
|
+
billing_interval: b(n.string()),
|
|
408
|
+
billing_interval_count: b(n.number().int()),
|
|
409
|
+
quantity: n.number().int()
|
|
410
|
+
}), rr = n.record(n.string(), n.any()), or = n.object({
|
|
411
|
+
name: n.string(),
|
|
412
|
+
settings: b(rr)
|
|
413
|
+
}), ge = n.object({
|
|
414
|
+
provider: n.string(),
|
|
415
|
+
processor_name: b(n.string()),
|
|
416
|
+
metadata: b(n.record(n.string(), n.any()))
|
|
417
|
+
}), sr = n.object({
|
|
418
|
+
quantity: n.number()
|
|
419
|
+
}), ir = n.object({
|
|
420
|
+
id: b(n.string()),
|
|
421
|
+
billing_interval: b(n.string()),
|
|
422
|
+
billing_interval_count: b(n.number().int()),
|
|
423
|
+
subscription_items: n.array(sr),
|
|
424
|
+
trial_start: b(n.string()),
|
|
425
|
+
trial_end: b(n.string())
|
|
426
|
+
}), Et = n.object({
|
|
427
|
+
amount_atom: n.number()
|
|
428
|
+
}), ar = n.object({
|
|
429
|
+
amount_atom: n.number(),
|
|
430
|
+
amount_atom_considering_discount_applied: n.number(),
|
|
431
|
+
currency: n.string(),
|
|
432
|
+
discount_amount_atoms: n.array(Et),
|
|
433
|
+
subscription_item_id: n.string()
|
|
434
|
+
}), cr = n.object({
|
|
435
|
+
coupon: ht
|
|
436
|
+
}), lr = n.object({
|
|
437
|
+
currency: n.string(),
|
|
438
|
+
discounts: n.array(cr),
|
|
439
|
+
hosted_invoice_url: b(n.string()),
|
|
440
|
+
lines: n.array(ar),
|
|
441
|
+
remaining_amount_atom: n.number(),
|
|
442
|
+
tax_amount_atom: n.number(),
|
|
443
|
+
total_amount_atom: n.number(),
|
|
444
|
+
total_discount_amount_atoms: n.array(Et)
|
|
445
|
+
}), Ge = n.object({
|
|
446
|
+
created: n.array(ir),
|
|
447
|
+
invoices: n.array(lr)
|
|
448
|
+
}), Ct = n.object({
|
|
449
|
+
preview: Ge,
|
|
450
|
+
preview_post_trial: b(Ge),
|
|
451
|
+
coupons: n.array(ht)
|
|
452
|
+
}), Qe = n.object({
|
|
453
|
+
status: n.literal("open"),
|
|
454
|
+
token: n.string(),
|
|
455
|
+
email: b(n.string()),
|
|
456
|
+
line_items: n.array(wt),
|
|
457
|
+
amount_subtotal_atom: n.number().int(),
|
|
458
|
+
amount_total_atom: n.number().int(),
|
|
459
|
+
brand: or,
|
|
460
|
+
subs_preview: b(Ct),
|
|
723
461
|
// Null in setup mode
|
|
724
|
-
methods_available:
|
|
725
|
-
}),
|
|
726
|
-
|
|
727
|
-
mode:
|
|
728
|
-
currency:
|
|
729
|
-
}).extend(
|
|
730
|
-
|
|
731
|
-
mode:
|
|
732
|
-
currency:
|
|
733
|
-
}).extend(
|
|
734
|
-
]),
|
|
735
|
-
status:
|
|
736
|
-
}),
|
|
737
|
-
status:
|
|
462
|
+
methods_available: n.array(ge)
|
|
463
|
+
}), bt = n.discriminatedUnion("mode", [
|
|
464
|
+
n.object({
|
|
465
|
+
mode: n.literal("setup"),
|
|
466
|
+
currency: n.nullable(n.undefined())
|
|
467
|
+
}).extend(Qe.shape),
|
|
468
|
+
n.object({
|
|
469
|
+
mode: n.enum(["payment", "subscription"]),
|
|
470
|
+
currency: n.string()
|
|
471
|
+
}).extend(Qe.shape)
|
|
472
|
+
]), ur = n.object({
|
|
473
|
+
status: n.literal("complete")
|
|
474
|
+
}), dr = n.object({
|
|
475
|
+
status: n.literal("expired")
|
|
738
476
|
});
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
logo:
|
|
742
|
-
icon:
|
|
743
|
-
primary_color:
|
|
744
|
-
secondary_color:
|
|
477
|
+
n.union([bt, ur, dr]);
|
|
478
|
+
n.object({
|
|
479
|
+
logo: n.string(),
|
|
480
|
+
icon: n.string(),
|
|
481
|
+
primary_color: n.string(),
|
|
482
|
+
secondary_color: n.string()
|
|
745
483
|
});
|
|
746
|
-
const
|
|
747
|
-
invoice_urls:
|
|
748
|
-
subscription_ids:
|
|
749
|
-
customer_id:
|
|
484
|
+
const St = n.object({
|
|
485
|
+
invoice_urls: n.array(n.string()),
|
|
486
|
+
subscription_ids: n.array(n.string()),
|
|
487
|
+
customer_id: n.string()
|
|
750
488
|
});
|
|
751
|
-
|
|
752
|
-
secure_token:
|
|
753
|
-
payment_input:
|
|
489
|
+
n.object({
|
|
490
|
+
secure_token: n.string(),
|
|
491
|
+
payment_input: n.any(),
|
|
754
492
|
// Should follow AnyPaymentInput from CDE
|
|
755
|
-
customer_email:
|
|
756
|
-
customer_zip_code:
|
|
757
|
-
customer_country:
|
|
758
|
-
line_items:
|
|
759
|
-
total_amount_atom:
|
|
760
|
-
cancel_at_end:
|
|
761
|
-
checkout_payment_method:
|
|
762
|
-
promotion_code:
|
|
763
|
-
do_not_use_legacy_cc_flow:
|
|
493
|
+
customer_email: n.string(),
|
|
494
|
+
customer_zip_code: n.string(),
|
|
495
|
+
customer_country: n.string(),
|
|
496
|
+
line_items: n.array(wt),
|
|
497
|
+
total_amount_atom: n.number().int(),
|
|
498
|
+
cancel_at_end: n.boolean(),
|
|
499
|
+
checkout_payment_method: ge,
|
|
500
|
+
promotion_code: n.string().optional(),
|
|
501
|
+
do_not_use_legacy_cc_flow: n.boolean().optional()
|
|
764
502
|
});
|
|
765
|
-
const
|
|
766
|
-
payment_method_id:
|
|
503
|
+
const mr = n.object({
|
|
504
|
+
payment_method_id: n.string()
|
|
767
505
|
});
|
|
768
|
-
|
|
769
|
-
id:
|
|
770
|
-
return_url:
|
|
506
|
+
n.object({
|
|
507
|
+
id: n.string(),
|
|
508
|
+
return_url: n.string()
|
|
771
509
|
});
|
|
772
|
-
const
|
|
773
|
-
type:
|
|
774
|
-
loc:
|
|
775
|
-
msg:
|
|
776
|
-
url:
|
|
510
|
+
const fr = n.object({
|
|
511
|
+
type: n.string(),
|
|
512
|
+
loc: n.array(n.string()),
|
|
513
|
+
msg: n.string(),
|
|
514
|
+
url: n.string()
|
|
777
515
|
});
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
required_user_actions:
|
|
516
|
+
n.array(fr);
|
|
517
|
+
const pr = n.object({
|
|
518
|
+
required_user_actions: n.array(n.record(n.string(), n.any()))
|
|
781
519
|
});
|
|
782
|
-
|
|
783
|
-
fields:
|
|
784
|
-
checkoutPaymentMethod:
|
|
520
|
+
n.object({
|
|
521
|
+
fields: In,
|
|
522
|
+
checkoutPaymentMethod: ge
|
|
785
523
|
});
|
|
786
|
-
|
|
787
|
-
session_id:
|
|
788
|
-
non_cde_form_fields:
|
|
789
|
-
checkout_payment_method:
|
|
524
|
+
n.object({
|
|
525
|
+
session_id: n.string(),
|
|
526
|
+
non_cde_form_fields: oe,
|
|
527
|
+
checkout_payment_method: ge
|
|
790
528
|
});
|
|
791
|
-
const
|
|
792
|
-
required_user_actions:
|
|
793
|
-
cc_pm_id:
|
|
529
|
+
const yr = n.object({
|
|
530
|
+
required_user_actions: n.array(n.record(n.string(), n.any())),
|
|
531
|
+
cc_pm_id: n.string()
|
|
794
532
|
});
|
|
795
|
-
|
|
796
|
-
const
|
|
797
|
-
function
|
|
798
|
-
var
|
|
799
|
-
|
|
533
|
+
n.record(n.any());
|
|
534
|
+
const _r = (e) => e.reduce((t, r) => t + r, 0);
|
|
535
|
+
function gr(e, t) {
|
|
536
|
+
var r = Object.setPrototypeOf;
|
|
537
|
+
r ? r(e, t) : e.__proto__ = t;
|
|
800
538
|
}
|
|
801
|
-
function
|
|
539
|
+
function hr(e, t) {
|
|
802
540
|
t === void 0 && (t = e.constructor);
|
|
803
|
-
var
|
|
804
|
-
|
|
541
|
+
var r = Error.captureStackTrace;
|
|
542
|
+
r && r(e, t);
|
|
805
543
|
}
|
|
806
|
-
var
|
|
807
|
-
var e = function(
|
|
544
|
+
var wr = /* @__PURE__ */ function() {
|
|
545
|
+
var e = function(r, o) {
|
|
808
546
|
return e = Object.setPrototypeOf || {
|
|
809
547
|
__proto__: []
|
|
810
548
|
} instanceof Array && function(s, i) {
|
|
@@ -812,112 +550,113 @@ var So = /* @__PURE__ */ function() {
|
|
|
812
550
|
} || function(s, i) {
|
|
813
551
|
for (var a in i)
|
|
814
552
|
Object.prototype.hasOwnProperty.call(i, a) && (s[a] = i[a]);
|
|
815
|
-
}, e(
|
|
553
|
+
}, e(r, o);
|
|
816
554
|
};
|
|
817
|
-
return function(t,
|
|
818
|
-
if (typeof
|
|
819
|
-
e(t,
|
|
820
|
-
function
|
|
555
|
+
return function(t, r) {
|
|
556
|
+
if (typeof r != "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
|
557
|
+
e(t, r);
|
|
558
|
+
function o() {
|
|
821
559
|
this.constructor = t;
|
|
822
560
|
}
|
|
823
|
-
t.prototype =
|
|
561
|
+
t.prototype = r === null ? Object.create(r) : (o.prototype = r.prototype, new o());
|
|
824
562
|
};
|
|
825
|
-
}(),
|
|
826
|
-
|
|
827
|
-
function t(
|
|
828
|
-
var s = this.constructor, i = e.call(this,
|
|
563
|
+
}(), Er = function(e) {
|
|
564
|
+
wr(t, e);
|
|
565
|
+
function t(r, o) {
|
|
566
|
+
var s = this.constructor, i = e.call(this, r, o) || this;
|
|
829
567
|
return Object.defineProperty(i, "name", {
|
|
830
568
|
value: s.name,
|
|
831
569
|
enumerable: !1,
|
|
832
570
|
configurable: !0
|
|
833
|
-
}),
|
|
571
|
+
}), gr(i, s.prototype), hr(i), i;
|
|
834
572
|
}
|
|
835
573
|
return t;
|
|
836
574
|
}(Error);
|
|
837
|
-
class
|
|
575
|
+
class Pt extends Er {
|
|
838
576
|
constructor(t) {
|
|
839
|
-
const
|
|
840
|
-
super(
|
|
577
|
+
const r = `[cde-client] Error querying CDE: ${t.message}`;
|
|
578
|
+
super(r), this.response = t;
|
|
841
579
|
}
|
|
842
580
|
get originalErrorMessage() {
|
|
843
581
|
return this.response.message;
|
|
844
582
|
}
|
|
845
583
|
}
|
|
846
|
-
const
|
|
847
|
-
const
|
|
848
|
-
if (
|
|
849
|
-
throw new
|
|
850
|
-
if (!
|
|
851
|
-
const s =
|
|
584
|
+
const x = async (e, t, r) => {
|
|
585
|
+
const o = await e.send(t);
|
|
586
|
+
if (br(o))
|
|
587
|
+
throw new Pt(o);
|
|
588
|
+
if (!Cr(o, r)) {
|
|
589
|
+
const s = r.safeParse(o);
|
|
852
590
|
throw s.success ? new Error("Invalid state") : s.error;
|
|
853
591
|
}
|
|
854
|
-
return
|
|
855
|
-
},
|
|
856
|
-
const
|
|
857
|
-
for (
|
|
592
|
+
return o;
|
|
593
|
+
}, Cr = (e, t) => t.safeParse(e).success, br = (e) => nr.safeParse(e).success, Sr = async (e, t) => await x(e, { type: "get_checkout_preview", payload: t }, Ct), se = async (e) => await x(e, { type: "get_prefill", payload: {} }, bt), Pr = async (e, t) => await x(e, { type: "start_payment_flow_for_cc", payload: t }, yr), vr = async (e, t) => await x(e, { type: "start_payment_flow_for_pr", payload: t }, pr), xe = async (e, t) => await x(e, { type: "confirm_payment_flow", payload: t }, xn), Or = async (e, t, r) => {
|
|
594
|
+
const o = Date.now();
|
|
595
|
+
for (r = r ?? 5e3; Date.now() - o < r; ) {
|
|
858
596
|
const s = e.querySelector(`input[data-opid=${t}]`);
|
|
859
597
|
if (s !== null) {
|
|
860
598
|
if (!(s instanceof HTMLInputElement))
|
|
861
599
|
throw new Error(`Invalid state: matched input element had wrong class: ${s.tagName}`);
|
|
862
600
|
return s;
|
|
863
601
|
}
|
|
864
|
-
await
|
|
602
|
+
await _t(300);
|
|
865
603
|
}
|
|
866
604
|
return null;
|
|
867
|
-
},
|
|
868
|
-
const
|
|
605
|
+
}, Rr = async (e, t, r) => {
|
|
606
|
+
const o = await Sr(e, {
|
|
869
607
|
secure_token: t,
|
|
870
|
-
promotion_code:
|
|
871
|
-
}), s = new Set(
|
|
608
|
+
promotion_code: r
|
|
609
|
+
}), s = new Set(o.preview.invoices.map((c) => c.currency));
|
|
872
610
|
if (s.size !== 1)
|
|
873
611
|
throw new Error(`Expected exactly one currency, got ${s.size}`);
|
|
874
|
-
const i = s.values().next().value ?? "usd", a =
|
|
612
|
+
const i = s.values().next().value ?? "usd", a = _r(o.preview.invoices.map((c) => c.remaining_amount_atom));
|
|
875
613
|
return {
|
|
876
614
|
currency: i,
|
|
877
615
|
amountAtom: a
|
|
878
616
|
};
|
|
879
|
-
},
|
|
880
|
-
if (
|
|
617
|
+
}, vt = async (e, t, r, o) => {
|
|
618
|
+
if (r)
|
|
881
619
|
return { amountAtom: 0, currency: "usd" };
|
|
882
620
|
{
|
|
883
|
-
|
|
884
|
-
const s = await
|
|
621
|
+
o = o || void 0;
|
|
622
|
+
const s = await Rr(e, t, o);
|
|
885
623
|
return { amountAtom: s.amountAtom, currency: s.currency };
|
|
886
624
|
}
|
|
887
|
-
},
|
|
625
|
+
}, kr = async (e, t) => {
|
|
888
626
|
if (e.size === 0)
|
|
889
627
|
throw new Error("No CDE connections found");
|
|
890
628
|
return await Promise.all(
|
|
891
629
|
Array.from(e.values()).map(
|
|
892
|
-
(
|
|
630
|
+
(o) => x(o, { type: "tokenize_card", payload: t }, Un)
|
|
893
631
|
)
|
|
894
632
|
);
|
|
895
|
-
},
|
|
633
|
+
}, Xe = async (e, t) => {
|
|
896
634
|
try {
|
|
897
|
-
return await
|
|
898
|
-
} catch (
|
|
899
|
-
throw
|
|
635
|
+
return await x(e, { type: "checkout_card_elements", payload: t }, St);
|
|
636
|
+
} catch (r) {
|
|
637
|
+
throw r;
|
|
900
638
|
}
|
|
901
|
-
},
|
|
902
|
-
const
|
|
639
|
+
}, Tr = async (e, t) => await x(e, { type: "setup_payment_method", payload: t }, mr), Ar = async (e, t) => await x(e, { type: "checkout", payload: t }, St), Ot = 1e3, Ir = async (e, t) => {
|
|
640
|
+
const o = await it({
|
|
903
641
|
iframe: e,
|
|
904
642
|
debug: !0,
|
|
905
|
-
timeout:
|
|
906
|
-
childOrigin:
|
|
643
|
+
timeout: Ot,
|
|
644
|
+
childOrigin: "*"
|
|
645
|
+
// TODO: use with proper childOrigin
|
|
907
646
|
}).promise;
|
|
908
|
-
return (await
|
|
909
|
-
},
|
|
647
|
+
return (await x(o, { type: "ping-3ds-status" }, qn)).status;
|
|
648
|
+
}, jr = (e) => {
|
|
910
649
|
if (typeof e != "string") return !1;
|
|
911
650
|
try {
|
|
912
651
|
return JSON.parse(e), !0;
|
|
913
652
|
} catch {
|
|
914
653
|
return !1;
|
|
915
654
|
}
|
|
916
|
-
},
|
|
655
|
+
}, Mr = "@keyframes fadeIn{0%{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}.overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483648!important;display:flex;justify-content:center;align-items:center;background-color:#00000080}.container{max-width:500px;max-height:600px;width:100%;height:100%;background-color:#fff;position:relative;animation:fadeIn .3s ease-out}.frame{max-width:500px;max-height:600px;width:100%;height:100%;border:none}.cancel-button{position:absolute;background:transparent;border:none;font-size:1rem;color:#fff;cursor:pointer;top:-1.5rem;padding:0;right:0}", Fr = (e) => {
|
|
917
656
|
const t = document.createElement("template");
|
|
918
657
|
t.innerHTML = `
|
|
919
658
|
<style>
|
|
920
|
-
${
|
|
659
|
+
${Mr}
|
|
921
660
|
</style>
|
|
922
661
|
<div class="overlay">
|
|
923
662
|
<div class="container">
|
|
@@ -926,486 +665,214 @@ const H = async (e, t, n) => {
|
|
|
926
665
|
</div>
|
|
927
666
|
</div>
|
|
928
667
|
`;
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
const s =
|
|
932
|
-
return document.body.appendChild(
|
|
668
|
+
const r = document.createElement("div"), o = r.attachShadow({ mode: "open" });
|
|
669
|
+
o.appendChild(t.content.cloneNode(!0));
|
|
670
|
+
const s = o.querySelector("#three-ds-iframe"), i = o.querySelector(".cancel-button");
|
|
671
|
+
return document.body.appendChild(r), { host: r, iframe: s, cancelButton: i };
|
|
933
672
|
};
|
|
934
|
-
function
|
|
935
|
-
const
|
|
673
|
+
function Dr(e, t, r) {
|
|
674
|
+
const o = async () => {
|
|
936
675
|
try {
|
|
937
|
-
const i = await
|
|
676
|
+
const i = await Ir(e, r);
|
|
938
677
|
i && (clearInterval(s), t(i));
|
|
939
678
|
} catch {
|
|
940
679
|
}
|
|
941
680
|
};
|
|
942
|
-
|
|
943
|
-
const s = setInterval(
|
|
681
|
+
o();
|
|
682
|
+
const s = setInterval(o, Ot);
|
|
944
683
|
return s;
|
|
945
684
|
}
|
|
946
|
-
function
|
|
685
|
+
function Nr({
|
|
947
686
|
elements: e,
|
|
948
687
|
pollingInterval: t,
|
|
949
|
-
resolve:
|
|
688
|
+
resolve: r
|
|
950
689
|
}) {
|
|
951
|
-
const
|
|
952
|
-
clearInterval(t), e.host.remove(),
|
|
690
|
+
const o = () => {
|
|
691
|
+
clearInterval(t), e.host.remove(), r(me.CANCELLED);
|
|
953
692
|
};
|
|
954
|
-
return e.cancelButton.addEventListener("click",
|
|
955
|
-
e.cancelButton.removeEventListener("click",
|
|
693
|
+
return e.cancelButton.addEventListener("click", o), () => {
|
|
694
|
+
e.cancelButton.removeEventListener("click", o);
|
|
956
695
|
};
|
|
957
696
|
}
|
|
958
|
-
async function
|
|
697
|
+
async function xr({
|
|
959
698
|
url: e,
|
|
960
699
|
baseUrl: t
|
|
961
700
|
}) {
|
|
962
|
-
const
|
|
963
|
-
return new Promise((
|
|
701
|
+
const r = Fr(e);
|
|
702
|
+
return new Promise((o) => {
|
|
964
703
|
const s = (c) => {
|
|
965
704
|
setTimeout(() => {
|
|
966
|
-
|
|
967
|
-
}, 1e3),
|
|
968
|
-
}, i =
|
|
969
|
-
elements:
|
|
705
|
+
r.host.remove();
|
|
706
|
+
}, 1e3), o(c), a == null || a();
|
|
707
|
+
}, i = Dr(r.iframe, s, new URL(t).origin), a = Nr({
|
|
708
|
+
elements: r,
|
|
970
709
|
pollingInterval: i,
|
|
971
|
-
resolve:
|
|
710
|
+
resolve: o
|
|
972
711
|
});
|
|
973
712
|
});
|
|
974
713
|
}
|
|
975
|
-
const
|
|
976
|
-
modifier: {
|
|
977
|
-
reset: [0, 0],
|
|
978
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
979
|
-
bold: [1, 22],
|
|
980
|
-
dim: [2, 22],
|
|
981
|
-
italic: [3, 23],
|
|
982
|
-
underline: [4, 24],
|
|
983
|
-
overline: [53, 55],
|
|
984
|
-
inverse: [7, 27],
|
|
985
|
-
hidden: [8, 28],
|
|
986
|
-
strikethrough: [9, 29]
|
|
987
|
-
},
|
|
988
|
-
color: {
|
|
989
|
-
black: [30, 39],
|
|
990
|
-
red: [31, 39],
|
|
991
|
-
green: [32, 39],
|
|
992
|
-
yellow: [33, 39],
|
|
993
|
-
blue: [34, 39],
|
|
994
|
-
magenta: [35, 39],
|
|
995
|
-
cyan: [36, 39],
|
|
996
|
-
white: [37, 39],
|
|
997
|
-
// Bright color
|
|
998
|
-
blackBright: [90, 39],
|
|
999
|
-
gray: [90, 39],
|
|
1000
|
-
// Alias of `blackBright`
|
|
1001
|
-
grey: [90, 39],
|
|
1002
|
-
// Alias of `blackBright`
|
|
1003
|
-
redBright: [91, 39],
|
|
1004
|
-
greenBright: [92, 39],
|
|
1005
|
-
yellowBright: [93, 39],
|
|
1006
|
-
blueBright: [94, 39],
|
|
1007
|
-
magentaBright: [95, 39],
|
|
1008
|
-
cyanBright: [96, 39],
|
|
1009
|
-
whiteBright: [97, 39]
|
|
1010
|
-
},
|
|
1011
|
-
bgColor: {
|
|
1012
|
-
bgBlack: [40, 49],
|
|
1013
|
-
bgRed: [41, 49],
|
|
1014
|
-
bgGreen: [42, 49],
|
|
1015
|
-
bgYellow: [43, 49],
|
|
1016
|
-
bgBlue: [44, 49],
|
|
1017
|
-
bgMagenta: [45, 49],
|
|
1018
|
-
bgCyan: [46, 49],
|
|
1019
|
-
bgWhite: [47, 49],
|
|
1020
|
-
// Bright color
|
|
1021
|
-
bgBlackBright: [100, 49],
|
|
1022
|
-
bgGray: [100, 49],
|
|
1023
|
-
// Alias of `bgBlackBright`
|
|
1024
|
-
bgGrey: [100, 49],
|
|
1025
|
-
// Alias of `bgBlackBright`
|
|
1026
|
-
bgRedBright: [101, 49],
|
|
1027
|
-
bgGreenBright: [102, 49],
|
|
1028
|
-
bgYellowBright: [103, 49],
|
|
1029
|
-
bgBlueBright: [104, 49],
|
|
1030
|
-
bgMagentaBright: [105, 49],
|
|
1031
|
-
bgCyanBright: [106, 49],
|
|
1032
|
-
bgWhiteBright: [107, 49]
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
Object.keys(b.modifier);
|
|
1036
|
-
const zo = Object.keys(b.color), Vo = Object.keys(b.bgColor);
|
|
1037
|
-
[...zo, ...Vo];
|
|
1038
|
-
function Ho() {
|
|
1039
|
-
const e = /* @__PURE__ */ new Map();
|
|
1040
|
-
for (const [t, n] of Object.entries(b)) {
|
|
1041
|
-
for (const [r, s] of Object.entries(n))
|
|
1042
|
-
b[r] = {
|
|
1043
|
-
open: `\x1B[${s[0]}m`,
|
|
1044
|
-
close: `\x1B[${s[1]}m`
|
|
1045
|
-
}, n[r] = b[r], e.set(s[0], s[1]);
|
|
1046
|
-
Object.defineProperty(b, t, {
|
|
1047
|
-
value: n,
|
|
1048
|
-
enumerable: !1
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
return Object.defineProperty(b, "codes", {
|
|
1052
|
-
value: e,
|
|
1053
|
-
enumerable: !1
|
|
1054
|
-
}), b.color.close = "\x1B[39m", b.bgColor.close = "\x1B[49m", b.color.ansi = Rt(), b.color.ansi256 = Ot(), b.color.ansi16m = kt(), b.bgColor.ansi = Rt(We), b.bgColor.ansi256 = Ot(We), b.bgColor.ansi16m = kt(We), Object.defineProperties(b, {
|
|
1055
|
-
rgbToAnsi256: {
|
|
1056
|
-
value(t, n, r) {
|
|
1057
|
-
return t === n && n === r ? t < 8 ? 16 : t > 248 ? 231 : Math.round((t - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(t / 255 * 5) + 6 * Math.round(n / 255 * 5) + Math.round(r / 255 * 5);
|
|
1058
|
-
},
|
|
1059
|
-
enumerable: !1
|
|
1060
|
-
},
|
|
1061
|
-
hexToRgb: {
|
|
1062
|
-
value(t) {
|
|
1063
|
-
const n = /[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));
|
|
1064
|
-
if (!n)
|
|
1065
|
-
return [0, 0, 0];
|
|
1066
|
-
let [r] = n;
|
|
1067
|
-
r.length === 3 && (r = [...r].map((i) => i + i).join(""));
|
|
1068
|
-
const s = Number.parseInt(r, 16);
|
|
1069
|
-
return [
|
|
1070
|
-
/* eslint-disable no-bitwise */
|
|
1071
|
-
s >> 16 & 255,
|
|
1072
|
-
s >> 8 & 255,
|
|
1073
|
-
s & 255
|
|
1074
|
-
/* eslint-enable no-bitwise */
|
|
1075
|
-
];
|
|
1076
|
-
},
|
|
1077
|
-
enumerable: !1
|
|
1078
|
-
},
|
|
1079
|
-
hexToAnsi256: {
|
|
1080
|
-
value: (t) => b.rgbToAnsi256(...b.hexToRgb(t)),
|
|
1081
|
-
enumerable: !1
|
|
1082
|
-
},
|
|
1083
|
-
ansi256ToAnsi: {
|
|
1084
|
-
value(t) {
|
|
1085
|
-
if (t < 8)
|
|
1086
|
-
return 30 + t;
|
|
1087
|
-
if (t < 16)
|
|
1088
|
-
return 90 + (t - 8);
|
|
1089
|
-
let n, r, s;
|
|
1090
|
-
if (t >= 232)
|
|
1091
|
-
n = ((t - 232) * 10 + 8) / 255, r = n, s = n;
|
|
1092
|
-
else {
|
|
1093
|
-
t -= 16;
|
|
1094
|
-
const c = t % 36;
|
|
1095
|
-
n = Math.floor(t / 36) / 5, r = Math.floor(c / 6) / 5, s = c % 6 / 5;
|
|
1096
|
-
}
|
|
1097
|
-
const i = Math.max(n, r, s) * 2;
|
|
1098
|
-
if (i === 0)
|
|
1099
|
-
return 30;
|
|
1100
|
-
let a = 30 + (Math.round(s) << 2 | Math.round(r) << 1 | Math.round(n));
|
|
1101
|
-
return i === 2 && (a += 60), a;
|
|
1102
|
-
},
|
|
1103
|
-
enumerable: !1
|
|
1104
|
-
},
|
|
1105
|
-
rgbToAnsi: {
|
|
1106
|
-
value: (t, n, r) => b.ansi256ToAnsi(b.rgbToAnsi256(t, n, r)),
|
|
1107
|
-
enumerable: !1
|
|
1108
|
-
},
|
|
1109
|
-
hexToAnsi: {
|
|
1110
|
-
value: (t) => b.ansi256ToAnsi(b.hexToAnsi256(t)),
|
|
1111
|
-
enumerable: !1
|
|
1112
|
-
}
|
|
1113
|
-
}), b;
|
|
1114
|
-
}
|
|
1115
|
-
const z = Ho(), Re = (() => {
|
|
1116
|
-
if (navigator.userAgentData) {
|
|
1117
|
-
const e = navigator.userAgentData.brands.find(({ brand: t }) => t === "Chromium");
|
|
1118
|
-
if (e && e.version > 93)
|
|
1119
|
-
return 3;
|
|
1120
|
-
}
|
|
1121
|
-
return /\b(Chrome|Chromium)\//.test(navigator.userAgent) ? 1 : 0;
|
|
1122
|
-
})(), At = Re !== 0 && {
|
|
1123
|
-
level: Re,
|
|
1124
|
-
hasBasic: !0,
|
|
1125
|
-
has256: Re >= 2,
|
|
1126
|
-
has16m: Re >= 3
|
|
1127
|
-
}, Ko = {
|
|
1128
|
-
stdout: At,
|
|
1129
|
-
stderr: At
|
|
1130
|
-
};
|
|
1131
|
-
function Yo(e, t, n) {
|
|
1132
|
-
let r = e.indexOf(t);
|
|
1133
|
-
if (r === -1)
|
|
1134
|
-
return e;
|
|
1135
|
-
const s = t.length;
|
|
1136
|
-
let i = 0, a = "";
|
|
1137
|
-
do
|
|
1138
|
-
a += e.slice(i, r) + t + n, i = r + s, r = e.indexOf(t, i);
|
|
1139
|
-
while (r !== -1);
|
|
1140
|
-
return a += e.slice(i), a;
|
|
1141
|
-
}
|
|
1142
|
-
function Go(e, t, n, r) {
|
|
1143
|
-
let s = 0, i = "";
|
|
1144
|
-
do {
|
|
1145
|
-
const a = e[r - 1] === "\r";
|
|
1146
|
-
i += e.slice(s, a ? r - 1 : r) + t + (a ? `\r
|
|
1147
|
-
` : `
|
|
1148
|
-
`) + n, s = r + 1, r = e.indexOf(`
|
|
1149
|
-
`, s);
|
|
1150
|
-
} while (r !== -1);
|
|
1151
|
-
return i += e.slice(s), i;
|
|
1152
|
-
}
|
|
1153
|
-
const { stdout: Tt, stderr: It } = Ko, nt = Symbol("GENERATOR"), de = Symbol("STYLER"), be = Symbol("IS_EMPTY"), Mt = [
|
|
1154
|
-
"ansi",
|
|
1155
|
-
"ansi",
|
|
1156
|
-
"ansi256",
|
|
1157
|
-
"ansi16m"
|
|
1158
|
-
], me = /* @__PURE__ */ Object.create(null), Zo = (e, t = {}) => {
|
|
1159
|
-
if (t.level && !(Number.isInteger(t.level) && t.level >= 0 && t.level <= 3))
|
|
1160
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1161
|
-
const n = Tt ? Tt.level : 0;
|
|
1162
|
-
e.level = t.level === void 0 ? n : t.level;
|
|
1163
|
-
}, Wo = (e) => {
|
|
1164
|
-
const t = (...n) => n.join(" ");
|
|
1165
|
-
return Zo(t, e), Object.setPrototypeOf(t, ve.prototype), t;
|
|
1166
|
-
};
|
|
1167
|
-
function ve(e) {
|
|
1168
|
-
return Wo(e);
|
|
1169
|
-
}
|
|
1170
|
-
Object.setPrototypeOf(ve.prototype, Function.prototype);
|
|
1171
|
-
for (const [e, t] of Object.entries(z))
|
|
1172
|
-
me[e] = {
|
|
1173
|
-
get() {
|
|
1174
|
-
const n = je(this, ot(t.open, t.close, this[de]), this[be]);
|
|
1175
|
-
return Object.defineProperty(this, e, { value: n }), n;
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
me.visible = {
|
|
1179
|
-
get() {
|
|
1180
|
-
const e = je(this, this[de], !0);
|
|
1181
|
-
return Object.defineProperty(this, "visible", { value: e }), e;
|
|
1182
|
-
}
|
|
1183
|
-
};
|
|
1184
|
-
const rt = (e, t, n, ...r) => e === "rgb" ? t === "ansi16m" ? z[n].ansi16m(...r) : t === "ansi256" ? z[n].ansi256(z.rgbToAnsi256(...r)) : z[n].ansi(z.rgbToAnsi(...r)) : e === "hex" ? rt("rgb", t, n, ...z.hexToRgb(...r)) : z[n][e](...r), Jo = ["rgb", "hex", "ansi256"];
|
|
1185
|
-
for (const e of Jo) {
|
|
1186
|
-
me[e] = {
|
|
1187
|
-
get() {
|
|
1188
|
-
const { level: n } = this;
|
|
1189
|
-
return function(...r) {
|
|
1190
|
-
const s = ot(rt(e, Mt[n], "color", ...r), z.color.close, this[de]);
|
|
1191
|
-
return je(this, s, this[be]);
|
|
1192
|
-
};
|
|
1193
|
-
}
|
|
1194
|
-
};
|
|
1195
|
-
const t = "bg" + e[0].toUpperCase() + e.slice(1);
|
|
1196
|
-
me[t] = {
|
|
1197
|
-
get() {
|
|
1198
|
-
const { level: n } = this;
|
|
1199
|
-
return function(...r) {
|
|
1200
|
-
const s = ot(rt(e, Mt[n], "bgColor", ...r), z.bgColor.close, this[de]);
|
|
1201
|
-
return je(this, s, this[be]);
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
const Qo = Object.defineProperties(() => {
|
|
1207
|
-
}, {
|
|
1208
|
-
...me,
|
|
1209
|
-
level: {
|
|
1210
|
-
enumerable: !0,
|
|
1211
|
-
get() {
|
|
1212
|
-
return this[nt].level;
|
|
1213
|
-
},
|
|
1214
|
-
set(e) {
|
|
1215
|
-
this[nt].level = e;
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
}), ot = (e, t, n) => {
|
|
1219
|
-
let r, s;
|
|
1220
|
-
return n === void 0 ? (r = e, s = t) : (r = n.openAll + e, s = t + n.closeAll), {
|
|
1221
|
-
open: e,
|
|
1222
|
-
close: t,
|
|
1223
|
-
openAll: r,
|
|
1224
|
-
closeAll: s,
|
|
1225
|
-
parent: n
|
|
1226
|
-
};
|
|
1227
|
-
}, je = (e, t, n) => {
|
|
1228
|
-
const r = (...s) => Xo(r, s.length === 1 ? "" + s[0] : s.join(" "));
|
|
1229
|
-
return Object.setPrototypeOf(r, Qo), r[nt] = e, r[de] = t, r[be] = n, r;
|
|
1230
|
-
}, Xo = (e, t) => {
|
|
1231
|
-
if (e.level <= 0 || !t)
|
|
1232
|
-
return e[be] ? "" : t;
|
|
1233
|
-
let n = e[de];
|
|
1234
|
-
if (n === void 0)
|
|
1235
|
-
return t;
|
|
1236
|
-
const { openAll: r, closeAll: s } = n;
|
|
1237
|
-
if (t.includes("\x1B"))
|
|
1238
|
-
for (; n !== void 0; )
|
|
1239
|
-
t = Yo(t, n.close, n.open), n = n.parent;
|
|
1240
|
-
const i = t.indexOf(`
|
|
1241
|
-
`);
|
|
1242
|
-
return i !== -1 && (t = Go(t, s, r, i)), r + t + s;
|
|
1243
|
-
};
|
|
1244
|
-
Object.defineProperties(ve.prototype, me);
|
|
1245
|
-
const Oe = ve();
|
|
1246
|
-
ve({ level: It ? It.level : 0 });
|
|
1247
|
-
const un = (e) => async (t) => {
|
|
714
|
+
const Rt = (e) => async (t) => {
|
|
1248
715
|
try {
|
|
1249
716
|
t.flowCallbacks.onCheckoutStarted();
|
|
1250
|
-
const
|
|
1251
|
-
if (
|
|
1252
|
-
t.flowCallbacks.onSetupPaymentMethodSuccess(
|
|
1253
|
-
else if (
|
|
717
|
+
const r = await e(t);
|
|
718
|
+
if (r.mode === "setup")
|
|
719
|
+
t.flowCallbacks.onSetupPaymentMethodSuccess(r.result.payment_method_id);
|
|
720
|
+
else if (r.mode === "checkout")
|
|
1254
721
|
t.flowCallbacks.onCheckoutSuccess(
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
722
|
+
r.result.invoice_urls,
|
|
723
|
+
r.result.subscription_ids,
|
|
724
|
+
r.result.customer_id
|
|
1258
725
|
);
|
|
1259
726
|
else
|
|
1260
|
-
throw new Error(`Unhandled mode: ${
|
|
1261
|
-
} catch (
|
|
1262
|
-
throw t.flowCallbacks.onCheckoutError(
|
|
727
|
+
throw new Error(`Unhandled mode: ${r}`);
|
|
728
|
+
} catch (r) {
|
|
729
|
+
throw t.flowCallbacks.onCheckoutError(pe(r)), r;
|
|
1263
730
|
}
|
|
1264
|
-
},
|
|
731
|
+
}, Lr = (e) => async (t) => {
|
|
1265
732
|
try {
|
|
1266
733
|
return await e(t);
|
|
1267
|
-
} catch (
|
|
1268
|
-
const { err__:
|
|
1269
|
-
return r
|
|
734
|
+
} catch (r) {
|
|
735
|
+
const { err__: o } = J("init-error-catcher");
|
|
736
|
+
return o(r), { isAvailable: !1, reason: pe(r) };
|
|
1270
737
|
}
|
|
1271
|
-
},
|
|
1272
|
-
const t = (...
|
|
1273
|
-
window.console.log(`${
|
|
1274
|
-
},
|
|
1275
|
-
window.console.error(`${
|
|
738
|
+
}, J = (e) => {
|
|
739
|
+
const t = (...o) => {
|
|
740
|
+
window.console.log(`${ae.green.bold("ojs/")}${ae.bold.gray(`${e}`)} `, ...o);
|
|
741
|
+
}, r = (...o) => {
|
|
742
|
+
window.console.error(`${ae.red.bold("ojs/")}${ae.bold.gray(`${e}`)} `, ...o);
|
|
1276
743
|
};
|
|
1277
744
|
return {
|
|
1278
745
|
log: t,
|
|
1279
|
-
err:
|
|
746
|
+
err: r,
|
|
1280
747
|
log__: t,
|
|
1281
|
-
err__:
|
|
748
|
+
err__: r
|
|
1282
749
|
};
|
|
1283
|
-
}, { log__:
|
|
1284
|
-
const
|
|
1285
|
-
if (!
|
|
1286
|
-
const
|
|
750
|
+
}, { log__: $r, err__: kt } = J("common-cc"), Tt = (e, t) => {
|
|
751
|
+
const r = oe.safeParse(e);
|
|
752
|
+
if (!r.success) {
|
|
753
|
+
const o = r.error.format(), s = pt(o);
|
|
1287
754
|
for (const [i, a] of Object.entries(s))
|
|
1288
755
|
t(i, a, i);
|
|
1289
|
-
throw
|
|
756
|
+
throw kt("Got validation errors in non-CDE form fields", s), new Error("Got validation errors in non-CDE form fields");
|
|
1290
757
|
}
|
|
1291
|
-
return
|
|
1292
|
-
},
|
|
1293
|
-
for (const
|
|
1294
|
-
if (
|
|
1295
|
-
throw
|
|
1296
|
-
const s =
|
|
758
|
+
return r.data;
|
|
759
|
+
}, Ur = (e, t) => {
|
|
760
|
+
for (const r of e)
|
|
761
|
+
if (r.success === !1)
|
|
762
|
+
throw r.errors.forEach((o) => {
|
|
763
|
+
const s = dt.safeParse(o.elementType);
|
|
1297
764
|
if (!s.success)
|
|
1298
|
-
|
|
765
|
+
kt(`Unknown field name in onValidationError: ${o.elementType}`);
|
|
1299
766
|
else {
|
|
1300
767
|
const i = s.data;
|
|
1301
|
-
t(i,
|
|
768
|
+
t(i, o.errors);
|
|
1302
769
|
}
|
|
1303
|
-
}),
|
|
1304
|
-
}, { err__:
|
|
770
|
+
}), $r(`Error tokenizing card: got validation errors: ${JSON.stringify(r.errors)}`), new Error("Got validation errors while tokenizing card");
|
|
771
|
+
}, { err__: Ae } = J("commmon"), At = (e) => {
|
|
1305
772
|
if (e.payment_methods.length !== 1)
|
|
1306
773
|
throw new Error(`Expected exactly one payment method, got ${e.payment_methods.length}`);
|
|
1307
774
|
return { payment_method_id: e.payment_methods[0].id };
|
|
1308
|
-
},
|
|
1309
|
-
const
|
|
1310
|
-
if (!
|
|
1311
|
-
throw
|
|
1312
|
-
return t.parse(
|
|
1313
|
-
}, { log__:
|
|
1314
|
-
async ({ context: e, checkoutPaymentMethod: t, nonCdeFormInputs:
|
|
1315
|
-
var
|
|
1316
|
-
|
|
1317
|
-
const s = Array.from(e.cdeConnections.values())[0], i = await
|
|
1318
|
-
|
|
1319
|
-
const a =
|
|
1320
|
-
|
|
1321
|
-
const c = await
|
|
775
|
+
}, qr = (e, t) => {
|
|
776
|
+
const r = e.find((o) => t.safeParse(o).success);
|
|
777
|
+
if (!r)
|
|
778
|
+
throw Ae(`No CPMs found for model ${t}`), Ae(e), Ae("zodModel"), new Error(`No CPMs found for model ${t}`);
|
|
779
|
+
return t.parse(r);
|
|
780
|
+
}, { log__: P, err__: et } = J("common-cc"), { log__: tt } = J("stripe-cc"), zr = Rt(
|
|
781
|
+
async ({ context: e, checkoutPaymentMethod: t, nonCdeFormInputs: r, flowCallbacks: o }) => {
|
|
782
|
+
var d;
|
|
783
|
+
P("├ Running common CC flow...", { checkoutPaymentMethod: t });
|
|
784
|
+
const s = Array.from(e.cdeConnections.values())[0], i = await se(s);
|
|
785
|
+
P(`├ Validating non-CDE form fields [Mode: ${i.mode}]`);
|
|
786
|
+
const a = Tt(r, o.onValidationError);
|
|
787
|
+
P(`├ Tokenizing card info in CDE [Session: ${e.elementsSessionId}]`);
|
|
788
|
+
const c = await kr(e.cdeConnections, {
|
|
1322
789
|
session_id: e.elementsSessionId
|
|
1323
790
|
});
|
|
1324
|
-
|
|
1325
|
-
const
|
|
791
|
+
Ur(c, o.onValidationError);
|
|
792
|
+
const l = {
|
|
1326
793
|
session_id: e.elementsSessionId,
|
|
1327
794
|
checkout_payment_method: t,
|
|
1328
795
|
non_cde_form_fields: a
|
|
1329
796
|
};
|
|
1330
797
|
try {
|
|
1331
798
|
if (i.mode === "setup") {
|
|
1332
|
-
|
|
1333
|
-
const
|
|
1334
|
-
return
|
|
799
|
+
P(`├ Setting up payment method in CDE [Token: ${i.token}]`);
|
|
800
|
+
const m = await Tr(s, l);
|
|
801
|
+
return P(`╰ Setup completed successfully [PM ID: ${m.payment_method_id}]`), { mode: "setup", result: m };
|
|
1335
802
|
} else {
|
|
1336
|
-
|
|
1337
|
-
const
|
|
1338
|
-
return
|
|
803
|
+
P(`├ Initial checkout flow. Checking out card info in CDE [Session: ${e.elementsSessionId}]`);
|
|
804
|
+
const m = await Xe(s, l);
|
|
805
|
+
return P("╰ Checkout completed successfully."), { mode: "checkout", result: m };
|
|
1339
806
|
}
|
|
1340
|
-
} catch (
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1343
|
-
const
|
|
1344
|
-
if (
|
|
1345
|
-
|
|
1346
|
-
const
|
|
807
|
+
} catch (m) {
|
|
808
|
+
if (m instanceof Pt && m.originalErrorMessage === "3DS_REQUIRED") {
|
|
809
|
+
P("├ Card requires 3DS, starting non-legacy payment flow");
|
|
810
|
+
const E = ((d = m.response.headers) == null ? void 0 : d["op-should-use-new-flow"]) === "true", g = await Pr(s, l);
|
|
811
|
+
if (P(`├ op-should-use-new-flow: ${E}`), P("├ Payment flow result:", g), E ? await Kr(g, e.baseUrl) : await Yr(g), i.mode === "setup") {
|
|
812
|
+
P(`├ Confirming payment flow [cc_pm_id: ${g.cc_pm_id}]`);
|
|
813
|
+
const _ = await xe(s, {
|
|
1347
814
|
secure_token: i.token,
|
|
1348
|
-
existing_cc_pm_id:
|
|
815
|
+
existing_cc_pm_id: g.cc_pm_id
|
|
1349
816
|
});
|
|
1350
|
-
|
|
1351
|
-
const
|
|
1352
|
-
return
|
|
817
|
+
P("├ Confirm payment flow result received Result:", _);
|
|
818
|
+
const h = At(_);
|
|
819
|
+
return P(`╰ Setup completed successfully [PM ID: ${h.payment_method_id}]`), { mode: "setup", result: h };
|
|
1353
820
|
} else {
|
|
1354
|
-
|
|
1355
|
-
const
|
|
1356
|
-
...
|
|
1357
|
-
existing_cc_pm_id:
|
|
1358
|
-
do_not_use_legacy_cc_flow: !
|
|
821
|
+
P(`├ Checking out after 3DS flow [Flow: ${E ? "new" : "legacy"}]`);
|
|
822
|
+
const _ = await Xe(s, {
|
|
823
|
+
...l,
|
|
824
|
+
existing_cc_pm_id: g.cc_pm_id,
|
|
825
|
+
do_not_use_legacy_cc_flow: !E
|
|
1359
826
|
});
|
|
1360
|
-
return
|
|
827
|
+
return P("╰ Checkout completed successfully."), { mode: "checkout", result: _ };
|
|
1361
828
|
}
|
|
1362
829
|
}
|
|
1363
|
-
throw
|
|
830
|
+
throw et("╰ Error checking out card info in CDE"), et(m), m;
|
|
1364
831
|
}
|
|
1365
832
|
}
|
|
1366
|
-
),
|
|
1367
|
-
const t = e.required_user_actions.find((
|
|
833
|
+
), Hr = (e) => {
|
|
834
|
+
const t = e.required_user_actions.find((r) => r.type === "stripe_3ds");
|
|
1368
835
|
if (!t)
|
|
1369
836
|
throw new Error("No stripe 3DS action found");
|
|
1370
|
-
return
|
|
1371
|
-
},
|
|
1372
|
-
const t = e.required_user_actions.find((
|
|
837
|
+
return yt.parse(t);
|
|
838
|
+
}, Vr = (e) => {
|
|
839
|
+
const t = e.required_user_actions.find((r) => r.type === "airwallex_payment_consent");
|
|
1373
840
|
if (!t)
|
|
1374
841
|
throw new Error("No common 3DS action found");
|
|
1375
|
-
return
|
|
1376
|
-
},
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1380
|
-
if (
|
|
842
|
+
return zn.parse(t);
|
|
843
|
+
}, Kr = async (e, t) => {
|
|
844
|
+
const r = Vr(e);
|
|
845
|
+
P(`├ Using common 3DS flow [URL: ${r.redirect_url}]`);
|
|
846
|
+
const o = await xr({ url: r.redirect_url, baseUrl: t });
|
|
847
|
+
if (P(`╰ 3DS verification completed [Status: ${o}]`), o === me.CANCELLED)
|
|
1381
848
|
throw new Error("3DS verification cancelled");
|
|
1382
|
-
if (
|
|
849
|
+
if (o === me.FAILURE)
|
|
1383
850
|
throw new Error("3DS verification failed");
|
|
1384
|
-
},
|
|
1385
|
-
const t =
|
|
1386
|
-
|
|
1387
|
-
}, { log__:
|
|
1388
|
-
provider:
|
|
1389
|
-
processor_name:
|
|
1390
|
-
metadata:
|
|
1391
|
-
stripe_pk:
|
|
851
|
+
}, Yr = async (e) => {
|
|
852
|
+
const t = Hr(e);
|
|
853
|
+
tt(`├ Using stripe 3DS flow [Client Secret: ${t.client_secret.substring(0, 8)}...]`), await gt(t), tt("╰ Stripe 3DS flow completed successfully");
|
|
854
|
+
}, { log__: T, err__: Zr } = J("stripe-pr"), Jr = n.object({
|
|
855
|
+
provider: n.union([n.literal("apple_pay"), n.literal("google_pay")]),
|
|
856
|
+
processor_name: n.literal("stripe"),
|
|
857
|
+
metadata: n.object({
|
|
858
|
+
stripe_pk: n.string()
|
|
1392
859
|
})
|
|
1393
|
-
}),
|
|
860
|
+
}), Wr = Lr(
|
|
1394
861
|
async ({ context: e }) => {
|
|
1395
|
-
|
|
1396
|
-
const t =
|
|
1397
|
-
|
|
1398
|
-
const
|
|
1399
|
-
|
|
1400
|
-
const i = await
|
|
862
|
+
T("Checking if there are any CPMs for Stripe PR...");
|
|
863
|
+
const t = qr(e.checkoutPaymentMethods, Jr);
|
|
864
|
+
T("Initializing Stripe PR flow...");
|
|
865
|
+
const r = Array.from(e.cdeConnections.values())[0], o = await se(r), s = o.mode === "setup";
|
|
866
|
+
T("Getting initial preview amount");
|
|
867
|
+
const i = await vt(r, o.token, s, void 0), a = await Kn(
|
|
1401
868
|
t.metadata.stripe_pk,
|
|
1402
869
|
i.amountAtom,
|
|
1403
870
|
i.currency,
|
|
1404
871
|
s
|
|
1405
872
|
);
|
|
1406
|
-
|
|
873
|
+
T("Checking if can make payment");
|
|
1407
874
|
const c = await a.canMakePayment();
|
|
1408
|
-
return c === null ? (
|
|
875
|
+
return c === null ? (Zr("canMakePayment returned null"), { isAvailable: !1, reason: "canMakePayment returned null" }) : (T("Stripe PR flow initialized successfully. Can make payment", c), {
|
|
1409
876
|
isAvailable: !0,
|
|
1410
877
|
pr: a,
|
|
1411
878
|
availableProviders: {
|
|
@@ -1414,217 +881,218 @@ const un = (e) => async (t) => {
|
|
|
1414
881
|
}
|
|
1415
882
|
});
|
|
1416
883
|
}
|
|
1417
|
-
),
|
|
884
|
+
), Br = Rt(
|
|
1418
885
|
async ({
|
|
1419
886
|
context: e,
|
|
1420
887
|
checkoutPaymentMethod: t,
|
|
1421
|
-
nonCdeFormInputs:
|
|
1422
|
-
flowCallbacks:
|
|
888
|
+
nonCdeFormInputs: r,
|
|
889
|
+
flowCallbacks: o,
|
|
1423
890
|
customParams: s,
|
|
1424
891
|
initResult: i
|
|
1425
892
|
}) => {
|
|
1426
|
-
if (
|
|
893
|
+
if (T("Running Stripe PR flow..."), s.provider !== t.provider)
|
|
1427
894
|
throw new Error(`Provider mismatch. Expected ${s.provider}, got ${t.provider}`);
|
|
1428
895
|
const a = Array.from(e.cdeConnections.values())[0], c = i.pr;
|
|
1429
|
-
F("Validating non-CDE form fields");
|
|
1430
|
-
const d = fs(n), l = mn(d, r.onValidationError);
|
|
1431
896
|
if (s != null && s.overridePaymentRequest) {
|
|
1432
|
-
const
|
|
1433
|
-
|
|
897
|
+
const h = s.overridePaymentRequest;
|
|
898
|
+
T("Overriding PR amount with", h), Qr(c, h.amount, h.pending);
|
|
1434
899
|
}
|
|
1435
|
-
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1438
|
-
const
|
|
1439
|
-
|
|
900
|
+
T("Showing PR dialog..."), c.show();
|
|
901
|
+
const l = await Yn(c);
|
|
902
|
+
T("Stripe PM added event:", l), T("Merging PM fields with form fields...");
|
|
903
|
+
const d = Gr(r, l), m = Tt(d, o.onValidationError);
|
|
904
|
+
T("PR dialog finished. Starting payment flow...");
|
|
905
|
+
const E = await vr(a, {
|
|
906
|
+
fields: m,
|
|
1440
907
|
checkoutPaymentMethod: t
|
|
1441
|
-
}),
|
|
1442
|
-
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1445
|
-
|
|
1446
|
-
const
|
|
1447
|
-
secure_token:
|
|
908
|
+
}), g = Xr(E);
|
|
909
|
+
T("Confirming PR with Stripe..."), await Jn(g, l);
|
|
910
|
+
const _ = await se(a);
|
|
911
|
+
if (_.mode === "setup") {
|
|
912
|
+
T("Confirming payment flow for setup...");
|
|
913
|
+
const h = await xe(a, {
|
|
914
|
+
secure_token: _.token
|
|
1448
915
|
});
|
|
1449
|
-
return { mode: "setup", result:
|
|
916
|
+
return { mode: "setup", result: At(h) };
|
|
1450
917
|
} else {
|
|
1451
|
-
|
|
1452
|
-
const
|
|
1453
|
-
secure_token:
|
|
918
|
+
T("Performing checkout...");
|
|
919
|
+
const h = {
|
|
920
|
+
secure_token: _.token,
|
|
1454
921
|
payment_input: {
|
|
1455
922
|
provider_type: t.provider
|
|
1456
923
|
},
|
|
1457
|
-
customer_email:
|
|
1458
|
-
customer_zip_code:
|
|
1459
|
-
customer_country:
|
|
1460
|
-
promotion_code:
|
|
1461
|
-
line_items:
|
|
1462
|
-
total_amount_atom:
|
|
924
|
+
customer_email: m[C.EMAIL],
|
|
925
|
+
customer_zip_code: m[C.ZIP_CODE],
|
|
926
|
+
customer_country: m[C.COUNTRY],
|
|
927
|
+
promotion_code: m[C.PROMOTION_CODE],
|
|
928
|
+
line_items: _.line_items,
|
|
929
|
+
total_amount_atom: _.amount_total_atom,
|
|
1463
930
|
cancel_at_end: !1,
|
|
1464
931
|
checkout_payment_method: t
|
|
1465
932
|
};
|
|
1466
|
-
return { mode: "checkout", result: await
|
|
933
|
+
return { mode: "checkout", result: await Ar(a, h) };
|
|
1467
934
|
}
|
|
1468
935
|
}
|
|
1469
|
-
),
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
936
|
+
), Gr = (e, t) => {
|
|
937
|
+
var a, c, l, d;
|
|
938
|
+
const r = { ...e }, [o, ...s] = ((c = (a = t.payerName) == null ? void 0 : a.trim()) == null ? void 0 : c.split(/\s+/)) ?? [], i = s.join(" ") || void 0;
|
|
939
|
+
return r[C.FIRST_NAME] = r[C.FIRST_NAME] || o || "_OP_UNKNOWN", r[C.LAST_NAME] = r[C.LAST_NAME] || i || "_OP_UNKNOWN", r[C.EMAIL] = r[C.EMAIL] || t.payerEmail || "op_unfilled@getopenpay.com", r[C.ZIP_CODE] = r[C.ZIP_CODE] || ((l = t.shippingAddress) == null ? void 0 : l.postalCode) || "00000", r[C.COUNTRY] = r[C.COUNTRY] || ((d = t.shippingAddress) == null ? void 0 : d.country) || "US", T("Final form inputs:", r), r;
|
|
940
|
+
}, Qr = (e, t, r) => {
|
|
1473
941
|
e.update({
|
|
1474
942
|
total: {
|
|
1475
943
|
amount: t.amountAtom,
|
|
1476
944
|
label: "Total",
|
|
1477
|
-
pending:
|
|
945
|
+
pending: r
|
|
1478
946
|
},
|
|
1479
947
|
currency: t.currency
|
|
1480
948
|
});
|
|
1481
|
-
},
|
|
949
|
+
}, Xr = (e) => {
|
|
1482
950
|
if (e.required_user_actions.length !== 1)
|
|
1483
951
|
throw new Error(`Error occurred.
|
|
1484
952
|
Details: got ${e.required_user_actions.length} required user actions`);
|
|
1485
|
-
return
|
|
1486
|
-
},
|
|
1487
|
-
const
|
|
1488
|
-
if (
|
|
1489
|
-
throw new Error(`No CPMs found with provider '${t}' and processor '${
|
|
1490
|
-
if (
|
|
1491
|
-
throw new Error(`More than one CPM found with provider '${t}' and processor '${
|
|
1492
|
-
return
|
|
1493
|
-
},
|
|
953
|
+
return Hn.parse(e.required_user_actions[0]);
|
|
954
|
+
}, nt = (e, t, r) => {
|
|
955
|
+
const o = e.filter((s) => s.provider === t);
|
|
956
|
+
if (o.length === 0)
|
|
957
|
+
throw new Error(`No CPMs found with provider '${t}' and processor '${r}'`);
|
|
958
|
+
if (o.length !== 1)
|
|
959
|
+
throw new Error(`More than one CPM found with provider '${t}' and processor '${r}'`);
|
|
960
|
+
return o[0];
|
|
961
|
+
}, Fe = {
|
|
1494
962
|
// ✋ Note: For flows that require initialization, please add them to `init-flows.ts`
|
|
1495
963
|
// Stripe
|
|
1496
964
|
commonCC: {
|
|
1497
|
-
run:
|
|
965
|
+
run: zr
|
|
1498
966
|
},
|
|
1499
967
|
stripePR: {
|
|
1500
|
-
init:
|
|
1501
|
-
run:
|
|
968
|
+
init: Wr,
|
|
969
|
+
run: Br
|
|
1502
970
|
}
|
|
1503
971
|
// 👉 Add more flows here
|
|
1504
972
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1505
973
|
};
|
|
1506
|
-
function
|
|
974
|
+
function It(e) {
|
|
1507
975
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
1508
976
|
}
|
|
1509
|
-
var
|
|
1510
|
-
Object.defineProperty(
|
|
977
|
+
var he = {};
|
|
978
|
+
Object.defineProperty(he, "__esModule", {
|
|
1511
979
|
value: !0
|
|
1512
980
|
});
|
|
1513
|
-
|
|
1514
|
-
const
|
|
1515
|
-
function
|
|
1516
|
-
let
|
|
1517
|
-
if (
|
|
1518
|
-
if (typeof
|
|
1519
|
-
return
|
|
981
|
+
he.Observable = void 0;
|
|
982
|
+
const jt = (e) => !!Symbol[e], Le = (e) => jt(e) ? Symbol[e] : "@@" + e, eo = Le("iterator"), De = Le("observable"), Mt = Le("species");
|
|
983
|
+
function fe(e, t) {
|
|
984
|
+
let r = e[t];
|
|
985
|
+
if (r != null) {
|
|
986
|
+
if (typeof r != "function") throw new TypeError(r + " is not a function");
|
|
987
|
+
return r;
|
|
1520
988
|
}
|
|
1521
989
|
}
|
|
1522
|
-
function
|
|
990
|
+
function ne(e) {
|
|
1523
991
|
let t = e.constructor;
|
|
1524
|
-
return t !== void 0 && (t = t[
|
|
992
|
+
return t !== void 0 && (t = t[Mt], t === null && (t = void 0)), t !== void 0 ? t : we;
|
|
1525
993
|
}
|
|
1526
|
-
function
|
|
1527
|
-
return e instanceof
|
|
994
|
+
function to(e) {
|
|
995
|
+
return e instanceof we;
|
|
1528
996
|
}
|
|
1529
|
-
function
|
|
1530
|
-
|
|
997
|
+
function X(e) {
|
|
998
|
+
X.log ? X.log(e) : setTimeout(() => {
|
|
1531
999
|
throw e;
|
|
1532
1000
|
});
|
|
1533
1001
|
}
|
|
1534
|
-
function
|
|
1002
|
+
function le(e) {
|
|
1535
1003
|
Promise.resolve().then(() => {
|
|
1536
1004
|
try {
|
|
1537
1005
|
e();
|
|
1538
1006
|
} catch (t) {
|
|
1539
|
-
|
|
1007
|
+
X(t);
|
|
1540
1008
|
}
|
|
1541
1009
|
});
|
|
1542
1010
|
}
|
|
1543
|
-
function
|
|
1011
|
+
function Ft(e) {
|
|
1544
1012
|
let t = e._cleanup;
|
|
1545
1013
|
if (t !== void 0 && (e._cleanup = void 0, !!t))
|
|
1546
1014
|
try {
|
|
1547
1015
|
if (typeof t == "function")
|
|
1548
1016
|
t();
|
|
1549
1017
|
else {
|
|
1550
|
-
let
|
|
1551
|
-
|
|
1018
|
+
let r = fe(t, "unsubscribe");
|
|
1019
|
+
r && r.call(t);
|
|
1552
1020
|
}
|
|
1553
|
-
} catch (
|
|
1554
|
-
|
|
1021
|
+
} catch (r) {
|
|
1022
|
+
X(r);
|
|
1555
1023
|
}
|
|
1556
1024
|
}
|
|
1557
|
-
function
|
|
1025
|
+
function Ne(e) {
|
|
1558
1026
|
e._observer = void 0, e._queue = void 0, e._state = "closed";
|
|
1559
1027
|
}
|
|
1560
|
-
function
|
|
1028
|
+
function no(e) {
|
|
1561
1029
|
let t = e._queue;
|
|
1562
1030
|
if (t) {
|
|
1563
1031
|
e._queue = void 0, e._state = "ready";
|
|
1564
|
-
for (let
|
|
1032
|
+
for (let r = 0; r < t.length && (Dt(e, t[r].type, t[r].value), e._state !== "closed"); ++r)
|
|
1565
1033
|
;
|
|
1566
1034
|
}
|
|
1567
1035
|
}
|
|
1568
|
-
function
|
|
1036
|
+
function Dt(e, t, r) {
|
|
1569
1037
|
e._state = "running";
|
|
1570
|
-
let
|
|
1038
|
+
let o = e._observer;
|
|
1571
1039
|
try {
|
|
1572
|
-
let s =
|
|
1040
|
+
let s = fe(o, t);
|
|
1573
1041
|
switch (t) {
|
|
1574
1042
|
case "next":
|
|
1575
|
-
s && s.call(
|
|
1043
|
+
s && s.call(o, r);
|
|
1576
1044
|
break;
|
|
1577
1045
|
case "error":
|
|
1578
|
-
if (
|
|
1579
|
-
else throw
|
|
1046
|
+
if (Ne(e), s) s.call(o, r);
|
|
1047
|
+
else throw r;
|
|
1580
1048
|
break;
|
|
1581
1049
|
case "complete":
|
|
1582
|
-
|
|
1050
|
+
Ne(e), s && s.call(o);
|
|
1583
1051
|
break;
|
|
1584
1052
|
}
|
|
1585
1053
|
} catch (s) {
|
|
1586
|
-
|
|
1054
|
+
X(s);
|
|
1587
1055
|
}
|
|
1588
|
-
e._state === "closed" ?
|
|
1056
|
+
e._state === "closed" ? Ft(e) : e._state === "running" && (e._state = "ready");
|
|
1589
1057
|
}
|
|
1590
|
-
function
|
|
1058
|
+
function Ie(e, t, r) {
|
|
1591
1059
|
if (e._state !== "closed") {
|
|
1592
1060
|
if (e._state === "buffering") {
|
|
1593
1061
|
e._queue.push({
|
|
1594
1062
|
type: t,
|
|
1595
|
-
value:
|
|
1063
|
+
value: r
|
|
1596
1064
|
});
|
|
1597
1065
|
return;
|
|
1598
1066
|
}
|
|
1599
1067
|
if (e._state !== "ready") {
|
|
1600
1068
|
e._state = "buffering", e._queue = [{
|
|
1601
1069
|
type: t,
|
|
1602
|
-
value:
|
|
1603
|
-
}],
|
|
1070
|
+
value: r
|
|
1071
|
+
}], le(() => no(e));
|
|
1604
1072
|
return;
|
|
1605
1073
|
}
|
|
1606
|
-
|
|
1074
|
+
Dt(e, t, r);
|
|
1607
1075
|
}
|
|
1608
1076
|
}
|
|
1609
|
-
class
|
|
1610
|
-
constructor(t,
|
|
1077
|
+
class ro {
|
|
1078
|
+
constructor(t, r) {
|
|
1611
1079
|
this._cleanup = void 0, this._observer = t, this._queue = void 0, this._state = "initializing";
|
|
1612
|
-
let
|
|
1080
|
+
let o = this, s = {
|
|
1613
1081
|
get closed() {
|
|
1614
|
-
return
|
|
1082
|
+
return o._state === "closed";
|
|
1615
1083
|
},
|
|
1616
1084
|
next(i) {
|
|
1617
|
-
|
|
1085
|
+
Ie(o, "next", i);
|
|
1618
1086
|
},
|
|
1619
1087
|
error(i) {
|
|
1620
|
-
|
|
1088
|
+
Ie(o, "error", i);
|
|
1621
1089
|
},
|
|
1622
1090
|
complete() {
|
|
1623
|
-
|
|
1091
|
+
Ie(o, "complete");
|
|
1624
1092
|
}
|
|
1625
1093
|
};
|
|
1626
1094
|
try {
|
|
1627
|
-
this._cleanup =
|
|
1095
|
+
this._cleanup = r.call(void 0, s);
|
|
1628
1096
|
} catch (i) {
|
|
1629
1097
|
s.error(i);
|
|
1630
1098
|
}
|
|
@@ -1634,12 +1102,12 @@ class ws {
|
|
|
1634
1102
|
return this._state === "closed";
|
|
1635
1103
|
}
|
|
1636
1104
|
unsubscribe() {
|
|
1637
|
-
this._state !== "closed" && (
|
|
1105
|
+
this._state !== "closed" && (Ne(this), Ft(this));
|
|
1638
1106
|
}
|
|
1639
1107
|
}
|
|
1640
|
-
let
|
|
1108
|
+
let we = class ue {
|
|
1641
1109
|
constructor(t) {
|
|
1642
|
-
if (!(this instanceof
|
|
1110
|
+
if (!(this instanceof ue)) throw new TypeError("Observable cannot be called as a function");
|
|
1643
1111
|
if (typeof t != "function") throw new TypeError("Observable initializer must be a function");
|
|
1644
1112
|
this._subscriber = t;
|
|
1645
1113
|
}
|
|
@@ -1648,112 +1116,112 @@ let Ue = class Te {
|
|
|
1648
1116
|
next: t,
|
|
1649
1117
|
error: arguments[1],
|
|
1650
1118
|
complete: arguments[2]
|
|
1651
|
-
}), new
|
|
1119
|
+
}), new ro(t, this._subscriber);
|
|
1652
1120
|
}
|
|
1653
1121
|
forEach(t) {
|
|
1654
|
-
return new Promise((
|
|
1122
|
+
return new Promise((r, o) => {
|
|
1655
1123
|
if (typeof t != "function") {
|
|
1656
|
-
|
|
1124
|
+
o(new TypeError(t + " is not a function"));
|
|
1657
1125
|
return;
|
|
1658
1126
|
}
|
|
1659
1127
|
function s() {
|
|
1660
|
-
i.unsubscribe(),
|
|
1128
|
+
i.unsubscribe(), r();
|
|
1661
1129
|
}
|
|
1662
1130
|
let i = this.subscribe({
|
|
1663
1131
|
next(a) {
|
|
1664
1132
|
try {
|
|
1665
1133
|
t(a, s);
|
|
1666
1134
|
} catch (c) {
|
|
1667
|
-
|
|
1135
|
+
o(c), i.unsubscribe();
|
|
1668
1136
|
}
|
|
1669
1137
|
},
|
|
1670
|
-
error:
|
|
1671
|
-
complete:
|
|
1138
|
+
error: o,
|
|
1139
|
+
complete: r
|
|
1672
1140
|
});
|
|
1673
1141
|
});
|
|
1674
1142
|
}
|
|
1675
1143
|
map(t) {
|
|
1676
1144
|
if (typeof t != "function") throw new TypeError(t + " is not a function");
|
|
1677
|
-
let
|
|
1678
|
-
return new
|
|
1145
|
+
let r = ne(this);
|
|
1146
|
+
return new r((o) => this.subscribe({
|
|
1679
1147
|
next(s) {
|
|
1680
1148
|
try {
|
|
1681
1149
|
s = t(s);
|
|
1682
1150
|
} catch (i) {
|
|
1683
|
-
return
|
|
1151
|
+
return o.error(i);
|
|
1684
1152
|
}
|
|
1685
|
-
|
|
1153
|
+
o.next(s);
|
|
1686
1154
|
},
|
|
1687
1155
|
error(s) {
|
|
1688
|
-
|
|
1156
|
+
o.error(s);
|
|
1689
1157
|
},
|
|
1690
1158
|
complete() {
|
|
1691
|
-
|
|
1159
|
+
o.complete();
|
|
1692
1160
|
}
|
|
1693
1161
|
}));
|
|
1694
1162
|
}
|
|
1695
1163
|
filter(t) {
|
|
1696
1164
|
if (typeof t != "function") throw new TypeError(t + " is not a function");
|
|
1697
|
-
let
|
|
1698
|
-
return new
|
|
1165
|
+
let r = ne(this);
|
|
1166
|
+
return new r((o) => this.subscribe({
|
|
1699
1167
|
next(s) {
|
|
1700
1168
|
try {
|
|
1701
1169
|
if (!t(s)) return;
|
|
1702
1170
|
} catch (i) {
|
|
1703
|
-
return
|
|
1171
|
+
return o.error(i);
|
|
1704
1172
|
}
|
|
1705
|
-
|
|
1173
|
+
o.next(s);
|
|
1706
1174
|
},
|
|
1707
1175
|
error(s) {
|
|
1708
|
-
|
|
1176
|
+
o.error(s);
|
|
1709
1177
|
},
|
|
1710
1178
|
complete() {
|
|
1711
|
-
|
|
1179
|
+
o.complete();
|
|
1712
1180
|
}
|
|
1713
1181
|
}));
|
|
1714
1182
|
}
|
|
1715
1183
|
reduce(t) {
|
|
1716
1184
|
if (typeof t != "function") throw new TypeError(t + " is not a function");
|
|
1717
|
-
let
|
|
1718
|
-
return new
|
|
1719
|
-
next(
|
|
1720
|
-
let
|
|
1721
|
-
if (s = !0, !
|
|
1185
|
+
let r = ne(this), o = arguments.length > 1, s = !1, a = arguments[1];
|
|
1186
|
+
return new r((c) => this.subscribe({
|
|
1187
|
+
next(l) {
|
|
1188
|
+
let d = !s;
|
|
1189
|
+
if (s = !0, !d || o)
|
|
1722
1190
|
try {
|
|
1723
|
-
a = t(a,
|
|
1724
|
-
} catch (
|
|
1725
|
-
return c.error(
|
|
1191
|
+
a = t(a, l);
|
|
1192
|
+
} catch (m) {
|
|
1193
|
+
return c.error(m);
|
|
1726
1194
|
}
|
|
1727
1195
|
else
|
|
1728
|
-
a =
|
|
1196
|
+
a = l;
|
|
1729
1197
|
},
|
|
1730
|
-
error(
|
|
1731
|
-
c.error(
|
|
1198
|
+
error(l) {
|
|
1199
|
+
c.error(l);
|
|
1732
1200
|
},
|
|
1733
1201
|
complete() {
|
|
1734
|
-
if (!s && !
|
|
1202
|
+
if (!s && !o) return c.error(new TypeError("Cannot reduce an empty sequence"));
|
|
1735
1203
|
c.next(a), c.complete();
|
|
1736
1204
|
}
|
|
1737
1205
|
}));
|
|
1738
1206
|
}
|
|
1739
1207
|
async all() {
|
|
1740
1208
|
let t = [];
|
|
1741
|
-
return await this.forEach((
|
|
1209
|
+
return await this.forEach((r) => t.push(r)), t;
|
|
1742
1210
|
}
|
|
1743
1211
|
concat(...t) {
|
|
1744
|
-
let
|
|
1745
|
-
return new
|
|
1212
|
+
let r = ne(this);
|
|
1213
|
+
return new r((o) => {
|
|
1746
1214
|
let s, i = 0;
|
|
1747
1215
|
function a(c) {
|
|
1748
1216
|
s = c.subscribe({
|
|
1749
|
-
next(
|
|
1750
|
-
|
|
1217
|
+
next(l) {
|
|
1218
|
+
o.next(l);
|
|
1751
1219
|
},
|
|
1752
|
-
error(
|
|
1753
|
-
|
|
1220
|
+
error(l) {
|
|
1221
|
+
o.error(l);
|
|
1754
1222
|
},
|
|
1755
1223
|
complete() {
|
|
1756
|
-
i === t.length ? (s = void 0,
|
|
1224
|
+
i === t.length ? (s = void 0, o.complete()) : a(r.from(t[i++]));
|
|
1757
1225
|
}
|
|
1758
1226
|
});
|
|
1759
1227
|
}
|
|
@@ -1764,70 +1232,70 @@ let Ue = class Te {
|
|
|
1764
1232
|
}
|
|
1765
1233
|
flatMap(t) {
|
|
1766
1234
|
if (typeof t != "function") throw new TypeError(t + " is not a function");
|
|
1767
|
-
let
|
|
1768
|
-
return new
|
|
1235
|
+
let r = ne(this);
|
|
1236
|
+
return new r((o) => {
|
|
1769
1237
|
let s = [], i = this.subscribe({
|
|
1770
1238
|
next(c) {
|
|
1771
1239
|
if (t)
|
|
1772
1240
|
try {
|
|
1773
1241
|
c = t(c);
|
|
1774
|
-
} catch (
|
|
1775
|
-
return
|
|
1242
|
+
} catch (d) {
|
|
1243
|
+
return o.error(d);
|
|
1776
1244
|
}
|
|
1777
|
-
let
|
|
1778
|
-
next(
|
|
1779
|
-
|
|
1245
|
+
let l = r.from(c).subscribe({
|
|
1246
|
+
next(d) {
|
|
1247
|
+
o.next(d);
|
|
1780
1248
|
},
|
|
1781
|
-
error(
|
|
1782
|
-
|
|
1249
|
+
error(d) {
|
|
1250
|
+
o.error(d);
|
|
1783
1251
|
},
|
|
1784
1252
|
complete() {
|
|
1785
|
-
let
|
|
1786
|
-
|
|
1253
|
+
let d = s.indexOf(l);
|
|
1254
|
+
d >= 0 && s.splice(d, 1), a();
|
|
1787
1255
|
}
|
|
1788
1256
|
});
|
|
1789
|
-
s.push(
|
|
1257
|
+
s.push(l);
|
|
1790
1258
|
},
|
|
1791
1259
|
error(c) {
|
|
1792
|
-
|
|
1260
|
+
o.error(c);
|
|
1793
1261
|
},
|
|
1794
1262
|
complete() {
|
|
1795
1263
|
a();
|
|
1796
1264
|
}
|
|
1797
1265
|
});
|
|
1798
1266
|
function a() {
|
|
1799
|
-
i.closed && s.length === 0 &&
|
|
1267
|
+
i.closed && s.length === 0 && o.complete();
|
|
1800
1268
|
}
|
|
1801
1269
|
return () => {
|
|
1802
1270
|
s.forEach((c) => c.unsubscribe()), i.unsubscribe();
|
|
1803
1271
|
};
|
|
1804
1272
|
});
|
|
1805
1273
|
}
|
|
1806
|
-
[
|
|
1274
|
+
[De]() {
|
|
1807
1275
|
return this;
|
|
1808
1276
|
}
|
|
1809
1277
|
static from(t) {
|
|
1810
|
-
let
|
|
1278
|
+
let r = typeof this == "function" ? this : ue;
|
|
1811
1279
|
if (t == null) throw new TypeError(t + " is not an object");
|
|
1812
|
-
let
|
|
1813
|
-
if (
|
|
1814
|
-
let s =
|
|
1280
|
+
let o = fe(t, De);
|
|
1281
|
+
if (o) {
|
|
1282
|
+
let s = o.call(t);
|
|
1815
1283
|
if (Object(s) !== s) throw new TypeError(s + " is not an object");
|
|
1816
|
-
return
|
|
1284
|
+
return to(s) && s.constructor === r ? s : new r((i) => s.subscribe(i));
|
|
1817
1285
|
}
|
|
1818
|
-
if (
|
|
1819
|
-
return new
|
|
1820
|
-
|
|
1286
|
+
if (jt("iterator") && (o = fe(t, eo), o))
|
|
1287
|
+
return new r((s) => {
|
|
1288
|
+
le(() => {
|
|
1821
1289
|
if (!s.closed) {
|
|
1822
|
-
for (let i of
|
|
1290
|
+
for (let i of o.call(t))
|
|
1823
1291
|
if (s.next(i), s.closed) return;
|
|
1824
1292
|
s.complete();
|
|
1825
1293
|
}
|
|
1826
1294
|
});
|
|
1827
1295
|
});
|
|
1828
1296
|
if (Array.isArray(t))
|
|
1829
|
-
return new
|
|
1830
|
-
|
|
1297
|
+
return new r((s) => {
|
|
1298
|
+
le(() => {
|
|
1831
1299
|
if (!s.closed) {
|
|
1832
1300
|
for (let i = 0; i < t.length; ++i)
|
|
1833
1301
|
if (s.next(t[i]), s.closed) return;
|
|
@@ -1838,446 +1306,446 @@ let Ue = class Te {
|
|
|
1838
1306
|
throw new TypeError(t + " is not observable");
|
|
1839
1307
|
}
|
|
1840
1308
|
static of(...t) {
|
|
1841
|
-
let
|
|
1842
|
-
return new
|
|
1843
|
-
|
|
1844
|
-
if (!
|
|
1309
|
+
let r = typeof this == "function" ? this : ue;
|
|
1310
|
+
return new r((o) => {
|
|
1311
|
+
le(() => {
|
|
1312
|
+
if (!o.closed) {
|
|
1845
1313
|
for (let s = 0; s < t.length; ++s)
|
|
1846
|
-
if (
|
|
1847
|
-
|
|
1314
|
+
if (o.next(t[s]), o.closed) return;
|
|
1315
|
+
o.complete();
|
|
1848
1316
|
}
|
|
1849
1317
|
});
|
|
1850
1318
|
});
|
|
1851
1319
|
}
|
|
1852
|
-
static get [
|
|
1320
|
+
static get [Mt]() {
|
|
1853
1321
|
return this;
|
|
1854
1322
|
}
|
|
1855
1323
|
};
|
|
1856
|
-
|
|
1857
|
-
Object.defineProperty(
|
|
1324
|
+
he.Observable = we;
|
|
1325
|
+
Object.defineProperty(we, Symbol("extensions"), {
|
|
1858
1326
|
value: {
|
|
1859
|
-
symbol:
|
|
1860
|
-
hostReportError:
|
|
1327
|
+
symbol: De,
|
|
1328
|
+
hostReportError: X
|
|
1861
1329
|
},
|
|
1862
1330
|
configurable: !0
|
|
1863
1331
|
});
|
|
1864
|
-
var
|
|
1865
|
-
const
|
|
1332
|
+
var oo = he.Observable;
|
|
1333
|
+
const so = /* @__PURE__ */ It(oo), { log__: io, err__: ao } = J("init-flows"), co = (e) => ({
|
|
1866
1334
|
// Stripe PR
|
|
1867
|
-
stripePR:
|
|
1335
|
+
stripePR: lo("stripePR", Fe.stripePR.init({ context: e }))
|
|
1868
1336
|
// 👉 Add initialization flows here
|
|
1869
|
-
}),
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
|
|
1337
|
+
}), lo = (e, t) => {
|
|
1338
|
+
const r = new so((o) => {
|
|
1339
|
+
o.next({ status: "loading" }), t.then((s) => {
|
|
1340
|
+
o.next({ status: "loaded", result: s });
|
|
1873
1341
|
}).catch((s) => {
|
|
1874
|
-
|
|
1342
|
+
o.next({ status: "error", message: s.message });
|
|
1875
1343
|
});
|
|
1876
1344
|
});
|
|
1877
|
-
return
|
|
1878
|
-
next: (
|
|
1879
|
-
|
|
1345
|
+
return r.subscribe({
|
|
1346
|
+
next: (o) => {
|
|
1347
|
+
io(`${e} flow result`, o);
|
|
1880
1348
|
},
|
|
1881
|
-
error: (
|
|
1882
|
-
throw
|
|
1883
|
-
${JSON.stringify(
|
|
1349
|
+
error: (o) => {
|
|
1350
|
+
throw ao(`${e} flow initialization error:
|
|
1351
|
+
${JSON.stringify(o)}`), o;
|
|
1884
1352
|
}
|
|
1885
|
-
}),
|
|
1886
|
-
},
|
|
1353
|
+
}), r;
|
|
1354
|
+
}, ce = {
|
|
1887
1355
|
isLoading: !0,
|
|
1888
1356
|
isAvailable: !1,
|
|
1889
1357
|
startFlow: async () => {
|
|
1890
1358
|
}
|
|
1891
|
-
},
|
|
1359
|
+
}, rt = {
|
|
1892
1360
|
isLoading: !1,
|
|
1893
1361
|
isAvailable: !1,
|
|
1894
1362
|
startFlow: async () => {
|
|
1895
1363
|
}
|
|
1896
1364
|
};
|
|
1897
|
-
var
|
|
1898
|
-
function
|
|
1899
|
-
var
|
|
1900
|
-
|
|
1365
|
+
var $e = { exports: {} }, uo = rn;
|
|
1366
|
+
function Nt(e, t, r) {
|
|
1367
|
+
var o = typeof t == "function";
|
|
1368
|
+
uo.useEffect(function() {
|
|
1901
1369
|
var s, i = !0, a = e(function() {
|
|
1902
1370
|
return i;
|
|
1903
1371
|
});
|
|
1904
1372
|
return Promise.resolve(a).then(function(c) {
|
|
1905
1373
|
s = c;
|
|
1906
1374
|
}), function() {
|
|
1907
|
-
i = !1,
|
|
1375
|
+
i = !1, o && t(s);
|
|
1908
1376
|
};
|
|
1909
|
-
},
|
|
1377
|
+
}, o ? r : t);
|
|
1910
1378
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
var
|
|
1914
|
-
const
|
|
1915
|
-
function
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
1379
|
+
$e.exports = Nt;
|
|
1380
|
+
$e.exports.useAsyncEffect = Nt;
|
|
1381
|
+
var mo = $e.exports;
|
|
1382
|
+
const ot = /* @__PURE__ */ It(mo);
|
|
1383
|
+
function fo(e, t = 0) {
|
|
1384
|
+
const r = re(!1), o = re(), s = re(e), i = Z(() => r.current, []), a = Z(() => {
|
|
1385
|
+
r.current = !1, o.current && clearTimeout(o.current), o.current = setTimeout(() => {
|
|
1386
|
+
r.current = !0, s.current();
|
|
1919
1387
|
}, t);
|
|
1920
|
-
}, [t]), c =
|
|
1921
|
-
|
|
1388
|
+
}, [t]), c = Z(() => {
|
|
1389
|
+
r.current = null, o.current && clearTimeout(o.current);
|
|
1922
1390
|
}, []);
|
|
1923
|
-
return
|
|
1391
|
+
return q(() => {
|
|
1924
1392
|
s.current = e;
|
|
1925
|
-
}, [e]),
|
|
1393
|
+
}, [e]), q(() => (a(), c), [t]), [i, c, a];
|
|
1926
1394
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const [
|
|
1929
|
-
return
|
|
1395
|
+
function po(e, t = 0, r = []) {
|
|
1396
|
+
const [o, s, i] = fo(e, t);
|
|
1397
|
+
return q(i, r), [o, s];
|
|
1930
1398
|
}
|
|
1931
|
-
const
|
|
1932
|
-
const [s, i] =
|
|
1933
|
-
return
|
|
1934
|
-
if (!
|
|
1399
|
+
const yo = (e, t, r, o) => {
|
|
1400
|
+
const [s, i] = w(""), [a, c] = w(""), [l, d] = w(null), [m, E] = w(!1), [g, _] = w(null);
|
|
1401
|
+
return ot(async () => {
|
|
1402
|
+
if (!o || !e)
|
|
1935
1403
|
return;
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
|
|
1404
|
+
const h = await Or(o, C.PROMOTION_CODE);
|
|
1405
|
+
h == null || h.addEventListener("input", () => {
|
|
1406
|
+
E(!0), _(null), i(h.value);
|
|
1939
1407
|
});
|
|
1940
|
-
}, [!!
|
|
1408
|
+
}, [!!o, e]), po(
|
|
1941
1409
|
() => {
|
|
1942
1410
|
e && c(s);
|
|
1943
1411
|
},
|
|
1944
1412
|
1e3,
|
|
1945
1413
|
[s, e]
|
|
1946
|
-
),
|
|
1947
|
-
async (
|
|
1414
|
+
), ot(
|
|
1415
|
+
async (h) => {
|
|
1948
1416
|
try {
|
|
1949
|
-
if (!t || !
|
|
1417
|
+
if (!t || !r || !e)
|
|
1950
1418
|
return;
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
} catch (
|
|
1954
|
-
|
|
1419
|
+
const L = (await se(t)).mode === "setup", Ce = await vt(t, r, L, a);
|
|
1420
|
+
h() && (_(null), d(Ce));
|
|
1421
|
+
} catch (I) {
|
|
1422
|
+
h() && _(pe(I));
|
|
1955
1423
|
} finally {
|
|
1956
|
-
|
|
1424
|
+
h() && E(!1);
|
|
1957
1425
|
}
|
|
1958
1426
|
},
|
|
1959
|
-
[!t, !
|
|
1427
|
+
[!t, !r, a, e]
|
|
1960
1428
|
), {
|
|
1961
|
-
amount:
|
|
1962
|
-
isLoading:
|
|
1963
|
-
error:
|
|
1429
|
+
amount: l,
|
|
1430
|
+
isLoading: m,
|
|
1431
|
+
error: g
|
|
1964
1432
|
};
|
|
1965
|
-
},
|
|
1966
|
-
const [t,
|
|
1433
|
+
}, xt = (e = {}) => {
|
|
1434
|
+
const [t, r] = w(e), o = Q(
|
|
1967
1435
|
() => ({
|
|
1968
1436
|
set: (i, a) => {
|
|
1969
|
-
|
|
1437
|
+
r((c) => ({
|
|
1970
1438
|
...c,
|
|
1971
1439
|
[i]: a
|
|
1972
1440
|
}));
|
|
1973
1441
|
},
|
|
1974
1442
|
setAll: (i) => {
|
|
1975
|
-
|
|
1443
|
+
r(i);
|
|
1976
1444
|
},
|
|
1977
1445
|
remove: (i) => {
|
|
1978
|
-
|
|
1979
|
-
const { [i]: c, ...
|
|
1980
|
-
return
|
|
1446
|
+
r((a) => {
|
|
1447
|
+
const { [i]: c, ...l } = a;
|
|
1448
|
+
return l;
|
|
1981
1449
|
});
|
|
1982
1450
|
},
|
|
1983
|
-
reset: () =>
|
|
1451
|
+
reset: () => r(e)
|
|
1984
1452
|
}),
|
|
1985
1453
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1986
|
-
[
|
|
1454
|
+
[r]
|
|
1987
1455
|
), s = {
|
|
1988
|
-
get:
|
|
1989
|
-
...
|
|
1456
|
+
get: Z((i) => t[i], [t]),
|
|
1457
|
+
...o
|
|
1990
1458
|
};
|
|
1991
1459
|
return [t, s];
|
|
1992
|
-
},
|
|
1993
|
-
const [e, t] =
|
|
1460
|
+
}, _o = () => {
|
|
1461
|
+
const [e, t] = xt({
|
|
1994
1462
|
card: void 0,
|
|
1995
1463
|
"card-cvc": void 0,
|
|
1996
1464
|
"card-expiry": void 0,
|
|
1997
1465
|
"card-number": void 0
|
|
1998
|
-
}),
|
|
1466
|
+
}), r = Object.values(e).filter((o) => o !== void 0)[0] ?? null;
|
|
1999
1467
|
return {
|
|
2000
1468
|
cdeConns: e,
|
|
2001
|
-
anyCdeConn:
|
|
2002
|
-
connectToCdeIframe: async (
|
|
2003
|
-
t.set(
|
|
1469
|
+
anyCdeConn: r,
|
|
1470
|
+
connectToCdeIframe: async (o, s) => {
|
|
1471
|
+
t.set(o, await tr(s));
|
|
2004
1472
|
}
|
|
2005
1473
|
};
|
|
2006
|
-
},
|
|
2007
|
-
const t = e.replace("ojs-", "").replace("-element", ""),
|
|
2008
|
-
if (!
|
|
1474
|
+
}, go = (e) => {
|
|
1475
|
+
const t = e.replace("ojs-", "").replace("-element", ""), r = gn.safeParse(t);
|
|
1476
|
+
if (!r.success)
|
|
2009
1477
|
throw new Error(
|
|
2010
1478
|
`Invalid element id: ${e}, it needs to be in the format "ojs-{elementType}-element" (e.g. "ojs-card-number-element")`
|
|
2011
1479
|
);
|
|
2012
|
-
return
|
|
2013
|
-
},
|
|
1480
|
+
return r.data;
|
|
1481
|
+
}, Po = (e) => {
|
|
2014
1482
|
const {
|
|
2015
1483
|
children: t,
|
|
2016
|
-
checkoutSecureToken:
|
|
2017
|
-
className:
|
|
1484
|
+
checkoutSecureToken: r,
|
|
1485
|
+
className: o,
|
|
2018
1486
|
onFocus: s,
|
|
2019
1487
|
onBlur: i,
|
|
2020
1488
|
onChange: a,
|
|
2021
1489
|
onLoad: c,
|
|
2022
|
-
onLoadError:
|
|
2023
|
-
onValidationError:
|
|
2024
|
-
onCheckoutStarted:
|
|
2025
|
-
onCheckoutSuccess:
|
|
2026
|
-
onCheckoutError:
|
|
2027
|
-
onSetupPaymentMethodSuccess:
|
|
2028
|
-
baseUrl:
|
|
2029
|
-
enableDynamicPreviews:
|
|
2030
|
-
} = e,
|
|
2031
|
-
apple_pay:
|
|
2032
|
-
google_pay:
|
|
1490
|
+
onLoadError: l,
|
|
1491
|
+
onValidationError: d,
|
|
1492
|
+
onCheckoutStarted: m,
|
|
1493
|
+
onCheckoutSuccess: E,
|
|
1494
|
+
onCheckoutError: g,
|
|
1495
|
+
onSetupPaymentMethodSuccess: _,
|
|
1496
|
+
baseUrl: h,
|
|
1497
|
+
enableDynamicPreviews: I
|
|
1498
|
+
} = e, L = h ?? cn, [Ce, Lt] = w(void 0), [Ue, $t] = w([]), [Ut, qt] = w("1px"), [be, zt] = w(!1), [D, Se] = w(void 0), [qe, K] = w(!1), [Y, Ht] = w([]), [ee, Vt] = w({}), [ze, ie] = w(0), [He, z] = w(!1), [$, Kt] = w(void 0), [Ve, Yt] = w(void 0), [Ke, Zt] = w(void 0), [U, Jt] = w(void 0), [Pe] = w(void 0), W = Q(() => `opjs-form-${st()}`, []), j = re(null), { cdeConns: Ye, anyCdeConn: B, connectToCdeIframe: Wt } = _o(), [Bt, Gt] = w(null), [Ze, G] = xt({
|
|
1499
|
+
apple_pay: ce,
|
|
1500
|
+
google_pay: ce
|
|
2033
1501
|
});
|
|
2034
|
-
|
|
2035
|
-
const
|
|
2036
|
-
window.ojs_version =
|
|
1502
|
+
q(() => {
|
|
1503
|
+
const u = { version: "0.1.7", release_version: "0.1.7" };
|
|
1504
|
+
window.ojs_version = u;
|
|
2037
1505
|
}, []);
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
),
|
|
2044
|
-
(
|
|
2045
|
-
if (
|
|
2046
|
-
const
|
|
2047
|
-
if (
|
|
1506
|
+
const Qt = yo(
|
|
1507
|
+
I ?? !1,
|
|
1508
|
+
B,
|
|
1509
|
+
r,
|
|
1510
|
+
j.current
|
|
1511
|
+
), ve = Z(
|
|
1512
|
+
(u) => {
|
|
1513
|
+
if (u.origin !== L || !u.source) return;
|
|
1514
|
+
const M = u.source;
|
|
1515
|
+
if (!jr(u.data))
|
|
2048
1516
|
return;
|
|
2049
|
-
const
|
|
2050
|
-
if (
|
|
1517
|
+
const A = JSON.parse(u.data), p = Qn(A), H = p.elementId;
|
|
1518
|
+
if (p.formId !== W || !H || p.nonce in Ue)
|
|
2051
1519
|
return;
|
|
2052
|
-
|
|
2053
|
-
const
|
|
2054
|
-
if (
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2057
|
-
} else if (
|
|
2058
|
-
s(
|
|
2059
|
-
else if (
|
|
2060
|
-
i(
|
|
2061
|
-
else if (
|
|
2062
|
-
a(
|
|
2063
|
-
else if (
|
|
2064
|
-
const
|
|
2065
|
-
if (
|
|
1520
|
+
$t((k) => [...k, p.nonce]);
|
|
1521
|
+
const y = p.payload, R = y.type;
|
|
1522
|
+
if (R === f.enum.LAYOUT) {
|
|
1523
|
+
const k = y.height ? `${y.height}px` : "100%";
|
|
1524
|
+
qt(k);
|
|
1525
|
+
} else if (R === f.enum.FOCUS && s)
|
|
1526
|
+
s(p.elementId);
|
|
1527
|
+
else if (R === f.enum.BLUR && i)
|
|
1528
|
+
i(p.elementId);
|
|
1529
|
+
else if (R === f.enum.CHANGE && a)
|
|
1530
|
+
a(p.elementId);
|
|
1531
|
+
else if (R === f.enum.LOADED) {
|
|
1532
|
+
const k = Y.find((S) => S.contentWindow === M);
|
|
1533
|
+
if (K(!1), !k)
|
|
2066
1534
|
return;
|
|
2067
|
-
|
|
2068
|
-
} else if (
|
|
2069
|
-
|
|
2070
|
-
else if (
|
|
2071
|
-
|
|
2072
|
-
else if (
|
|
2073
|
-
if (!
|
|
1535
|
+
Vt((S) => ({ ...S, [H]: M })), Zt(y.totalAmountAtoms), Yt(y.currency), Jt(y.checkoutPaymentMethods), $ || Kt(y.sessionId);
|
|
1536
|
+
} else if (R === f.enum.TOKENIZE_STARTED)
|
|
1537
|
+
K(!0);
|
|
1538
|
+
else if (R === f.enum.CHECKOUT_STARTED)
|
|
1539
|
+
m && m();
|
|
1540
|
+
else if (R === f.enum.PAYMENT_FLOW_STARTED) {
|
|
1541
|
+
if (!D)
|
|
2074
1542
|
throw new Error("extraData not populated");
|
|
2075
|
-
if (!
|
|
1543
|
+
if (!B)
|
|
2076
1544
|
throw new Error("Not connected to CDE");
|
|
2077
1545
|
(async () => {
|
|
2078
|
-
const
|
|
2079
|
-
if (
|
|
2080
|
-
await
|
|
2081
|
-
else if (
|
|
2082
|
-
if (!
|
|
1546
|
+
const S = y.nextActionMetadata.type;
|
|
1547
|
+
if (S !== void 0) if (S === "stripe_3ds")
|
|
1548
|
+
await Wn(y);
|
|
1549
|
+
else if (S === "stripe_payment_request") {
|
|
1550
|
+
if (!Pe)
|
|
2083
1551
|
throw new Error("Stripe PM not set");
|
|
2084
|
-
await
|
|
1552
|
+
await Zn(y, Pe);
|
|
2085
1553
|
} else
|
|
2086
|
-
throw new Error(`Unknown next action type: ${
|
|
2087
|
-
const
|
|
2088
|
-
if (
|
|
2089
|
-
const { payment_methods:
|
|
2090
|
-
secure_token:
|
|
2091
|
-
existing_cc_pm_id:
|
|
1554
|
+
throw new Error(`Unknown next action type: ${S}`);
|
|
1555
|
+
const F = await se(B);
|
|
1556
|
+
if (F.mode === "setup") {
|
|
1557
|
+
const { payment_methods: N } = await xe(B, {
|
|
1558
|
+
secure_token: F.token,
|
|
1559
|
+
existing_cc_pm_id: D.existingCCPMId
|
|
2092
1560
|
});
|
|
2093
|
-
if (
|
|
2094
|
-
throw new Error(`Expected exactly one payment method, got ${
|
|
2095
|
-
return
|
|
1561
|
+
if (N.length !== 1)
|
|
1562
|
+
throw new Error(`Expected exactly one payment method, got ${N.length}`);
|
|
1563
|
+
return K(!1), ie(0), z(!1), _ && _(N[0].id), {
|
|
2096
1564
|
proceedToCheckout: !1
|
|
2097
1565
|
};
|
|
2098
1566
|
} else
|
|
2099
1567
|
return {
|
|
2100
1568
|
proceedToCheckout: !0
|
|
2101
1569
|
};
|
|
2102
|
-
})().then(({ proceedToCheckout:
|
|
2103
|
-
var
|
|
2104
|
-
if (!
|
|
1570
|
+
})().then(({ proceedToCheckout: S }) => {
|
|
1571
|
+
var N;
|
|
1572
|
+
if (!S)
|
|
2105
1573
|
return;
|
|
2106
|
-
let
|
|
2107
|
-
if (
|
|
1574
|
+
let F;
|
|
1575
|
+
if (D.checkoutPaymentMethod.provider === "credit_card" && (F = (N = y.startPFMetadata) == null ? void 0 : N.cc_pm_id, !F))
|
|
2108
1576
|
throw new Error("CC PM ID not found");
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
{ ...
|
|
2114
|
-
|
|
2115
|
-
),
|
|
2116
|
-
}).catch((
|
|
2117
|
-
const
|
|
2118
|
-
|
|
1577
|
+
Te(
|
|
1578
|
+
M,
|
|
1579
|
+
W,
|
|
1580
|
+
H,
|
|
1581
|
+
{ ...D, type: "CHECKOUT", doNotUseLegacyCCFlow: !0, existingCCPMId: F },
|
|
1582
|
+
L
|
|
1583
|
+
), z(!0), Se(void 0), m && m();
|
|
1584
|
+
}).catch((S) => {
|
|
1585
|
+
const F = pe(S);
|
|
1586
|
+
K(!1), z(!1), g && g(F);
|
|
2119
1587
|
});
|
|
2120
|
-
} else if (
|
|
2121
|
-
const
|
|
2122
|
-
!
|
|
2123
|
-
} else if (
|
|
2124
|
-
|
|
2125
|
-
else if (
|
|
2126
|
-
|
|
2127
|
-
else if (
|
|
2128
|
-
|
|
2129
|
-
else if (
|
|
2130
|
-
const
|
|
2131
|
-
(
|
|
2132
|
-
} else if (
|
|
2133
|
-
if (
|
|
2134
|
-
const
|
|
2135
|
-
if (
|
|
2136
|
-
for (const [
|
|
2137
|
-
if (!
|
|
2138
|
-
const
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
1588
|
+
} else if (R === f.enum.TOKENIZE_SUCCESS && D) {
|
|
1589
|
+
const k = ze + 1, S = k === Object.keys(ee).length;
|
|
1590
|
+
!He && (S || y.isReadyForCheckout) ? (Te(M, W, H, D, L), z(!0), Se(void 0)) : ie(k);
|
|
1591
|
+
} else if (R === f.enum.CHECKOUT_SUCCESS)
|
|
1592
|
+
K(!1), ie(0), z(!1), E && E(y.invoiceUrls, y.subscriptionIds, y.customerId);
|
|
1593
|
+
else if (R === f.enum.SETUP_PAYMENT_METHOD_SUCCESS)
|
|
1594
|
+
K(!1), ie(0), z(!1), _ && _(y.paymentMethodId);
|
|
1595
|
+
else if (R === f.enum.LOAD_ERROR)
|
|
1596
|
+
l && l(y.message);
|
|
1597
|
+
else if (R === f.enum.VALIDATION_ERROR) {
|
|
1598
|
+
const k = D == null ? void 0 : D.checkoutPaymentMethod.provider;
|
|
1599
|
+
(k === "credit_card" || k === void 0) && d && d(y.elementType, y.errors, H);
|
|
1600
|
+
} else if (R === f.enum.TOKENIZE_ERROR || R === f.enum.CHECKOUT_ERROR)
|
|
1601
|
+
if (y.message === "3DS_REQUIRED") {
|
|
1602
|
+
const k = U == null ? void 0 : U.find((S) => S.provider === "credit_card");
|
|
1603
|
+
if (!$ || !j.current || !d || !k) return;
|
|
1604
|
+
for (const [S, F] of Object.entries(ee)) {
|
|
1605
|
+
if (!F) continue;
|
|
1606
|
+
const N = Gn(
|
|
1607
|
+
f.enum.START_PAYMENT_FLOW,
|
|
1608
|
+
$,
|
|
1609
|
+
j.current,
|
|
1610
|
+
d,
|
|
2143
1611
|
// Only stripe supports frontend 3DS right now,
|
|
2144
1612
|
// so we pass processor_name: 'stripe' to tell delegator to only use stripe
|
|
2145
|
-
{ ...
|
|
1613
|
+
{ ...k, processor_name: "stripe" },
|
|
2146
1614
|
!1
|
|
2147
1615
|
);
|
|
2148
|
-
if (
|
|
2149
|
-
|
|
1616
|
+
if (N) {
|
|
1617
|
+
z(!0), Se(N), Te(F, W, S, N, L);
|
|
2150
1618
|
break;
|
|
2151
1619
|
}
|
|
2152
1620
|
}
|
|
2153
1621
|
} else
|
|
2154
|
-
|
|
1622
|
+
K(!1), z(!1), g && g(y.message);
|
|
2155
1623
|
},
|
|
2156
1624
|
[
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
1625
|
+
W,
|
|
1626
|
+
$,
|
|
1627
|
+
Ue,
|
|
1628
|
+
D,
|
|
1629
|
+
Y,
|
|
1630
|
+
ee,
|
|
1631
|
+
ze,
|
|
1632
|
+
He,
|
|
2165
1633
|
i,
|
|
2166
1634
|
a,
|
|
2167
1635
|
s,
|
|
2168
|
-
d,
|
|
2169
|
-
u,
|
|
2170
|
-
y,
|
|
2171
|
-
m,
|
|
2172
|
-
f,
|
|
2173
1636
|
l,
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
1637
|
+
m,
|
|
1638
|
+
E,
|
|
1639
|
+
_,
|
|
1640
|
+
g,
|
|
1641
|
+
d,
|
|
1642
|
+
L,
|
|
1643
|
+
Pe,
|
|
1644
|
+
U,
|
|
1645
|
+
B
|
|
2178
1646
|
]
|
|
2179
|
-
),
|
|
2180
|
-
const
|
|
1647
|
+
), Je = Q(() => {
|
|
1648
|
+
const u = () => {
|
|
2181
1649
|
};
|
|
2182
1650
|
return {
|
|
2183
|
-
onCheckoutError:
|
|
2184
|
-
onCheckoutStarted:
|
|
2185
|
-
onCheckoutSuccess:
|
|
2186
|
-
onSetupPaymentMethodSuccess:
|
|
2187
|
-
onValidationError:
|
|
1651
|
+
onCheckoutError: te("onCheckoutError", g ?? u),
|
|
1652
|
+
onCheckoutStarted: te("onCheckoutStarted", m ?? u),
|
|
1653
|
+
onCheckoutSuccess: te("onCheckoutSuccess", E ?? u),
|
|
1654
|
+
onSetupPaymentMethodSuccess: te("onSetupPaymentMethodSuccess", _ ?? u),
|
|
1655
|
+
onValidationError: te("onValidationError", d ?? u)
|
|
2188
1656
|
};
|
|
2189
|
-
}, [
|
|
2190
|
-
if (!
|
|
2191
|
-
const
|
|
2192
|
-
return Object.entries(
|
|
2193
|
-
|
|
2194
|
-
}),
|
|
2195
|
-
formDiv:
|
|
2196
|
-
elementsSessionId:
|
|
2197
|
-
checkoutPaymentMethods:
|
|
2198
|
-
cdeConnections:
|
|
2199
|
-
baseUrl: new URL(
|
|
1657
|
+
}, [g, m, E, _, d]), Oe = () => {
|
|
1658
|
+
if (!j.current || !$ || !U) return null;
|
|
1659
|
+
const u = /* @__PURE__ */ new Map();
|
|
1660
|
+
return Object.entries(Ye).forEach(([A, p]) => {
|
|
1661
|
+
p && u.set(A, p);
|
|
1662
|
+
}), u.size === 0 ? null : {
|
|
1663
|
+
formDiv: j.current,
|
|
1664
|
+
elementsSessionId: $,
|
|
1665
|
+
checkoutPaymentMethods: U,
|
|
1666
|
+
cdeConnections: u,
|
|
1667
|
+
baseUrl: new URL(L).origin
|
|
2200
1668
|
};
|
|
2201
|
-
},
|
|
2202
|
-
const
|
|
2203
|
-
if (!(!
|
|
2204
|
-
return
|
|
2205
|
-
context:
|
|
2206
|
-
checkoutPaymentMethod:
|
|
2207
|
-
nonCdeFormInputs:
|
|
2208
|
-
flowCallbacks:
|
|
2209
|
-
customParams: { provider:
|
|
2210
|
-
initResult:
|
|
1669
|
+
}, We = (u, M, A) => {
|
|
1670
|
+
const p = Oe();
|
|
1671
|
+
if (!(!p || !j.current))
|
|
1672
|
+
return Fe.stripePR.run({
|
|
1673
|
+
context: p,
|
|
1674
|
+
checkoutPaymentMethod: nt(p.checkoutPaymentMethods, u),
|
|
1675
|
+
nonCdeFormInputs: Me(j.current),
|
|
1676
|
+
flowCallbacks: Je,
|
|
1677
|
+
customParams: { provider: u, overridePaymentRequest: A == null ? void 0 : A.overridePaymentRequest },
|
|
1678
|
+
initResult: M
|
|
2211
1679
|
});
|
|
2212
1680
|
};
|
|
2213
|
-
|
|
2214
|
-
if (
|
|
2215
|
-
const
|
|
2216
|
-
if (!
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2219
|
-
if (
|
|
2220
|
-
|
|
2221
|
-
else if (
|
|
2222
|
-
|
|
2223
|
-
else if (
|
|
2224
|
-
const
|
|
2225
|
-
|
|
1681
|
+
q(() => {
|
|
1682
|
+
if (Bt !== null) return;
|
|
1683
|
+
const u = Oe();
|
|
1684
|
+
if (!u) return;
|
|
1685
|
+
const M = co(u);
|
|
1686
|
+
Gt(M), M.stripePR.subscribe((A) => {
|
|
1687
|
+
if (A.status === "loading")
|
|
1688
|
+
G.set("apple_pay", ce), G.set("google_pay", ce);
|
|
1689
|
+
else if (A.status === "error")
|
|
1690
|
+
G.set("apple_pay", rt), G.set("google_pay", rt);
|
|
1691
|
+
else if (A.status === "loaded") {
|
|
1692
|
+
const p = A.result, H = p.isAvailable && p.availableProviders.applePay, ke = p.isAvailable && p.availableProviders.googlePay;
|
|
1693
|
+
G.set("apple_pay", {
|
|
2226
1694
|
isLoading: !1,
|
|
2227
|
-
isAvailable:
|
|
2228
|
-
startFlow: async (
|
|
2229
|
-
}),
|
|
1695
|
+
isAvailable: H,
|
|
1696
|
+
startFlow: async (y) => H ? We("apple_pay", p, y) : void 0
|
|
1697
|
+
}), G.set("google_pay", {
|
|
2230
1698
|
isLoading: !1,
|
|
2231
|
-
isAvailable:
|
|
2232
|
-
startFlow: async (
|
|
1699
|
+
isAvailable: ke,
|
|
1700
|
+
startFlow: async (y) => ke ? We("google_pay", p, y) : void 0
|
|
2233
1701
|
});
|
|
2234
1702
|
}
|
|
2235
1703
|
});
|
|
2236
|
-
}, [
|
|
2237
|
-
const
|
|
2238
|
-
const
|
|
2239
|
-
!
|
|
2240
|
-
context:
|
|
2241
|
-
checkoutPaymentMethod:
|
|
2242
|
-
nonCdeFormInputs:
|
|
2243
|
-
flowCallbacks:
|
|
1704
|
+
}, [j.current, $, U, Object.keys(Ye).length]);
|
|
1705
|
+
const Xt = () => {
|
|
1706
|
+
const u = Oe();
|
|
1707
|
+
!j.current || !$ || !B || !U || !u || Fe.commonCC.run({
|
|
1708
|
+
context: u,
|
|
1709
|
+
checkoutPaymentMethod: nt(U, "credit_card"),
|
|
1710
|
+
nonCdeFormInputs: Me(j.current),
|
|
1711
|
+
flowCallbacks: Je,
|
|
2244
1712
|
customParams: void 0,
|
|
2245
1713
|
// This flow requires no custom params
|
|
2246
1714
|
initResult: void 0
|
|
2247
1715
|
// This flow requires no initialization
|
|
2248
1716
|
});
|
|
2249
|
-
},
|
|
2250
|
-
(
|
|
2251
|
-
|
|
1717
|
+
}, Re = Z(
|
|
1718
|
+
(u) => {
|
|
1719
|
+
qe && u.preventDefault();
|
|
2252
1720
|
},
|
|
2253
|
-
[
|
|
1721
|
+
[qe]
|
|
2254
1722
|
);
|
|
2255
|
-
|
|
2256
|
-
if (
|
|
2257
|
-
|
|
2258
|
-
}, [
|
|
2259
|
-
window.removeEventListener("beforeunload",
|
|
2260
|
-
}), [
|
|
2261
|
-
const
|
|
2262
|
-
async (
|
|
2263
|
-
if (
|
|
2264
|
-
|
|
2265
|
-
const
|
|
2266
|
-
await
|
|
1723
|
+
q(() => {
|
|
1724
|
+
if (be || !j.current) return;
|
|
1725
|
+
Y.length > 0 && Y.length === Object.keys(ee).length && (zt(!0), c && c(Ke, Ve));
|
|
1726
|
+
}, [Y, ee, be, c, Ke, Ve]), q(() => (Lt(window.location.origin), window.addEventListener("message", ve), window.addEventListener("beforeunload", Re), () => {
|
|
1727
|
+
window.removeEventListener("beforeunload", Re), window.removeEventListener("message", ve);
|
|
1728
|
+
}), [$, ve, Re]);
|
|
1729
|
+
const en = Z(
|
|
1730
|
+
async (u) => {
|
|
1731
|
+
if (Y.find((p) => p.contentWindow === u.contentWindow)) return;
|
|
1732
|
+
Ht((p) => [...p, u]);
|
|
1733
|
+
const A = go(u.id);
|
|
1734
|
+
await Wt(A, u);
|
|
2267
1735
|
},
|
|
2268
1736
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2269
|
-
[
|
|
2270
|
-
),
|
|
2271
|
-
formId:
|
|
2272
|
-
formHeight:
|
|
2273
|
-
referer:
|
|
2274
|
-
checkoutSecureToken:
|
|
2275
|
-
registerIframe:
|
|
2276
|
-
baseUrl:
|
|
2277
|
-
},
|
|
2278
|
-
submit:
|
|
2279
|
-
applePay:
|
|
2280
|
-
googlePay:
|
|
1737
|
+
[Y]
|
|
1738
|
+
), tn = {
|
|
1739
|
+
formId: W,
|
|
1740
|
+
formHeight: Ut,
|
|
1741
|
+
referer: Ce,
|
|
1742
|
+
checkoutSecureToken: r,
|
|
1743
|
+
registerIframe: en,
|
|
1744
|
+
baseUrl: L
|
|
1745
|
+
}, nn = {
|
|
1746
|
+
submit: Xt,
|
|
1747
|
+
applePay: Ze.apple_pay,
|
|
1748
|
+
googlePay: Ze.google_pay,
|
|
2281
1749
|
// stripeLink: {
|
|
2282
1750
|
// TODO: uncomment if we need stripe elements later.
|
|
2283
1751
|
// Better if we can make stripe link work in prod without elements.
|
|
@@ -2285,40 +1753,40 @@ const Ts = (e, t, n, r) => {
|
|
|
2285
1753
|
// authElement: stripeElements.isReady ? StripeLinkAuthElement : NoOpElement,
|
|
2286
1754
|
// pr: paymentRequests.stripe_link,
|
|
2287
1755
|
// },
|
|
2288
|
-
loaded:
|
|
2289
|
-
preview:
|
|
1756
|
+
loaded: be,
|
|
1757
|
+
preview: Qt
|
|
2290
1758
|
};
|
|
2291
|
-
return /* @__PURE__ */
|
|
2292
|
-
},
|
|
2293
|
-
const { subPath: t, styles:
|
|
1759
|
+
return /* @__PURE__ */ V(at.Provider, { value: tn, children: /* @__PURE__ */ V("div", { className: o, ref: j, children: t(nn) }) });
|
|
1760
|
+
}, Ee = (e) => {
|
|
1761
|
+
const { subPath: t, styles: r } = e, { formId: o, referer: s, formHeight: i, checkoutSecureToken: a, registerIframe: c, baseUrl: l } = an(), [d, m] = w(!1), E = re(null), g = Q(() => r ? Bn(r) : "", [r]), _ = Q(() => ({
|
|
2294
1762
|
border: "none",
|
|
2295
1763
|
width: "100%",
|
|
2296
1764
|
height: i
|
|
2297
|
-
}), [i]),
|
|
1765
|
+
}), [i]), h = Q(() => {
|
|
2298
1766
|
if (!a || !s) return "";
|
|
2299
|
-
const
|
|
2300
|
-
return
|
|
2301
|
-
}, [
|
|
2302
|
-
return
|
|
2303
|
-
!
|
|
2304
|
-
}, [
|
|
1767
|
+
const I = new URLSearchParams();
|
|
1768
|
+
return I.append("referer", s), I.append("styles", g), I.append("formId", o), I.append("secureToken", a), I.toString();
|
|
1769
|
+
}, [g, o, s, a]);
|
|
1770
|
+
return q(() => m(!0), []), q(() => {
|
|
1771
|
+
!E.current || !d || c(E.current);
|
|
1772
|
+
}, [d]), a ? /* @__PURE__ */ V(
|
|
2305
1773
|
"iframe",
|
|
2306
1774
|
{
|
|
2307
1775
|
id: `ojs-${t}-element`,
|
|
2308
1776
|
name: `${t}-element`,
|
|
2309
1777
|
className: "ojs-iframe",
|
|
2310
|
-
src: `${
|
|
2311
|
-
style:
|
|
2312
|
-
ref:
|
|
1778
|
+
src: `${l}/app/v1/${t}-element/?${h}`,
|
|
1779
|
+
style: _,
|
|
1780
|
+
ref: E
|
|
2313
1781
|
}
|
|
2314
|
-
) : /* @__PURE__ */
|
|
2315
|
-
},
|
|
1782
|
+
) : /* @__PURE__ */ V("div", {});
|
|
1783
|
+
}, vo = ({ styles: e }) => /* @__PURE__ */ V(Ee, { styles: e, subPath: "card-cvc" }), Oo = ({ styles: e }) => /* @__PURE__ */ V(Ee, { styles: e, subPath: "card" }), Ro = ({ styles: e }) => /* @__PURE__ */ V(Ee, { styles: e, subPath: "card-expiry" }), ko = ({ styles: e }) => /* @__PURE__ */ V(Ee, { styles: e, subPath: "card-number" });
|
|
2316
1784
|
export {
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
1785
|
+
vo as CardCvcElement,
|
|
1786
|
+
Oo as CardElement,
|
|
1787
|
+
Ro as CardExpiryElement,
|
|
1788
|
+
ko as CardNumberElement,
|
|
1789
|
+
Po as ElementsForm,
|
|
1790
|
+
C as FieldName,
|
|
1791
|
+
an as useOpenPayElements
|
|
2324
1792
|
};
|