@amos.com/react-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 +36 -5
- package/dist/index.d.ts +21 -7
- package/dist/index.js +1 -1
- package/dist/index.mjs +64 -44
- package/package.json +2 -2
- package/src/index.tsx +86 -31
package/README.md
CHANGED
|
@@ -172,6 +172,7 @@ import type { components } from "@amos.com/node";
|
|
|
172
172
|
|
|
173
173
|
function CheckoutForm() {
|
|
174
174
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
175
|
+
const [isValid, setIsValid] = useState(false);
|
|
175
176
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
176
177
|
const [error, setError] = useState<string | null>(null);
|
|
177
178
|
|
|
@@ -222,6 +223,7 @@ function CheckoutForm() {
|
|
|
222
223
|
ref={iframeRef}
|
|
223
224
|
renderToken="the-render-token-that-you-created-on-dashboard.amos.com"
|
|
224
225
|
additionalFields={{ cardholderName: true }}
|
|
226
|
+
onValidityChange={({ isValid }) => setIsValid(isValid)}
|
|
225
227
|
onResult={(result) => {
|
|
226
228
|
// Unlock UI. Verify settlement on your backend via webhooks.
|
|
227
229
|
if (result.status === "succeeded") {
|
|
@@ -234,7 +236,7 @@ function CheckoutForm() {
|
|
|
234
236
|
}}
|
|
235
237
|
/>
|
|
236
238
|
{error ? <p>{error}</p> : null}
|
|
237
|
-
<button type="submit" disabled={isProcessing}>
|
|
239
|
+
<button type="submit" disabled={!isValid || isProcessing}>
|
|
238
240
|
{isProcessing ? "Processing..." : "Pay Now"}
|
|
239
241
|
</button>
|
|
240
242
|
</form>
|
|
@@ -428,6 +430,7 @@ Renders the secure credit card iframe form.
|
|
|
428
430
|
|
|
429
431
|
- `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
|
|
430
432
|
- `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.
|
|
433
|
+
- `onValidityChange` (`(event: { isValid: boolean }) => void`) — called when form validity changes. `isValid` is true when all required fields are present and valid. Does not include PCI data. Use this to enable or disable your checkout button.
|
|
431
434
|
|
|
432
435
|
**Also accepts:** standard iframe props (`React.ComponentProps<"iframe">`), minus `src`, `title`, `name`, and `role` (which are controlled by the SDK).
|
|
433
436
|
|
|
@@ -437,7 +440,7 @@ Renders the secure bank account iframe form.
|
|
|
437
440
|
|
|
438
441
|
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `onResult`.
|
|
439
442
|
|
|
440
|
-
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`.
|
|
443
|
+
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange`.
|
|
441
444
|
|
|
442
445
|
**Also accepts:** standard iframe props.
|
|
443
446
|
|
|
@@ -457,12 +460,40 @@ Renders the secure Google Pay iframe button (express checkout flow).
|
|
|
457
460
|
**Optional props:**
|
|
458
461
|
|
|
459
462
|
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`)
|
|
463
|
+
- `buttonType` (`"book" | "buy" | "checkout" | "donate" | "order" | "pay" | "plain" | "subscribe" | "short" | "long"`, defaults to `"short"`)
|
|
464
|
+
- `buttonColor` (`"default" | "black" | "white"`)
|
|
465
|
+
- `buttonRadius` (`number`, 0–20)
|
|
466
|
+
- `buttonSizeMode` (`"static" | "fill"`)
|
|
467
|
+
- `buttonLocale` (`string`)
|
|
468
|
+
- `buttonBorderType` (`"no_border" | "default_border"`)
|
|
469
|
+
- `style` — forwarded to the Google Pay button **inside** the iframe (not the iframe element). Example: `style={{ height: "48px", width: "100%" }}` with `buttonSizeMode="fill"`.
|
|
460
470
|
|
|
461
|
-
**Also accepts:** standard iframe props, minus
|
|
471
|
+
**Also accepts:** standard iframe props, minus `src`, `title`, `name`, `role`, `allow`, and `style` (which is the inner button style).
|
|
462
472
|
|
|
463
473
|
### `AmosApplePayButton`
|
|
464
474
|
|
|
465
|
-
Renders the secure Apple Pay iframe button (express checkout flow). Same props and callbacks as `AmosGooglePayButton`.
|
|
475
|
+
Renders the secure Apple Pay iframe button (express checkout flow). Same required props and callbacks as `AmosGooglePayButton`.
|
|
476
|
+
|
|
477
|
+
**Optional visual props** use Apple's `<apple-pay-button>` attribute names:
|
|
478
|
+
|
|
479
|
+
- `buttonstyle` (`"black" | "white" | "white-outline"`, defaults to `"black"`)
|
|
480
|
+
- `type` (`"plain" | "buy" | "set-up" | "donate" | "check-out" | "book" | "subscribe" | "reload" | "add-money" | "top-up" | "order" | "rent" | "support" | "contribute" | "tip"`, defaults to `"plain"`)
|
|
481
|
+
- `locale` (`string`, BCP 47, defaults to `"en-US"`)
|
|
482
|
+
- `style` — forwarded to the `<apple-pay-button>` inside the iframe. Apple sizes the button with CSS custom properties:
|
|
483
|
+
|
|
484
|
+
```tsx
|
|
485
|
+
<AmosApplePayButton
|
|
486
|
+
buttonstyle="white-outline"
|
|
487
|
+
type="buy"
|
|
488
|
+
locale="en-GB"
|
|
489
|
+
style={{
|
|
490
|
+
"--apple-pay-button-height": "48px",
|
|
491
|
+
"--apple-pay-button-width": "100%",
|
|
492
|
+
width: "100%",
|
|
493
|
+
}}
|
|
494
|
+
// ...required props
|
|
495
|
+
/>
|
|
496
|
+
```
|
|
466
497
|
|
|
467
498
|
Only Amos domains need Apple merchant registration. The button and `ApplePaySession` run inside the Amos embed iframe. On Safari, the native payment sheet is used. On other browsers, Apple's QR handoff opens in a popup (`pay.apple.com`); while that popup is open, the SDK automatically shows a full-viewport waiting overlay on the host page with instructions and a **Cancel payment** button. You do not need to implement popup or overlay handling yourself.
|
|
468
499
|
|
|
@@ -482,7 +513,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
482
513
|
|
|
483
514
|
### Exported types
|
|
484
515
|
|
|
485
|
-
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmationResult`, `ConfirmationIncompleteReason`, `FormattedGooglePayPaymentData`, `Message`, `Appearance`, `ThemeVariable`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
|
|
516
|
+
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmationResult`, `ConfirmationIncompleteReason`, `PaymentMethodFormValidityChangeEvent`, `FormattedGooglePayPaymentData`, `Message`, `Appearance`, `ThemeVariable`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
|
|
486
517
|
|
|
487
518
|
## Notes and potential gotchas
|
|
488
519
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="googlepay" />
|
|
2
|
-
import { Appearance, BillingAddressRequirement, ConfirmationResult, CreditCardAdditionalFields } from '@amos.com/amos-js';
|
|
2
|
+
import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmationResult, CreditCardAdditionalFields, GooglePayButtonElementProps } 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';
|
|
@@ -45,18 +45,32 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
45
45
|
renderToken: string;
|
|
46
46
|
appearance?: Appearance;
|
|
47
47
|
onResult: (result: ConfirmationResult) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Called when form validity changes. `isValid` is true when all
|
|
50
|
+
* required fields are present and valid. Does not include PCI data.
|
|
51
|
+
*/
|
|
52
|
+
onValidityChange?: (event: {
|
|
53
|
+
isValid: boolean;
|
|
54
|
+
}) => void;
|
|
48
55
|
additionalFields?: CreditCardAdditionalFields;
|
|
49
56
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
50
57
|
};
|
|
51
|
-
export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onResult, additionalFields, billingAddressRequirement, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
|
|
58
|
+
export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, additionalFields, billingAddressRequirement, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
|
|
52
59
|
type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
53
60
|
renderToken: string;
|
|
54
61
|
appearance?: Appearance;
|
|
55
62
|
onResult: (result: ConfirmationResult) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Called when form validity changes. `isValid` is true when all
|
|
65
|
+
* required fields are present and valid. Does not include PCI data.
|
|
66
|
+
*/
|
|
67
|
+
onValidityChange?: (event: {
|
|
68
|
+
isValid: boolean;
|
|
69
|
+
}) => void;
|
|
56
70
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
57
71
|
};
|
|
58
|
-
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onResult, billingAddressRequirement, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
|
|
59
|
-
type AmosGooglePayButtonProps = IframePassthroughProps & {
|
|
72
|
+
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, billingAddressRequirement, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
|
|
73
|
+
type AmosGooglePayButtonProps = Omit<IframePassthroughProps, "style"> & GooglePayButtonElementProps & {
|
|
60
74
|
renderToken: string;
|
|
61
75
|
amount: string;
|
|
62
76
|
merchantName: string;
|
|
@@ -67,8 +81,8 @@ type AmosGooglePayButtonProps = IframePassthroughProps & {
|
|
|
67
81
|
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
68
82
|
onResult: (result: ConfirmationResult) => void;
|
|
69
83
|
};
|
|
70
|
-
export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, style, ...rest }: AmosGooglePayButtonProps): import("react").JSX.Element;
|
|
71
|
-
type AmosApplePayButtonProps = IframePassthroughProps & {
|
|
84
|
+
export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, buttonType, buttonColor, buttonRadius, buttonSizeMode, buttonLocale, buttonBorderType, style, ...rest }: AmosGooglePayButtonProps): import("react").JSX.Element;
|
|
85
|
+
type AmosApplePayButtonProps = Omit<IframePassthroughProps, "style" | "type"> & ApplePayButtonElementProps & {
|
|
72
86
|
renderToken: string;
|
|
73
87
|
amount: string;
|
|
74
88
|
merchantName: string;
|
|
@@ -79,4 +93,4 @@ type AmosApplePayButtonProps = IframePassthroughProps & {
|
|
|
79
93
|
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
80
94
|
onResult: (result: ConfirmationResult) => void;
|
|
81
95
|
};
|
|
82
|
-
export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, style, ...rest }: AmosApplePayButtonProps): import("react").JSX.Element;
|
|
96
|
+
export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, buttonstyle, type, locale, 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({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function l(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 u({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){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,c(n,a.iframe),l(a.iframe,o),()=>{a.destroy(),u.current=null,c(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&l(e,o)})}function d({ref:r,renderToken:i,appearance:a,onResult:o,additionalFields:
|
|
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({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function l(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 u({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){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,c(n,a.iframe),l(a.iframe,o),()=>{a.destroy(),u.current=null,c(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&l(e,o)})}function d({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,additionalFields:c={cardholderName:!1},billingAddressRequirement:l=`country`,style:d,...f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:c,billingAddressRequirement:l,onResult:o,onValidityChange:s},remountDeps:[i,c.cardholderName,l],iframePassthrough:{style:d,...f},updateDeps:[a,c,l,o,s]}),(0,n.jsx)(`div`,{ref:p})}function f({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,billingAddressRequirement:c=`country`,style:l,...d}){let f=(0,t.useRef)(null);return u({containerRef:f,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:c,onResult:o,onValidityChange:s},remountDeps:[i,c],iframePassthrough:{style:l,...d},updateDeps:[a,c,o,s]}),(0,n.jsx)(`div`,{ref:f})}function p({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,buttonType:d,buttonColor:f,buttonRadius:p,buttonSizeMode:m,buttonLocale:h,buttonBorderType:g,style:_,...v}){let y=(0,t.useRef)(null);return u({containerRef:y,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,buttonType:d,buttonColor:f,buttonRadius:p,buttonSizeMode:m,buttonLocale:h,buttonBorderType:g,style:_},remountDeps:[i],iframePassthrough:{...v},updateDeps:[a,o,s,c,l,d,f,p,m,h,g,_]}),(0,n.jsx)(`div`,{ref:y})}function m({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,buttonstyle:d,type:f,locale:p,style:m,...h}){let g=(0,t.useRef)(null);return u({containerRef:g,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,buttonstyle:d,type:f,locale:p,style:m},remountDeps:[i],iframePassthrough:{...h},updateDeps:[a,o,s,c,l,d,f,p,m]}),(0,n.jsx)(`div`,{ref:g})}exports.AmosApplePayButton=m,exports.AmosBankAccountPaymentMethodForm=f,exports.AmosCreditCardPaymentMethodForm=d,exports.AmosGooglePayButton=p,exports.confirmPaymentIntent=a,exports.confirmSetupIntent=o,exports.resetForm=s,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
|
@@ -47,64 +47,68 @@ function v({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i
|
|
|
47
47
|
e && _(e, a);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function y({ ref: e, renderToken: t, appearance: n, onResult: r,
|
|
51
|
-
let
|
|
50
|
+
function y({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, additionalFields: o = { cardholderName: !1 }, billingAddressRequirement: s = "country", style: c, ...d }) {
|
|
51
|
+
let f = l(null);
|
|
52
52
|
return v({
|
|
53
|
-
containerRef:
|
|
53
|
+
containerRef: f,
|
|
54
54
|
iframeRef: e,
|
|
55
55
|
mount: i,
|
|
56
56
|
options: {
|
|
57
57
|
renderToken: t,
|
|
58
58
|
appearance: n,
|
|
59
|
-
additionalFields:
|
|
60
|
-
billingAddressRequirement:
|
|
61
|
-
onResult: r
|
|
59
|
+
additionalFields: o,
|
|
60
|
+
billingAddressRequirement: s,
|
|
61
|
+
onResult: r,
|
|
62
|
+
onValidityChange: a
|
|
62
63
|
},
|
|
63
64
|
remountDeps: [
|
|
64
65
|
t,
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
o.cardholderName,
|
|
67
|
+
s
|
|
67
68
|
],
|
|
68
69
|
iframePassthrough: {
|
|
69
|
-
style:
|
|
70
|
-
...
|
|
70
|
+
style: c,
|
|
71
|
+
...d
|
|
71
72
|
},
|
|
72
73
|
updateDeps: [
|
|
73
74
|
n,
|
|
74
|
-
a,
|
|
75
75
|
o,
|
|
76
|
-
|
|
76
|
+
s,
|
|
77
|
+
r,
|
|
78
|
+
a
|
|
77
79
|
]
|
|
78
|
-
}), /* @__PURE__ */ u("div", { ref:
|
|
80
|
+
}), /* @__PURE__ */ u("div", { ref: f });
|
|
79
81
|
}
|
|
80
|
-
function b({ ref: e, renderToken: t, appearance: n, onResult: i,
|
|
81
|
-
let
|
|
82
|
+
function b({ ref: e, renderToken: t, appearance: n, onResult: i, onValidityChange: a, billingAddressRequirement: o = "country", style: s, ...c }) {
|
|
83
|
+
let d = l(null);
|
|
82
84
|
return v({
|
|
83
|
-
containerRef:
|
|
85
|
+
containerRef: d,
|
|
84
86
|
iframeRef: e,
|
|
85
87
|
mount: r,
|
|
86
88
|
options: {
|
|
87
89
|
renderToken: t,
|
|
88
90
|
appearance: n,
|
|
89
|
-
billingAddressRequirement:
|
|
90
|
-
onResult: i
|
|
91
|
+
billingAddressRequirement: o,
|
|
92
|
+
onResult: i,
|
|
93
|
+
onValidityChange: a
|
|
91
94
|
},
|
|
92
|
-
remountDeps: [t,
|
|
95
|
+
remountDeps: [t, o],
|
|
93
96
|
iframePassthrough: {
|
|
94
|
-
style:
|
|
95
|
-
...
|
|
97
|
+
style: s,
|
|
98
|
+
...c
|
|
96
99
|
},
|
|
97
100
|
updateDeps: [
|
|
98
101
|
n,
|
|
99
|
-
|
|
100
|
-
i
|
|
102
|
+
o,
|
|
103
|
+
i,
|
|
104
|
+
a
|
|
101
105
|
]
|
|
102
|
-
}), /* @__PURE__ */ u("div", { ref:
|
|
106
|
+
}), /* @__PURE__ */ u("div", { ref: d });
|
|
103
107
|
}
|
|
104
|
-
function x({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onResult: s,
|
|
105
|
-
let
|
|
108
|
+
function x({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onResult: s, buttonType: c, buttonColor: d, buttonRadius: f, buttonSizeMode: p, buttonLocale: m, buttonBorderType: h, style: g, ..._ }) {
|
|
109
|
+
let y = l(null);
|
|
106
110
|
return v({
|
|
107
|
-
containerRef:
|
|
111
|
+
containerRef: y,
|
|
108
112
|
iframeRef: e,
|
|
109
113
|
mount: a,
|
|
110
114
|
options: {
|
|
@@ -113,26 +117,37 @@ function x({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i,
|
|
|
113
117
|
merchantName: r,
|
|
114
118
|
appearance: i,
|
|
115
119
|
onInitiatePaymentIntentRequest: o,
|
|
116
|
-
onResult: s
|
|
120
|
+
onResult: s,
|
|
121
|
+
buttonType: c,
|
|
122
|
+
buttonColor: d,
|
|
123
|
+
buttonRadius: f,
|
|
124
|
+
buttonSizeMode: p,
|
|
125
|
+
buttonLocale: m,
|
|
126
|
+
buttonBorderType: h,
|
|
127
|
+
style: g
|
|
117
128
|
},
|
|
118
129
|
remountDeps: [t],
|
|
119
|
-
iframePassthrough: {
|
|
120
|
-
style: c,
|
|
121
|
-
...d
|
|
122
|
-
},
|
|
130
|
+
iframePassthrough: { ..._ },
|
|
123
131
|
updateDeps: [
|
|
124
132
|
n,
|
|
125
133
|
r,
|
|
126
134
|
i,
|
|
127
135
|
o,
|
|
128
|
-
s
|
|
136
|
+
s,
|
|
137
|
+
c,
|
|
138
|
+
d,
|
|
139
|
+
f,
|
|
140
|
+
p,
|
|
141
|
+
m,
|
|
142
|
+
h,
|
|
143
|
+
g
|
|
129
144
|
]
|
|
130
|
-
}), /* @__PURE__ */ u("div", { ref:
|
|
145
|
+
}), /* @__PURE__ */ u("div", { ref: y });
|
|
131
146
|
}
|
|
132
|
-
function S({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onResult: s,
|
|
133
|
-
let
|
|
147
|
+
function S({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onResult: s, buttonstyle: c, type: d, locale: f, style: p, ...m }) {
|
|
148
|
+
let h = l(null);
|
|
134
149
|
return v({
|
|
135
|
-
containerRef:
|
|
150
|
+
containerRef: h,
|
|
136
151
|
iframeRef: e,
|
|
137
152
|
mount: n,
|
|
138
153
|
options: {
|
|
@@ -141,21 +156,26 @@ function S({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a,
|
|
|
141
156
|
merchantName: i,
|
|
142
157
|
appearance: a,
|
|
143
158
|
onInitiatePaymentIntentRequest: o,
|
|
144
|
-
onResult: s
|
|
159
|
+
onResult: s,
|
|
160
|
+
buttonstyle: c,
|
|
161
|
+
type: d,
|
|
162
|
+
locale: f,
|
|
163
|
+
style: p
|
|
145
164
|
},
|
|
146
165
|
remountDeps: [t],
|
|
147
|
-
iframePassthrough: {
|
|
148
|
-
style: c,
|
|
149
|
-
...d
|
|
150
|
-
},
|
|
166
|
+
iframePassthrough: { ...m },
|
|
151
167
|
updateDeps: [
|
|
152
168
|
r,
|
|
153
169
|
i,
|
|
154
170
|
a,
|
|
155
171
|
o,
|
|
156
|
-
s
|
|
172
|
+
s,
|
|
173
|
+
c,
|
|
174
|
+
d,
|
|
175
|
+
f,
|
|
176
|
+
p
|
|
157
177
|
]
|
|
158
|
-
}), /* @__PURE__ */ u("div", { ref:
|
|
178
|
+
}), /* @__PURE__ */ u("div", { ref: h });
|
|
159
179
|
}
|
|
160
180
|
//#endregion
|
|
161
181
|
export { S as AmosApplePayButton, b as AmosBankAccountPaymentMethodForm, y as AmosCreditCardPaymentMethodForm, x as AmosGooglePayButton, p as confirmPaymentIntent, m as confirmSetupIntent, h as resetForm, f as validateForm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vite-plugin-dts": "5.0.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@amos.com/amos-js": "0.9.
|
|
51
|
+
"@amos.com/amos-js": "0.9.11",
|
|
52
52
|
"@types/googlepay": "0.7.11"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type Appearance,
|
|
5
|
+
type ApplePayButtonElementProps,
|
|
5
6
|
confirmPaymentIntent as amosConfirmPaymentIntent,
|
|
6
7
|
confirmSetupIntent as amosConfirmSetupIntent,
|
|
7
8
|
resetForm as amosResetForm,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
type BillingAddressRequirement,
|
|
10
11
|
type ConfirmationResult,
|
|
11
12
|
type CreditCardAdditionalFields,
|
|
13
|
+
type GooglePayButtonElementProps,
|
|
12
14
|
mountAmosApplePayButton,
|
|
13
15
|
mountAmosBankAccountPaymentMethodForm,
|
|
14
16
|
mountAmosCreditCardPaymentMethodForm,
|
|
@@ -192,6 +194,11 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
192
194
|
renderToken: string;
|
|
193
195
|
appearance?: Appearance;
|
|
194
196
|
onResult: (result: ConfirmationResult) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Called when form validity changes. `isValid` is true when all
|
|
199
|
+
* required fields are present and valid. Does not include PCI data.
|
|
200
|
+
*/
|
|
201
|
+
onValidityChange?: (event: { isValid: boolean }) => void;
|
|
195
202
|
additionalFields?: CreditCardAdditionalFields;
|
|
196
203
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
197
204
|
};
|
|
@@ -201,6 +208,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
201
208
|
renderToken,
|
|
202
209
|
appearance,
|
|
203
210
|
onResult,
|
|
211
|
+
onValidityChange,
|
|
204
212
|
additionalFields = { cardholderName: false },
|
|
205
213
|
billingAddressRequirement = "country",
|
|
206
214
|
style,
|
|
@@ -218,6 +226,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
218
226
|
additionalFields,
|
|
219
227
|
billingAddressRequirement,
|
|
220
228
|
onResult,
|
|
229
|
+
onValidityChange,
|
|
221
230
|
},
|
|
222
231
|
remountDeps: [
|
|
223
232
|
renderToken,
|
|
@@ -230,6 +239,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
230
239
|
additionalFields,
|
|
231
240
|
billingAddressRequirement,
|
|
232
241
|
onResult,
|
|
242
|
+
onValidityChange,
|
|
233
243
|
],
|
|
234
244
|
});
|
|
235
245
|
|
|
@@ -240,6 +250,11 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
240
250
|
renderToken: string;
|
|
241
251
|
appearance?: Appearance;
|
|
242
252
|
onResult: (result: ConfirmationResult) => void;
|
|
253
|
+
/**
|
|
254
|
+
* Called when form validity changes. `isValid` is true when all
|
|
255
|
+
* required fields are present and valid. Does not include PCI data.
|
|
256
|
+
*/
|
|
257
|
+
onValidityChange?: (event: { isValid: boolean }) => void;
|
|
243
258
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
244
259
|
};
|
|
245
260
|
|
|
@@ -248,6 +263,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
248
263
|
renderToken,
|
|
249
264
|
appearance,
|
|
250
265
|
onResult,
|
|
266
|
+
onValidityChange,
|
|
251
267
|
billingAddressRequirement = "country",
|
|
252
268
|
style,
|
|
253
269
|
...rest
|
|
@@ -263,29 +279,36 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
263
279
|
appearance,
|
|
264
280
|
billingAddressRequirement,
|
|
265
281
|
onResult,
|
|
282
|
+
onValidityChange,
|
|
266
283
|
},
|
|
267
284
|
remountDeps: [renderToken, billingAddressRequirement],
|
|
268
285
|
iframePassthrough: { style, ...rest },
|
|
269
|
-
updateDeps: [
|
|
286
|
+
updateDeps: [
|
|
287
|
+
appearance,
|
|
288
|
+
billingAddressRequirement,
|
|
289
|
+
onResult,
|
|
290
|
+
onValidityChange,
|
|
291
|
+
],
|
|
270
292
|
});
|
|
271
293
|
|
|
272
294
|
return <div ref={containerRef} />;
|
|
273
295
|
}
|
|
274
296
|
|
|
275
|
-
type AmosGooglePayButtonProps = IframePassthroughProps &
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
297
|
+
type AmosGooglePayButtonProps = Omit<IframePassthroughProps, "style"> &
|
|
298
|
+
GooglePayButtonElementProps & {
|
|
299
|
+
renderToken: string;
|
|
300
|
+
amount: string;
|
|
301
|
+
merchantName: string;
|
|
302
|
+
appearance?: Appearance;
|
|
303
|
+
onInitiatePaymentIntentRequest: ({
|
|
304
|
+
paymentIntentCreateAttributes,
|
|
305
|
+
customerCreateAttributes,
|
|
306
|
+
}: {
|
|
307
|
+
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
308
|
+
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
309
|
+
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
310
|
+
onResult: (result: ConfirmationResult) => void;
|
|
311
|
+
};
|
|
289
312
|
|
|
290
313
|
export function AmosGooglePayButton({
|
|
291
314
|
ref,
|
|
@@ -295,6 +318,12 @@ export function AmosGooglePayButton({
|
|
|
295
318
|
appearance,
|
|
296
319
|
onInitiatePaymentIntentRequest,
|
|
297
320
|
onResult,
|
|
321
|
+
buttonType,
|
|
322
|
+
buttonColor,
|
|
323
|
+
buttonRadius,
|
|
324
|
+
buttonSizeMode,
|
|
325
|
+
buttonLocale,
|
|
326
|
+
buttonBorderType,
|
|
298
327
|
style,
|
|
299
328
|
...rest
|
|
300
329
|
}: AmosGooglePayButtonProps) {
|
|
@@ -311,35 +340,50 @@ export function AmosGooglePayButton({
|
|
|
311
340
|
appearance,
|
|
312
341
|
onInitiatePaymentIntentRequest,
|
|
313
342
|
onResult,
|
|
343
|
+
buttonType,
|
|
344
|
+
buttonColor,
|
|
345
|
+
buttonRadius,
|
|
346
|
+
buttonSizeMode,
|
|
347
|
+
buttonLocale,
|
|
348
|
+
buttonBorderType,
|
|
349
|
+
style,
|
|
314
350
|
},
|
|
315
351
|
remountDeps: [renderToken],
|
|
316
|
-
iframePassthrough: {
|
|
352
|
+
iframePassthrough: { ...rest },
|
|
317
353
|
updateDeps: [
|
|
318
354
|
amount,
|
|
319
355
|
merchantName,
|
|
320
356
|
appearance,
|
|
321
357
|
onInitiatePaymentIntentRequest,
|
|
322
358
|
onResult,
|
|
359
|
+
buttonType,
|
|
360
|
+
buttonColor,
|
|
361
|
+
buttonRadius,
|
|
362
|
+
buttonSizeMode,
|
|
363
|
+
buttonLocale,
|
|
364
|
+
buttonBorderType,
|
|
365
|
+
style,
|
|
323
366
|
],
|
|
324
367
|
});
|
|
325
368
|
|
|
326
369
|
return <div ref={containerRef} />;
|
|
327
370
|
}
|
|
328
371
|
|
|
329
|
-
type AmosApplePayButtonProps = IframePassthroughProps &
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
372
|
+
type AmosApplePayButtonProps = Omit<IframePassthroughProps, "style" | "type"> &
|
|
373
|
+
ApplePayButtonElementProps & {
|
|
374
|
+
renderToken: string;
|
|
375
|
+
amount: string;
|
|
376
|
+
merchantName: string;
|
|
377
|
+
appearance?: Appearance;
|
|
378
|
+
onInitiatePaymentIntentRequest: ({
|
|
379
|
+
paymentIntentCreateAttributes,
|
|
380
|
+
customerCreateAttributes,
|
|
381
|
+
}: {
|
|
382
|
+
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
383
|
+
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
384
|
+
}) => Promise<components["schemas"]["EmbedToken"]["token"]>;
|
|
385
|
+
onResult: (result: ConfirmationResult) => void;
|
|
386
|
+
};
|
|
343
387
|
|
|
344
388
|
export function AmosApplePayButton({
|
|
345
389
|
ref,
|
|
@@ -349,6 +393,9 @@ export function AmosApplePayButton({
|
|
|
349
393
|
appearance,
|
|
350
394
|
onInitiatePaymentIntentRequest,
|
|
351
395
|
onResult,
|
|
396
|
+
buttonstyle,
|
|
397
|
+
type,
|
|
398
|
+
locale,
|
|
352
399
|
style,
|
|
353
400
|
...rest
|
|
354
401
|
}: AmosApplePayButtonProps) {
|
|
@@ -365,15 +412,23 @@ export function AmosApplePayButton({
|
|
|
365
412
|
appearance,
|
|
366
413
|
onInitiatePaymentIntentRequest,
|
|
367
414
|
onResult,
|
|
415
|
+
buttonstyle,
|
|
416
|
+
type,
|
|
417
|
+
locale,
|
|
418
|
+
style,
|
|
368
419
|
},
|
|
369
420
|
remountDeps: [renderToken],
|
|
370
|
-
iframePassthrough: {
|
|
421
|
+
iframePassthrough: { ...rest },
|
|
371
422
|
updateDeps: [
|
|
372
423
|
amount,
|
|
373
424
|
merchantName,
|
|
374
425
|
appearance,
|
|
375
426
|
onInitiatePaymentIntentRequest,
|
|
376
427
|
onResult,
|
|
428
|
+
buttonstyle,
|
|
429
|
+
type,
|
|
430
|
+
locale,
|
|
431
|
+
style,
|
|
377
432
|
],
|
|
378
433
|
});
|
|
379
434
|
|