@amos.com/react-amos-js 0.7.2 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -32
- package/dist/index.d.ts +9 -15
- package/dist/index.js +1 -1
- package/dist/index.mjs +39 -51
- package/package.json +7 -7
- package/src/index.tsx +17 -56
package/README.md
CHANGED
|
@@ -37,12 +37,12 @@ The render token configures the iframe's allowed origin(s), allowed payment meth
|
|
|
37
37
|
The following flow is for credit card and bank account payment method types only.
|
|
38
38
|
|
|
39
39
|
1. **Set up prerequisites**: create a `renderToken` (safe for client), and keep `apiKey` and `accountId` server-side only.
|
|
40
|
-
2. **Render your checkout UI** with one of the payment method components (e.g. `AmosCreditCardPaymentMethodForm`) along with the required
|
|
40
|
+
2. **Render your checkout UI** with one of the payment method components (e.g. `AmosCreditCardPaymentMethodForm`) along with the required `onResult` prop. The iframe height is auto-managed by the SDK.
|
|
41
41
|
3. **User clicks "Pay now" button**: call `validateForm({ iframeRef })`, which returns `Promise<true>` if the embedded form is valid and `Promise<false>` otherwise.
|
|
42
42
|
4. **Create payment intent on your server**: use your server-side Amos client to call `POST /payment_intents`. You may also associate this payment intent with a new or existing customer via `POST /customers`. This must be server-side because it uses your private API key.
|
|
43
43
|
5. **Return the payment intent token to the browser**: your backend responds with the embed token (`components["schemas"]["EmbedToken"]`) needed for confirmation.
|
|
44
44
|
6. **Confirm the payment intent from the client**: call `confirmPaymentIntent({ iframeRef, token })` to continue the payment flow.
|
|
45
|
-
7. **Handle UX**: show the user a "processing" state when the "Pay now" button is clicked, and
|
|
45
|
+
7. **Handle UX**: show the user a "processing" state when the "Pay now" button is clicked, and handle `onResult`. Verify settlement on your backend via webhooks. Recoverable field errors stay in the iframe (`status: "incomplete"`).
|
|
46
46
|
|
|
47
47
|
### Google Pay & Apple Pay
|
|
48
48
|
|
|
@@ -60,7 +60,7 @@ Setup intents are used to save payment methods for future use (e.g. recurring pa
|
|
|
60
60
|
|
|
61
61
|
- On the server, call `POST /setup_intents` instead of `POST /payment_intents`.
|
|
62
62
|
- On the client, call `confirmSetupIntent({ iframeRef, token })` instead of `confirmPaymentIntent({ iframeRef, token })`.
|
|
63
|
-
-
|
|
63
|
+
- The same `onResult` callback is used for setup intents (`intent: "setup"`).
|
|
64
64
|
|
|
65
65
|
The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents — they are differentiated by which confirmation function you call.
|
|
66
66
|
|
|
@@ -92,7 +92,9 @@ Every component accepts an optional `appearance` prop that controls the look of
|
|
|
92
92
|
"--radius": "0.25rem",
|
|
93
93
|
},
|
|
94
94
|
}}
|
|
95
|
-
|
|
95
|
+
onResult={(result) => {
|
|
96
|
+
if (result.status === "failed") setError(result.errorMessage)
|
|
97
|
+
}}
|
|
96
98
|
/>
|
|
97
99
|
```
|
|
98
100
|
|
|
@@ -197,13 +199,11 @@ function CheckoutForm() {
|
|
|
197
199
|
ref={iframeRef}
|
|
198
200
|
renderToken="the-render-token-that-you-created-on-dashboard.amos.com"
|
|
199
201
|
additionalFields={{ cardholderName: true }}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
setError(errorMessage);
|
|
206
|
-
}}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
onResult={(result) => {
|
|
205
|
+
if (result.status === "failed") console.error(result.errorMessage)
|
|
206
|
+
}}}
|
|
207
207
|
/>
|
|
208
208
|
{error ? <p>{error}</p> : null}
|
|
209
209
|
<button type="submit" disabled={isProcessing}>
|
|
@@ -249,12 +249,10 @@ function CheckoutGooglePay() {
|
|
|
249
249
|
const { token } = await response.json();
|
|
250
250
|
return token;
|
|
251
251
|
}}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
setError(errorMessage);
|
|
257
|
-
}}
|
|
252
|
+
}
|
|
253
|
+
onResult={(result) => {
|
|
254
|
+
if (result.status === "failed") console.error(result.errorMessage)
|
|
255
|
+
}}}
|
|
258
256
|
/>
|
|
259
257
|
{error ? <p>{error}</p> : null}
|
|
260
258
|
</>
|
|
@@ -319,13 +317,11 @@ function SavePaymentMethodForm() {
|
|
|
319
317
|
<AmosCreditCardPaymentMethodForm
|
|
320
318
|
ref={iframeRef}
|
|
321
319
|
renderToken="the-render-token-that-you-created-on-dashboard.amos.com"
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
setError(errorMessage);
|
|
328
|
-
}}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
onResult={(result) => {
|
|
323
|
+
if (result.status === "failed") console.error(result.errorMessage)
|
|
324
|
+
}}}
|
|
329
325
|
/>
|
|
330
326
|
{error ? <p>{error}</p> : null}
|
|
331
327
|
<button type="submit" disabled={isProcessing}>
|
|
@@ -377,13 +373,13 @@ Renders the secure credit card iframe form.
|
|
|
377
373
|
**Required props:**
|
|
378
374
|
|
|
379
375
|
- `renderToken` (`string`)
|
|
380
|
-
- `
|
|
376
|
+
- `onResult` (`(result: ConfirmationResult) => void`) — required
|
|
381
377
|
|
|
382
378
|
**Optional props:**
|
|
383
379
|
|
|
384
380
|
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`) — appearance overrides for the iframe UI (see [Appearance](#appearance))
|
|
385
|
-
|
|
386
|
-
|
|
381
|
+
|
|
382
|
+
|
|
387
383
|
- `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
|
|
388
384
|
- `billingAddressRequirement` (`"country" | "full"`, defaults to `"country"`) — how much billing address the iframe collects. `country` collects country / region and, for CA / PR / GB / US, a postal code (labeled ZIP for the United States). `full` shows a full street address form with Smarty autocomplete.
|
|
389
385
|
|
|
@@ -393,9 +389,9 @@ Renders the secure credit card iframe form.
|
|
|
393
389
|
|
|
394
390
|
Renders the secure bank account iframe form.
|
|
395
391
|
|
|
396
|
-
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `
|
|
392
|
+
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `onResult`.
|
|
397
393
|
|
|
398
|
-
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement
|
|
394
|
+
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`.
|
|
399
395
|
|
|
400
396
|
**Also accepts:** standard iframe props.
|
|
401
397
|
|
|
@@ -409,8 +405,8 @@ Renders the secure Google Pay iframe button (express checkout flow).
|
|
|
409
405
|
- `amount` (`string`)
|
|
410
406
|
- `merchantName` (`string`)
|
|
411
407
|
- `onInitiatePaymentIntentRequest` (callback receiving `{ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"]; customerCreateAttributes: components["schemas"]["CreateCustomerInput"] }`, returns `Promise<components["schemas"]["EmbedToken"]["token"]>` — the embed JWT string for confirmation)
|
|
412
|
-
|
|
413
|
-
- `
|
|
408
|
+
|
|
409
|
+
- `onResult` (`(result: ConfirmationResult) => void`) — required
|
|
414
410
|
|
|
415
411
|
**Optional props:**
|
|
416
412
|
|
|
@@ -445,7 +441,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
445
441
|
## Notes and potential gotchas
|
|
446
442
|
|
|
447
443
|
- **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPaymentIntent`, or `confirmSetupIntent`. The component forwards the ref to the inner iframe.
|
|
448
|
-
- **Same components for payment vs setup intents**: `AmosCreditCardPaymentMethodForm` and `AmosBankAccountPaymentMethodForm` support both payment intents and setup intents. The flow differs only by which server call you make and which confirmation function you use (`confirmPaymentIntent` vs `confirmSetupIntent`).
|
|
444
|
+
- **Same components for payment vs setup intents**: `AmosCreditCardPaymentMethodForm` and `AmosBankAccountPaymentMethodForm` support both payment intents and setup intents. The flow differs only by which server call you make and which confirmation function you use (`confirmPaymentIntent` vs `confirmSetupIntent`). Handle both payment and setup outcomes via `onResult`.
|
|
449
445
|
- **Amount format**: for `AmosGooglePayButton` and `AmosApplePayButton`, `amount` is a string (e.g. `"5000"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server, `amount` is a number in cents (e.g. `5000`).
|
|
450
446
|
- **Apple Pay waiting overlay**: on browsers where Apple's QR handoff opens in a popup (non-Safari), `AmosApplePayButton` shows a fixed full-viewport overlay on the host page until payment completes, the popup closes, or the user clicks **Cancel payment**. Avoid stacking other fixed UI above it.
|
|
451
447
|
- **Going framework-free**: if you need to use Amos outside of React (vanilla JS, another framework, etc.), use [`@amos.com/amos-js`](../amos-js) directly.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="googlepay" />
|
|
2
|
-
import { Appearance, BillingAddressRequirement, CreditCardAdditionalFields } from '@amos.com/amos-js';
|
|
2
|
+
import { Appearance, BillingAddressRequirement, ConfirmationResult, CreditCardAdditionalFields } from '@amos.com/amos-js';
|
|
3
3
|
import { components } from '@amos.com/node';
|
|
4
4
|
import { ComponentProps, RefObject } from 'react';
|
|
5
5
|
export * from '@amos.com/amos-js';
|
|
@@ -37,22 +37,18 @@ type IframePassthroughProps = Omit<ComponentProps<"iframe">, "src" | "title" | "
|
|
|
37
37
|
type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
38
38
|
renderToken: string;
|
|
39
39
|
appearance?: Appearance;
|
|
40
|
-
|
|
41
|
-
onSetupIntentConfirmationSucceeded?: (setupIntent: components["schemas"]["SetupIntent"]) => void;
|
|
42
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
40
|
+
onResult: (result: ConfirmationResult) => void;
|
|
43
41
|
additionalFields?: CreditCardAdditionalFields;
|
|
44
42
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
45
43
|
};
|
|
46
|
-
export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance,
|
|
44
|
+
export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onResult, additionalFields, billingAddressRequirement, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
|
|
47
45
|
type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
48
46
|
renderToken: string;
|
|
49
47
|
appearance?: Appearance;
|
|
50
|
-
|
|
51
|
-
onSetupIntentConfirmationSucceeded?: (setupIntent: components["schemas"]["SetupIntent"]) => void;
|
|
52
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
48
|
+
onResult: (result: ConfirmationResult) => void;
|
|
53
49
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
54
50
|
};
|
|
55
|
-
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance,
|
|
51
|
+
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onResult, billingAddressRequirement, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
|
|
56
52
|
type AmosGooglePayButtonProps = IframePassthroughProps & {
|
|
57
53
|
renderToken: string;
|
|
58
54
|
amount: string;
|
|
@@ -62,10 +58,9 @@ type AmosGooglePayButtonProps = IframePassthroughProps & {
|
|
|
62
58
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
63
59
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
64
60
|
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
65
|
-
|
|
66
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
61
|
+
onResult: (result: ConfirmationResult) => void;
|
|
67
62
|
};
|
|
68
|
-
export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest,
|
|
63
|
+
export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, style, ...rest }: AmosGooglePayButtonProps): import("react").JSX.Element;
|
|
69
64
|
type AmosApplePayButtonProps = IframePassthroughProps & {
|
|
70
65
|
renderToken: string;
|
|
71
66
|
amount: string;
|
|
@@ -75,7 +70,6 @@ type AmosApplePayButtonProps = IframePassthroughProps & {
|
|
|
75
70
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
76
71
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
77
72
|
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
78
|
-
|
|
79
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
73
|
+
onResult: (result: ConfirmationResult) => void;
|
|
80
74
|
};
|
|
81
|
-
export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest,
|
|
75
|
+
export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, style, ...rest }: AmosApplePayButtonProps): import("react").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function r(e){return e?e.current??null:null}function i({iframeRef:t}){return(0,e.validateForm)({iframe:r(t)})}function a({iframeRef:t,token:n}){(0,e.confirmPaymentIntent)({iframe:r(t),token:n})}function o({iframeRef:t,token:n}){(0,e.confirmSetupIntent)({iframe:r(t),token:n})}function s(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function c(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),t!=null&&Object.assign(e.style,t);for(let[t,n]of Object.entries(i))n!=null&&(t in e?Reflect.set(e,t,n):e.setAttribute(t,String(n)))}function l({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:l}){let u=(0,t.useRef)(null);(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return u.current=a,s(n,a.iframe),c(a.iframe,o),()=>{a.destroy(),u.current=null,s(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...l]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&c(e,o)})}function u({ref:r,renderToken:i,appearance:a,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function r(e){return e?e.current??null:null}function i({iframeRef:t}){return(0,e.validateForm)({iframe:r(t)})}function a({iframeRef:t,token:n}){(0,e.confirmPaymentIntent)({iframe:r(t),token:n})}function o({iframeRef:t,token:n}){(0,e.confirmSetupIntent)({iframe:r(t),token:n})}function s(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function c(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),t!=null&&Object.assign(e.style,t);for(let[t,n]of Object.entries(i))n!=null&&(t in e?Reflect.set(e,t,n):e.setAttribute(t,String(n)))}function l({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:l}){let u=(0,t.useRef)(null);(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return u.current=a,s(n,a.iframe),c(a.iframe,o),()=>{a.destroy(),u.current=null,s(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...l]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&c(e,o)})}function u({ref:r,renderToken:i,appearance:a,onResult:o,additionalFields:s={cardholderName:!1},billingAddressRequirement:c=`country`,style:u,...d}){let f=(0,t.useRef)(null);return l({containerRef:f,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:s,billingAddressRequirement:c,onResult:o},remountDeps:[i,s.cardholderName,c],iframePassthrough:{style:u,...d},updateDeps:[a,s,c,o]}),(0,n.jsx)(`div`,{ref:f})}function d({ref:r,renderToken:i,appearance:a,onResult:o,billingAddressRequirement:s=`country`,style:c,...u}){let d=(0,t.useRef)(null);return l({containerRef:d,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:s,onResult:o},remountDeps:[i,s],iframePassthrough:{style:c,...u},updateDeps:[a,s,o]}),(0,n.jsx)(`div`,{ref:d})}function f({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u},remountDeps:[i],iframePassthrough:{style:d,...f},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(`div`,{ref:p})}function p({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u},remountDeps:[i],iframePassthrough:{style:d,...f},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(`div`,{ref:p})}exports.AmosApplePayButton=p,exports.AmosBankAccountPaymentMethodForm=d,exports.AmosCreditCardPaymentMethodForm=u,exports.AmosGooglePayButton=f,exports.confirmPaymentIntent=a,exports.confirmSetupIntent=o,exports.validateForm=i,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
package/dist/index.mjs
CHANGED
|
@@ -44,72 +44,64 @@ function g({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i
|
|
|
44
44
|
e && h(e, a);
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function _({ ref: e, renderToken: t, appearance: n,
|
|
48
|
-
let
|
|
47
|
+
function _({ ref: e, renderToken: t, appearance: n, onResult: r, additionalFields: a = { cardholderName: !1 }, billingAddressRequirement: o = "country", style: s, ...u }) {
|
|
48
|
+
let d = c(null);
|
|
49
49
|
return g({
|
|
50
|
-
containerRef:
|
|
50
|
+
containerRef: d,
|
|
51
51
|
iframeRef: e,
|
|
52
52
|
mount: i,
|
|
53
53
|
options: {
|
|
54
54
|
renderToken: t,
|
|
55
55
|
appearance: n,
|
|
56
|
-
additionalFields:
|
|
57
|
-
billingAddressRequirement:
|
|
58
|
-
|
|
59
|
-
onSetupIntentConfirmationSucceeded: a,
|
|
60
|
-
onConfirmationFailed: o
|
|
56
|
+
additionalFields: a,
|
|
57
|
+
billingAddressRequirement: o,
|
|
58
|
+
onResult: r
|
|
61
59
|
},
|
|
62
60
|
remountDeps: [
|
|
63
61
|
t,
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
a.cardholderName,
|
|
63
|
+
o
|
|
66
64
|
],
|
|
67
65
|
iframePassthrough: {
|
|
68
|
-
style:
|
|
69
|
-
...
|
|
66
|
+
style: s,
|
|
67
|
+
...u
|
|
70
68
|
},
|
|
71
69
|
updateDeps: [
|
|
72
70
|
n,
|
|
73
|
-
s,
|
|
74
|
-
u,
|
|
75
|
-
r,
|
|
76
71
|
a,
|
|
77
|
-
o
|
|
72
|
+
o,
|
|
73
|
+
r
|
|
78
74
|
]
|
|
79
|
-
}), /* @__PURE__ */ l("div", { ref:
|
|
75
|
+
}), /* @__PURE__ */ l("div", { ref: d });
|
|
80
76
|
}
|
|
81
|
-
function v({ ref: e, renderToken: t, appearance: n,
|
|
82
|
-
let
|
|
77
|
+
function v({ ref: e, renderToken: t, appearance: n, onResult: i, billingAddressRequirement: a = "country", style: o, ...s }) {
|
|
78
|
+
let u = c(null);
|
|
83
79
|
return g({
|
|
84
|
-
containerRef:
|
|
80
|
+
containerRef: u,
|
|
85
81
|
iframeRef: e,
|
|
86
82
|
mount: r,
|
|
87
83
|
options: {
|
|
88
84
|
renderToken: t,
|
|
89
85
|
appearance: n,
|
|
90
|
-
billingAddressRequirement:
|
|
91
|
-
|
|
92
|
-
onSetupIntentConfirmationSucceeded: a,
|
|
93
|
-
onConfirmationFailed: o
|
|
86
|
+
billingAddressRequirement: a,
|
|
87
|
+
onResult: i
|
|
94
88
|
},
|
|
95
|
-
remountDeps: [t,
|
|
89
|
+
remountDeps: [t, a],
|
|
96
90
|
iframePassthrough: {
|
|
97
|
-
style:
|
|
98
|
-
...
|
|
91
|
+
style: o,
|
|
92
|
+
...s
|
|
99
93
|
},
|
|
100
94
|
updateDeps: [
|
|
101
95
|
n,
|
|
102
|
-
s,
|
|
103
|
-
i,
|
|
104
96
|
a,
|
|
105
|
-
|
|
97
|
+
i
|
|
106
98
|
]
|
|
107
|
-
}), /* @__PURE__ */ l("div", { ref:
|
|
99
|
+
}), /* @__PURE__ */ l("div", { ref: u });
|
|
108
100
|
}
|
|
109
|
-
function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o,
|
|
110
|
-
let
|
|
101
|
+
function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onResult: s, style: u, ...d }) {
|
|
102
|
+
let f = c(null);
|
|
111
103
|
return g({
|
|
112
|
-
containerRef:
|
|
104
|
+
containerRef: f,
|
|
113
105
|
iframeRef: e,
|
|
114
106
|
mount: a,
|
|
115
107
|
options: {
|
|
@@ -118,28 +110,26 @@ function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i,
|
|
|
118
110
|
merchantName: r,
|
|
119
111
|
appearance: i,
|
|
120
112
|
onInitiatePaymentIntentRequest: o,
|
|
121
|
-
|
|
122
|
-
onConfirmationFailed: u
|
|
113
|
+
onResult: s
|
|
123
114
|
},
|
|
124
115
|
remountDeps: [t],
|
|
125
116
|
iframePassthrough: {
|
|
126
|
-
style:
|
|
127
|
-
...
|
|
117
|
+
style: u,
|
|
118
|
+
...d
|
|
128
119
|
},
|
|
129
120
|
updateDeps: [
|
|
130
121
|
n,
|
|
131
122
|
r,
|
|
132
123
|
i,
|
|
133
124
|
o,
|
|
134
|
-
s
|
|
135
|
-
u
|
|
125
|
+
s
|
|
136
126
|
]
|
|
137
|
-
}), /* @__PURE__ */ l("div", { ref:
|
|
127
|
+
}), /* @__PURE__ */ l("div", { ref: f });
|
|
138
128
|
}
|
|
139
|
-
function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o,
|
|
140
|
-
let
|
|
129
|
+
function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onResult: s, style: u, ...d }) {
|
|
130
|
+
let f = c(null);
|
|
141
131
|
return g({
|
|
142
|
-
containerRef:
|
|
132
|
+
containerRef: f,
|
|
143
133
|
iframeRef: e,
|
|
144
134
|
mount: n,
|
|
145
135
|
options: {
|
|
@@ -148,23 +138,21 @@ function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a,
|
|
|
148
138
|
merchantName: i,
|
|
149
139
|
appearance: a,
|
|
150
140
|
onInitiatePaymentIntentRequest: o,
|
|
151
|
-
|
|
152
|
-
onConfirmationFailed: u
|
|
141
|
+
onResult: s
|
|
153
142
|
},
|
|
154
143
|
remountDeps: [t],
|
|
155
144
|
iframePassthrough: {
|
|
156
|
-
style:
|
|
157
|
-
...
|
|
145
|
+
style: u,
|
|
146
|
+
...d
|
|
158
147
|
},
|
|
159
148
|
updateDeps: [
|
|
160
149
|
r,
|
|
161
150
|
i,
|
|
162
151
|
a,
|
|
163
152
|
o,
|
|
164
|
-
s
|
|
165
|
-
u
|
|
153
|
+
s
|
|
166
154
|
]
|
|
167
|
-
}), /* @__PURE__ */ l("div", { ref:
|
|
155
|
+
}), /* @__PURE__ */ l("div", { ref: f });
|
|
168
156
|
}
|
|
169
157
|
//#endregion
|
|
170
158
|
export { b as AmosApplePayButton, v as AmosBankAccountPaymentMethodForm, _ as AmosCreditCardPaymentMethodForm, y as AmosGooglePayButton, f as confirmPaymentIntent, p as confirmSetupIntent, d as validateForm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"description": "React SDK for embedding Amos payment methods via iframes. Wraps @amos.com/amos-js.",
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@biomejs/biome": "2.5.
|
|
39
|
+
"@biomejs/biome": "2.5.7",
|
|
40
40
|
"@changesets/cli": "2.31.1",
|
|
41
|
-
"@types/node": "26.1.
|
|
42
|
-
"@types/react": "19.2.
|
|
41
|
+
"@types/node": "26.1.2",
|
|
42
|
+
"@types/react": "19.2.18",
|
|
43
43
|
"@typescript/typescript6": "6.0.2",
|
|
44
44
|
"typescript": "7.0.2",
|
|
45
|
-
"vite": "8.
|
|
45
|
+
"vite": "8.2.0",
|
|
46
46
|
"vite-plugin-dts": "5.0.3"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@amos.com/amos-js": "0.
|
|
50
|
-
"@amos.com/node": "0.1.
|
|
49
|
+
"@amos.com/amos-js": "0.9.1",
|
|
50
|
+
"@amos.com/node": "0.1.35",
|
|
51
51
|
"@types/googlepay": "0.7.11"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
confirmSetupIntent as amosConfirmSetupIntent,
|
|
7
7
|
validateForm as amosValidateForm,
|
|
8
8
|
type BillingAddressRequirement,
|
|
9
|
+
type ConfirmationResult,
|
|
9
10
|
type CreditCardAdditionalFields,
|
|
10
11
|
mountAmosApplePayButton,
|
|
11
12
|
mountAmosBankAccountPaymentMethodForm,
|
|
@@ -181,13 +182,7 @@ function useAmosEmbed<TOptions extends Record<string, unknown>>({
|
|
|
181
182
|
type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
182
183
|
renderToken: string;
|
|
183
184
|
appearance?: Appearance;
|
|
184
|
-
|
|
185
|
-
paymentIntent: components["schemas"]["PaymentIntent"],
|
|
186
|
-
) => void;
|
|
187
|
-
onSetupIntentConfirmationSucceeded?: (
|
|
188
|
-
setupIntent: components["schemas"]["SetupIntent"],
|
|
189
|
-
) => void;
|
|
190
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
185
|
+
onResult: (result: ConfirmationResult) => void;
|
|
191
186
|
additionalFields?: CreditCardAdditionalFields;
|
|
192
187
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
193
188
|
};
|
|
@@ -196,9 +191,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
196
191
|
ref,
|
|
197
192
|
renderToken,
|
|
198
193
|
appearance,
|
|
199
|
-
|
|
200
|
-
onSetupIntentConfirmationSucceeded,
|
|
201
|
-
onConfirmationFailed,
|
|
194
|
+
onResult,
|
|
202
195
|
additionalFields = { cardholderName: false },
|
|
203
196
|
billingAddressRequirement = "country",
|
|
204
197
|
style,
|
|
@@ -215,9 +208,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
215
208
|
appearance,
|
|
216
209
|
additionalFields,
|
|
217
210
|
billingAddressRequirement,
|
|
218
|
-
|
|
219
|
-
onSetupIntentConfirmationSucceeded,
|
|
220
|
-
onConfirmationFailed,
|
|
211
|
+
onResult,
|
|
221
212
|
},
|
|
222
213
|
remountDeps: [
|
|
223
214
|
renderToken,
|
|
@@ -229,9 +220,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
229
220
|
appearance,
|
|
230
221
|
additionalFields,
|
|
231
222
|
billingAddressRequirement,
|
|
232
|
-
|
|
233
|
-
onSetupIntentConfirmationSucceeded,
|
|
234
|
-
onConfirmationFailed,
|
|
223
|
+
onResult,
|
|
235
224
|
],
|
|
236
225
|
});
|
|
237
226
|
|
|
@@ -241,13 +230,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
241
230
|
type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
242
231
|
renderToken: string;
|
|
243
232
|
appearance?: Appearance;
|
|
244
|
-
|
|
245
|
-
paymentIntent: components["schemas"]["PaymentIntent"],
|
|
246
|
-
) => void;
|
|
247
|
-
onSetupIntentConfirmationSucceeded?: (
|
|
248
|
-
setupIntent: components["schemas"]["SetupIntent"],
|
|
249
|
-
) => void;
|
|
250
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
233
|
+
onResult: (result: ConfirmationResult) => void;
|
|
251
234
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
252
235
|
};
|
|
253
236
|
|
|
@@ -255,9 +238,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
255
238
|
ref,
|
|
256
239
|
renderToken,
|
|
257
240
|
appearance,
|
|
258
|
-
|
|
259
|
-
onSetupIntentConfirmationSucceeded,
|
|
260
|
-
onConfirmationFailed,
|
|
241
|
+
onResult,
|
|
261
242
|
billingAddressRequirement = "country",
|
|
262
243
|
style,
|
|
263
244
|
...rest
|
|
@@ -272,19 +253,11 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
272
253
|
renderToken,
|
|
273
254
|
appearance,
|
|
274
255
|
billingAddressRequirement,
|
|
275
|
-
|
|
276
|
-
onSetupIntentConfirmationSucceeded,
|
|
277
|
-
onConfirmationFailed,
|
|
256
|
+
onResult,
|
|
278
257
|
},
|
|
279
258
|
remountDeps: [renderToken, billingAddressRequirement],
|
|
280
259
|
iframePassthrough: { style, ...rest },
|
|
281
|
-
updateDeps: [
|
|
282
|
-
appearance,
|
|
283
|
-
billingAddressRequirement,
|
|
284
|
-
onPaymentIntentConfirmationSucceeded,
|
|
285
|
-
onSetupIntentConfirmationSucceeded,
|
|
286
|
-
onConfirmationFailed,
|
|
287
|
-
],
|
|
260
|
+
updateDeps: [appearance, billingAddressRequirement, onResult],
|
|
288
261
|
});
|
|
289
262
|
|
|
290
263
|
return <div ref={containerRef} />;
|
|
@@ -302,10 +275,7 @@ type AmosGooglePayButtonProps = IframePassthroughProps & {
|
|
|
302
275
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
303
276
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
304
277
|
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
305
|
-
|
|
306
|
-
paymentIntent: components["schemas"]["PaymentIntent"],
|
|
307
|
-
) => void;
|
|
308
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
278
|
+
onResult: (result: ConfirmationResult) => void;
|
|
309
279
|
};
|
|
310
280
|
|
|
311
281
|
export function AmosGooglePayButton({
|
|
@@ -315,8 +285,7 @@ export function AmosGooglePayButton({
|
|
|
315
285
|
merchantName,
|
|
316
286
|
appearance,
|
|
317
287
|
onInitiatePaymentIntentRequest,
|
|
318
|
-
|
|
319
|
-
onConfirmationFailed,
|
|
288
|
+
onResult,
|
|
320
289
|
style,
|
|
321
290
|
...rest
|
|
322
291
|
}: AmosGooglePayButtonProps) {
|
|
@@ -332,8 +301,7 @@ export function AmosGooglePayButton({
|
|
|
332
301
|
merchantName,
|
|
333
302
|
appearance,
|
|
334
303
|
onInitiatePaymentIntentRequest,
|
|
335
|
-
|
|
336
|
-
onConfirmationFailed,
|
|
304
|
+
onResult,
|
|
337
305
|
},
|
|
338
306
|
remountDeps: [renderToken],
|
|
339
307
|
iframePassthrough: { style, ...rest },
|
|
@@ -342,8 +310,7 @@ export function AmosGooglePayButton({
|
|
|
342
310
|
merchantName,
|
|
343
311
|
appearance,
|
|
344
312
|
onInitiatePaymentIntentRequest,
|
|
345
|
-
|
|
346
|
-
onConfirmationFailed,
|
|
313
|
+
onResult,
|
|
347
314
|
],
|
|
348
315
|
});
|
|
349
316
|
|
|
@@ -362,10 +329,7 @@ type AmosApplePayButtonProps = IframePassthroughProps & {
|
|
|
362
329
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
363
330
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
364
331
|
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
365
|
-
|
|
366
|
-
paymentIntent: components["schemas"]["PaymentIntent"],
|
|
367
|
-
) => void;
|
|
368
|
-
onConfirmationFailed: (errorMessage: string) => void;
|
|
332
|
+
onResult: (result: ConfirmationResult) => void;
|
|
369
333
|
};
|
|
370
334
|
|
|
371
335
|
export function AmosApplePayButton({
|
|
@@ -375,8 +339,7 @@ export function AmosApplePayButton({
|
|
|
375
339
|
merchantName,
|
|
376
340
|
appearance,
|
|
377
341
|
onInitiatePaymentIntentRequest,
|
|
378
|
-
|
|
379
|
-
onConfirmationFailed,
|
|
342
|
+
onResult,
|
|
380
343
|
style,
|
|
381
344
|
...rest
|
|
382
345
|
}: AmosApplePayButtonProps) {
|
|
@@ -392,8 +355,7 @@ export function AmosApplePayButton({
|
|
|
392
355
|
merchantName,
|
|
393
356
|
appearance,
|
|
394
357
|
onInitiatePaymentIntentRequest,
|
|
395
|
-
|
|
396
|
-
onConfirmationFailed,
|
|
358
|
+
onResult,
|
|
397
359
|
},
|
|
398
360
|
remountDeps: [renderToken],
|
|
399
361
|
iframePassthrough: { style, ...rest },
|
|
@@ -402,8 +364,7 @@ export function AmosApplePayButton({
|
|
|
402
364
|
merchantName,
|
|
403
365
|
appearance,
|
|
404
366
|
onInitiatePaymentIntentRequest,
|
|
405
|
-
|
|
406
|
-
onConfirmationFailed,
|
|
367
|
+
onResult,
|
|
407
368
|
],
|
|
408
369
|
});
|
|
409
370
|
|