@amos.com/amos-js 0.9.8 → 0.9.10
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/README.md +58 -12
- package/dist/apple-pay.d.ts +5 -3
- package/dist/google-pay.d.ts +6 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +151 -98
- package/dist/messaging.d.ts +15 -1
- package/dist/types.d.ts +106 -1
- package/package.json +1 -1
- package/src/apple-pay.ts +19 -2
- package/src/google-pay.ts +28 -3
- package/src/index.ts +13 -1
- package/src/messaging.ts +55 -1
- package/src/types.ts +312 -1
package/dist/index.mjs
CHANGED
|
@@ -85,41 +85,82 @@ function i(e) {
|
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region src/types.ts
|
|
87
87
|
function a(e) {
|
|
88
|
+
if (!e || typeof e != "object") return;
|
|
89
|
+
let t = {};
|
|
90
|
+
for (let [n, r] of Object.entries(e)) {
|
|
91
|
+
if (typeof r == "string") {
|
|
92
|
+
if (r.length === 0) continue;
|
|
93
|
+
t[n] = r;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
typeof r == "number" && Number.isFinite(r) && (t[n] = r);
|
|
97
|
+
}
|
|
98
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
99
|
+
}
|
|
100
|
+
function o(e) {
|
|
101
|
+
let t = {};
|
|
102
|
+
if (e.buttonstyle !== void 0 && (t.buttonstyle = e.buttonstyle), e.type !== void 0 && (t.type = e.type), e.locale !== void 0 && (t.locale = e.locale), e.style !== void 0) {
|
|
103
|
+
let n = a(e.style);
|
|
104
|
+
n && (t.style = n);
|
|
105
|
+
}
|
|
106
|
+
return t;
|
|
107
|
+
}
|
|
108
|
+
function s(e) {
|
|
109
|
+
let t = {};
|
|
110
|
+
if (e.buttonType !== void 0 && (t.buttonType = e.buttonType), e.buttonColor !== void 0 && (t.buttonColor = e.buttonColor), e.buttonRadius !== void 0 && (t.buttonRadius = e.buttonRadius), e.buttonSizeMode !== void 0 && (t.buttonSizeMode = e.buttonSizeMode), e.buttonLocale !== void 0 && (t.buttonLocale = e.buttonLocale), e.buttonBorderType !== void 0 && (t.buttonBorderType = e.buttonBorderType), e.style !== void 0) {
|
|
111
|
+
let n = a(e.style);
|
|
112
|
+
n && (t.style = n);
|
|
113
|
+
}
|
|
114
|
+
return t;
|
|
115
|
+
}
|
|
116
|
+
function c(e) {
|
|
88
117
|
return e;
|
|
89
118
|
}
|
|
90
119
|
//#endregion
|
|
91
120
|
//#region src/messaging.ts
|
|
92
|
-
function
|
|
121
|
+
function l(e) {
|
|
93
122
|
return new URL(e.src).origin;
|
|
94
123
|
}
|
|
95
|
-
function
|
|
96
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
124
|
+
function u(e) {
|
|
125
|
+
e?.contentWindow && e.contentWindow.postMessage(c({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), l(e));
|
|
97
126
|
}
|
|
98
|
-
function
|
|
99
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
127
|
+
function d({ iframe: e, appearance: t = {} }) {
|
|
128
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
100
129
|
type: "UPDATE_APPEARANCE",
|
|
101
130
|
appearance: t
|
|
102
|
-
}),
|
|
103
|
-
}
|
|
104
|
-
function
|
|
105
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
131
|
+
}), l(e));
|
|
132
|
+
}
|
|
133
|
+
function f({ iframe: e, props: t }) {
|
|
134
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
135
|
+
type: "UPDATE_APPLE_PAY_BUTTON",
|
|
136
|
+
props: o(t)
|
|
137
|
+
}), l(e));
|
|
138
|
+
}
|
|
139
|
+
function p({ iframe: e, props: t }) {
|
|
140
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
141
|
+
type: "UPDATE_GOOGLE_PAY_BUTTON",
|
|
142
|
+
props: s(t)
|
|
143
|
+
}), l(e));
|
|
144
|
+
}
|
|
145
|
+
function m({ iframe: e, amount: t }) {
|
|
146
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
106
147
|
type: "UPDATE_AMOUNT",
|
|
107
148
|
amount: t
|
|
108
|
-
}),
|
|
149
|
+
}), l(e));
|
|
109
150
|
}
|
|
110
|
-
function
|
|
111
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
151
|
+
function h({ iframe: e, merchantName: t }) {
|
|
152
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
112
153
|
type: "UPDATE_MERCHANT_NAME",
|
|
113
154
|
merchantName: t
|
|
114
|
-
}),
|
|
155
|
+
}), l(e));
|
|
115
156
|
}
|
|
116
|
-
function
|
|
157
|
+
function g({ iframe: e }) {
|
|
117
158
|
let t = crypto.randomUUID();
|
|
118
159
|
return new Promise((n) => {
|
|
119
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
160
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
120
161
|
type: "VALIDATE_FORM",
|
|
121
162
|
requestId: t
|
|
122
|
-
}),
|
|
163
|
+
}), l(e));
|
|
123
164
|
let r = setTimeout(() => {
|
|
124
165
|
window.removeEventListener("message", i), n(!1);
|
|
125
166
|
}, 5e3);
|
|
@@ -129,71 +170,77 @@ function d({ iframe: e }) {
|
|
|
129
170
|
window.addEventListener("message", i);
|
|
130
171
|
});
|
|
131
172
|
}
|
|
132
|
-
function
|
|
133
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
173
|
+
function _({ iframe: e }) {
|
|
174
|
+
e?.contentWindow && e.contentWindow.postMessage(c({ type: "RESET_FORM" }), l(e));
|
|
134
175
|
}
|
|
135
|
-
function
|
|
176
|
+
function v({ iframe: e, token: t }) {
|
|
136
177
|
if (!e?.contentWindow) return;
|
|
137
178
|
let { payment_intent_id: n } = r(t).payload;
|
|
138
|
-
e.contentWindow.postMessage(
|
|
179
|
+
e.contentWindow.postMessage(c({
|
|
139
180
|
type: "CONFIRM_PAYMENT_INTENT",
|
|
140
181
|
token: t,
|
|
141
182
|
id: n ?? void 0
|
|
142
|
-
}),
|
|
183
|
+
}), l(e));
|
|
143
184
|
}
|
|
144
|
-
function
|
|
185
|
+
function y({ iframe: e, token: t }) {
|
|
145
186
|
if (!e?.contentWindow) return;
|
|
146
187
|
let { setup_intent_id: n } = r(t).payload;
|
|
147
|
-
e.contentWindow.postMessage(
|
|
188
|
+
e.contentWindow.postMessage(c({
|
|
148
189
|
type: "CONFIRM_SETUP_INTENT",
|
|
149
190
|
token: t,
|
|
150
191
|
id: n ?? void 0
|
|
151
|
-
}),
|
|
192
|
+
}), l(e));
|
|
152
193
|
}
|
|
153
|
-
function
|
|
154
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
194
|
+
function b({ iframe: e, result: t }) {
|
|
195
|
+
e?.contentWindow && e.contentWindow.postMessage(c({
|
|
155
196
|
type: "CONFIRMATION_RESULT",
|
|
156
197
|
result: t
|
|
157
|
-
}),
|
|
198
|
+
}), l(e));
|
|
158
199
|
}
|
|
159
200
|
//#endregion
|
|
160
201
|
//#region src/apple-pay.ts
|
|
161
|
-
function
|
|
202
|
+
function x(e) {
|
|
162
203
|
return `${i(e)}/iframe/apple-pay?token=${e}`;
|
|
163
204
|
}
|
|
164
|
-
function
|
|
205
|
+
function S() {
|
|
165
206
|
return "40px";
|
|
166
207
|
}
|
|
167
|
-
function
|
|
168
|
-
e.contentWindow?.postMessage(
|
|
208
|
+
function C(e) {
|
|
209
|
+
e.contentWindow?.postMessage(c({ type: "APPLE_PAY_CANCEL" }), l(e));
|
|
169
210
|
}
|
|
170
|
-
function
|
|
211
|
+
function w(e, r) {
|
|
171
212
|
let i = { ...r };
|
|
172
213
|
function a() {
|
|
173
|
-
|
|
214
|
+
m({
|
|
174
215
|
iframe: e,
|
|
175
216
|
amount: i.amount
|
|
176
217
|
});
|
|
177
218
|
}
|
|
178
219
|
function o() {
|
|
179
|
-
|
|
220
|
+
h({
|
|
180
221
|
iframe: e,
|
|
181
222
|
merchantName: i.merchantName
|
|
182
223
|
});
|
|
183
224
|
}
|
|
184
|
-
function
|
|
225
|
+
function s() {
|
|
226
|
+
f({
|
|
227
|
+
iframe: e,
|
|
228
|
+
props: i
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function c(r) {
|
|
185
232
|
if (r.source === e.contentWindow) switch (r.data.type) {
|
|
186
233
|
case "IFRAME_READY":
|
|
187
|
-
|
|
234
|
+
u(e), d({
|
|
188
235
|
iframe: e,
|
|
189
236
|
appearance: i.appearance
|
|
190
|
-
}), a(), o();
|
|
237
|
+
}), a(), o(), s();
|
|
191
238
|
break;
|
|
192
239
|
case "UPDATE_HEIGHT":
|
|
193
240
|
i.onHeightChange?.(r.data.height);
|
|
194
241
|
break;
|
|
195
242
|
case "UPDATE_APPEARANCE":
|
|
196
|
-
|
|
243
|
+
d({
|
|
197
244
|
iframe: e,
|
|
198
245
|
appearance: r.data.appearance
|
|
199
246
|
});
|
|
@@ -203,7 +250,7 @@ function y(e, r) {
|
|
|
203
250
|
break;
|
|
204
251
|
case "APPLE_PAY_WINDOW_OPEN":
|
|
205
252
|
t({ onCancel: () => {
|
|
206
|
-
|
|
253
|
+
C(e), n();
|
|
207
254
|
} });
|
|
208
255
|
break;
|
|
209
256
|
case "APPLE_PAY_WINDOW_CLOSE":
|
|
@@ -214,7 +261,7 @@ function y(e, r) {
|
|
|
214
261
|
paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
|
|
215
262
|
customerCreateAttributes: r.data.customerCreateAttributes
|
|
216
263
|
}).then((t) => {
|
|
217
|
-
|
|
264
|
+
v({
|
|
218
265
|
iframe: e,
|
|
219
266
|
token: t
|
|
220
267
|
});
|
|
@@ -228,57 +275,63 @@ function y(e, r) {
|
|
|
228
275
|
case "CONFIRMATION_RESULT": n(), i.onResult(r.data.result);
|
|
229
276
|
}
|
|
230
277
|
}
|
|
231
|
-
return window.addEventListener("message",
|
|
278
|
+
return window.addEventListener("message", c), {
|
|
232
279
|
update(t) {
|
|
233
|
-
let n = "appearance" in t, r = "amount" in t,
|
|
280
|
+
let n = "appearance" in t, r = "amount" in t, c = "merchantName" in t, l = "buttonstyle" in t || "type" in t || "locale" in t || "style" in t;
|
|
234
281
|
i = {
|
|
235
282
|
...i,
|
|
236
283
|
...t
|
|
237
|
-
}, n &&
|
|
284
|
+
}, n && d({
|
|
238
285
|
iframe: e,
|
|
239
286
|
appearance: i.appearance
|
|
240
|
-
}), r && a(),
|
|
287
|
+
}), r && a(), c && o(), l && s();
|
|
241
288
|
},
|
|
242
289
|
destroy() {
|
|
243
|
-
window.removeEventListener("message",
|
|
290
|
+
window.removeEventListener("message", c), n();
|
|
244
291
|
}
|
|
245
292
|
};
|
|
246
293
|
}
|
|
247
294
|
//#endregion
|
|
248
295
|
//#region src/google-pay.ts
|
|
249
|
-
function
|
|
296
|
+
function T(e) {
|
|
250
297
|
return `${i(e)}/iframe/google-pay?token=${e}`;
|
|
251
298
|
}
|
|
252
|
-
function
|
|
299
|
+
function E() {
|
|
253
300
|
return "40px";
|
|
254
301
|
}
|
|
255
|
-
function
|
|
302
|
+
function D(e, t) {
|
|
256
303
|
let n = { ...t };
|
|
257
304
|
function r() {
|
|
258
|
-
|
|
305
|
+
m({
|
|
259
306
|
iframe: e,
|
|
260
307
|
amount: n.amount
|
|
261
308
|
});
|
|
262
309
|
}
|
|
263
310
|
function i() {
|
|
264
|
-
|
|
311
|
+
h({
|
|
265
312
|
iframe: e,
|
|
266
313
|
merchantName: n.merchantName
|
|
267
314
|
});
|
|
268
315
|
}
|
|
269
|
-
function a(
|
|
316
|
+
function a() {
|
|
317
|
+
p({
|
|
318
|
+
iframe: e,
|
|
319
|
+
props: n
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function o(t) {
|
|
270
323
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
271
324
|
case "IFRAME_READY":
|
|
272
|
-
|
|
325
|
+
u(e), d({
|
|
273
326
|
iframe: e,
|
|
274
327
|
appearance: n.appearance
|
|
275
|
-
}), r(), i();
|
|
328
|
+
}), r(), i(), a();
|
|
276
329
|
break;
|
|
277
330
|
case "UPDATE_HEIGHT":
|
|
278
331
|
n.onHeightChange?.(t.data.height);
|
|
279
332
|
break;
|
|
280
333
|
case "UPDATE_APPEARANCE":
|
|
281
|
-
|
|
334
|
+
d({
|
|
282
335
|
iframe: e,
|
|
283
336
|
appearance: t.data.appearance
|
|
284
337
|
});
|
|
@@ -291,7 +344,7 @@ function S(e, t) {
|
|
|
291
344
|
paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
|
|
292
345
|
customerCreateAttributes: t.data.customerCreateAttributes
|
|
293
346
|
}).then((t) => {
|
|
294
|
-
|
|
347
|
+
v({
|
|
295
348
|
iframe: e,
|
|
296
349
|
token: t
|
|
297
350
|
});
|
|
@@ -305,23 +358,23 @@ function S(e, t) {
|
|
|
305
358
|
case "CONFIRMATION_RESULT": n.onResult(t.data.result);
|
|
306
359
|
}
|
|
307
360
|
}
|
|
308
|
-
return window.addEventListener("message",
|
|
361
|
+
return window.addEventListener("message", o), {
|
|
309
362
|
update(t) {
|
|
310
|
-
let
|
|
363
|
+
let o = "appearance" in t, s = "amount" in t, c = "merchantName" in t, l = "buttonType" in t || "buttonColor" in t || "buttonRadius" in t || "buttonSizeMode" in t || "buttonLocale" in t || "buttonBorderType" in t || "style" in t;
|
|
311
364
|
n = {
|
|
312
365
|
...n,
|
|
313
366
|
...t
|
|
314
|
-
},
|
|
367
|
+
}, o && d({
|
|
315
368
|
iframe: e,
|
|
316
369
|
appearance: n.appearance
|
|
317
|
-
}),
|
|
370
|
+
}), s && r(), c && i(), l && a();
|
|
318
371
|
},
|
|
319
372
|
destroy() {
|
|
320
|
-
window.removeEventListener("message",
|
|
373
|
+
window.removeEventListener("message", o);
|
|
321
374
|
}
|
|
322
375
|
};
|
|
323
376
|
}
|
|
324
|
-
function
|
|
377
|
+
function O({ paymentData: e }) {
|
|
325
378
|
return { paymentMethod: {
|
|
326
379
|
type: "googlepay",
|
|
327
380
|
billing_address_attributes: {
|
|
@@ -340,14 +393,14 @@ function C({ paymentData: e }) {
|
|
|
340
393
|
}
|
|
341
394
|
//#endregion
|
|
342
395
|
//#region src/payment-method-form.ts
|
|
343
|
-
var
|
|
396
|
+
var k = {
|
|
344
397
|
country: 212,
|
|
345
398
|
full: 452
|
|
346
|
-
},
|
|
399
|
+
}, A = 80, j = {
|
|
347
400
|
country: 400,
|
|
348
401
|
full: 640
|
|
349
402
|
};
|
|
350
|
-
function
|
|
403
|
+
function M(e, t = { cardholderName: !1 }, n = "country") {
|
|
351
404
|
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
|
|
352
405
|
token: e,
|
|
353
406
|
additionalFields: r,
|
|
@@ -355,25 +408,25 @@ function D(e, t = { cardholderName: !1 }, n = "country") {
|
|
|
355
408
|
});
|
|
356
409
|
return `${i(e)}/iframe/card?${a}`;
|
|
357
410
|
}
|
|
358
|
-
function
|
|
411
|
+
function N(e, t = "country") {
|
|
359
412
|
let n = new URLSearchParams({
|
|
360
413
|
token: e,
|
|
361
414
|
billingAddressRequirement: t
|
|
362
415
|
});
|
|
363
416
|
return `${i(e)}/iframe/bank?${n}`;
|
|
364
417
|
}
|
|
365
|
-
function
|
|
366
|
-
return `${(
|
|
418
|
+
function P(e = { cardholderName: !1 }, t = "country") {
|
|
419
|
+
return `${(k[t] ?? k.country) + (e.cardholderName ? A : 0)}px`;
|
|
367
420
|
}
|
|
368
|
-
function
|
|
369
|
-
return `${
|
|
421
|
+
function F(e = "country") {
|
|
422
|
+
return `${j[e] ?? j.country}px`;
|
|
370
423
|
}
|
|
371
|
-
function
|
|
424
|
+
function I(e, t) {
|
|
372
425
|
let n = { ...t };
|
|
373
426
|
function r(t) {
|
|
374
427
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
375
428
|
case "IFRAME_READY":
|
|
376
|
-
|
|
429
|
+
u(e), d({
|
|
377
430
|
iframe: e,
|
|
378
431
|
appearance: n.appearance
|
|
379
432
|
});
|
|
@@ -382,7 +435,7 @@ function j(e, t) {
|
|
|
382
435
|
n.onHeightChange?.(t.data.height);
|
|
383
436
|
break;
|
|
384
437
|
case "UPDATE_APPEARANCE":
|
|
385
|
-
|
|
438
|
+
d({
|
|
386
439
|
iframe: e,
|
|
387
440
|
appearance: t.data.appearance
|
|
388
441
|
});
|
|
@@ -399,7 +452,7 @@ function j(e, t) {
|
|
|
399
452
|
n = {
|
|
400
453
|
...n,
|
|
401
454
|
...t
|
|
402
|
-
}, r &&
|
|
455
|
+
}, r && d({
|
|
403
456
|
iframe: e,
|
|
404
457
|
appearance: n.appearance
|
|
405
458
|
});
|
|
@@ -411,7 +464,7 @@ function j(e, t) {
|
|
|
411
464
|
}
|
|
412
465
|
//#endregion
|
|
413
466
|
//#region src/mount.ts
|
|
414
|
-
function
|
|
467
|
+
function L(e) {
|
|
415
468
|
if (typeof e == "string") {
|
|
416
469
|
let t = document.querySelector(e);
|
|
417
470
|
if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
|
|
@@ -419,26 +472,26 @@ function M(e) {
|
|
|
419
472
|
}
|
|
420
473
|
return e;
|
|
421
474
|
}
|
|
422
|
-
var
|
|
475
|
+
var R = {
|
|
423
476
|
width: "calc(100% + 8px)",
|
|
424
477
|
transition: "opacity 150ms ease-in, height 200ms ease-in-out",
|
|
425
478
|
margin: "0 -4px",
|
|
426
479
|
opacity: "0",
|
|
427
480
|
border: "0"
|
|
428
481
|
};
|
|
429
|
-
function
|
|
482
|
+
function z({ src: e, title: t, name: n, height: r, allow: i }) {
|
|
430
483
|
let a = document.createElement("iframe");
|
|
431
|
-
return a.src = e, a.title = t, a.name = n, a.setAttribute("role", "presentation"), a.scrolling = "no", i && (a.allow = i), Object.assign(a.style,
|
|
484
|
+
return a.src = e, a.title = t, a.name = n, a.setAttribute("role", "presentation"), a.scrolling = "no", i && (a.allow = i), Object.assign(a.style, R, { height: r }), a;
|
|
432
485
|
}
|
|
433
|
-
function
|
|
434
|
-
let n =
|
|
435
|
-
src:
|
|
486
|
+
function B(e, t) {
|
|
487
|
+
let n = L(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t, s = z({
|
|
488
|
+
src: M(r, i, a),
|
|
436
489
|
title: "Secure credit card payment method form powered by Amos",
|
|
437
490
|
name: "amos-credit-card-payment-method-form",
|
|
438
|
-
height:
|
|
491
|
+
height: P(i, a)
|
|
439
492
|
});
|
|
440
493
|
n.appendChild(s);
|
|
441
|
-
let c =
|
|
494
|
+
let c = I(s, {
|
|
442
495
|
...o,
|
|
443
496
|
onHeightChange: (e) => {
|
|
444
497
|
s.style.height = e, o.onHeightChange?.(e);
|
|
@@ -455,15 +508,15 @@ function F(e, t) {
|
|
|
455
508
|
}
|
|
456
509
|
};
|
|
457
510
|
}
|
|
458
|
-
function
|
|
459
|
-
let n =
|
|
460
|
-
src:
|
|
511
|
+
function V(e, t) {
|
|
512
|
+
let n = L(e), { renderToken: r, billingAddressRequirement: i = "country", ...a } = t, o = z({
|
|
513
|
+
src: N(r, i),
|
|
461
514
|
title: "Secure bank account payment method form powered by Amos",
|
|
462
515
|
name: "amos-bank-account-payment-method-form",
|
|
463
|
-
height:
|
|
516
|
+
height: F(i)
|
|
464
517
|
});
|
|
465
518
|
n.appendChild(o);
|
|
466
|
-
let s =
|
|
519
|
+
let s = I(o, {
|
|
467
520
|
...a,
|
|
468
521
|
onHeightChange: (e) => {
|
|
469
522
|
o.style.height = e, a.onHeightChange?.(e);
|
|
@@ -480,16 +533,16 @@ function I(e, t) {
|
|
|
480
533
|
}
|
|
481
534
|
};
|
|
482
535
|
}
|
|
483
|
-
function
|
|
484
|
-
let n =
|
|
485
|
-
src:
|
|
536
|
+
function H(e, t) {
|
|
537
|
+
let n = L(e), { renderToken: r, ...i } = t, a = z({
|
|
538
|
+
src: T(r),
|
|
486
539
|
title: "Secure Google Pay button powered by Amos",
|
|
487
540
|
name: "amos-google-pay-button",
|
|
488
|
-
height:
|
|
541
|
+
height: E(),
|
|
489
542
|
allow: "payment"
|
|
490
543
|
});
|
|
491
544
|
n.appendChild(a);
|
|
492
|
-
let o =
|
|
545
|
+
let o = D(a, {
|
|
493
546
|
...i,
|
|
494
547
|
onHeightChange: (e) => {
|
|
495
548
|
a.style.height = e, i.onHeightChange?.(e);
|
|
@@ -506,16 +559,16 @@ function L(e, t) {
|
|
|
506
559
|
}
|
|
507
560
|
};
|
|
508
561
|
}
|
|
509
|
-
function
|
|
510
|
-
let n =
|
|
511
|
-
src:
|
|
562
|
+
function U(e, t) {
|
|
563
|
+
let n = L(e), { renderToken: r, ...i } = t, a = z({
|
|
564
|
+
src: x(r),
|
|
512
565
|
title: "Secure Apple Pay button powered by Amos",
|
|
513
566
|
name: "amos-apple-pay-button",
|
|
514
|
-
height:
|
|
567
|
+
height: S(),
|
|
515
568
|
allow: "payment"
|
|
516
569
|
});
|
|
517
570
|
n.appendChild(a);
|
|
518
|
-
let o =
|
|
571
|
+
let o = w(a, {
|
|
519
572
|
...i,
|
|
520
573
|
onHeightChange: (e) => {
|
|
521
574
|
a.style.height = e, i.onHeightChange?.(e);
|
|
@@ -533,4 +586,4 @@ function R(e, t) {
|
|
|
533
586
|
};
|
|
534
587
|
}
|
|
535
588
|
//#endregion
|
|
536
|
-
export {
|
|
589
|
+
export { w as attachApplePayButtonListeners, D as attachGooglePayButtonListeners, I as attachPaymentMethodFormListeners, v as confirmPaymentIntent, y as confirmSetupIntent, c as createMessage, r as decodeJwt, O as formatGooglePayPaymentData, S as getApplePayButtonInitialHeight, x as getApplePayButtonSrc, F as getBankAccountFormInitialHeight, N as getBankAccountFormSrc, P as getCreditCardFormInitialHeight, M as getCreditCardFormSrc, i as getEmbedOrigin, E as getGooglePayButtonInitialHeight, T as getGooglePayButtonSrc, U as mountAmosApplePayButton, V as mountAmosBankAccountPaymentMethodForm, B as mountAmosCreditCardPaymentMethodForm, H as mountAmosGooglePayButton, o as pickApplePayButtonElementProps, s as pickGooglePayButtonElementProps, _ as resetForm, b as sendConfirmationResult, u as sendParentReadyMessage, a as serializeWalletButtonStyle, m as updateAmount, d as updateAppearance, f as updateApplePayButton, p as updateGooglePayButton, h as updateMerchantName, g as validateForm };
|
package/dist/messaging.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from '@amos.com/node';
|
|
2
|
-
import { Appearance, Message } from './types';
|
|
2
|
+
import { Appearance, ApplePayButtonElementProps, GooglePayButtonElementProps, Message } from './types';
|
|
3
3
|
type Iframe = HTMLIFrameElement | null | undefined;
|
|
4
4
|
/**
|
|
5
5
|
* Resolve the Amos embed origin from an iframe's configured `src`.
|
|
@@ -26,6 +26,20 @@ export declare function updateAppearance({ iframe, appearance, }: {
|
|
|
26
26
|
iframe: Iframe;
|
|
27
27
|
appearance?: Appearance;
|
|
28
28
|
}): void;
|
|
29
|
+
/**
|
|
30
|
+
* Push Apple Pay button visual options into the embedded iframe.
|
|
31
|
+
*/
|
|
32
|
+
export declare function updateApplePayButton({ iframe, props, }: {
|
|
33
|
+
iframe: Iframe;
|
|
34
|
+
props: ApplePayButtonElementProps;
|
|
35
|
+
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* Push Google Pay button visual options into the embedded iframe.
|
|
38
|
+
*/
|
|
39
|
+
export declare function updateGooglePayButton({ iframe, props, }: {
|
|
40
|
+
iframe: Iframe;
|
|
41
|
+
props: GooglePayButtonElementProps;
|
|
42
|
+
}): void;
|
|
29
43
|
/**
|
|
30
44
|
* Push the express-checkout amount into the embedded Google Pay iframe.
|
|
31
45
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export type ConfirmationResult = {
|
|
|
48
48
|
* Amos iframe UI. Only the variables you provide are sent; omitted
|
|
49
49
|
* variables keep their defaults.
|
|
50
50
|
*/
|
|
51
|
-
export type ThemeVariable = "--background" | "--foreground" | "--primary" | "--primary-foreground" | "--secondary" | "--secondary-foreground" | "--muted-foreground" | "--accent" | "--accent-foreground" | "--destructive" | "--border" | "--input" | "--input-background" | "--input-height" | "--input-font-size" | "--floating-label-font-size" | "--floating-label-font-weight" | "--ring" | "--radius";
|
|
51
|
+
export type ThemeVariable = "--background" | "--foreground" | "--primary" | "--primary-foreground" | "--secondary" | "--secondary-foreground" | "--muted" | "--muted-foreground" | "--accent" | "--accent-foreground" | "--destructive" | "--destructive-foreground" | "--border" | "--popover" | "--popover-foreground" | "--input" | "--input-background" | "--input-height" | "--input-font-size" | "--input-font-weight" | "--input-padding" | "--input-border-width" | "--input-shadow" | "--floating-input-height" | "--floating-label-font-size" | "--floating-label-font-weight" | "--floating-label-color" | "--floating-label-offset" | "--label-font-size" | "--label-font-weight" | "--field-gap" | "--control-gap" | "--error-font-size" | "--radio-size" | "--ring" | "--ring-width" | "--radius";
|
|
52
52
|
/**
|
|
53
53
|
* Placement of field labels in payment method forms.
|
|
54
54
|
*
|
|
@@ -69,6 +69,99 @@ export type Appearance = {
|
|
|
69
69
|
*/
|
|
70
70
|
labels?: AppearanceLabels;
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Inline style bag sent through `postMessage` to the wallet-button iframe.
|
|
74
|
+
*
|
|
75
|
+
* Matches the serializable subset of a CSSStyleDeclaration / React
|
|
76
|
+
* `CSSProperties` object (string or number values). Custom properties such
|
|
77
|
+
* as `--apple-pay-button-height` are allowed.
|
|
78
|
+
*/
|
|
79
|
+
export type WalletButtonStyle = {
|
|
80
|
+
[property: string]: string | number | undefined;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* `buttonstyle` attribute on Apple's `<apple-pay-button>`.
|
|
84
|
+
*
|
|
85
|
+
* @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple-pay-button
|
|
86
|
+
*/
|
|
87
|
+
export type ApplePayButtonStyle = "black" | "white" | "white-outline";
|
|
88
|
+
/**
|
|
89
|
+
* `type` attribute on Apple's `<apple-pay-button>`.
|
|
90
|
+
*
|
|
91
|
+
* @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple-pay-button
|
|
92
|
+
*/
|
|
93
|
+
export type ApplePayButtonType = "plain" | "buy" | "set-up" | "donate" | "check-out" | "book" | "subscribe" | "reload" | "add-money" | "top-up" | "order" | "rent" | "support" | "contribute" | "tip";
|
|
94
|
+
/**
|
|
95
|
+
* Visual props for Apple's `<apple-pay-button>`, using Apple's attribute
|
|
96
|
+
* names. Applied inside the Amos embed iframe.
|
|
97
|
+
*
|
|
98
|
+
* @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple-pay-button
|
|
99
|
+
*/
|
|
100
|
+
export type ApplePayButtonElementProps = {
|
|
101
|
+
/**
|
|
102
|
+
* Apple Pay button color.
|
|
103
|
+
*
|
|
104
|
+
* @default "black"
|
|
105
|
+
*/
|
|
106
|
+
buttonstyle?: ApplePayButtonStyle;
|
|
107
|
+
/**
|
|
108
|
+
* Apple Pay button label / verb.
|
|
109
|
+
*
|
|
110
|
+
* @default "plain"
|
|
111
|
+
*/
|
|
112
|
+
type?: ApplePayButtonType;
|
|
113
|
+
/**
|
|
114
|
+
* BCP 47 locale for the button label (e.g. `"en-US"`).
|
|
115
|
+
*
|
|
116
|
+
* @default "en-US"
|
|
117
|
+
*/
|
|
118
|
+
locale?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Inline style for the `<apple-pay-button>`. Height is controlled with
|
|
121
|
+
* `--apple-pay-button-height` (Apple ignores CSS `height`). Width uses
|
|
122
|
+
* `--apple-pay-button-width` or CSS `width`.
|
|
123
|
+
*/
|
|
124
|
+
style?: WalletButtonStyle;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Visual props for Google's Pay button, using `@google-pay/button-react`
|
|
128
|
+
* / Google Pay API names. Applied inside the Amos embed iframe.
|
|
129
|
+
*
|
|
130
|
+
* @see https://developers.google.com/pay/api/web/guides/resources/customize
|
|
131
|
+
*/
|
|
132
|
+
export type GooglePayButtonElementProps = {
|
|
133
|
+
/**
|
|
134
|
+
* Button label / verb.
|
|
135
|
+
*
|
|
136
|
+
* @default "short"
|
|
137
|
+
*/
|
|
138
|
+
buttonType?: google.payments.api.ButtonType;
|
|
139
|
+
/** Button color. */
|
|
140
|
+
buttonColor?: google.payments.api.ButtonColor;
|
|
141
|
+
/** Corner radius in pixels (0–20). */
|
|
142
|
+
buttonRadius?: number;
|
|
143
|
+
/**
|
|
144
|
+
* `"fill"` stretches the button to the container width; `"static"`
|
|
145
|
+
* uses Google's default size.
|
|
146
|
+
*/
|
|
147
|
+
buttonSizeMode?: google.payments.api.ButtonSizeMode;
|
|
148
|
+
/** BCP 47 locale for the button label (e.g. `"en"`). */
|
|
149
|
+
buttonLocale?: string;
|
|
150
|
+
/** Whether the button draws a border. */
|
|
151
|
+
buttonBorderType?: google.payments.api.ButtonBorderType;
|
|
152
|
+
/**
|
|
153
|
+
* Inline style for the Google Pay button wrapper. Use `height` /
|
|
154
|
+
* `width` here (unlike Apple Pay, Google honors CSS `height`).
|
|
155
|
+
*/
|
|
156
|
+
style?: WalletButtonStyle;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Keep only JSON-cloneable string/number declarations from a style object
|
|
160
|
+
* before sending it through `postMessage`.
|
|
161
|
+
*/
|
|
162
|
+
export declare function serializeWalletButtonStyle(style: WalletButtonStyle | undefined): Record<string, string | number> | undefined;
|
|
163
|
+
export declare function pickApplePayButtonElementProps(options: ApplePayButtonElementProps): ApplePayButtonElementProps;
|
|
164
|
+
export declare function pickGooglePayButtonElementProps(options: GooglePayButtonElementProps): GooglePayButtonElementProps;
|
|
72
165
|
/**
|
|
73
166
|
* Typed `postMessage` payloads exchanged between the host page and the
|
|
74
167
|
* embedded Amos iframe.
|
|
@@ -95,6 +188,18 @@ export type Message = {
|
|
|
95
188
|
/** Parent → embed: push appearance overrides into the iframe. */
|
|
96
189
|
type: "UPDATE_APPEARANCE";
|
|
97
190
|
appearance: Appearance;
|
|
191
|
+
} | {
|
|
192
|
+
/**
|
|
193
|
+
* Parent → embed: visual options for the Apple Pay button. Nested
|
|
194
|
+
* under `props` so Apple's `type` attribute does not collide with
|
|
195
|
+
* this message discriminant.
|
|
196
|
+
*/
|
|
197
|
+
type: "UPDATE_APPLE_PAY_BUTTON";
|
|
198
|
+
props: ApplePayButtonElementProps;
|
|
199
|
+
} | {
|
|
200
|
+
/** Parent → embed: visual options for the Google Pay button. */
|
|
201
|
+
type: "UPDATE_GOOGLE_PAY_BUTTON";
|
|
202
|
+
props: GooglePayButtonElementProps;
|
|
98
203
|
} | {
|
|
99
204
|
/**
|
|
100
205
|
* Parent → embed: validate form inputs (`requestId` only).
|