@flopay/react 2.0.12 → 2.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/README.md CHANGED
@@ -39,6 +39,19 @@ If neither is set, the SDK uses the staging billing API.
39
39
 
40
40
  ## Usage
41
41
 
42
+ ### Buyer language on SDK 2.x (`next`)
43
+
44
+ The hosted runtime sends the browser's language preferences to the API. The API chooses the merchant's
45
+ `locale` override, then the customer's stored preference, then the browser preference, then English.
46
+ Only operator-enabled translations are served; missing translations fall back to English.
47
+
48
+ Set `locale="fr"` on any 2.x checkout or setup component to override the preference. The runtime renders
49
+ the language and wording returned by the API; language catalogues are not bundled in the wrappers.
50
+ Wording precedence is the merchant's canonical key, merchant's legacy alias, API canonical key, then API legacy alias.
51
+ Changing a checkout's `locale` updates its existing session without creating or paying another session.
52
+ Changing a no-charge setup's `locale` remounts its setup form. The override requires runtime contract
53
+ 2.7.0. Use the 2.x packages on npm's `next` channel; released 1.x packages keep their existing behavior.
54
+
42
55
  ### FloPayCheckout
43
56
 
44
57
  `FloPayCheckout` is the recommended integration. Give it a session and it fetches the session, initializes the right payment providers, and renders the hosted card form plus the session's supported wallets, alternative payment methods, and PayPal. Customer data (email, user id, name) comes from the session.
