@amos.com/react-amos-js 0.3.21 → 0.4.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/README.md CHANGED
@@ -383,6 +383,7 @@ Renders the secure credit card iframe form.
383
383
  - `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: components["schemas"]["PaymentIntent"]) => void`)
384
384
  - `onSetupIntentConfirmationSucceeded` (`(setupIntent: components["schemas"]["SetupIntent"]) => void`)
385
385
  - `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
386
+ - `billingAddressRequirement` (`"postalCode" | "postalCodeAndCountry" | "full"`, defaults to `"postalCode"`) — how much billing address the iframe collects. `postalCode` sends only postal code (no country). `full` shows a full street address form with Smarty autocomplete.
386
387
 
387
388
  **Also accepts:** standard iframe props (`React.ComponentProps<"iframe">`), minus `src`, `title`, `name`, and `role` (which are controlled by the SDK).
388
389
 
@@ -392,7 +393,7 @@ Renders the secure bank account iframe form.
392
393
 
393
394
  **Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `onConfirmationFailed`.
394
395
 
395
- **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `onPaymentIntentConfirmationSucceeded`, `onSetupIntentConfirmationSucceeded`.
396
+ **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onPaymentIntentConfirmationSucceeded`, `onSetupIntentConfirmationSucceeded`.
396
397
 
397
398
  **Also accepts:** standard iframe props.
398
399
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="googlepay" />
2
- import { Appearance, CreditCardAdditionalFields } from '@amos.com/amos-js';
2
+ import { Appearance, BillingAddressRequirement, 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';
@@ -41,16 +41,18 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
41
41
  onSetupIntentConfirmationSucceeded?: (setupIntent: components["schemas"]["SetupIntent"]) => void;
42
42
  onConfirmationFailed: (errorMessage: string) => void;
43
43
  additionalFields?: CreditCardAdditionalFields;
44
+ billingAddressRequirement?: BillingAddressRequirement;
44
45
  };
45
- export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onPaymentIntentConfirmationSucceeded, onSetupIntentConfirmationSucceeded, onConfirmationFailed, additionalFields, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
46
+ export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onPaymentIntentConfirmationSucceeded, onSetupIntentConfirmationSucceeded, onConfirmationFailed, additionalFields, billingAddressRequirement, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
46
47
  type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
47
48
  renderToken: string;
48
49
  appearance?: Appearance;
49
50
  onPaymentIntentConfirmationSucceeded?: (paymentIntent: components["schemas"]["PaymentIntent"]) => void;
50
51
  onSetupIntentConfirmationSucceeded?: (setupIntent: components["schemas"]["SetupIntent"]) => void;
51
52
  onConfirmationFailed: (errorMessage: string) => void;
53
+ billingAddressRequirement?: BillingAddressRequirement;
52
54
  };
53
- export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onPaymentIntentConfirmationSucceeded, onSetupIntentConfirmationSucceeded, onConfirmationFailed, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
55
+ export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onPaymentIntentConfirmationSucceeded, onSetupIntentConfirmationSucceeded, onConfirmationFailed, billingAddressRequirement, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
54
56
  type AmosGooglePayButtonProps = IframePassthroughProps & {
55
57
  renderToken: string;
56
58
  amount: string;
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,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,additionalFields:u={cardholderName:!1},style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:u,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u.cardholderName],iframePassthrough:{style:d,...f},updateDeps:[a,u,o,s,c]}),(0,n.jsx)(`div`,{ref:p})}function d({ref:r,renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,style:u,...d}){let f=(0,t.useRef)(null);return l({containerRef:f,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i],iframePassthrough:{style:u,...d},updateDeps:[a,o,s,c]}),(0,n.jsx)(`div`,{ref:f})}function f({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d},remountDeps:[i],iframePassthrough:{style:f,...p},updateDeps:[a,o,s,c,u,d]}),(0,n.jsx)(`div`,{ref:m})}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]}})});
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,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,additionalFields:u={cardholderName:!1},billingAddressRequirement:d=`postalCode`,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:u,billingAddressRequirement:d,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u.cardholderName,d],iframePassthrough:{style:f,...p},updateDeps:[a,u,d,o,s,c]}),(0,n.jsx)(`div`,{ref:m})}function d({ref:r,renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,billingAddressRequirement:u=`postalCode`,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:u,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u],iframePassthrough:{style:d,...f},updateDeps:[a,u,o,s,c]}),(0,n.jsx)(`div`,{ref:p})}function f({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d},remountDeps:[i],iframePassthrough:{style:f,...p},updateDeps:[a,o,s,c,u,d]}),(0,n.jsx)(`div`,{ref:m})}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,59 +44,67 @@ function h({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i
44
44
  e && m(e, a);
45
45
  });
