@flopay/react 1.9.30 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -1
- package/dist/card-setup-entry.cjs +2 -2
- package/dist/card-setup-entry.mjs +1 -1
- package/dist/{chunk-CSBYK62Y.mjs → chunk-I4TPZWBS.mjs} +1 -1
- package/dist/chunk-M7R46EDF.mjs +1 -0
- package/dist/chunk-OYOJA6FI.mjs +1 -0
- package/dist/chunk-R73QOXY5.mjs +1 -0
- package/dist/chunk-U3PMJDD4.mjs +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.mjs +7 -7
- package/dist/payment-method-setup-entry.cjs +6 -0
- package/dist/payment-method-setup-entry.d.cts +16 -0
- package/dist/payment-method-setup-entry.d.ts +16 -0
- package/dist/payment-method-setup-entry.mjs +1 -0
- package/dist/payment-method-setup-paypal-MWDJVYVO.mjs +1 -0
- package/dist/payment-method-setup-stripe-NCEEB7GN.mjs +1 -0
- package/dist/payment-method-setup-surface-BQltFPXs.d.cts +45 -0
- package/dist/payment-method-setup-surface-Zf-DUxA0.d.ts +45 -0
- package/package.json +8 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var Mt=Object.create;var de=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty;var pe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ee=(e,t)=>{for(var r in t)de(e,r,{get:t[r],enumerable:!0})},Ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of At(t))!Bt.call(e,o)&&o!==r&&de(e,o,{get:()=>t[o],enumerable:!(n=xt(t,o))||n.enumerable});return e};var Lt=(e,t,r)=>(r=e!=null?Mt(Tt(e)):{},Ne(t||!e||!e.__esModule?de(r,"default",{value:e,enumerable:!0}):r,e)),Ot=e=>Ne(de({},"__esModule",{value:!0}),e);function he(e,t,r){let n=`We couldn't open ${e}. Try again or choose another payment method.`;return t?r?`${n} Open this page in your system browser, then try again.`:`${n} Allow pop-ups for this site, then try again.`:n}function dt(e){if(e instanceof Error)return e.message;if(typeof e=="object"&&e!==null){let t=e.message;return typeof t=="string"?t:void 0}return typeof e=="string"?e:void 0}function se(e){if(typeof e!="string")return;let t=e.trim();return/^[a-z0-9_.-]{1,64}$/i.test(t)?t:void 0}function pt(e){if(typeof e!="object"||e===null)return;let t=e;return se(t.code)??se(t.type)??se(t.name)}function fr(e){if(!(typeof e!="object"||e===null))return se(e.decline_code)}function Fe(e){return typeof e!="object"||e===null?!1:se(e.type)?.toLowerCase()==="card_error"||fr(e)!==void 0}function mr(e){let t=dt(e)?.toLowerCase()??"",r=pt(e)?.toLowerCase()??"";return dr.has(r)?!0:/(?:popup|pop-up).{0,40}(?:block|denied|prevent)/i.test(t)||/(?:block|denied|prevent).{0,40}(?:popup|pop-up)/i.test(t)}function yr(e){if(pt(e)?.toLowerCase()==="paypal_init_timeout")return!0;let r=dt(e)??"";return r.includes("No ack for postMessage init()")&&pr.some(n=>r.includes(n))&&r.includes("10000ms")}function Se(e,t){if(Fe(e))return{errorCode:"PROVIDER_RUNTIME_FAILED",popupBlocked:!1,providerDeclined:!0,terminalReason:"provider_declined"};let n=mr(e)||t.inAppBrowser&&!t.handoffObserved&&yr(e);return{errorCode:n?"POPUP_BLOCKED":"PROVIDER_RUNTIME_FAILED",popupBlocked:n,providerDeclined:!1,terminalReason:n?"popup_blocked":"provider_error"}}var dr,pr,Me=pe(()=>{"use strict";dr=new Set(["err_blocked_by_client","notallowederror","popup_blocked","popupblocked"]),pr=["https://www.paypal.com","https://www.sandbox.paypal.com"]});function be(e){let t=e??(typeof navigator>"u"?"":navigator.userAgent),r=n=>({inAppBrowser:n!=="none",appFamily:n,popupCapability:"unknown"});return t?/FBAN|FBAV|FB_IAB|FBIOS/i.test(t)?r("facebook"):/Instagram/i.test(t)?r("instagram"):/musical_ly|BytedanceWebview|TikTok/i.test(t)?r("tiktok"):/Twitter|Snapchat|Pinterest|LinkedInApp|Line\/|MicroMessenger|GSA\//i.test(t)?r("other_in_app"):/Android.*;\s?wv\)/.test(t)||/(iPhone|iPad|iPod).*AppleWebKit(?!.*Safari)/.test(t)?r("generic_webview"):r("none"):r("none")}function ft(e,t,r=e.popupCapability){return e.inAppBrowser||r==="blocked"||t==="prefer_redirect"?"redirect":"popup"}var xe=pe(()=>{"use strict"});var ht={};Ee(ht,{StripeSetupMethod:()=>vr});function gr(e){let t=Ae.get(e);if(t)return t;let r=(0,yt.loadStripe)(e).catch(n=>{throw Ae.delete(e),n});return Ae.set(e,r),r}function Sr(e){return e?{theme:hr[e.theme??"default"]??"stripe",...e.variables?{variables:e.variables}:{},...e.rules?{rules:e.rules}:{}}:void 0}function br(e){return Fe(e)||e.code==="setup_intent_authentication_failure"||e.code==="payment_method_provider_decline"}function Pr(e){return e==="paypal"?"PayPal":(0,Pe.getStripeMethodDisplayName)(e)}function Cr(){return typeof window>"u"?"":window.location.href}function vr(e){let{publishableKey:t,method:r,currency:n,appearance:o}=e,[a]=(0,V.useState)(()=>gr(t)),i=(0,V.useMemo)(()=>{let l=Sr(o);return{mode:"setup",currency:n.toLowerCase(),paymentMethodTypes:gt[r]?.types??[r],...l?{appearance:l}:{}}},[o,n,r]);return(0,z.jsx)(U.Elements,{stripe:a,options:i,children:(0,z.jsx)(wr,{...e})})}function wr({method:e,category:t,sessionId:r,nonce:n,billingApiUrl:o,telemetry:a,onSubmitting:i,onConfirmed:l,onDeclined:c,onFailed:p,onValidation:d}){let y=(0,U.useStripe)(),h=(0,U.useElements)(),[A,w]=(0,V.useState)(!1),F=(0,V.useRef)(!1),[m]=(0,V.useState)(()=>be()),[T,D]=(0,V.useState)(!1),R=(0,V.useCallback)((f,v)=>{if(Se(f,{inAppBrowser:m.inAppBrowser,handoffObserved:!1}).popupBlocked){D(!0),p(new Error(he(Pr(e),!0,m.inAppBrowser)),{code:"popup_blocked",retryable:!0});return}p(v.message===void 0?f:new Error(v.message),{code:v.code,retryable:!0})},[m.inAppBrowser,e,p]),S=(0,V.useCallback)(async()=>{if(!(!y||!h||F.current)){F.current=!0,w(!0);try{let f=await h.submit();if(f.error){d(f.error.message??null);return}i();let v=await new mt.PaymentAPI(o,{telemetry:a}).createSessionIntent(r,n,{provider:"stripe",paymentMethodCategory:t,paymentMethodType:e,paymentMethodId:null,intentKind:"setup"});if(v.provider!=="stripe"||v.intentKind!=="setup")throw new Pe.FloPayError("The billing API returned a non-setup intent.","api_error",{code:"InvalidSessionIntentResponse"});let P=await y.confirmSetup({elements:h,clientSecret:v.clientSecret,confirmParams:{return_url:Cr()},redirect:"if_required"});if(P.error){br(P.error)?c({...P.error.decline_code||P.error.code?{reason:P.error.decline_code??P.error.code}:{},...P.error.message?{message:P.error.message}:{}}):R(P.error,{code:"payment_method_setup_provider_failed",message:P.error.message??"The payment method could not be saved."});return}l()}catch(f){R(f,{code:"payment_method_setup_failed"})}finally{F.current=!1,w(!1)}}},[o,t,h,e,n,l,c,i,d,R,r,y,a]),L=gt[e]?.wallet,O=L==="paypal"&&ft(m,"auto",T?"blocked":m.popupCapability)==="redirect";if(t==="wallet"&&L&&!O){let f={applePay:"never",googlePay:"never",link:"never",paypal:"never",amazonPay:"never"};return f[L]="auto",(0,z.jsx)(U.ExpressCheckoutElement,{options:{paymentMethods:f},onConfirm:()=>{S()}})}return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U.PaymentElement,{onChange:f=>{f.complete&&d(null)}}),(0,z.jsx)("button",{type:"button","data-flopay-payment-method-save":e,disabled:!y||!h||A,onClick:()=>{S()},children:"Save payment method"})]})}var mt,Pe,U,yt,V,z,gt,Ae,hr,St=pe(()=>{"use strict";mt=require("@flopay/js/card-setup"),Pe=require("@flopay/shared"),U=require("@stripe/react-stripe-js"),yt=require("@stripe/stripe-js"),V=require("react");Me();xe();z=require("react/jsx-runtime"),gt={apple_pay:{types:["card"],wallet:"applePay"},google_pay:{types:["card"],wallet:"googlePay"},link:{types:["link"],wallet:"link"},paypal:{types:["paypal"],wallet:"paypal"},amazon_pay:{types:["amazon_pay"],wallet:"amazonPay"}},Ae=new Map;hr={night:"night",flat:"flat"}});var Ct={};Ee(Ct,{PayPalSetupMethod:()=>Er});function Er({clientId:e,environment:t,currency:r,sessionId:n,nonce:o,billingApiUrl:a,telemetry:i,customer:{userId:l,email:c},onSubmitting:p,onConfirmed:d,onFailed:y,onAbandoned:h}){let A=(0,K.useRef)(null),w=(0,K.useRef)({onSubmitting:p,onConfirmed:d,onFailed:y,onAbandoned:h});w.current={onSubmitting:p,onConfirmed:d,onFailed:y,onAbandoned:h};let[F]=(0,K.useState)(()=>be().inAppBrowser);return(0,K.useEffect)(()=>{let m=!0,T,D=new bt.PaymentAPI(a,{telemetry:i}),R={userId:l,email:c};return(async()=>{try{let S=await(0,Pt.loadScript)({clientId:e,currency:r.toUpperCase(),components:"buttons",...t==="sandbox"||t==="production"?{environment:t}:{}}),L=A.current;if(!m||!L)return;if(!S?.Buttons)throw new H.FloPayError("PayPal could not be loaded.","api_error",{code:"paypal_unavailable"});let O=S.Buttons({createVaultSetupToken:async()=>{w.current.onSubmitting();let f=await D.createSessionIntent(n,o,{provider:"paypal",paymentMethodCategory:"wallet",paymentMethodType:H.PAYPAL_VAULTED_PAYMENT_METHOD_TYPE,paymentMethodId:null,intentKind:"setup"});if(f.provider!=="paypal"||f.providerObjectType!=="setup_token")throw new H.FloPayError("The billing API did not return a PayPal setup token.","api_error",{code:"InvalidSessionIntentResponse"});return f.providerObjectId},onApprove:async f=>{let v=f.vaultSetupToken;if(!v)throw new H.FloPayError("PayPal approved without a setup token.","api_error",{code:"paypal_setup_token_missing"});let P=await D.processPayment(R.userId,{sessionId:n,nonce:o,paymentMethodCategory:"paypal",tokenizedData:{id:v,type:"paypal_setup_token",isPaypal:!0,gateway:"paypal",paymentMethodType:H.PAYPAL_VAULTED_PAYMENT_METHOD_TYPE},accountData:R});if(!P.ok)throw new H.FloPayError("PayPal could not be saved.","api_error",{code:"paypal_setup_failed",statusCode:P.status});m&&w.current.onConfirmed()},onCancel:()=>{m&&w.current.onAbandoned()},onError:f=>{if(!m)return;let{popupBlocked:v}=Se(f,{inAppBrowser:F,handoffObserved:!1});w.current.onFailed(v?new Error(he("PayPal",!0,F)):f,{code:v?"popup_blocked":"paypal_setup_failed",retryable:!0})}});T=()=>O.close(),await O.render(L)}catch(S){if(!m)return;w.current.onFailed(S,{code:"paypal_unavailable",retryable:!0})}})(),()=>{m=!1,T?.().catch(()=>{}),D.destroy()}},[a,e,r,c,t,F,o,n,i,l]),(0,vt.jsx)("div",{ref:A,"data-flopay-paypal-setup":""})}var bt,H,Pt,K,vt,wt=pe(()=>{"use strict";bt=require("@flopay/js/card-setup"),H=require("@flopay/shared"),Pt=require("@paypal/paypal-js"),K=require("react");Me();xe();vt=require("react/jsx-runtime")});var Rr={};Ee(Rr,{FloPayCardSetupError:()=>oe,FloPayPaymentMethodSetup:()=>Et});module.exports=Ot(Rr);var rt=require("@flopay/js/card-setup"),Q=require("@flopay/shared"),ye=require("react");function We(e,t){if(!e)return t;let r=t??{},n=Object.keys(r),o=n.some(i=>i.startsWith("background")),a={};for(let[i,l]of Object.entries(e))i in r||o&&i.startsWith("background")||(a[i]=l);for(let i of n)a[i]=r[i];return a}var It=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridArea","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","fontWeight","lineClamp","lineHeight","opacity","order","orphans","scale","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"]);function Vt(e){let t=e.replace(/^(Webkit|Moz|ms)(?=[A-Z])/,"");return It.has(t.charAt(0).toLowerCase()+t.slice(1))}function Dt(e,t){return typeof t=="number"&&t!==0&&!Vt(e)?`${t}px`:String(t).trim()}function ze(e,t){if(e.style.cssText="",!!t){for(let[r,n]of Object.entries(t))if(!(n==null||n==="")){if(r.startsWith("--")){e.style.setProperty(r,String(n));continue}e.style[r]=Dt(r,n)}}}var Ue={light:{success:"#166534",error:"#991B1B"},dark:{success:"#4ADE80",error:"#FCA5A5"}};function Ge(e){let t=e.appearance.variables??{},r=e.buttonsLayout.cardFormContainer??{},n=e.appearance.theme==="night",o=n?Ue.dark:Ue.light,a=t.colorText??(n?"#F1F5F9":"#262833"),i=e.appearance.rules?.[".Label"];return{panel:{...r.background===void 0?{}:{background:r.background},...r.backgroundColor===void 0?{}:{backgroundColor:r.backgroundColor},...r.border===void 0?{}:{border:r.border},...r.borderRadius===void 0?{}:{borderRadius:r.borderRadius},...r.boxShadow===void 0?{}:{boxShadow:r.boxShadow},color:a,...t.fontFamily?{fontFamily:t.fontFamily}:{}},spinnerTrackColor:e.buttonsLayout.cardInputBorder??(n?"#374151":"#e5e7eb"),spinnerAccentColor:t.colorPrimary??"#4A49FF",labelColors:{processing:a,success:o.success,error:o.error},noteColor:i?.color??a}}function G(e){if(!e)return;let t=r=>{console.error("[FloPay] Merchant callback failed; checkout continued.",r)};try{Promise.resolve(e()).catch(t)}catch(r){t(r)}}var b=require("react/jsx-runtime");var Nt={panel:{background:"white"},spinnerTrackColor:"#e5e7eb",spinnerAccentColor:"#4A49FF",labelColors:{processing:"#374151",success:"#16a34a",error:"#dc2626"},noteColor:"#6b7280"};function He({status:e,errorMessage:t,authorized:r=!1,processingLabel:n="PROCESSING...",successLabel:o,errorLabel:a="PAYMENT FAILED",successNote:i="You will be automatically redirected, do not close or navigate away from this window.",theme:l=Nt}){let c={fontSize:13,color:l.noteColor,fontWeight:400,maxWidth:260,lineHeight:1.4,margin:0};return(0,b.jsx)("div",{"data-testid":"flopay-processing-overlay","data-status":e,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(2px)"},children:(0,b.jsxs)("div",{"data-testid":"flopay-processing-overlay-panel",style:{borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.18)",...l.panel,padding:"2rem 2.5rem",textAlign:"center",minWidth:240,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[(0,b.jsxs)("div",{style:{width:48,height:48,position:"relative"},children:[e==="processing"&&(0,b.jsxs)("svg",{"aria-hidden":"true",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{animation:"flopay-spin 0.8s linear infinite"},children:[(0,b.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:l.spinnerTrackColor,strokeWidth:"3"}),(0,b.jsx)("path",{d:"M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z",fill:l.spinnerAccentColor})]}),e==="success"&&(0,b.jsx)("div",{style:{animation:"flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)"},children:(0,b.jsxs)("svg",{"aria-hidden":"true",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"#22c55e"}),(0,b.jsx)("path",{d:"M7 12.5l3 3 7-7",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:20,strokeDashoffset:20,animation:"flopay-draw 0.4s 0.15s ease forwards"}})]})}),e==="error"&&(0,b.jsx)("div",{style:{animation:"flopay-shake 0.4s ease"},children:(0,b.jsxs)("svg",{"aria-hidden":"true",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"#ef4444"}),(0,b.jsx)("path",{d:"M8 8l8 8M16 8l-8 8",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",style:{strokeDasharray:12,strokeDashoffset:12,animation:"flopay-draw 0.3s 0.1s ease forwards"}})]})})]}),(0,b.jsxs)("span",{style:{fontSize:14,fontWeight:600,letterSpacing:"0.05em",color:l.labelColors[e]},children:[e==="processing"&&n,e==="success"&&(o??(r?"PAYMENT AUTHORISED":"PAYMENT SUCCESSFUL")),e==="error"&&a]}),e==="success"&&i!==null&&(0,b.jsx)("p",{style:c,children:i}),e==="error"&&t&&(0,b.jsx)("p",{style:c,children:t}),(0,b.jsx)("style",{children:`
|
|
2
|
+
@keyframes flopay-spin { to { transform: rotate(360deg); } }
|
|
3
|
+
@keyframes flopay-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
|
|
4
|
+
@keyframes flopay-draw { to { stroke-dashoffset: 0; } }
|
|
5
|
+
@keyframes flopay-shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-4px); } 40%,80% { transform: translateX(4px); } }
|
|
6
|
+
`})]})})}var B=require("react");var fe=require("react"),Ye=typeof window>"u"?fe.useEffect:fe.useLayoutEffect;var je=require("react/jsx-runtime"),ke=new WeakSet;function $e({capture:e,html:t,messageToken:r,expectedOrigin:n,theme:o,submitLabel:a,containerStyle:i,onReady:l,onError:c,onValidation:p}){let d=(0,B.useRef)(null),y=(0,B.useRef)(l),h=(0,B.useRef)(c),A=(0,B.useRef)(p);y.current=l,h.current=c,A.current=p;let w=(0,B.useRef)(o);w.current=o;let F=(0,B.useRef)(null),m=a??void 0,T=(0,B.useRef)(m);T.current=m;let D=(0,B.useRef)(void 0);return(0,B.useEffect)(()=>{let R=d.current;if(!R)return;let S=!0,L=!1,O=()=>{!S||L||(L=!0,y.current?.())},f=e.on("ready",()=>{O()}),v=e.on("error",_=>{h.current?.(_.message??"There was a problem loading the secure card form.")}),P=e.on("validation",_=>{A.current?.(_.message??null)}),Y=T.current??(ke.has(e)?null:void 0),x={html:t,...r?{messageToken:r}:{},...n?{expectedOrigin:n}:{},...w.current?{theme:w.current}:{},...Y===void 0?{}:{submitLabel:Y}};return F.current=w.current??null,D.current=T.current,T.current!==void 0&&ke.add(e),e.mount(R,x).then(()=>{O()}).catch(_=>{S&&h.current?.(_ instanceof Error?_.message:"Failed to load the secure card form.")}),()=>{S=!1,f(),v(),P(),e.unmount()}},[e,t,r,n]),Ye(()=>{let R=d.current;R&&ze(R,i)},[i]),(0,B.useEffect)(()=>{o!==void 0&&(o===null&&F.current===null||(F.current=o,e.applyTheme?.(o)))},[e,o]),(0,B.useEffect)(()=>{m!==D.current&&(D.current=m,m!==void 0&&ke.add(e),e.setSubmitLabel?.(m??null))},[e,m]),(0,je.jsx)("div",{ref:d,"data-testid":"flopay-vault-card-fields"})}var Xe=/^#([0-9a-f]{6})$/i,Wt=/^#([0-9a-f]{3})$/i,qe=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,Ze=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+|1\.0+)\s*\)$/i,zt=/^linear-gradient\(\s*(-?\d+(?:\.\d+)?)deg\s*,\s*(.+)\)$/i,Ut=/^(-?\d+(?:\.\d+)?)(?:px)?$/,Gt=/^(-?\d+(?:\.\d+)?)em$/,Ht=/^blur\(\s*(\d+(?:\.\d+)?)(?:px)?\s*\)$/i,Yt=/^[a-z][a-z0-9 -]{0,31}$/i,$t=new Set(["none","uppercase","lowercase","capitalize"]);function Je(e){if(typeof e!="string")return null;let t=e.trim(),r=Xe.exec(t);if(r){let d=Number.parseInt(r[1],16);return{r:d>>16&255,g:d>>8&255,b:d&255,a:null}}let n=Wt.exec(t);if(n){let[d,y,h]=n[1].split("").map(A=>Number.parseInt(A+A,16));return{r:d,g:y,b:h,a:null}}let o=qe.exec(t),a=o?null:Ze.exec(t),i=o??a;if(!i)return null;let l=Number(i[1]),c=Number(i[2]),p=Number(i[3]);return l>255||c>255||p>255?null:{r:l,g:c,b:p,a:a?Number(a[4]):null}}function Qe({r:e,g:t,b:r,a:n}){return n===null?`#${(1<<24|e<<16|t<<8|r).toString(16).slice(1)}`:`rgba(${e},${t},${r},${n})`}function re(e){if(typeof e!="string")return;let t=e.trim();if(Xe.test(t)||qe.test(t))return t;let r=Ze.exec(t);if(r&&/^\d/.test(r[4]))return t;let n=Je(t);return n?Qe(n):void 0}function me(e,t=.12){let r=Je(e);if(!r)return e;let n=Math.max(0,Math.min(1,1-t));return Qe({r:Math.round(r.r*n),g:Math.round(r.g*n),b:Math.round(r.b*n),a:r.a})}function ne(e,t){let r=[],n=0,o="";for(let a of e){if(a==="("&&(n+=1),a===")"&&(n-=1),a===t&&n===0){o.trim()&&r.push(o.trim()),o="";continue}o+=a}return o.trim()&&r.push(o.trim()),r}function j(e,t,r){if(typeof e!="number"&&typeof e!="string")return;let n=Ut.exec(String(e).trim());if(!n)return;let o=Number(n[1]);return Number.isFinite(o)&&o>=t&&o<=r?o:void 0}function jt(e,t,r){if(typeof e!="string")return;let n=Gt.exec(e.trim());if(!n)return;let o=Number(n[1]);return Number.isFinite(o)&&o>=t&&o<=r?o:void 0}function Kt(e){let t=ne(e,",");if(t.length<2||t.length>5)return;let r=[];for(let[n,o]of t.entries()){let a=ne(o," "),i=re(a[0]);if(!i)return;let l=n/(t.length-1)*100,c=a[1]===void 0?l:Number(/^(\d+(?:\.\d+)?)%$/.exec(a[1])?.[1]),p=r[r.length-1]?.position??-1;if(!Number.isFinite(c)||c<0||c>100||c<p)return;r.push({color:i,position:c})}return{type:"linearGradient",angle:0,stops:r}}function Xt(e){if(typeof e!="string")return;let t=e.trim(),r=re(t);if(r)return{type:"solid",color:r};let n=zt.exec(t);if(!n)return;let o=Number(n[1]);if(!Number.isFinite(o)||o<0||o>360)return;let a=Kt(n[2]);return a&&a.type==="linearGradient"?{...a,angle:o}:void 0}function qt(e){return e.type==="solid"?{type:"solid",color:me(e.color)}:{...e,stops:e.stops.map(t=>({...t,color:me(t.color)}))}}function Zt(e){let t=!1,r,n=[];for(let c of ne(e," ")){if(c.toLowerCase()==="inset"){t=!0;continue}let p=re(c);if(p){r=p;continue}let d=j(c,-128,128);if(d===void 0)return;n.push(d)}if(!r||n.length<2||n.length>4)return;let[o,a,i=0,l=0]=n;if(!(Math.abs(o)>64||Math.abs(a)>64||i>128||Math.abs(l)>32))return{color:r,inset:t,offsetX:o,offsetY:a,blur:i,spread:l}}function Jt(e){if(typeof e!="string")return;let t=e.trim();if(t.toLowerCase()==="none")return[];let r=ne(t,",").map(Zt);if(!(r.length===0||r.length>4))return r.every(n=>n!==void 0)?r:void 0}function Ke(e){if(typeof e!="string")return;let t=ne(e,",").map(r=>r.replace(/^['"]|['"]$/g,"").trim()).filter(r=>Yt.test(r)).slice(0,4);return t.length>0?t:void 0}function Qt(e){let t=typeof e=="string"?e.trim().split(/\s+/):[e],r=j(t[0],0,64),n=j(t[1]??t[0],0,64);if(!(r===void 0||n===void 0))return{paddingBlock:r,paddingInline:n}}function er(e){if(e==="bold")return 700;if(e==="normal")return 400;let t=Number(e);return Number.isInteger(t)&&t>=100&&t<=900?t:void 0}function et({appearance:e,buttonsStyles:t,fontFamily:r}){let n=t.submitButton;if(!n)return;let o=e?.variables,a=Xt(n.background??n.backgroundColor),i=re(o?.colorPrimaryHover),l=i?{type:"solid",color:i}:a&&qt(a),c={fontFamilies:Ke(n.fontFamily)??Ke(r),fontSize:j(n.fontSize??t.submitButtonFontSize,10,32)??16,fontWeight:er(n.fontWeight)??600,letterSpacing:jt(n.letterSpacing,-.1,.5)??.01,lineHeight:j(n.lineHeight,.8,2)??1,textTransform:$t.has(String(n.textTransform))?n.textTransform:"uppercase"},p=Qt(n.padding),d=Jt(n.boxShadow),y=j(n.borderRadius,0,9999),h=typeof n.backdropFilter=="string"?j(Ht.exec(n.backdropFilter.trim())?.[1],0,40):void 0;return{foregroundColor:re(n.color)??"#FFFFFF",...a?{background:a,disabledBackground:a}:{},...l?{hoverBackground:l}:{},typography:c,...p?{spacing:p}:{},...d?{shadow:d}:{},...y===void 0?{}:{borderRadius:y},disabledOpacity:e?.theme==="night"?.8:.6,...h===void 0?{}:{backdropBlur:h}}}function tr(e,t=.12){let r=e.trim(),n=/^[0-9a-fA-F]{6}$/.test(r)?`#${r}`:r;return/^#[0-9a-fA-F]{6}$/.test(n)?me(n,t):e}function rr(e){if(typeof e=="number"||typeof e=="string")return e}function tt({appearance:e,buttonsStyles:t,layout:r="default"}){let n=e?.variables,o=y=>typeof y=="string"&&y?y:void 0,a=t.submitButton,i=o(n?.colorPrimary)??o(a?.backgroundColor)??"#4A49FF",l=r==="buttons",c=t.nameInput,p=o(c?.fontFamily)??o(n?.fontFamily)??"Poppins, sans-serif",d=et({appearance:e,buttonsStyles:t,fontFamily:p});return{primaryColor:i,primaryHoverColor:o(n?.colorPrimaryHover)??tr(i,.12),inputBackgroundColor:o(t.cardInputBackground)??o(n?.colorBackground)??"#ffffff",textColor:o(t.cardInputColor)??o(c?.color)??o(n?.colorText)??"#262833",borderColor:o(t.cardInputBorder)??(l?"#e5e7eb":"#A4A4FF"),placeholderColor:o(t.cardInputPlaceholderColor)??"#9ca3af",errorColor:o(n?.colorDanger)??"#dc2626",successColor:"#16a34a",fontFamily:p,fontSize:o(t.cardInputFontSize)??o(n?.fontSizeBase)??"16px",fontWeight:String(rr(c?.fontWeight)??400),borderRadius:o(n?.borderRadius)??"8px",...d?{submitButton:d}:{}}}var Re=require("react/jsx-runtime"),oe=class extends Q.FloPayError{constructor(t,r,n){super(t,r,n),this.name="FloPayCardSetupError",this.retryable=n.retryable}};function ae(e,t={}){let r=e instanceof Q.FloPayError?e:void 0,n=r?.statusCode,o=t.retryable??(r?.type==="network_error"||r?.type==="rate_limit_error"||typeof n=="number"&&n>=500||r?.code==="vault_capture_timeout"||!r);return new oe(r?.message??(e instanceof Error?e.message:"Failed to load the secure card form."),r?.type??"api_error",{code:t.code??r?.code??"card_setup_load_failed",retryable:o,...r?.param?{param:r.param}:{},...n===void 0?{}:{statusCode:n}})}var Te=require("react");var ie=require("@flopay/js/card-setup"),k=require("@flopay/shared"),s=Lt(require("react"),1);var nr=new Set(["apple_pay","google_pay","link","paypal","amazon_pay"]);function nt(e){let t=e.data.stripe,r=Array.from(new Set(t?.enabledPaymentMethods??[])),n=e.data.paypal,o=n?.publishableKey?{clientId:n.publishableKey,...n.environment?{environment:String(n.environment)}:{}}:null,a=r.filter(i=>i!=="card"&&!(o&&i==="paypal"));return{card:r.includes("card"),stripe:t?.publishableKey&&a.length>0?{publishableKey:t.publishableKey,methods:a}:null,paypal:o}}function ot(e){return e.card||e.stripe!==null||e.paypal!==null}function at(e){return nr.has(e)?"wallet":"apm"}var or=["setup_intent","setup_intent_client_secret","redirect_status"];function it(){if(typeof window>"u")return null;let e=new URLSearchParams(window.location.search);return!e.has("setup_intent")||!e.has("redirect_status")?null:{failed:e.get("redirect_status")==="failed"}}function st(){if(typeof window>"u")return;let e=new URL(window.location.href),t=!1;for(let r of or)e.searchParams.has(r)&&(e.searchParams.delete(r),t=!0);t&&window.history.replaceState(window.history.state,"",e.toString())}function lt(e){return e==="card"?{processingLabel:"SAVING CARD...",successLabel:"CARD SAVED",errorLabel:"CARD NOT SAVED"}:{processingLabel:"SAVING PAYMENT METHOD...",successLabel:"PAYMENT METHOD SAVED",errorLabel:"PAYMENT METHOD NOT SAVED"}}var C=require("react/jsx-runtime"),ir=15,sr=2e3;function lr(e){return{userId:e.customer?.id??"",email:e.customer?.email??""}}function _e(e){return new Promise(t=>setTimeout(t,e))}async function ur(e,t,r){if(!t.trim())throw new k.FloPayError("FloPayPaymentMethodSetup requires a sessionId.","validation_error",{code:"MissingCheckoutSessionId",param:"sessionId"});if(!r.trim())throw new k.FloPayError("FloPayPaymentMethodSetup requires a session nonce.","validation_error",{code:"MissingCheckoutSessionToken",param:"nonce"});let n=await e.getUnifiedCheckoutSession(t,r),o=n.data.session;if(!o||!(0,k.isCardSetupCheckoutSession)(o))throw new k.FloPayError("FloPayPaymentMethodSetup only accepts a zero-amount, productless setup session.","validation_error",{code:"InvalidPaymentMethodSetupSession",param:"sessionId"});let a=nt(n);if(!ot(a))throw new k.FloPayError("FloPay: this setup session advertises no payment method.","validation_error",{code:"NoAdvertisedPaymentMethods",param:"sessionId"});return{session:o,advertisement:a}}async function cr(e,t,r,n){let o=t.vault??null;if(o?.html?.trim()||(o=await e.getVaultCapture(r,n)),!o.html?.trim())throw new k.FloPayError("FloPay: this setup session has no vault card capability. Upgrade the billing backend integration.","api_error",{code:"UnsupportedBackendVaultCapability"});return o}var ge=class extends s.default.Component{constructor(){super(...arguments);this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(r){this.props.onFailed(r,{code:"payment_method_setup_load_failed",retryable:!1})}render(){return this.state.failed?null:this.props.children}};function ct({branches:{StripeSetupMethod:e,PayPalSetupMethod:t},sessionId:r,nonce:n,billingApiUrl:o,telemetry:a,theme:i="modern-light",containerStyle:l,loading:c=null,onReady:p,onComplete:d,onDecline:y,onCancel:h,onValidation:A,onError:w}){let[F]=(0,s.useState)(it),[m,T]=(0,s.useState)(null),[D,R]=(0,s.useState)(!1),[S,L]=(0,s.useState)(null),[O,f]=(0,s.useState)(null),[v,P]=(0,s.useState)(null),[Y,x]=(0,s.useState)(null),_=(0,s.useRef)(!1),Ce=(0,s.useRef)(!1),ee=(0,s.useRef)(!1),ve=(0,s.useRef)(!1),we=(0,s.useRef)(0),le=(0,s.useRef)(0),X=(0,s.useRef)(!1),N=(0,s.useMemo)(()=>typeof i=="object"?void 0:(0,k.resolveTheme)(i),[i]),Rt=(0,s.useMemo)(()=>typeof i=="object"?i:N?tt({appearance:N.appearance,buttonsStyles:N.buttonsLayout,layout:"default"}):null,[N,i]),_t=(0,s.useMemo)(()=>We(N?.buttonsLayout.cardFormContainer,l),[N,l]),Be=(0,s.useMemo)(()=>N?Ge(N):void 0,[N]),M=(0,s.useRef)({sessionId:r,nonce:n,billingApiUrl:o,telemetry:a,onReady:p,onComplete:d,onDecline:y,onCancel:h,onValidation:A,onError:w});M.current={sessionId:r,nonce:n,billingApiUrl:o,telemetry:a,onReady:p,onComplete:d,onDecline:y,onCancel:h,onValidation:A,onError:w},(0,s.useEffect)(()=>{X.current=!0;let u=we.current+1;return we.current=u,()=>{X.current=!1,le.current+=1,queueMicrotask(()=>{we.current===u&&(ee.current||ve.current||(ve.current=!0,G(()=>{M.current.onCancel?.({status:"cancelled",sessionId:r})})))})}},[r]);let q=(0,s.useCallback)((u,g)=>{ee.current=!0,_.current=!1,x({status:"success",wording:u,message:null}),(async()=>(await _e(600),!Ce.current&&(Ce.current=!0,G(()=>{M.current.onComplete?.({status:"succeeded",sessionId:M.current.sessionId,...g?{paymentMethod:g}:{}})}),X.current&&x(null))))()},[]),Z=(0,s.useCallback)((u,g)=>{ee.current=!0,_.current=!1,x({status:"error",wording:u,message:g.message??null}),G(()=>{M.current.onDecline?.({status:"declined",sessionId:M.current.sessionId,...g.reason?{reason:g.reason}:{},...g.message?{message:g.message}:{}})}),(async()=>(await _e(400),X.current&&x(null)))()},[]),te=(0,s.useCallback)((u,g)=>{_.current?(_.current=!1,x({status:"error",wording:u,message:g.message}),setTimeout(()=>{X.current&&x(null)},400)):x(null),G(()=>M.current.onError?.(g))},[]),ue=(0,s.useCallback)(async u=>{let g=le.current+1;le.current=g;let I=()=>!X.current||g!==le.current;_.current=!0,x({status:"processing",wording:"payment_method",message:null});let W=new ie.PaymentAPI((0,k.resolveBillingApiUrl)(M.current.billingApiUrl),{telemetry:M.current.telemetry});try{for(let E=0;E<ir;E+=1){if((E>0||u.waitFirst)&&await _e(sr),I())return;let J=await W.getUnifiedCheckoutSession(M.current.sessionId,M.current.nonce);if(I())return;let De=J.data.session?.status;if(De==="complete"){R(!0),q("payment_method");return}if(De==="expired")throw new k.FloPayError("This setup session expired before the payment method was saved.","validation_error",{code:"payment_method_setup_expired"})}throw new k.FloPayError("The payment method could not be confirmed yet. Please try again.","api_error",{code:"payment_method_setup_unverified"})}catch(E){if(I())return;let J=E instanceof k.FloPayError&&E.code==="payment_method_setup_unverified";te("payment_method",ae(E,J?{retryable:!0}:{}))}finally{W.destroy()}},[te,q]);(0,s.useEffect)(()=>{let u=!0,g=new ie.PaymentAPI((0,k.resolveBillingApiUrl)(o),{telemetry:a});return T(null),R(!1),L(null),f(null),P(null),ee.current=!1,ve.current=!1,Ce.current=!1,(async()=>{try{let{session:I,advertisement:W}=await ur(g,r,n);if(!u)return;let E={advertisement:W,currency:I.currency,customer:lr(I)};if(F){if(st(),I.status==="complete"){R(!0),T(E),q("payment_method");return}F.failed?Z("payment_method",{reason:"redirect_failed"}):ue({waitFirst:!0})}let J=W.card?await cr(g,I,r,n):null;if(!u)return;T(E),J&&(f(J),L(new ie.PciVaultCardCapture({sessionId:r,operation:"card_setup",telemetry:a})))}catch(I){if(!u)return;let W=ae(I);ee.current=!0,P(W),G(()=>M.current.onError?.(W))}})(),()=>{u=!1,g.destroy()}},[o,n,F,Z,q,r,a,ue]),(0,s.useEffect)(()=>{if(!S)return;_.current=!1;let u=S.on("submitting",()=>{_.current=!0,x({status:"processing",wording:"card",message:null})}),g=S.on("complete",E=>{q("card",E.paymentMethod)}),I=S.on("decline",E=>{Z("card",{...E.declineReason?{reason:E.declineReason}:{},...E.message?{message:E.message}:{}})}),W=S.on("challenge_dismissed",()=>{x(null)});return()=>{u(),g(),I(),W()}},[S,Z,q]);let ce=(0,s.useMemo)(()=>({onSubmitting:()=>{_.current=!0,x({status:"processing",wording:"payment_method",message:null})},onConfirmed:()=>{ue({waitFirst:!1})},onDeclined:u=>Z("payment_method",u),onFailed:(u,g)=>{te("payment_method",ae(u,g))},onValidation:u=>{G(()=>M.current.onValidation?.(u))},onAbandoned:()=>{_.current=!1,x(null)}}),[Z,te,ue]),Le=Y?(0,C.jsx)(He,{status:Y.status,errorMessage:Y.message,...lt(Y.wording),successNote:null,...Be?{theme:Be}:{}}):null;if(v)return(0,C.jsx)("div",{role:"alert",children:v.message});if(!m||D)return(0,C.jsxs)(C.Fragment,{children:[Le,m?null:c]});let{advertisement:$,currency:Oe,customer:Ft}=m,Ie=(0,k.resolveBillingApiUrl)(o),Ve=a===void 0?{}:{telemetry:a};return(0,C.jsxs)(C.Fragment,{children:[Le,$.card&&S&&O?.html?(0,C.jsx)("div",{"data-flopay-payment-method":"card",children:(0,C.jsx)($e,{capture:S,html:O.html,messageToken:O.messageToken,expectedOrigin:O.expectedOrigin,theme:Rt,containerStyle:_t,onReady:()=>{G(()=>M.current.onReady?.())},onValidation:u=>{G(()=>M.current.onValidation?.(u))},onError:u=>{u&&te("card",ae(new Error(u),{code:"card_setup_widget_failed",retryable:!0}))}})}):null,$.stripe?.methods.map(u=>(0,C.jsx)("div",{"data-flopay-payment-method":u,children:(0,C.jsx)(ge,{onFailed:ce.onFailed,children:(0,C.jsx)(s.Suspense,{fallback:null,children:(0,C.jsx)(e,{method:u,category:at(u),publishableKey:$.stripe?.publishableKey??"",currency:Oe,sessionId:r,nonce:n,billingApiUrl:Ie,...Ve,...N?{appearance:N.appearance}:{},...ce})})})},u)),$.paypal?(0,C.jsx)("div",{"data-flopay-payment-method":"paypal",children:(0,C.jsx)(ge,{onFailed:ce.onFailed,children:(0,C.jsx)(s.Suspense,{fallback:null,children:(0,C.jsx)(t,{clientId:$.paypal.clientId,...$.paypal.environment?{environment:$.paypal.environment}:{},currency:Oe,sessionId:r,nonce:n,billingApiUrl:Ie,customer:Ft,...Ve,...ce})})})}):null]})}var kt=require("react/jsx-runtime"),kr={StripeSetupMethod:(0,Te.lazy)(()=>Promise.resolve().then(()=>(St(),ht)).then(e=>({default:e.StripeSetupMethod}))),PayPalSetupMethod:(0,Te.lazy)(()=>Promise.resolve().then(()=>(wt(),Ct)).then(e=>({default:e.PayPalSetupMethod})))};function Et(e){return(0,kt.jsx)(ct,{...e,branches:kr})}0&&(module.exports={FloPayCardSetupError,FloPayPaymentMethodSetup});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { FloPayCardSetupError } from './card-setup-entry.cjs';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { F as FloPayPaymentMethodSetupProps } from './payment-method-setup-surface-BQltFPXs.cjs';
|
|
4
|
+
export { a as FloPayPaymentMethodSetupCancelEvent, b as FloPayPaymentMethodSetupCompleteEvent, c as FloPayPaymentMethodSetupDeclineEvent } from './payment-method-setup-surface-BQltFPXs.cjs';
|
|
5
|
+
import '@flopay/shared';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Renders every payment method a setup session advertises — the hosted card
|
|
9
|
+
* widget, Stripe wallets/APMs in setup mode, and the PayPal vault flow — and
|
|
10
|
+
* saves the buyer's choice without a purchase. The advertisement is the single
|
|
11
|
+
* source of truth. A card-only session behaves exactly like `FloPayCardSetup`
|
|
12
|
+
* and never requests Stripe.js.
|
|
13
|
+
*/
|
|
14
|
+
declare function FloPayPaymentMethodSetup(props: FloPayPaymentMethodSetupProps): React.ReactElement;
|
|
15
|
+
|
|
16
|
+
export { FloPayPaymentMethodSetup, FloPayPaymentMethodSetupProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { FloPayCardSetupError } from './card-setup-entry.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { F as FloPayPaymentMethodSetupProps } from './payment-method-setup-surface-Zf-DUxA0.js';
|
|
4
|
+
export { a as FloPayPaymentMethodSetupCancelEvent, b as FloPayPaymentMethodSetupCompleteEvent, c as FloPayPaymentMethodSetupDeclineEvent } from './payment-method-setup-surface-Zf-DUxA0.js';
|
|
5
|
+
import '@flopay/shared';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Renders every payment method a setup session advertises — the hosted card
|
|
9
|
+
* widget, Stripe wallets/APMs in setup mode, and the PayPal vault flow — and
|
|
10
|
+
* saves the buyer's choice without a purchase. The advertisement is the single
|
|
11
|
+
* source of truth. A card-only session behaves exactly like `FloPayCardSetup`
|
|
12
|
+
* and never requests Stripe.js.
|
|
13
|
+
*/
|
|
14
|
+
declare function FloPayPaymentMethodSetup(props: FloPayPaymentMethodSetupProps): React.ReactElement;
|
|
15
|
+
|
|
16
|
+
export { FloPayPaymentMethodSetup, FloPayPaymentMethodSetupProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-R73QOXY5.mjs";import{j as a}from"./chunk-I4TPZWBS.mjs";import{lazy as o}from"react";import{jsx as P}from"react/jsx-runtime";var p={StripeSetupMethod:o(()=>import("./payment-method-setup-stripe-NCEEB7GN.mjs").then(e=>({default:e.StripeSetupMethod}))),PayPalSetupMethod:o(()=>import("./payment-method-setup-paypal-MWDJVYVO.mjs").then(e=>({default:e.PayPalSetupMethod})))};function y(e){return P(t,{...e,branches:p})}export{a as FloPayCardSetupError,y as FloPayPaymentMethodSetup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-U3PMJDD4.mjs";import"./chunk-M7R46EDF.mjs";export{a as PayPalSetupMethod};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-OYOJA6FI.mjs";import"./chunk-M7R46EDF.mjs";export{a as StripeSetupMethod};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ThemeId, VaultCardThemeColors } from '@flopay/shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FloPayCardSetupCompleteEvent, FloPayCardSetupDeclineEvent, FloPayCardSetupCancelEvent, FloPayCardSetupError } from './card-setup-entry.cjs';
|
|
4
|
+
|
|
5
|
+
/** Verified terminal result from a no-charge payment-method setup. */
|
|
6
|
+
type FloPayPaymentMethodSetupCompleteEvent = FloPayCardSetupCompleteEvent;
|
|
7
|
+
/** Provider-neutral terminal decline from payment-method verification. */
|
|
8
|
+
type FloPayPaymentMethodSetupDeclineEvent = FloPayCardSetupDeclineEvent;
|
|
9
|
+
/** Abandoned setup result emitted when the surface unmounts pre-terminally. */
|
|
10
|
+
type FloPayPaymentMethodSetupCancelEvent = FloPayCardSetupCancelEvent;
|
|
11
|
+
/** Props for the browser-only payment-method setup surface. */
|
|
12
|
+
interface FloPayPaymentMethodSetupProps {
|
|
13
|
+
/** Opaque id returned by the merchant-authenticated setup-session endpoint. */
|
|
14
|
+
sessionId: string;
|
|
15
|
+
/** Session-bound token returned alongside {@link FloPayPaymentMethodSetupProps.sessionId}. */
|
|
16
|
+
nonce: string;
|
|
17
|
+
/** Billing API base URL. Defaults to the configured FloPay environment URL. */
|
|
18
|
+
billingApiUrl?: string;
|
|
19
|
+
/** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
|
|
20
|
+
telemetry?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The same {@link ThemeId} bundle `FloPayCheckout` and `FloPayCardSetup`
|
|
23
|
+
* resolve, or raw {@link VaultCardThemeColors} for the hosted card widget.
|
|
24
|
+
* Defaults to `'modern-light'`.
|
|
25
|
+
*/
|
|
26
|
+
theme?: ThemeId | VaultCardThemeColors;
|
|
27
|
+
/** Inline styles for the hosted card-widget container (as `FloPayCardSetup`). */
|
|
28
|
+
containerStyle?: React.CSSProperties;
|
|
29
|
+
/** Optional content shown while the session and methods are loading. */
|
|
30
|
+
loading?: React.ReactNode;
|
|
31
|
+
/** Fired once the hosted card widget has mounted and can accept card input. */
|
|
32
|
+
onReady?: () => void;
|
|
33
|
+
/** Fired only after the backend reports that the method is verified and usable. */
|
|
34
|
+
onComplete?: (event: FloPayPaymentMethodSetupCompleteEvent) => void;
|
|
35
|
+
/** Fired when verification terminally declines; never paired with `onComplete`. */
|
|
36
|
+
onDecline?: (event: FloPayPaymentMethodSetupDeclineEvent) => void;
|
|
37
|
+
/** Fired exactly once if the surface unmounts before a terminal outcome. */
|
|
38
|
+
onCancel?: (event: FloPayPaymentMethodSetupCancelEvent) => void;
|
|
39
|
+
/** Live validation message, or `null` when validation clears. */
|
|
40
|
+
onValidation?: (message: string | null) => void;
|
|
41
|
+
/** Fired for session validation, transport, provider or widget failures. */
|
|
42
|
+
onError?: (error: FloPayCardSetupError) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { FloPayPaymentMethodSetupProps as F, FloPayPaymentMethodSetupCancelEvent as a, FloPayPaymentMethodSetupCompleteEvent as b, FloPayPaymentMethodSetupDeclineEvent as c };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ThemeId, VaultCardThemeColors } from '@flopay/shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FloPayCardSetupCompleteEvent, FloPayCardSetupDeclineEvent, FloPayCardSetupCancelEvent, FloPayCardSetupError } from './card-setup-entry.js';
|
|
4
|
+
|
|
5
|
+
/** Verified terminal result from a no-charge payment-method setup. */
|
|
6
|
+
type FloPayPaymentMethodSetupCompleteEvent = FloPayCardSetupCompleteEvent;
|
|
7
|
+
/** Provider-neutral terminal decline from payment-method verification. */
|
|
8
|
+
type FloPayPaymentMethodSetupDeclineEvent = FloPayCardSetupDeclineEvent;
|
|
9
|
+
/** Abandoned setup result emitted when the surface unmounts pre-terminally. */
|
|
10
|
+
type FloPayPaymentMethodSetupCancelEvent = FloPayCardSetupCancelEvent;
|
|
11
|
+
/** Props for the browser-only payment-method setup surface. */
|
|
12
|
+
interface FloPayPaymentMethodSetupProps {
|
|
13
|
+
/** Opaque id returned by the merchant-authenticated setup-session endpoint. */
|
|
14
|
+
sessionId: string;
|
|
15
|
+
/** Session-bound token returned alongside {@link FloPayPaymentMethodSetupProps.sessionId}. */
|
|
16
|
+
nonce: string;
|
|
17
|
+
/** Billing API base URL. Defaults to the configured FloPay environment URL. */
|
|
18
|
+
billingApiUrl?: string;
|
|
19
|
+
/** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
|
|
20
|
+
telemetry?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The same {@link ThemeId} bundle `FloPayCheckout` and `FloPayCardSetup`
|
|
23
|
+
* resolve, or raw {@link VaultCardThemeColors} for the hosted card widget.
|
|
24
|
+
* Defaults to `'modern-light'`.
|
|
25
|
+
*/
|
|
26
|
+
theme?: ThemeId | VaultCardThemeColors;
|
|
27
|
+
/** Inline styles for the hosted card-widget container (as `FloPayCardSetup`). */
|
|
28
|
+
containerStyle?: React.CSSProperties;
|
|
29
|
+
/** Optional content shown while the session and methods are loading. */
|
|
30
|
+
loading?: React.ReactNode;
|
|
31
|
+
/** Fired once the hosted card widget has mounted and can accept card input. */
|
|
32
|
+
onReady?: () => void;
|
|
33
|
+
/** Fired only after the backend reports that the method is verified and usable. */
|
|
34
|
+
onComplete?: (event: FloPayPaymentMethodSetupCompleteEvent) => void;
|
|
35
|
+
/** Fired when verification terminally declines; never paired with `onComplete`. */
|
|
36
|
+
onDecline?: (event: FloPayPaymentMethodSetupDeclineEvent) => void;
|
|
37
|
+
/** Fired exactly once if the surface unmounts before a terminal outcome. */
|
|
38
|
+
onCancel?: (event: FloPayPaymentMethodSetupCancelEvent) => void;
|
|
39
|
+
/** Live validation message, or `null` when validation clears. */
|
|
40
|
+
onValidation?: (message: string | null) => void;
|
|
41
|
+
/** Fired for session validation, transport, provider or widget failures. */
|
|
42
|
+
onError?: (error: FloPayCardSetupError) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { FloPayPaymentMethodSetupProps as F, FloPayPaymentMethodSetupCancelEvent as a, FloPayPaymentMethodSetupCompleteEvent as b, FloPayPaymentMethodSetupDeclineEvent as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"types": "./dist/card-setup-entry.d.ts",
|
|
23
23
|
"import": "./dist/card-setup-entry.mjs",
|
|
24
24
|
"require": "./dist/card-setup-entry.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./payment-method-setup": {
|
|
27
|
+
"types": "./dist/payment-method-setup-entry.d.ts",
|
|
28
|
+
"import": "./dist/payment-method-setup-entry.mjs",
|
|
29
|
+
"require": "./dist/payment-method-setup-entry.cjs"
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
32
|
"main": "./dist/index.cjs",
|
|
@@ -34,8 +39,8 @@
|
|
|
34
39
|
"@paypal/paypal-js": "^10.0.0",
|
|
35
40
|
"@stripe/react-stripe-js": "^6.6.0",
|
|
36
41
|
"@stripe/stripe-js": "^9.8.0",
|
|
37
|
-
"@flopay/shared": "1.
|
|
38
|
-
"@flopay/js": "1.
|
|
42
|
+
"@flopay/shared": "1.10.1",
|
|
43
|
+
"@flopay/js": "1.10.1"
|
|
39
44
|
},
|
|
40
45
|
"peerDependencies": {
|
|
41
46
|
"react": ">=18.0.0",
|