@@ -1 +1 @@
1
- "use strict";var P=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},O=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of x(t))!M.call(e,a)&&a!==n&&P(e,a,{get:()=>t[a],enumerable:!(l=D(t,a))||l.enumerable});return e};var V=e=>O(P({},"__esModule",{value:!0}),e);var H={};I(H,{FloPayCardSetup:()=>b});module.exports=V(H);var h=require("@flopay/js"),E=require("@flopay/shared"),s=require("react");var i=require("@flopay/shared");var g=require("react/jsx-runtime"),A="2.4.0";function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var J=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function S(e,t,n,l={}){return Object.assign(new E.FloPayError(e,t,l),{retryable:n})}function K(e){let t=k(e)?e:{},n=typeof t.type=="string"&&J.has(t.type)?t.type:"";return S(typeof t.message=="string"?t.message:"The setup failed.",n||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function N(e){return e instanceof E.FloPayError?S(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):S("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function v(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function j({kind:e,props:t}){let{sessionId:n,nonce:l,runtimeUrl:a,runtimeTimeoutMs:f}=t,F=(0,s.useRef)(null),d=(0,s.useRef)(null),p=(0,s.useRef)(t);p.current=t;let T=v(t),y=JSON.stringify(T),R=(0,s.useRef)(y);return(0,s.useEffect)(()=>{let m=F.current;if(!m)return;let o=!0,C=r=>{(0,i.invokeMerchantCallback)(()=>p.current.onError?.(r))},_=r=>{let u=p.current,c=r.payload;switch(r.name){case"setupReady":(0,i.invokeMerchantCallback)(()=>u.onReady?.());return;case"setupValidation":{let w=k(c)&&typeof c.message=="string"?c.message:null;(0,i.invokeMerchantCallback)(()=>u.onValidation?.(w));return}case"complete":(0,i.invokeMerchantCallback)(()=>u.onComplete?.(c));return;case"decline":(0,i.invokeMerchantCallback)(()=>u.onDecline?.(c));return;case"cancel":(0,i.invokeMerchantCallback)(()=>u.onCancel?.(c));return;case"error":C(K(c));return;default:return}};return(0,h.loadCheckoutRuntime)({runtimeUrl:a,...f===void 0?{}:{timeoutMs:f}}).then(r=>{if(!o)return;if(typeof r.mountSetup!="function"){C(S("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let u=v(p.current);R.current=JSON.stringify(u),d.current=r.mountSetup(m,{setup:e,sessionId:n,nonce:l,contractVersion:A,...u,onEvent:_})},r=>{o&&C(N(r))}),()=>{o=!1;let r=d.current;d.current=null,r?.unmount()}},[e,n,l,a,f]),(0,s.useEffect)(()=>{let m=d.current;if(!m||R.current===y)return;R.current=y;let o=p.current;m.update({theme:o.theme,appearance:o.appearance,buttonsStyles:o.buttonsStyles,containerStyle:o.containerStyle,strings:o.strings})},[y]),(0,g.jsx)("div",{ref:F})}function b(e){return(0,g.jsx)(j,{kind:"card",props:e})}0&&(module.exports={FloPayCardSetup});
1
+ "use strict";var E=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of M(t))!I.call(e,a)&&a!==n&&E(e,a,{get:()=>t[a],enumerable:!(l=x(t,a))||l.enumerable});return e};var A=e=>V(E({},"__esModule",{value:!0}),e);var L={};O(L,{FloPayCardSetup:()=>T});module.exports=A(L);var k=require("@flopay/js"),g=require("@flopay/shared"),s=require("react");var i=require("@flopay/shared");var F=require("react/jsx-runtime"),J="2.4.0";function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var K=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function S(e,t,n,l={}){return Object.assign(new g.FloPayError(e,t,l),{retryable:n})}function N(e){let t=b(e)?e:{},n=typeof t.type=="string"&&K.has(t.type)?t.type:"";return S(typeof t.message=="string"?t.message:"The setup failed.",n||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function j(e){return e instanceof g.FloPayError?S(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):S("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function h(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function H({kind:e,props:t}){let{sessionId:n,nonce:l,runtimeUrl:a,runtimeTimeoutMs:f,locale:R}=t,v=(0,s.useRef)(null),d=(0,s.useRef)(null),p=(0,s.useRef)(t);p.current=t;let _=h(t),y=JSON.stringify(_),C=(0,s.useRef)(y);return(0,s.useEffect)(()=>{let m=v.current;if(!m)return;let o=!0,P=r=>{(0,i.invokeMerchantCallback)(()=>p.current.onError?.(r))},w=r=>{let u=p.current,c=r.payload;switch(r.name){case"setupReady":(0,i.invokeMerchantCallback)(()=>u.onReady?.());return;case"setupValidation":{let D=b(c)&&typeof c.message=="string"?c.message:null;(0,i.invokeMerchantCallback)(()=>u.onValidation?.(D));return}case"complete":(0,i.invokeMerchantCallback)(()=>u.onComplete?.(c));return;case"decline":(0,i.invokeMerchantCallback)(()=>u.onDecline?.(c));return;case"cancel":(0,i.invokeMerchantCallback)(()=>u.onCancel?.(c));return;case"error":P(N(c));return;default:return}};return(0,k.loadCheckoutRuntime)({runtimeUrl:a,...f===void 0?{}:{timeoutMs:f}}).then(r=>{if(!o)return;if(typeof r.mountSetup!="function"){P(S("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let u=h(p.current);C.current=JSON.stringify(u),d.current=r.mountSetup(m,{setup:e,sessionId:n,nonce:l,contractVersion:R===void 0?J:"2.7.0",locale:R,...u,onEvent:w})},r=>{o&&P(j(r))}),()=>{o=!1;let r=d.current;d.current=null,r?.unmount()}},[e,n,l,a,f,R]),(0,s.useEffect)(()=>{let m=d.current;if(!m||C.current===y)return;C.current=y;let o=p.current;m.update({theme:o.theme,appearance:o.appearance,buttonsStyles:o.buttonsStyles,containerStyle:o.containerStyle,strings:o.strings})},[y]),(0,F.jsx)("div",{ref:v})}function T(e){return(0,F.jsx)(H,{kind:"card",props:e})}0&&(module.exports={FloPayCardSetup});
@@ -1 +1 @@
1
- import{c as e}from"./chunk-XRYDC367.mjs";export{e as FloPayCardSetup};
1
+ import{c as e}from"./chunk-QHQ55OPE.mjs";export{e as FloPayCardSetup};
@@ -0,0 +1 @@
1
+ import{loadCheckoutRuntime as w}from"@flopay/js";import{FloPayError as F}from"@flopay/shared";import{useEffect as E,useRef as d}from"react";import{invokeMerchantCallback as a}from"@flopay/shared";import{jsx as k}from"react/jsx-runtime";var M="2.4.0";function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var D=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function y(e,t,i,l={}){return Object.assign(new F(e,t,l),{retryable:i})}function I(e){let t=v(e)?e:{},i=typeof t.type=="string"&&D.has(t.type)?t.type:"";return y(typeof t.message=="string"?t.message:"The setup failed.",i||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function O(e){return e instanceof F?y(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):y("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function h(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function x({kind:e,props:t}){let{sessionId:i,nonce:l,runtimeUrl:g,runtimeTimeoutMs:f,locale:S}=t,P=d(null),p=d(null),s=d(t);s.current=t;let b=h(t),m=JSON.stringify(b),R=d(m);return E(()=>{let c=P.current;if(!c)return;let r=!0,C=n=>{a(()=>s.current.onError?.(n))},T=n=>{let o=s.current,u=n.payload;switch(n.name){case"setupReady":a(()=>o.onReady?.());return;case"setupValidation":{let _=v(u)&&typeof u.message=="string"?u.message:null;a(()=>o.onValidation?.(_));return}case"complete":a(()=>o.onComplete?.(u));return;case"decline":a(()=>o.onDecline?.(u));return;case"cancel":a(()=>o.onCancel?.(u));return;case"error":C(I(u));return;default:return}};return w({runtimeUrl:g,...f===void 0?{}:{timeoutMs:f}}).then(n=>{if(!r)return;if(typeof n.mountSetup!="function"){C(y("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let o=h(s.current);R.current=JSON.stringify(o),p.current=n.mountSetup(c,{setup:e,sessionId:i,nonce:l,contractVersion:S===void 0?M:"2.7.0",locale:S,...o,onEvent:T})},n=>{r&&C(O(n))}),()=>{r=!1;let n=p.current;p.current=null,n?.unmount()}},[e,i,l,g,f,S]),E(()=>{let c=p.current;if(!c||R.current===m)return;R.current=m;let r=s.current;c.update({theme:r.theme,appearance:r.appearance,buttonsStyles:r.buttonsStyles,containerStyle:r.containerStyle,strings:r.strings})},[m]),k("div",{ref:P})}function L(e){return k(x,{kind:"card",props:e})}export{a,x as b,L as c};
@@ -1 +1 @@
1
- import{b as t}from"./chunk-XRYDC367.mjs";import{jsx as o}from"react/jsx-runtime";function m(e){return o(t,{kind:"payment_method",props:e})}export{m as a};
1
+ import{b as t}from"./chunk-QHQ55OPE.mjs";import{jsx as o}from"react/jsx-runtime";function m(e){return o(t,{kind:"payment_method",props:e})}export{m as a};
@@ -27,6 +27,8 @@ export interface FloPayRuntimeCardSetupProps {
27
27
  /** A setup session the merchant's server created. */
28
28
  sessionId: string;
29
29
  nonce: string;
30
+ /** Merchant language override, resolved by the API. A change remounts this no-charge setup. */
31
+ locale?: string;
30
32
  theme?: ThemeId | VaultCardThemeColors;
31
33
  appearance?: FloPayAppearance;
32
34
  buttonsStyles?: ButtonsLayoutStyles;
@@ -15,6 +15,8 @@ export interface FloPayRuntimeCheckoutProps {
15
15
  appearance?: Record<string, unknown>;
16
16
  /** Merchant wording overrides, applied by the runtime over the strings the API returns. */
17
17
  strings?: Record<string, string>;
18
+ /** Merchant language override; the API selects and returns the resolved language. */
19
+ locale?: string;
18
20
  /**
19
21
  * The merchant's payment method layout rules. The runtime has the billing API resolve them
20
22
  * for the buyer and lays out the payment method groups in that order, with the groups behind
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var O=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var re=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},ae=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ne(t))!oe.call(e,a)&&a!==n&&O(e,a,{get:()=>t[a],enumerable:!(o=te(t,a))||o.enumerable});return e};var ue=e=>ae(O({},"__esModule",{value:!0}),e);var ke={};re(ke,{DirectPayPalButton:()=>W,FloPayAutomaticPaymentButton:()=>Z,FloPayCardSetup:()=>q,FloPayCheckout:()=>C,FloPayPaymentMethodSetup:()=>z,FloPayProvider:()=>Q,FloPayRuntimeCardSetup:()=>M,FloPayRuntimeCheckout:()=>C,FloPayRuntimePaymentMethodSetup:()=>b,SplitCardForm:()=>G,VaultCardFields:()=>X,dropThirdPartyOnlyError:()=>$.dropThirdPartyOnlyError});module.exports=ue(ke);var $=require("@flopay/shared");var B=require("@flopay/js"),T=require("@flopay/shared"),h=require("react");var l=require("@flopay/shared");var w=require("react/jsx-runtime"),ie="2.4.0";function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var se=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function v(e,t,n,o={}){return Object.assign(new T.FloPayError(e,t,o),{retryable:n})}function de(e){let t=K(e)?e:{},n=typeof t.type=="string"&&se.has(t.type)?t.type:"";return v(typeof t.message=="string"?t.message:"The setup failed.",n||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function le(e){return e instanceof T.FloPayError?v(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):v("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function V(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function _({kind:e,props:t}){let{sessionId:n,nonce:o,runtimeUrl:a,runtimeTimeoutMs:s}=t,F=(0,h.useRef)(null),R=(0,h.useRef)(null),P=(0,h.useRef)(t);P.current=t;let E=V(t),f=JSON.stringify(E),y=(0,h.useRef)(f);return(0,h.useEffect)(()=>{let c=F.current;if(!c)return;let d=!0,p=r=>{(0,l.invokeMerchantCallback)(()=>P.current.onError?.(r))},k=r=>{let u=P.current,i=r.payload;switch(r.name){case"setupReady":(0,l.invokeMerchantCallback)(()=>u.onReady?.());return;case"setupValidation":{let g=K(i)&&typeof i.message=="string"?i.message:null;(0,l.invokeMerchantCallback)(()=>u.onValidation?.(g));return}case"complete":(0,l.invokeMerchantCallback)(()=>u.onComplete?.(i));return;case"decline":(0,l.invokeMerchantCallback)(()=>u.onDecline?.(i));return;case"cancel":(0,l.invokeMerchantCallback)(()=>u.onCancel?.(i));return;case"error":p(de(i));return;default:return}};return(0,B.loadCheckoutRuntime)({runtimeUrl:a,...s===void 0?{}:{timeoutMs:s}}).then(r=>{if(!d)return;if(typeof r.mountSetup!="function"){p(v("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let u=V(P.current);y.current=JSON.stringify(u),R.current=r.mountSetup(c,{setup:e,sessionId:n,nonce:o,contractVersion:ie,...u,onEvent:k})},r=>{d&&p(le(r))}),()=>{d=!1;let r=R.current;R.current=null,r?.unmount()}},[e,n,o,a,s]),(0,h.useEffect)(()=>{let c=R.current;if(!c||y.current===f)return;y.current=f;let d=P.current;c.update({theme:d.theme,appearance:d.appearance,buttonsStyles:d.buttonsStyles,containerStyle:d.containerStyle,strings:d.strings})},[f]),(0,w.jsx)("div",{ref:F})}function M(e){return(0,w.jsx)(_,{kind:"card",props:e})}var U=require("react/jsx-runtime");function b(e){return(0,U.jsx)(_,{kind:"payment_method",props:e})}var x=require("react");var H=require("@flopay/js"),A=require("@flopay/shared"),m=require("react"),j=require("react/jsx-runtime"),ce="2.2.0",me="2.3.0",ye="2.5.0",pe="2.6.0",Pe=new Set(["publishableKey","sessionId","nonce","createSession","appearance","strings","onEvent","contractVersion","paymentMethodLayout","layout","automaticPayment","setup","hiddenPaymentMethods"]);function fe(e,t){return t!==void 0&&Object.keys(t).some(n=>!Pe.has(n))?pe:t!==void 0&&"hiddenPaymentMethods"in t?ye:e?me:ce}function he(e,t){let n={mode:e};return t&&Object.defineProperty(n,"getSession",{enumerable:!0,get:t}),n}function Re(e){return e instanceof A.FloPayError?e:new A.FloPayError("The checkout runtime failed to load.","network_error",{code:"runtime_load_failed",cause:e})}function J(e){let{publishableKey:t,sessionId:n,nonce:o,appearance:a,strings:s,layout:F,runtimeUrl:R,runtimeTimeoutMs:P}=e,E=e.extraMountOptions===void 0?void 0:JSON.stringify(e.extraMountOptions),f=e.createSession===void 0?void 0:JSON.stringify(e.createSession),y=e.paymentMethodLayout===void 0?void 0:JSON.stringify(e.paymentMethodLayout),c=e.automaticPayment?.mode,d=e.automaticPayment?.getSession!==void 0,p=(0,m.useRef)(void 0),k=(0,m.useRef)(null),r=(0,m.useRef)(null),u=(0,m.useRef)(e);return u.current=e,(0,m.useEffect)(()=>{let i=!0;return(0,H.loadCheckoutRuntime)({runtimeUrl:R,timeoutMs:P}).then(g=>{let L=k.current;if(!i||!L)return;let I=u.current.paymentMethodLayout;p.current=I===void 0?void 0:JSON.stringify(I);let D=E===void 0?void 0:JSON.parse(E);r.current=g.mount(L,{...D,contractVersion:fe(!!c,D),...c?{automaticPayment:he(c,d?()=>u.current.automaticPayment?.getSession:void 0)}:{},publishableKey:t,sessionId:n,nonce:o,createSession:f===void 0?void 0:JSON.parse(f),appearance:u.current.appearance,strings:u.current.strings,paymentMethodLayout:p.current===void 0?void 0:JSON.parse(p.current),...F?{layout:F}:{},onEvent:ee=>u.current.onEvent?.(ee)})},g=>{i&&u.current.onError?.(Re(g))}),()=>{i=!1,r.current?.unmount(),r.current=null}},[t,n,o,f,F,c,d,R,P,E]),(0,m.useEffect)(()=>{a!==void 0&&r.current?.update({appearance:a})},[a]),(0,m.useEffect)(()=>{s!==void 0&&r.current?.update({strings:s})},[s]),(0,m.useEffect)(()=>{if(y===void 0||y===p.current)return;let i=r.current;i&&(p.current=y,i.update({paymentMethodLayout:JSON.parse(y)}))},[y]),(0,j.jsx)("div",{ref:k,"data-flopay-runtime-checkout":""})}var Y=require("react"),N=(0,Y.createContext)({});var S=require("react/jsx-runtime"),Ce=["theme","showCardBrandIcons","showCardFieldLabels","cardFieldLabels","cardFieldPlaceholders","enabledPaymentMethods","initialPayPalOrderId"],Se={complete:"onComplete",decline:"onDecline",error:"onError",cancel:"onCancel",instruments:"onInstrument",cardFieldsReady:"onCardFieldsReady",cardFieldsFailed:"onCardFieldsFailed"};function Fe(e){let t={};for(let o of Ce)e[o]!==void 0&&(t[o]=e[o]);let n=[...e.hiddenPaymentMethods??[]];return e.showPayPal===!1&&!n.includes("paypal")&&n.push("paypal"),(e.hiddenPaymentMethods!==void 0||n.length>0)&&(t.hiddenPaymentMethods=n),Object.keys(t).length===0?void 0:t}function C(e){let t=(0,x.useContext)(N),n=(0,x.useRef)(e);return n.current=e,(0,S.jsx)(J,{sessionId:e.sessionId,nonce:e.nonce,createSession:e.createSession,appearance:e.appearance,strings:e.strings,paymentMethodLayout:e.paymentMethodLayout,layout:e.layout,automaticPayment:e.automaticPayment,runtimeTimeoutMs:e.runtimeTimeoutMs,publishableKey:e.publishableKey??t.publishableKey??"",runtimeUrl:e.runtimeUrl??t.runtimeUrl??"",extraMountOptions:Fe(e),onError:o=>n.current.onError?.(o),onEvent:o=>{let a=n.current;a.onEvent?.(o);let s=a[Se[o.name]];s&&(0,l.invokeMerchantCallback)(()=>s(o.payload))}})}function G(e){return(0,S.jsx)(C,{...e})}var q=M,z=b;function Q({publishableKey:e,runtimeUrl:t,children:n}){return(0,S.jsx)(N.Provider,{value:{publishableKey:e,runtimeUrl:t},children:n})}var Ee=["card","apple_pay","google_pay","apms"],ge=["paypal","apple_pay","google_pay","apms"];function W(e){return(0,S.jsx)(C,{...e,hiddenPaymentMethods:Ee})}function X(e){return(0,S.jsx)(C,{...e,hiddenPaymentMethods:ge})}function Z({mode:e,getSession:t,onSuccess:n,onComplete:o,...a}){return(0,S.jsx)(C,{...a,automaticPayment:{mode:e??"automatic",...t?{getSession:t}:{}},onComplete:s=>{o&&(0,l.invokeMerchantCallback)(()=>o(s)),n&&(0,l.invokeMerchantCallback)(()=>n(s))}})}0&&(module.exports={DirectPayPalButton,FloPayAutomaticPaymentButton,FloPayCardSetup,FloPayCheckout,FloPayPaymentMethodSetup,FloPayProvider,FloPayRuntimeCardSetup,FloPayRuntimeCheckout,FloPayRuntimePaymentMethodSetup,SplitCardForm,VaultCardFields,dropThirdPartyOnlyError});
1
+ "use strict";var T=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of oe(t))!re.call(e,u)&&u!==n&&T(e,u,{get:()=>t[u],enumerable:!(o=ne(t,u))||o.enumerable});return e};var ie=e=>ue(T({},"__esModule",{value:!0}),e);var ve={};ae(ve,{DirectPayPalButton:()=>X,FloPayAutomaticPaymentButton:()=>$,FloPayCardSetup:()=>z,FloPayCheckout:()=>S,FloPayPaymentMethodSetup:()=>Q,FloPayProvider:()=>W,FloPayRuntimeCardSetup:()=>b,FloPayRuntimeCheckout:()=>S,FloPayRuntimePaymentMethodSetup:()=>x,SplitCardForm:()=>q,VaultCardFields:()=>Z,dropThirdPartyOnlyError:()=>ee.dropThirdPartyOnlyError});module.exports=ie(ve);var ee=require("@flopay/shared");var K=require("@flopay/js"),_=require("@flopay/shared"),h=require("react");var c=require("@flopay/shared");var A=require("react/jsx-runtime"),se="2.4.0";function U(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var le=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function M(e,t,n,o={}){return Object.assign(new _.FloPayError(e,t,o),{retryable:n})}function ce(e){let t=U(e)?e:{},n=typeof t.type=="string"&&le.has(t.type)?t.type:"";return M(typeof t.message=="string"?t.message:"The setup failed.",n||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function de(e){return e instanceof _.FloPayError?M(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):M("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function B(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function w({kind:e,props:t}){let{sessionId:n,nonce:o,runtimeUrl:u,runtimeTimeoutMs:s,locale:R}=t,g=(0,h.useRef)(null),C=(0,h.useRef)(null),P=(0,h.useRef)(t);P.current=t;let E=B(t),f=JSON.stringify(E),y=(0,h.useRef)(f);return(0,h.useEffect)(()=>{let m=g.current;if(!m)return;let l=!0,p=r=>{(0,c.invokeMerchantCallback)(()=>P.current.onError?.(r))},v=r=>{let a=P.current,i=r.payload;switch(r.name){case"setupReady":(0,c.invokeMerchantCallback)(()=>a.onReady?.());return;case"setupValidation":{let k=U(i)&&typeof i.message=="string"?i.message:null;(0,c.invokeMerchantCallback)(()=>a.onValidation?.(k));return}case"complete":(0,c.invokeMerchantCallback)(()=>a.onComplete?.(i));return;case"decline":(0,c.invokeMerchantCallback)(()=>a.onDecline?.(i));return;case"cancel":(0,c.invokeMerchantCallback)(()=>a.onCancel?.(i));return;case"error":p(ce(i));return;default:return}};return(0,K.loadCheckoutRuntime)({runtimeUrl:u,...s===void 0?{}:{timeoutMs:s}}).then(r=>{if(!l)return;if(typeof r.mountSetup!="function"){p(M("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let a=B(P.current);y.current=JSON.stringify(a),C.current=r.mountSetup(m,{setup:e,sessionId:n,nonce:o,contractVersion:R===void 0?se:"2.7.0",locale:R,...a,onEvent:v})},r=>{l&&p(de(r))}),()=>{l=!1;let r=C.current;C.current=null,r?.unmount()}},[e,n,o,u,s,R]),(0,h.useEffect)(()=>{let m=C.current;if(!m||y.current===f)return;y.current=f;let l=P.current;m.update({theme:l.theme,appearance:l.appearance,buttonsStyles:l.buttonsStyles,containerStyle:l.containerStyle,strings:l.strings})},[f]),(0,A.jsx)("div",{ref:g})}function b(e){return(0,A.jsx)(w,{kind:"card",props:e})}var H=require("react/jsx-runtime");function x(e){return(0,H.jsx)(w,{kind:"payment_method",props:e})}var O=require("react");var J=require("@flopay/js"),N=require("@flopay/shared"),d=require("react"),Y=require("react/jsx-runtime"),me="2.2.0",ye="2.3.0",pe="2.5.0",Pe="2.6.0",fe=new Set(["publishableKey","sessionId","nonce","createSession","appearance","strings","onEvent","contractVersion","paymentMethodLayout","layout","automaticPayment","setup","hiddenPaymentMethods"]);function he(e,t,n){return n!==void 0?"2.7.0":t!==void 0&&Object.keys(t).some(o=>!fe.has(o))?Pe:t!==void 0&&"hiddenPaymentMethods"in t?pe:e?ye:me}function Re(e,t){let n={mode:e};return t&&Object.defineProperty(n,"getSession",{enumerable:!0,get:t}),n}function Ce(e){return e instanceof N.FloPayError?e:new N.FloPayError("The checkout runtime failed to load.","network_error",{code:"runtime_load_failed",cause:e})}function j(e){let{publishableKey:t,sessionId:n,nonce:o,appearance:u,strings:s,locale:R,layout:g,runtimeUrl:C,runtimeTimeoutMs:P}=e,E=e.extraMountOptions===void 0?void 0:JSON.stringify(e.extraMountOptions),f=e.createSession===void 0?void 0:JSON.stringify(e.createSession),y=e.paymentMethodLayout===void 0?void 0:JSON.stringify(e.paymentMethodLayout),m=e.automaticPayment?.mode,l=e.automaticPayment?.getSession!==void 0,p=(0,d.useRef)(void 0),v=(0,d.useRef)(null),r=(0,d.useRef)(null),a=(0,d.useRef)(e);return a.current=e,(0,d.useEffect)(()=>{let i=!0;return(0,J.loadCheckoutRuntime)({runtimeUrl:C,timeoutMs:P}).then(k=>{let I=v.current;if(!i||!I)return;let D=a.current.paymentMethodLayout;p.current=D===void 0?void 0:JSON.stringify(D);let V=E===void 0?void 0:JSON.parse(E);r.current=k.mount(I,{...V,contractVersion:he(!!m,V,a.current.locale),...m?{automaticPayment:Re(m,l?()=>a.current.automaticPayment?.getSession:void 0)}:{},publishableKey:t,sessionId:n,nonce:o,createSession:f===void 0?void 0:JSON.parse(f),appearance:a.current.appearance,strings:a.current.strings,locale:a.current.locale,paymentMethodLayout:p.current===void 0?void 0:JSON.parse(p.current),...g?{layout:g}:{},onEvent:te=>a.current.onEvent?.(te)})},k=>{i&&a.current.onError?.(Ce(k))}),()=>{i=!1,r.current?.unmount(),r.current=null}},[t,n,o,f,g,m,l,C,P,E]),(0,d.useEffect)(()=>{u!==void 0&&r.current?.update({appearance:u})},[u]),(0,d.useEffect)(()=>{s!==void 0&&r.current?.update({strings:s})},[s]),(0,d.useEffect)(()=>{R!==void 0&&r.current?.update({locale:R})},[R]),(0,d.useEffect)(()=>{if(y===void 0||y===p.current)return;let i=r.current;i&&(p.current=y,i.update({paymentMethodLayout:JSON.parse(y)}))},[y]),(0,Y.jsx)("div",{ref:v,"data-flopay-runtime-checkout":""})}var G=require("react"),L=(0,G.createContext)({});var F=require("react/jsx-runtime"),Se=["theme","showCardBrandIcons","showCardFieldLabels","cardFieldLabels","cardFieldPlaceholders","enabledPaymentMethods","initialPayPalOrderId"],Fe={complete:"onComplete",decline:"onDecline",error:"onError",cancel:"onCancel",instruments:"onInstrument",cardFieldsReady:"onCardFieldsReady",cardFieldsFailed:"onCardFieldsFailed"};function ge(e){let t={};for(let o of Se)e[o]!==void 0&&(t[o]=e[o]);let n=[...e.hiddenPaymentMethods??[]];return e.showPayPal===!1&&!n.includes("paypal")&&n.push("paypal"),(e.hiddenPaymentMethods!==void 0||n.length>0)&&(t.hiddenPaymentMethods=n),Object.keys(t).length===0?void 0:t}function S(e){let t=(0,O.useContext)(L),n=(0,O.useRef)(e);return n.current=e,(0,F.jsx)(j,{sessionId:e.sessionId,nonce:e.nonce,createSession:e.createSession,appearance:e.appearance,strings:e.strings,locale:e.locale,paymentMethodLayout:e.paymentMethodLayout,layout:e.layout,automaticPayment:e.automaticPayment,runtimeTimeoutMs:e.runtimeTimeoutMs,publishableKey:e.publishableKey??t.publishableKey??"",runtimeUrl:e.runtimeUrl??t.runtimeUrl??"",extraMountOptions:ge(e),onError:o=>n.current.onError?.(o),onEvent:o=>{let u=n.current;u.onEvent?.(o);let s=u[Fe[o.name]];s&&(0,c.invokeMerchantCallback)(()=>s(o.payload))}})}function q(e){return(0,F.jsx)(S,{...e})}var z=b,Q=x;function W({publishableKey:e,runtimeUrl:t,children:n}){return(0,F.jsx)(L.Provider,{value:{publishableKey:e,runtimeUrl:t},children:n})}var Ee=["card","apple_pay","google_pay","apms"],ke=["paypal","apple_pay","google_pay","apms"];function X(e){return(0,F.jsx)(S,{...e,hiddenPaymentMethods:Ee})}function Z(e){return(0,F.jsx)(S,{...e,hiddenPaymentMethods:ke})}function $({mode:e,getSession:t,onSuccess:n,onComplete:o,...u}){return(0,F.jsx)(S,{...u,automaticPayment:{mode:e??"automatic",...t?{getSession:t}:{}},onComplete:s=>{o&&(0,c.invokeMerchantCallback)(()=>o(s)),n&&(0,c.invokeMerchantCallback)(()=>n(s))}})}0&&(module.exports={DirectPayPalButton,FloPayAutomaticPaymentButton,FloPayCardSetup,FloPayCheckout,FloPayPaymentMethodSetup,FloPayProvider,FloPayRuntimeCardSetup,FloPayRuntimeCheckout,FloPayRuntimePaymentMethodSetup,SplitCardForm,VaultCardFields,dropThirdPartyOnlyError});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as S}from"./chunk-KPRDVWZP.mjs";import{a as P,c as k}from"./chunk-XRYDC367.mjs";import{dropThirdPartyOnlyError as Se}from"@flopay/shared";import{useContext as Y,useRef as G}from"react";import{loadCheckoutRuntime as T}from"@flopay/js";import{FloPayError as N}from"@flopay/shared";import{useEffect as p,useRef as h}from"react";import{jsx as j}from"react/jsx-runtime";var _="2.2.0",I="2.3.0",B="2.5.0",D="2.6.0",V=new Set(["publishableKey","sessionId","nonce","createSession","appearance","strings","onEvent","contractVersion","paymentMethodLayout","layout","automaticPayment","setup","hiddenPaymentMethods"]);function U(e,t){return t!==void 0&&Object.keys(t).some(n=>!V.has(n))?D:t!==void 0&&"hiddenPaymentMethods"in t?B:e?I:_}function H(e,t){let n={mode:e};return t&&Object.defineProperty(n,"getSession",{enumerable:!0,get:t}),n}function K(e){return e instanceof N?e:new N("The checkout runtime failed to load.","network_error",{code:"runtime_load_failed",cause:e})}function w(e){let{publishableKey:t,sessionId:n,nonce:o,appearance:r,strings:a,layout:f,runtimeUrl:M,runtimeTimeoutMs:g}=e,C=e.extraMountOptions===void 0?void 0:JSON.stringify(e.extraMountOptions),R=e.createSession===void 0?void 0:JSON.stringify(e.createSession),c=e.paymentMethodLayout===void 0?void 0:JSON.stringify(e.paymentMethodLayout),y=e.automaticPayment?.mode,v=e.automaticPayment?.getSession!==void 0,m=h(void 0),b=h(null),u=h(null),i=h(e);return i.current=e,p(()=>{let d=!0;return T({runtimeUrl:M,timeoutMs:g}).then(F=>{let x=b.current;if(!d||!x)return;let O=i.current.paymentMethodLayout;m.current=O===void 0?void 0:JSON.stringify(O);let A=C===void 0?void 0:JSON.parse(C);u.current=F.mount(x,{...A,contractVersion:U(!!y,A),...y?{automaticPayment:H(y,v?()=>i.current.automaticPayment?.getSession:void 0)}:{},publishableKey:t,sessionId:n,nonce:o,createSession:R===void 0?void 0:JSON.parse(R),appearance:i.current.appearance,strings:i.current.strings,paymentMethodLayout:m.current===void 0?void 0:JSON.parse(m.current),...f?{layout:f}:{},onEvent:L=>i.current.onEvent?.(L)})},F=>{d&&i.current.onError?.(K(F))}),()=>{d=!1,u.current?.unmount(),u.current=null}},[t,n,o,R,f,y,v,M,g,C]),p(()=>{r!==void 0&&u.current?.update({appearance:r})},[r]),p(()=>{a!==void 0&&u.current?.update({strings:a})},[a]),p(()=>{if(c===void 0||c===m.current)return;let d=u.current;d&&(m.current=c,d.update({paymentMethodLayout:JSON.parse(c)}))},[c]),j("div",{ref:b,"data-flopay-runtime-checkout":""})}import{createContext as J}from"react";var E=J({});import{jsx as l}from"react/jsx-runtime";var q=["theme","showCardBrandIcons","showCardFieldLabels","cardFieldLabels","cardFieldPlaceholders","enabledPaymentMethods","initialPayPalOrderId"],z={complete:"onComplete",decline:"onDecline",error:"onError",cancel:"onCancel",instruments:"onInstrument",cardFieldsReady:"onCardFieldsReady",cardFieldsFailed:"onCardFieldsFailed"};function Q(e){let t={};for(let o of q)e[o]!==void 0&&(t[o]=e[o]);let n=[...e.hiddenPaymentMethods??[]];return e.showPayPal===!1&&!n.includes("paypal")&&n.push("paypal"),(e.hiddenPaymentMethods!==void 0||n.length>0)&&(t.hiddenPaymentMethods=n),Object.keys(t).length===0?void 0:t}function s(e){let t=Y(E),n=G(e);return n.current=e,l(w,{sessionId:e.sessionId,nonce:e.nonce,createSession:e.createSession,appearance:e.appearance,strings:e.strings,paymentMethodLayout:e.paymentMethodLayout,layout:e.layout,automaticPayment:e.automaticPayment,runtimeTimeoutMs:e.runtimeTimeoutMs,publishableKey:e.publishableKey??t.publishableKey??"",runtimeUrl:e.runtimeUrl??t.runtimeUrl??"",extraMountOptions:Q(e),onError:o=>n.current.onError?.(o),onEvent:o=>{let r=n.current;r.onEvent?.(o);let a=r[z[o.name]];a&&P(()=>a(o.payload))}})}function W(e){return l(s,{...e})}var X=k,Z=S;function $({publishableKey:e,runtimeUrl:t,children:n}){return l(E.Provider,{value:{publishableKey:e,runtimeUrl:t},children:n})}var ee=["card","apple_pay","google_pay","apms"],te=["paypal","apple_pay","google_pay","apms"];function ne(e){return l(s,{...e,hiddenPaymentMethods:ee})}function oe(e){return l(s,{...e,hiddenPaymentMethods:te})}function ae({mode:e,getSession:t,onSuccess:n,onComplete:o,...r}){return l(s,{...r,automaticPayment:{mode:e??"automatic",...t?{getSession:t}:{}},onComplete:a=>{o&&P(()=>o(a)),n&&P(()=>n(a))}})}export{ne as DirectPayPalButton,ae as FloPayAutomaticPaymentButton,X as FloPayCardSetup,s as FloPayCheckout,Z as FloPayPaymentMethodSetup,$ as FloPayProvider,k as FloPayRuntimeCardSetup,s as FloPayRuntimeCheckout,S as FloPayRuntimePaymentMethodSetup,W as SplitCardForm,oe as VaultCardFields,Se as dropThirdPartyOnlyError};
1
+ import{a as E}from"./chunk-ZG2NKEN7.mjs";import{a as p,c as S}from"./chunk-QHQ55OPE.mjs";import{dropThirdPartyOnlyError as Ee}from"@flopay/shared";import{useContext as G,useRef as q}from"react";import{loadCheckoutRuntime as _}from"@flopay/js";import{FloPayError as w}from"@flopay/shared";import{useEffect as y,useRef as h}from"react";import{jsx as J}from"react/jsx-runtime";var I="2.2.0",B="2.3.0",D="2.5.0",V="2.6.0",U=new Set(["publishableKey","sessionId","nonce","createSession","appearance","strings","onEvent","contractVersion","paymentMethodLayout","layout","automaticPayment","setup","hiddenPaymentMethods"]);function H(e,t,n){return n!==void 0?"2.7.0":t!==void 0&&Object.keys(t).some(o=>!U.has(o))?V:t!==void 0&&"hiddenPaymentMethods"in t?D:e?B:I}function K(e,t){let n={mode:e};return t&&Object.defineProperty(n,"getSession",{enumerable:!0,get:t}),n}function j(e){return e instanceof w?e:new w("The checkout runtime failed to load.","network_error",{code:"runtime_load_failed",cause:e})}function L(e){let{publishableKey:t,sessionId:n,nonce:o,appearance:i,strings:a,locale:f,layout:C,runtimeUrl:M,runtimeTimeoutMs:v}=e,R=e.extraMountOptions===void 0?void 0:JSON.stringify(e.extraMountOptions),F=e.createSession===void 0?void 0:JSON.stringify(e.createSession),c=e.paymentMethodLayout===void 0?void 0:JSON.stringify(e.paymentMethodLayout),P=e.automaticPayment?.mode,b=e.automaticPayment?.getSession!==void 0,m=h(void 0),x=h(null),u=h(null),r=h(e);return r.current=e,y(()=>{let d=!0;return _({runtimeUrl:M,timeoutMs:v}).then(k=>{let O=x.current;if(!d||!O)return;let A=r.current.paymentMethodLayout;m.current=A===void 0?void 0:JSON.stringify(A);let N=R===void 0?void 0:JSON.parse(R);u.current=k.mount(O,{...N,contractVersion:H(!!P,N,r.current.locale),...P?{automaticPayment:K(P,b?()=>r.current.automaticPayment?.getSession:void 0)}:{},publishableKey:t,sessionId:n,nonce:o,createSession:F===void 0?void 0:JSON.parse(F),appearance:r.current.appearance,strings:r.current.strings,locale:r.current.locale,paymentMethodLayout:m.current===void 0?void 0:JSON.parse(m.current),...C?{layout:C}:{},onEvent:T=>r.current.onEvent?.(T)})},k=>{d&&r.current.onError?.(j(k))}),()=>{d=!1,u.current?.unmount(),u.current=null}},[t,n,o,F,C,P,b,M,v,R]),y(()=>{i!==void 0&&u.current?.update({appearance:i})},[i]),y(()=>{a!==void 0&&u.current?.update({strings:a})},[a]),y(()=>{f!==void 0&&u.current?.update({locale:f})},[f]),y(()=>{if(c===void 0||c===m.current)return;let d=u.current;d&&(m.current=c,d.update({paymentMethodLayout:JSON.parse(c)}))},[c]),J("div",{ref:x,"data-flopay-runtime-checkout":""})}import{createContext as Y}from"react";var g=Y({});import{jsx as l}from"react/jsx-runtime";var z=["theme","showCardBrandIcons","showCardFieldLabels","cardFieldLabels","cardFieldPlaceholders","enabledPaymentMethods","initialPayPalOrderId"],Q={complete:"onComplete",decline:"onDecline",error:"onError",cancel:"onCancel",instruments:"onInstrument",cardFieldsReady:"onCardFieldsReady",cardFieldsFailed:"onCardFieldsFailed"};function W(e){let t={};for(let o of z)e[o]!==void 0&&(t[o]=e[o]);let n=[...e.hiddenPaymentMethods??[]];return e.showPayPal===!1&&!n.includes("paypal")&&n.push("paypal"),(e.hiddenPaymentMethods!==void 0||n.length>0)&&(t.hiddenPaymentMethods=n),Object.keys(t).length===0?void 0:t}function s(e){let t=G(g),n=q(e);return n.current=e,l(L,{sessionId:e.sessionId,nonce:e.nonce,createSession:e.createSession,appearance:e.appearance,strings:e.strings,locale:e.locale,paymentMethodLayout:e.paymentMethodLayout,layout:e.layout,automaticPayment:e.automaticPayment,runtimeTimeoutMs:e.runtimeTimeoutMs,publishableKey:e.publishableKey??t.publishableKey??"",runtimeUrl:e.runtimeUrl??t.runtimeUrl??"",extraMountOptions:W(e),onError:o=>n.current.onError?.(o),onEvent:o=>{let i=n.current;i.onEvent?.(o);let a=i[Q[o.name]];a&&p(()=>a(o.payload))}})}function X(e){return l(s,{...e})}var Z=S,$=E;function ee({publishableKey:e,runtimeUrl:t,children:n}){return l(g.Provider,{value:{publishableKey:e,runtimeUrl:t},children:n})}var te=["card","apple_pay","google_pay","apms"],ne=["paypal","apple_pay","google_pay","apms"];function oe(e){return l(s,{...e,hiddenPaymentMethods:te})}function ae(e){return l(s,{...e,hiddenPaymentMethods:ne})}function re({mode:e,getSession:t,onSuccess:n,onComplete:o,...i}){return l(s,{...i,automaticPayment:{mode:e??"automatic",...t?{getSession:t}:{}},onComplete:a=>{o&&p(()=>o(a)),n&&p(()=>n(a))}})}export{oe as DirectPayPalButton,re as FloPayAutomaticPaymentButton,Z as FloPayCardSetup,s as FloPayCheckout,$ as FloPayPaymentMethodSetup,ee as FloPayProvider,S as FloPayRuntimeCardSetup,s as FloPayRuntimeCheckout,E as FloPayRuntimePaymentMethodSetup,X as SplitCardForm,ae as VaultCardFields,Ee as dropThirdPartyOnlyError};
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var n in t)C(e,n,{get:t[n],enumerable:!0})},A=(e,t,n,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of I(t))!O.call(e,a)&&a!==n&&C(e,a,{get:()=>t[a],enumerable:!(p=D(t,a))||p.enumerable});return e};var j=e=>A(C({},"__esModule",{value:!0}),e);var L={};V(L,{FloPayPaymentMethodSetup:()=>_});module.exports=j(L);var g=require("@flopay/js"),E=require("@flopay/shared"),s=require("react");var i=require("@flopay/shared");var M=require("react/jsx-runtime"),J="2.4.0";function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var K=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function S(e,t,n,p={}){return Object.assign(new E.FloPayError(e,t,p),{retryable:n})}function N(e){let t=v(e)?e:{},n=typeof t.type=="string"&&K.has(t.type)?t.type:"";return S(typeof t.message=="string"?t.message:"The setup failed.",n||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function H(e){return e instanceof E.FloPayError?S(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):S("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function h(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function k({kind:e,props:t}){let{sessionId:n,nonce:p,runtimeUrl:a,runtimeTimeoutMs:f}=t,F=(0,s.useRef)(null),y=(0,s.useRef)(null),c=(0,s.useRef)(t);c.current=t;let T=h(t),d=JSON.stringify(T),P=(0,s.useRef)(d);return(0,s.useEffect)(()=>{let m=F.current;if(!m)return;let o=!0,R=r=>{(0,i.invokeMerchantCallback)(()=>c.current.onError?.(r))},w=r=>{let u=c.current,l=r.payload;switch(r.name){case"setupReady":(0,i.invokeMerchantCallback)(()=>u.onReady?.());return;case"setupValidation":{let x=v(l)&&typeof l.message=="string"?l.message:null;(0,i.invokeMerchantCallback)(()=>u.onValidation?.(x));return}case"complete":(0,i.invokeMerchantCallback)(()=>u.onComplete?.(l));return;case"decline":(0,i.invokeMerchantCallback)(()=>u.onDecline?.(l));return;case"cancel":(0,i.invokeMerchantCallback)(()=>u.onCancel?.(l));return;case"error":R(N(l));return;default:return}};return(0,g.loadCheckoutRuntime)({runtimeUrl:a,...f===void 0?{}:{timeoutMs:f}}).then(r=>{if(!o)return;if(typeof r.mountSetup!="function"){R(S("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let u=h(c.current);P.current=JSON.stringify(u),y.current=r.mountSetup(m,{setup:e,sessionId:n,nonce:p,contractVersion:J,...u,onEvent:w})},r=>{o&&R(H(r))}),()=>{o=!1;let r=y.current;y.current=null,r?.unmount()}},[e,n,p,a,f]),(0,s.useEffect)(()=>{let m=y.current;if(!m||P.current===d)return;P.current=d;let o=c.current;m.update({theme:o.theme,appearance:o.appearance,buttonsStyles:o.buttonsStyles,containerStyle:o.containerStyle,strings:o.strings})},[d]),(0,M.jsx)("div",{ref:F})}var b=require("react/jsx-runtime");function _(e){return(0,b.jsx)(k,{kind:"payment_method",props:e})}0&&(module.exports={FloPayPaymentMethodSetup});
1
+ "use strict";var E=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of O(t))!V.call(e,a)&&a!==n&&E(e,a,{get:()=>t[a],enumerable:!(l=I(t,a))||l.enumerable});return e};var J=e=>j(E({},"__esModule",{value:!0}),e);var U={};A(U,{FloPayPaymentMethodSetup:()=>b});module.exports=J(U);var v=require("@flopay/js"),F=require("@flopay/shared"),s=require("react");var i=require("@flopay/shared");var _=require("react/jsx-runtime"),K="2.4.0";function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var N=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function S(e,t,n,l={}){return Object.assign(new F.FloPayError(e,t,l),{retryable:n})}function H(e){let t=k(e)?e:{},n=typeof t.type=="string"&&N.has(t.type)?t.type:"";return S(typeof t.message=="string"?t.message:"The setup failed.",n||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function L(e){return e instanceof F.FloPayError?S(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):S("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function g(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function M({kind:e,props:t}){let{sessionId:n,nonce:l,runtimeUrl:a,runtimeTimeoutMs:f,locale:P}=t,h=(0,s.useRef)(null),y=(0,s.useRef)(null),c=(0,s.useRef)(t);c.current=t;let w=g(t),d=JSON.stringify(w),R=(0,s.useRef)(d);return(0,s.useEffect)(()=>{let m=h.current;if(!m)return;let o=!0,C=r=>{(0,i.invokeMerchantCallback)(()=>c.current.onError?.(r))},x=r=>{let u=c.current,p=r.payload;switch(r.name){case"setupReady":(0,i.invokeMerchantCallback)(()=>u.onReady?.());return;case"setupValidation":{let D=k(p)&&typeof p.message=="string"?p.message:null;(0,i.invokeMerchantCallback)(()=>u.onValidation?.(D));return}case"complete":(0,i.invokeMerchantCallback)(()=>u.onComplete?.(p));return;case"decline":(0,i.invokeMerchantCallback)(()=>u.onDecline?.(p));return;case"cancel":(0,i.invokeMerchantCallback)(()=>u.onCancel?.(p));return;case"error":C(H(p));return;default:return}};return(0,v.loadCheckoutRuntime)({runtimeUrl:a,...f===void 0?{}:{timeoutMs:f}}).then(r=>{if(!o)return;if(typeof r.mountSetup!="function"){C(S("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let u=g(c.current);R.current=JSON.stringify(u),y.current=r.mountSetup(m,{setup:e,sessionId:n,nonce:l,contractVersion:P===void 0?K:"2.7.0",locale:P,...u,onEvent:x})},r=>{o&&C(L(r))}),()=>{o=!1;let r=y.current;y.current=null,r?.unmount()}},[e,n,l,a,f,P]),(0,s.useEffect)(()=>{let m=y.current;if(!m||R.current===d)return;R.current=d;let o=c.current;m.update({theme:o.theme,appearance:o.appearance,buttonsStyles:o.buttonsStyles,containerStyle:o.containerStyle,strings:o.strings})},[d]),(0,_.jsx)("div",{ref:h})}var T=require("react/jsx-runtime");function b(e){return(0,T.jsx)(M,{kind:"payment_method",props:e})}0&&(module.exports={FloPayPaymentMethodSetup});
@@ -1 +1 @@
1
- import{a as e}from"./chunk-KPRDVWZP.mjs";import"./chunk-XRYDC367.mjs";export{e as FloPayPaymentMethodSetup};
1
+ import{a as e}from"./chunk-ZG2NKEN7.mjs";import"./chunk-QHQ55OPE.mjs";export{e as FloPayPaymentMethodSetup};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/react",
3
- "version": "2.0.12",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -36,8 +36,8 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@flopay/js": "2.0.12",
40
- "@flopay/shared": "2.0.12"
39
+ "@flopay/js": "2.1.0",
40
+ "@flopay/shared": "2.1.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=18.0.0",
@@ -1 +0,0 @@
1
- import{loadCheckoutRuntime as _}from"@flopay/js";import{FloPayError as h}from"@flopay/shared";import{useEffect as P,useRef as d}from"react";import{invokeMerchantCallback as a}from"@flopay/shared";import{jsx as v}from"react/jsx-runtime";var w="2.4.0";function F(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var M=new Set(["validation_error","api_error","authentication_error","rate_limit_error","network_error"]);function y(e,t,i,l={}){return Object.assign(new h(e,t,l),{retryable:i})}function D(e){let t=F(e)?e:{},i=typeof t.type=="string"&&M.has(t.type)?t.type:"";return y(typeof t.message=="string"?t.message:"The setup failed.",i||"api_error",t.retryable===!0,{...typeof t.code=="string"?{code:t.code}:{},...typeof t.param=="string"?{param:t.param}:{},...typeof t.statusCode=="number"?{statusCode:t.statusCode}:{}})}function I(e){return e instanceof h?y(e.message,e.type,!0,{code:e.code??"runtime_load_failed",cause:e}):y("The checkout runtime failed to load.","network_error",!0,{code:"runtime_load_failed",cause:e})}function E(e){return{...e.theme===void 0?{}:{theme:e.theme},...e.appearance===void 0?{}:{appearance:e.appearance},...e.buttonsStyles===void 0?{}:{buttonsStyles:e.buttonsStyles},...e.containerStyle===void 0?{}:{containerStyle:e.containerStyle},...e.strings===void 0?{}:{strings:e.strings}}}function O({kind:e,props:t}){let{sessionId:i,nonce:l,runtimeUrl:C,runtimeTimeoutMs:f}=t,g=d(null),p=d(null),s=d(t);s.current=t;let k=E(t),m=JSON.stringify(k),S=d(m);return P(()=>{let c=g.current;if(!c)return;let r=!0,R=n=>{a(()=>s.current.onError?.(n))},b=n=>{let o=s.current,u=n.payload;switch(n.name){case"setupReady":a(()=>o.onReady?.());return;case"setupValidation":{let T=F(u)&&typeof u.message=="string"?u.message:null;a(()=>o.onValidation?.(T));return}case"complete":a(()=>o.onComplete?.(u));return;case"decline":a(()=>o.onDecline?.(u));return;case"cancel":a(()=>o.onCancel?.(u));return;case"error":R(D(u));return;default:return}};return _({runtimeUrl:C,...f===void 0?{}:{timeoutMs:f}}).then(n=>{if(!r)return;if(typeof n.mountSetup!="function"){R(y("The checkout runtime on this page is too old to run setup.","api_error",!1,{code:"runtime_setup_unsupported"}));return}let o=E(s.current);S.current=JSON.stringify(o),p.current=n.mountSetup(c,{setup:e,sessionId:i,nonce:l,contractVersion:w,...o,onEvent:b})},n=>{r&&R(I(n))}),()=>{r=!1;let n=p.current;p.current=null,n?.unmount()}},[e,i,l,C,f]),P(()=>{let c=p.current;if(!c||S.current===m)return;S.current=m;let r=s.current;c.update({theme:r.theme,appearance:r.appearance,buttonsStyles:r.buttonsStyles,containerStyle:r.containerStyle,strings:r.strings})},[m]),v("div",{ref:g})}function H(e){return v(O,{kind:"card",props:e})}export{a,O as b,H as c};