46
46
  }
47
- function g({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, additionalFields: l = { cardholderName: !1 }, style: u, ...d }) {
48
- let f = s(null);
47
+ function g({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, additionalFields: l = { cardholderName: !1 }, billingAddressRequirement: u = "postalCode", style: d, ...f }) {
48
+ let p = s(null);
49
49
  return h({
50
- containerRef: f,
50
+ containerRef: p,
51
51
  iframeRef: e,
52
52
  mount: r,
53
53
  options: {
54
54
  renderToken: t,
55
55
  appearance: n,
56
56
  additionalFields: l,
57
+ billingAddressRequirement: u,
57
58
  onPaymentIntentConfirmationSucceeded: i,
58
59
  onSetupIntentConfirmationSucceeded: a,
59
60
  onConfirmationFailed: o
60
61
  },
61
- remountDeps: [t, l.cardholderName],
62
+ remountDeps: [
63
+ t,
64
+ l.cardholderName,
65
+ u
66
+ ],
62
67
  iframePassthrough: {
63
- style: u,
64
- ...d
68
+ style: d,
69
+ ...f
65
70
  },
66
71
  updateDeps: [
67
72
  n,
68
73
  l,
74
+ u,
69
75
  i,
70
76
  a,
71
77
  o
72
78
  ]
73
- }), /* @__PURE__ */ c("div", { ref: f });
79
+ }), /* @__PURE__ */ c("div", { ref: p });
74
80
  }
75
- function _({ ref: e, renderToken: t, appearance: r, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, style: l, ...u }) {
76
- let d = s(null);
81
+ function _({ ref: e, renderToken: t, appearance: r, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, billingAddressRequirement: l = "postalCode", style: u, ...d }) {
82
+ let f = s(null);
77
83
  return h({
78
- containerRef: d,
84
+ containerRef: f,
79
85
  iframeRef: e,
80
86
  mount: n,
81
87
  options: {
82
88
  renderToken: t,
83
89
  appearance: r,
90
+ billingAddressRequirement: l,
84
91
  onPaymentIntentConfirmationSucceeded: i,
85
92
  onSetupIntentConfirmationSucceeded: a,
86
93
  onConfirmationFailed: o
87
94
  },
88
- remountDeps: [t],
95
+ remountDeps: [t, l],
89
96
  iframePassthrough: {
90
- style: l,
91
- ...u
97
+ style: u,
98
+ ...d
92
99
  },
93
100
  updateDeps: [
94
101
  r,
102
+ l,
95
103
  i,
96
104
  a,
97
105
  o
98
106
  ]
99
- }), /* @__PURE__ */ c("div", { ref: d });
107
+ }), /* @__PURE__ */ c("div", { ref: f });
100
108
  }
