@flopay/react 2.0.13 → 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 +13 -0
- package/dist/card-setup-entry.cjs +1 -1
- package/dist/card-setup-entry.mjs +1 -1
- package/dist/chunk-QHQ55OPE.mjs +1 -0
- package/dist/{chunk-KPRDVWZP.mjs → chunk-ZG2NKEN7.mjs} +1 -1
- package/dist/flopay-runtime-card-setup.d.ts +2 -0
- package/dist/flopay-runtime-checkout.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/payment-method-setup-entry.cjs +1 -1
- package/dist/payment-method-setup-entry.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-XRYDC367.mjs +0 -1
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
|
|
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-
|
|
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-
|
|
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
|
|
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
|
|
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
|
|
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-
|
|
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
|
|
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
|
|
40
|
-
"@flopay/shared": "2.0
|
|
39
|
+
"@flopay/js": "2.1.0",
|
|
40
|
+
"@flopay/shared": "2.1.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">=18.0.0",
|
package/dist/chunk-XRYDC367.mjs
DELETED
|
@@ -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};
|