@amos.com/amos-js 0.1.0

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/index.mjs ADDED
@@ -0,0 +1,422 @@
1
+ var y = Object.defineProperty;
2
+ var o = (e, n) => y(e, "name", { value: n, configurable: !0 });
3
+ function u(e) {
4
+ const [n = "", t = "", i = ""] = e?.split(".") ?? [], r = typeof atob == "function" ? atob : (a) => Buffer.from(a, "base64").toString("utf8");
5
+ return {
6
+ header: JSON.parse(r(n)),
7
+ payload: JSON.parse(r(t)),
8
+ signature: i
9
+ };
10
+ }
11
+ o(u, "decodeJwt");
12
+ function m(e) {
13
+ const { env: n = "sandbox" } = u(e).payload;
14
+ switch (n) {
15
+ case "production":
16
+ return "https://embed.amos.com";
17
+ case "sandbox":
18
+ return "https://embed-sandbox.amos.com";
19
+ default:
20
+ return "https://embed-sandbox.amos.com";
21
+ }
22
+ }
23
+ o(m, "getEmbedOrigin");
24
+ function D(e) {
25
+ return e;
26
+ }
27
+ o(D, "createMessage");
28
+ function h(e) {
29
+ e?.contentWindow?.postMessage(
30
+ { type: "PARENT_ACKNOWLEDGED_IFRAME_READY" },
31
+ "*"
32
+ );
33
+ }
34
+ o(h, "sendParentReadyMessage");
35
+ function c({
36
+ iframe: e,
37
+ appearance: n = {}
38
+ }) {
39
+ e?.contentWindow?.postMessage(
40
+ { type: "UPDATE_APPEARANCE", appearance: n },
41
+ "*"
42
+ );
43
+ }
44
+ o(c, "updateAppearance");
45
+ function f({
46
+ iframe: e,
47
+ amount: n
48
+ }) {
49
+ e?.contentWindow?.postMessage(
50
+ { type: "UPDATE_AMOUNT", amount: n },
51
+ "*"
52
+ );
53
+ }
54
+ o(f, "updateAmount");
55
+ function C({
56
+ iframe: e,
57
+ merchantName: n
58
+ }) {
59
+ e?.contentWindow?.postMessage(
60
+ { type: "UPDATE_MERCHANT_NAME", merchantName: n },
61
+ "*"
62
+ );
63
+ }
64
+ o(C, "updateMerchantName");
65
+ function k({ iframe: e }) {
66
+ const n = crypto.randomUUID();
67
+ return new Promise((t) => {
68
+ e?.contentWindow?.postMessage(
69
+ { type: "VALIDATE_FORM", requestId: n },
70
+ "*"
71
+ );
72
+ const i = setTimeout(() => {
73
+ window.removeEventListener("message", r), t(!1);
74
+ }, 5e3);
75
+ function r(a) {
76
+ a.data.type === "VALIDATE_FORM" && a.data.requestId === n && (window.removeEventListener("message", r), clearTimeout(i), t(a.data.isValid ?? !1));
77
+ }
78
+ o(r, "handleMessage"), window.addEventListener("message", r);
79
+ });
80
+ }
81
+ o(k, "validateForm");
82
+ function N({
83
+ iframe: e,
84
+ token: n
85
+ }) {
86
+ const { payment_intent_id: t } = u(n).payload;
87
+ e?.contentWindow?.postMessage(
88
+ {
89
+ type: "CONFIRM_PAYMENT_INTENT",
90
+ token: n,
91
+ id: t ?? void 0
92
+ },
93
+ "*"
94
+ );
95
+ }
96
+ o(N, "confirmPaymentIntent");
97
+ function S({
98
+ iframe: e,
99
+ token: n
100
+ }) {
101
+ const { setup_intent_id: t } = u(n).payload;
102
+ e?.contentWindow?.postMessage(
103
+ {
104
+ type: "CONFIRM_SETUP_INTENT",
105
+ token: n,
106
+ id: t ?? void 0
107
+ },
108
+ "*"
109
+ );
110
+ }
111
+ o(S, "confirmSetupIntent");
112
+ function I({
113
+ iframe: e,
114
+ errorMessage: n
115
+ }) {
116
+ e?.contentWindow?.postMessage(
117
+ {
118
+ type: "CONFIRMATION_FAILED",
119
+ errorMessage: n
120
+ },
121
+ "*"
122
+ );
123
+ }
124
+ o(I, "sendConfirmationFailed");
125
+ function _(e) {
126
+ return `${m(e)}/iframe/google-pay?token=${e}`;
127
+ }
128
+ o(_, "getGooglePayButtonSrc");
129
+ function M() {
130
+ return "40px";
131
+ }
132
+ o(M, "getGooglePayButtonInitialHeight");
133
+ function b(e, n) {
134
+ let t = { ...n };
135
+ function i() {
136
+ f({ iframe: e, amount: t.amount });
137
+ }
138
+ o(i, "pushAmount");
139
+ function r() {
140
+ C({ iframe: e, merchantName: t.merchantName });
141
+ }
142
+ o(r, "pushMerchantName");
143
+ function a(s) {
144
+ switch (s.data.type) {
145
+ case "IFRAME_READY":
146
+ h(e), c({ iframe: e, appearance: t.appearance }), i(), r();
147
+ break;
148
+ case "UPDATE_HEIGHT":
149
+ t.onHeightChange?.(s.data.height);
150
+ break;
151
+ case "UPDATE_APPEARANCE":
152
+ c({ iframe: e, appearance: s.data.appearance });
153
+ break;
154
+ case "UPDATED_APPEARANCE":
155
+ t.onAppearanceReady?.();
156
+ break;
157
+ case "CREATE_PAYMENT_INTENT":
158
+ t.onInitiatePaymentIntentRequest({
159
+ paymentIntentCreateAttributes: s.data.paymentIntentCreateAttributes,
160
+ customerCreateAttributes: s.data.customerCreateAttributes
161
+ }).then((d) => {
162
+ N({ iframe: e, token: d });
163
+ }).catch((d) => {
164
+ I({
165
+ iframe: e,
166
+ errorMessage: d instanceof Error ? d.message : "Unknown error"
167
+ });
168
+ });
169
+ break;
170
+ case "PAYMENT_INTENT_CONFIRMATION_SUCCEEDED":
171
+ t.onPaymentIntentConfirmationSucceeded(s.data.paymentIntent);
172
+ break;
173
+ case "CONFIRMATION_FAILED":
174
+ t.onConfirmationFailed(s.data.errorMessage);
175
+ break;
176
+ }
177
+ }
178
+ return o(a, "handleMessage"), window.addEventListener("message", a), {
179
+ update(s) {
180
+ const d = "appearance" in s, p = "amount" in s, E = "merchantName" in s;
181
+ t = { ...t, ...s }, d && c({ iframe: e, appearance: t.appearance }), p && i(), E && r();
182
+ },
183
+ destroy() {
184
+ window.removeEventListener("message", a);
185
+ }
186
+ };
187
+ }
188
+ o(b, "attachGooglePayButtonListeners");
189
+ function H({
190
+ paymentData: e
191
+ }) {
192
+ return {
193
+ paymentMethod: {
194
+ billing_address_attributes: {
195
+ name: e.shippingAddress?.name,
196
+ address_line1: e.shippingAddress?.address1,
197
+ address_line2: e.shippingAddress?.address2,
198
+ city: e.shippingAddress?.locality,
199
+ state: e.shippingAddress?.administrativeArea,
200
+ postal_code: e.shippingAddress?.postalCode,
201
+ country: e.shippingAddress?.countryCode,
202
+ email: e.email,
203
+ phone: e.shippingAddress?.phoneNumber
204
+ },
205
+ card_profile_attributes: {
206
+ wallet_provider: "googlepay",
207
+ wallet_payload: e.paymentMethodData.tokenizationData.token,
208
+ wallet_last4: e.paymentMethodData.info?.cardDetails,
209
+ wallet_brand: (() => {
210
+ switch (e.paymentMethodData.info?.cardNetwork) {
211
+ case "AMEX":
212
+ return "american_express";
213
+ case "VISA":
214
+ return "visa";
215
+ case "MASTERCARD":
216
+ return "master";
217
+ case "DISCOVER":
218
+ return "discover";
219
+ default:
220
+ return;
221
+ }
222
+ })()
223
+ }
224
+ }
225
+ };
226
+ }
227
+ o(H, "formatGooglePayPaymentData");
228
+ function T(e, n = { cardholderName: !1 }) {
229
+ const t = Object.entries(n).filter(([, i]) => i).map(([i]) => i).join(",");
230
+ return `${m(e)}/iframe/card?token=${e}&additionalFields=${t}`;
231
+ }
232
+ o(T, "getCreditCardFormSrc");
233
+ function P(e) {
234
+ return `${m(e)}/iframe/bank?token=${e}`;
235
+ }
236
+ o(P, "getBankAccountFormSrc");
237
+ function w(e = { cardholderName: !1 }) {
238
+ return e.cardholderName ? "292px" : "212px";
239
+ }
240
+ o(w, "getCreditCardFormInitialHeight");
241
+ function R() {
242
+ return "400px";
243
+ }
244
+ o(R, "getBankAccountFormInitialHeight");
245
+ function g(e, n) {
246
+ let t = { ...n };
247
+ function i(r) {
248
+ switch (r.data.type) {
249
+ case "IFRAME_READY":
250
+ h(e), c({ iframe: e, appearance: t.appearance });
251
+ break;
252
+ case "UPDATE_HEIGHT":
253
+ t.onHeightChange?.(r.data.height);
254
+ break;
255
+ case "UPDATE_APPEARANCE":
256
+ c({ iframe: e, appearance: r.data.appearance });
257
+ break;
258
+ case "UPDATED_APPEARANCE":
259
+ t.onAppearanceReady?.();
260
+ break;
261
+ case "PAYMENT_INTENT_CONFIRMATION_SUCCEEDED":
262
+ t.onPaymentIntentConfirmationSucceeded?.(
263
+ r.data.paymentIntent
264
+ );
265
+ break;
266
+ case "SETUP_INTENT_CONFIRMATION_SUCCEEDED":
267
+ t.onSetupIntentConfirmationSucceeded?.(r.data.setupIntent);
268
+ break;
269
+ case "CONFIRMATION_FAILED":
270
+ t.onConfirmationFailed(r.data.errorMessage);
271
+ break;
272
+ }
273
+ }
274
+ return o(i, "handleMessage"), window.addEventListener("message", i), {
275
+ update(r) {
276
+ const a = "appearance" in r;
277
+ t = { ...t, ...r }, a && c({ iframe: e, appearance: t.appearance });
278
+ },
279
+ destroy() {
280
+ window.removeEventListener("message", i);
281
+ }
282
+ };
283
+ }
284
+ o(g, "attachPaymentMethodFormListeners");
285
+ function l(e) {
286
+ if (typeof e == "string") {
287
+ const n = document.querySelector(e);
288
+ if (!(n instanceof HTMLElement))
289
+ throw new Error(
290
+ `[amos-js] Container "${e}" did not match any HTMLElement.`
291
+ );
292
+ return n;
293
+ }
294
+ return e;
295
+ }
296
+ o(l, "resolveContainer");
297
+ const F = {
298
+ width: "calc(100% + 8px)",
299
+ transition: "opacity 150ms ease-in, height 200ms ease-in-out",
300
+ margin: "0 -4px",
301
+ opacity: "0",
302
+ border: "0"
303
+ };
304
+ function A({
305
+ src: e,
306
+ title: n,
307
+ name: t,
308
+ height: i,
309
+ allow: r
310
+ }) {
311
+ const a = document.createElement("iframe");
312
+ return a.src = e, a.title = n, a.name = t, a.setAttribute("role", "presentation"), a.scrolling = "no", r && (a.allow = r), Object.assign(a.style, F, { height: i }), a;
313
+ }
314
+ o(A, "createIframe");
315
+ function L(e, n) {
316
+ const t = l(e), {
317
+ renderToken: i,
318
+ additionalFields: r = { cardholderName: !1 },
319
+ ...a
320
+ } = n, s = A({
321
+ src: T(i, r),
322
+ title: "Secure credit card payment method form powered by Amos",
323
+ name: "amos-credit-card-payment-method-form",
324
+ height: w(r)
325
+ });
326
+ t.appendChild(s);
327
+ const d = g(s, {
328
+ ...a,
329
+ onHeightChange: /* @__PURE__ */ o((p) => {
330
+ s.style.height = p, a.onHeightChange?.(p);
331
+ }, "onHeightChange"),
332
+ onAppearanceReady: /* @__PURE__ */ o(() => {
333
+ s.style.opacity = "1", a.onAppearanceReady?.();
334
+ }, "onAppearanceReady")
335
+ });
336
+ return {
337
+ iframe: s,
338
+ update: d.update,
339
+ destroy() {
340
+ d.destroy(), s.remove();
341
+ }
342
+ };
343
+ }
344
+ o(L, "mountAmosCreditCardPaymentMethodForm");
345
+ function U(e, n) {
346
+ const t = l(e), { renderToken: i, ...r } = n, a = A({
347
+ src: P(i),
348
+ title: "Secure bank account payment method form powered by Amos",
349
+ name: "amos-bank-account-payment-method-form",
350
+ height: R()
351
+ });
352
+ t.appendChild(a);
353
+ const s = g(a, {
354
+ ...r,
355
+ onHeightChange: /* @__PURE__ */ o((d) => {
356
+ a.style.height = d, r.onHeightChange?.(d);
357
+ }, "onHeightChange"),
358
+ onAppearanceReady: /* @__PURE__ */ o(() => {
359
+ a.style.opacity = "1", r.onAppearanceReady?.();
360
+ }, "onAppearanceReady")
361
+ });
362
+ return {
363
+ iframe: a,
364
+ update: s.update,
365
+ destroy() {
366
+ s.destroy(), a.remove();
367
+ }
368
+ };
369
+ }
370
+ o(U, "mountAmosBankAccountPaymentMethodForm");
371
+ function x(e, n) {
372
+ const t = l(e), { renderToken: i, ...r } = n, a = A({
373
+ src: _(i),
374
+ title: "Secure Google Pay button powered by Amos",
375
+ name: "amos-google-pay-button",
376
+ height: M(),
377
+ allow: "payment"
378
+ });
379
+ t.appendChild(a);
380
+ const s = b(a, {
381
+ ...r,
382
+ onHeightChange: /* @__PURE__ */ o((d) => {
383
+ a.style.height = d, r.onHeightChange?.(d);
384
+ }, "onHeightChange"),
385
+ onAppearanceReady: /* @__PURE__ */ o(() => {
386
+ a.style.opacity = "1", r.onAppearanceReady?.();
387
+ }, "onAppearanceReady")
388
+ });
389
+ return {
390
+ iframe: a,
391
+ update: s.update,
392
+ destroy() {
393
+ s.destroy(), a.remove();
394
+ }
395
+ };
396
+ }
397
+ o(x, "mountAmosGooglePayButton");
398
+ export {
399
+ b as attachGooglePayButtonListeners,
400
+ g as attachPaymentMethodFormListeners,
401
+ N as confirmPaymentIntent,
402
+ S as confirmSetupIntent,
403
+ D as createMessage,
404
+ u as decodeJwt,
405
+ H as formatGooglePayPaymentData,
406
+ R as getBankAccountFormInitialHeight,
407
+ P as getBankAccountFormSrc,
408
+ w as getCreditCardFormInitialHeight,
409
+ T as getCreditCardFormSrc,
410
+ m as getEmbedOrigin,
411
+ M as getGooglePayButtonInitialHeight,
412
+ _ as getGooglePayButtonSrc,
413
+ U as mountAmosBankAccountPaymentMethodForm,
414
+ L as mountAmosCreditCardPaymentMethodForm,
415
+ x as mountAmosGooglePayButton,
416
+ I as sendConfirmationFailed,
417
+ h as sendParentReadyMessage,
418
+ f as updateAmount,
419
+ c as updateAppearance,
420
+ C as updateMerchantName,
421
+ k as validateForm
422
+ };
@@ -0,0 +1,105 @@
1
+ import { components } from '@amos.com/node';
2
+ import { Appearance } from './types';
3
+ /**
4
+ * Build the iframe `src` URL for the embedded Google Pay button.
5
+ */
6
+ export declare function getGooglePayButtonSrc(renderToken: string): string;
7
+ /**
8
+ * Default iframe pixel height for the Google Pay button.
9
+ */
10
+ export declare function getGooglePayButtonInitialHeight(): string;
11
+ /**
12
+ * Options accepted by {@link attachGooglePayButtonListeners}.
13
+ */
14
+ export type GooglePayButtonListenerOptions = {
15
+ /** The amount of the payment, in the same format passed in props. */
16
+ amount: string;
17
+ /** A user-visible merchant name. */
18
+ merchantName: string;
19
+ /**
20
+ * Custom appearance to apply when the iframe first becomes ready and
21
+ * whenever the appearance changes.
22
+ */
23
+ appearance?: Appearance;
24
+ /**
25
+ * Called whenever the iframe asks the host page to resize it. Update
26
+ * the iframe's `height` style here.
27
+ */
28
+ onHeightChange?: (height: string) => void;
29
+ /**
30
+ * Called once the iframe has applied the requested appearance and is
31
+ * ready to be revealed.
32
+ */
33
+ onAppearanceReady?: () => void;
34
+ /**
35
+ * Called when the user initiates a payment intent request via the
36
+ * Google Pay button. Your implementation should create a payment
37
+ * intent on your server and resolve with the resulting embed token.
38
+ */
39
+ onInitiatePaymentIntentRequest: ({ paymentIntentCreateAttributes, customerCreateAttributes, }: {
40
+ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
41
+ customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
42
+ }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
43
+ /**
44
+ * Called when payment intent confirmation succeeds.
45
+ */
46
+ onPaymentIntentConfirmationSucceeded: (paymentIntent: components["schemas"]["PaymentIntent"]) => void;
47
+ /**
48
+ * Called when payment intent confirmation fails.
49
+ */
50
+ onConfirmationFailed: (errorMessage: string) => void;
51
+ };
52
+ /**
53
+ * Controller returned by {@link attachGooglePayButtonListeners} and
54
+ * {@link mountAmosGooglePayButton}.
55
+ */
56
+ export type GooglePayButtonController = {
57
+ /**
58
+ * Update one or more listener options without re-attaching the
59
+ * message listener. Pass `amount` or `merchantName` to push the new
60
+ * value into the iframe; pass `appearance` to update theme variables.
61
+ */
62
+ update: (patch: Partial<GooglePayButtonListenerOptions>) => void;
63
+ /**
64
+ * Detach the iframe message listener.
65
+ */
66
+ destroy: () => void;
67
+ };
68
+ /**
69
+ * Wire up the host-page side of the Google Pay iframe message protocol
70
+ * on an existing `<iframe>` element. Returns a controller for updating
71
+ * options and tearing down the listener.
72
+ *
73
+ * The iframe is expected to have already been added to the DOM with the
74
+ * correct `src` (see {@link getGooglePayButtonSrc}).
75
+ */
76
+ export declare function attachGooglePayButtonListeners(iframe: HTMLIFrameElement, options: GooglePayButtonListenerOptions): GooglePayButtonController;
77
+ /**
78
+ * Transform raw Google Pay payment data into an Amos-compatible
79
+ * `paymentMethod` payload. Use this when integrating with the raw
80
+ * Google Pay API directly instead of through
81
+ * {@link mountAmosGooglePayButton} (or the React equivalent).
82
+ */
83
+ export declare function formatGooglePayPaymentData({ paymentData, }: {
84
+ paymentData: google.payments.api.PaymentData;
85
+ }): {
86
+ paymentMethod: {
87
+ billing_address_attributes: {
88
+ name: string | undefined;
89
+ address_line1: string | undefined;
90
+ address_line2: string | undefined;
91
+ city: string | undefined;
92
+ state: string | undefined;
93
+ postal_code: string | undefined;
94
+ country: string | undefined;
95
+ email: string | undefined;
96
+ phone: string | undefined;
97
+ };
98
+ card_profile_attributes: {
99
+ wallet_provider: string;
100
+ wallet_payload: string;
101
+ wallet_last4: string | undefined;
102
+ wallet_brand: string | undefined;
103
+ };
104
+ };
105
+ };
@@ -0,0 +1,52 @@
1
+ import { components } from '@amos.com/node';
2
+ export type { GooglePayButtonController, GooglePayButtonListenerOptions, } from './google-pay';
3
+ export { attachGooglePayButtonListeners, formatGooglePayPaymentData, getGooglePayButtonInitialHeight, getGooglePayButtonSrc, } from './google-pay';
4
+ export { decodeJwt, getEmbedOrigin } from './jwt';
5
+ export { confirmPaymentIntent, confirmSetupIntent, sendConfirmationFailed, sendParentReadyMessage, updateAmount, updateAppearance, updateMerchantName, validateForm, } from './messaging';
6
+ export type { AmosBankAccountPaymentMethodFormOptions, AmosCreditCardPaymentMethodFormOptions, AmosGooglePayButtonMountController, AmosGooglePayButtonOptions, AmosPaymentMethodFormMountController, } from './mount';
7
+ export { mountAmosBankAccountPaymentMethodForm, mountAmosCreditCardPaymentMethodForm, mountAmosGooglePayButton, } from './mount';
8
+ export type { CreditCardAdditionalFields, PaymentMethodFormController, PaymentMethodFormListenerOptions, } from './payment-method-form';
9
+ export { attachPaymentMethodFormListeners, getBankAccountFormInitialHeight, getBankAccountFormSrc, getCreditCardFormInitialHeight, getCreditCardFormSrc, } from './payment-method-form';
10
+ export type { Appearance, Message, ThemeVariable, } from './types';
11
+ export { createMessage } from './types';
12
+ /**
13
+ * Convenience alias for `components["schemas"]["CreateCustomerInput"]`.
14
+ */
15
+ export type CreateCustomerInput = components["schemas"]["CreateCustomerInput"];
16
+ /**
17
+ * Convenience alias for
18
+ * `components["schemas"]["CreatePaymentIntentInput"]`.
19
+ */
20
+ export type CreatePaymentIntentInput = components["schemas"]["CreatePaymentIntentInput"];
21
+ /**
22
+ * Convenience alias for
23
+ * `components["schemas"]["CreateSetupIntentInput"]`.
24
+ */
25
+ export type CreateSetupIntentInput = components["schemas"]["CreateSetupIntentInput"];
26
+ /**
27
+ * Convenience alias for `components["schemas"]["PaymentIntent"]`.
28
+ */
29
+ export type PaymentIntent = components["schemas"]["PaymentIntent"];
30
+ /**
31
+ * Convenience alias for `components["schemas"]["SetupIntent"]`.
32
+ */
33
+ export type SetupIntent = components["schemas"]["SetupIntent"];
34
+ /**
35
+ * API envelope `{ token?, ttl? }` for a minted embed JWT.
36
+ *
37
+ * `POST /payment_intents` and `POST /setup_intents` resolve to this
38
+ * shape. {@link confirmPaymentIntent}, {@link confirmSetupIntent}, and
39
+ * the Google Pay `onInitiatePaymentIntentRequest` return type use
40
+ * `Pick<EmbedToken, "token">` (the JWT string returned by your server).
41
+ */
42
+ export type EmbedToken = components["schemas"]["EmbedToken"];
43
+ /**
44
+ * Decoded JWT payload for an embed token (`account_id`,
45
+ * `payment_intent_id`, `setup_intent_id`, etc.).
46
+ */
47
+ export type EmbedTokenJwt = components["schemas"]["EmbedTokenJwt"];
48
+ /**
49
+ * Decoded JWT payload for the dashboard render token (`env`, `origins`,
50
+ * `allowed_payment_method_types`, `render_template_id`, etc.).
51
+ */
52
+ export type RenderTokenJwt = components["schemas"]["RenderTokenJwt"];
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Decode a JWT into its `{ header, payload, signature }` parts without
3
+ * verifying the signature.
4
+ *
5
+ * Works in both browser (`atob`) and Node (`Buffer`) environments.
6
+ */
7
+ export declare function decodeJwt(token: string | undefined): {
8
+ header: Record<string, unknown>;
9
+ payload: Record<string, unknown>;
10
+ signature: string;
11
+ };
12
+ /**
13
+ * Resolve the Amos embed origin (production vs. sandbox) from a render
14
+ * token's decoded payload.
15
+ */
16
+ export declare function getEmbedOrigin(renderToken: string): string;
@@ -0,0 +1,73 @@
1
+ import { components } from '@amos.com/node';
2
+ import { Appearance } from './types';
3
+ type Iframe = HTMLIFrameElement | null | undefined;
4
+ /**
5
+ * Notify the embedded iframe that the host page is ready to receive
6
+ * messages. The SDK calls this internally after receiving an
7
+ * `IFRAME_READY` event from the iframe.
8
+ */
9
+ export declare function sendParentReadyMessage(iframe: Iframe): void;
10
+ /**
11
+ * Push appearance overrides into the embedded iframe.
12
+ *
13
+ * Only the provided `themeVariables` are sent; omitted variables keep
14
+ * their defaults.
15
+ */
16
+ export declare function updateAppearance({ iframe, appearance, }: {
17
+ iframe: Iframe;
18
+ appearance?: Appearance;
19
+ }): void;
20
+ /**
21
+ * Push the express-checkout amount into the embedded Google Pay iframe.
22
+ */
23
+ export declare function updateAmount({ iframe, amount, }: {
24
+ iframe: Iframe;
25
+ amount: string;
26
+ }): void;
27
+ /**
28
+ * Push the user-visible merchant name into the embedded Google Pay
29
+ * iframe.
30
+ */
31
+ export declare function updateMerchantName({ iframe, merchantName, }: {
32
+ iframe: Iframe;
33
+ merchantName: string;
34
+ }): void;
35
+ /**
36
+ * Ask the embedded credit-card or bank-account iframe form to validate
37
+ * its inputs.
38
+ *
39
+ * Resolves to `true` if the form is valid, `false` if it is not, or
40
+ * `false` if the iframe does not respond within 5 seconds.
41
+ */
42
+ export declare function validateForm({ iframe }: {
43
+ iframe: Iframe;
44
+ }): Promise<boolean>;
45
+ /**
46
+ * Confirm a payment intent in the embedded iframe flow.
47
+ *
48
+ * Pass the embed JWT (`token`) returned by your server's
49
+ * `POST /payment_intents` call. The matching `payment_intent_id` is
50
+ * extracted from the JWT payload and forwarded to the iframe.
51
+ */
52
+ export declare function confirmPaymentIntent({ iframe, token, }: {
53
+ iframe: Iframe;
54
+ } & Pick<components["schemas"]["EmbedToken"], "token">): void;
55
+ /**
56
+ * Confirm a setup intent in the embedded iframe flow.
57
+ *
58
+ * Pass the embed JWT (`token`) returned by your server's
59
+ * `POST /setup_intents` call. The matching `setup_intent_id` is
60
+ * extracted from the JWT payload and forwarded to the iframe.
61
+ */
62
+ export declare function confirmSetupIntent({ iframe, token, }: {
63
+ iframe: Iframe;
64
+ } & Pick<components["schemas"]["EmbedToken"], "token">): void;
65
+ /**
66
+ * Notify the iframe that confirmation failed (used by express-checkout
67
+ * flows after `onInitiatePaymentIntentRequest` rejects).
68
+ */
69
+ export declare function sendConfirmationFailed({ iframe, errorMessage, }: {
70
+ iframe: Iframe;
71
+ errorMessage: string;
72
+ }): void;
73
+ export {};