101
109
  function v({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: a, onInitiatePaymentIntentRequest: o, onPaymentIntentConfirmationSucceeded: l, onConfirmationFailed: u, style: d, ...f }) {
102
110
  let p = s(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.3.21",
3
+ "version": "0.4.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,8 +46,8 @@
46
46
  "vite-plugin-dts": "5.0.3"
47
47
  },
48
48
  "dependencies": {
49
- "@amos.com/amos-js": "0.3.23",
50
- "@amos.com/node": "0.1.28",
49
+ "@amos.com/amos-js": "0.4.0",
50
+ "@amos.com/node": "0.1.31",
51
51
  "@types/googlepay": "0.7.11"
52
52
  },
53
53
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  confirmPaymentIntent as amosConfirmPaymentIntent,
6
6
  confirmSetupIntent as amosConfirmSetupIntent,
7
7
  validateForm as amosValidateForm,
8
+ type BillingAddressRequirement,
8
9
  type CreditCardAdditionalFields,
9
10
  mountAmosBankAccountPaymentMethodForm,
10
11
  mountAmosCreditCardPaymentMethodForm,
@@ -187,6 +188,7 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
187
188
  ) => void;
188
189
  onConfirmationFailed: (errorMessage: string) => void;
189
190
  additionalFields?: CreditCardAdditionalFields;
191
+ billingAddressRequirement?: BillingAddressRequirement;
190
192
  };
191
193
 
192
194
  export function AmosCreditCardPaymentMethodForm({
@@ -197,6 +199,7 @@ export function AmosCreditCardPaymentMethodForm({
197
199
  onSetupIntentConfirmationSucceeded,
198
200
  onConfirmationFailed,
199
201
  additionalFields = { cardholderName: false },
202
+ billingAddressRequirement = "postalCode",
200
203
  style,
201
204
  ...rest
202
205
  }: AmosCreditCardPaymentMethodFormProps) {
@@ -210,15 +213,21 @@ export function AmosCreditCardPaymentMethodForm({
210
213
  renderToken,
211
214
  appearance,
212
215
  additionalFields,
216
+ billingAddressRequirement,
213
217
  onPaymentIntentConfirmationSucceeded,
214
218
  onSetupIntentConfirmationSucceeded,
215
219
  onConfirmationFailed,
216
220
  },
217
- remountDeps: [renderToken, additionalFields.cardholderName],
221
+ remountDeps: [
222
+ renderToken,
223
+ additionalFields.cardholderName,
224
+ billingAddressRequirement,
225
+ ],
218
226
  iframePassthrough: { style, ...rest },
219
227
  updateDeps: [
220
228
  appearance,
221
229
  additionalFields,
230
+ billingAddressRequirement,
222
231
  onPaymentIntentConfirmationSucceeded,
223
232
  onSetupIntentConfirmationSucceeded,
224
233
  onConfirmationFailed,
@@ -238,6 +247,7 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
238
247
  setupIntent: components["schemas"]["SetupIntent"],
239
248
  ) => void;
240
249
  onConfirmationFailed: (errorMessage: string) => void;
250
+ billingAddressRequirement?: BillingAddressRequirement;
241
251
  };
242
252
 
243
253
  export function AmosBankAccountPaymentMethodForm({
@@ -247,6 +257,7 @@ export function AmosBankAccountPaymentMethodForm({
247
257
  onPaymentIntentConfirmationSucceeded,
248
258
  onSetupIntentConfirmationSucceeded,
249
259
  onConfirmationFailed,
260
+ billingAddressRequirement = "postalCode",
250
261
  style,
251
262
  ...rest
252
263
  }: AmosBankAccountPaymentMethodFormProps) {
@@ -259,14 +270,16 @@ export function AmosBankAccountPaymentMethodForm({
259
270
  options: {
260
271
  renderToken,
261
272
  appearance,
273
+ billingAddressRequirement,
262
274
  onPaymentIntentConfirmationSucceeded,
263
275
  onSetupIntentConfirmationSucceeded,
264
276
  onConfirmationFailed,
265
277
  },
266
- remountDeps: [renderToken],
278
+ remountDeps: [renderToken, billingAddressRequirement],
267
279
  iframePassthrough: { style, ...rest },
268
280
  updateDeps: [
269
281
  appearance,
282
+ billingAddressRequirement,
270
283
  onPaymentIntentConfirmationSucceeded,
271
284
  onSetupIntentConfirmationSucceeded,
272
285
  onConfirmationFailed,