@flopay/react 1.20.15 → 2.0.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.
Files changed (67) hide show
  1. package/README.md +107 -390
  2. package/dist/card-setup-entry.cjs +1 -6
  3. package/dist/card-setup-entry.d.ts +4 -10
  4. package/dist/card-setup-entry.mjs +1 -1
  5. package/dist/chunk-KPRDVWZP.mjs +1 -0
  6. package/dist/chunk-XRYDC367.mjs +1 -0
  7. package/dist/flopay-runtime-card-setup.d.ts +4 -5
  8. package/dist/flopay-runtime-checkout.d.ts +2 -0
  9. package/dist/hosted-runtime-components.d.ts +75 -0
  10. package/dist/index.cjs +1 -47
  11. package/dist/index.d.ts +3 -21
  12. package/dist/index.mjs +1 -21
  13. package/dist/payment-method-setup-entry.cjs +1 -27
  14. package/dist/payment-method-setup-entry.d.ts +5 -12
  15. package/dist/payment-method-setup-entry.mjs +1 -1
  16. package/dist/runtime-context.d.ts +10 -0
  17. package/package.json +3 -6
  18. package/dist/account-bound-elements.d.ts +0 -31
  19. package/dist/automatic-payment-button.d.ts +0 -88
  20. package/dist/buyer-identity-fallback.d.ts +0 -43
  21. package/dist/card-button-content.d.ts +0 -11
  22. package/dist/card-setup-surface.d.ts +0 -12
  23. package/dist/card-setup-theme.d.ts +0 -32
  24. package/dist/checkout-utils.d.ts +0 -172
  25. package/dist/chunk-BU7THP6H.mjs +0 -1
  26. package/dist/chunk-FGCZOMML.mjs +0 -22
  27. package/dist/chunk-ITRFSHZP.mjs +0 -6
  28. package/dist/chunk-PCIHQY3X.mjs +0 -1
  29. package/dist/chunk-VK67324N.mjs +0 -1
  30. package/dist/context.d.ts +0 -46
  31. package/dist/direct-paypal-button.d.ts +0 -155
  32. package/dist/error-banner.d.ts +0 -21
  33. package/dist/external-method-recovery.d.ts +0 -1
  34. package/dist/external-method-telemetry.d.ts +0 -17
  35. package/dist/flopay-card-setup.d.ts +0 -114
  36. package/dist/flopay-checkout.d.ts +0 -292
  37. package/dist/flopay-payment-method-setup-main.d.ts +0 -10
  38. package/dist/flopay-payment-method-setup.d.ts +0 -11
  39. package/dist/hooks.d.ts +0 -36
  40. package/dist/in-app-browser.d.ts +0 -5
  41. package/dist/inline-session-cache.d.ts +0 -1
  42. package/dist/instruments.d.ts +0 -5
  43. package/dist/more-payment-options.d.ts +0 -19
  44. package/dist/one-click-warnings.d.ts +0 -12
  45. package/dist/payment-logos.generated.d.ts +0 -1
  46. package/dist/payment-method-layout-placeholder.d.ts +0 -10
  47. package/dist/payment-method-setup-advertisement.d.ts +0 -36
  48. package/dist/payment-method-setup-paypal-CLV7JDJH.mjs +0 -1
  49. package/dist/payment-method-setup-paypal.d.ts +0 -25
  50. package/dist/payment-method-setup-stripe-526L4P5X.mjs +0 -1
  51. package/dist/payment-method-setup-stripe.d.ts +0 -31
  52. package/dist/payment-method-setup-surface.d.ts +0 -90
  53. package/dist/popup-capability.d.ts +0 -12
  54. package/dist/processing-overlay.d.ts +0 -33
  55. package/dist/provider-callback-ignored.d.ts +0 -8
  56. package/dist/provider.d.ts +0 -40
  57. package/dist/recent-completion.d.ts +0 -1
  58. package/dist/run-latest-abortable-action.d.ts +0 -5
  59. package/dist/saved-payment-flow.d.ts +0 -140
  60. package/dist/split-card-form.d.ts +0 -393
  61. package/dist/stripe-method-presentation.d.ts +0 -115
  62. package/dist/telemetry-bridge.d.ts +0 -41
  63. package/dist/use-external-attempt-reconciliation.d.ts +0 -27
  64. package/dist/use-isomorphic-layout-effect.d.ts +0 -3
  65. package/dist/use-payment-method-layout.d.ts +0 -27
  66. package/dist/vault-card-fields.d.ts +0 -97
  67. package/dist/vault-theme.d.ts +0 -1
@@ -1,6 +1 @@
1
- "use strict";var J=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var Se=(e,r)=>{for(var t in r)J(e,t,{get:r[t],enumerable:!0})},he=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of ge(r))!Ce.call(e,i)&&i!==t&&J(e,i,{get:()=>r[i],enumerable:!(o=ye(r,i))||o.enumerable});return e};var ve=e=>he(J({},"__esModule",{value:!0}),e);var Te={};Se(Te,{FloPayCardSetup:()=>me,FloPayCardSetupError:()=>B});module.exports=ve(Te);var q=require("@flopay/js/card-setup"),l=require("@flopay/shared"),n=require("react");var K=require("@flopay/shared"),Re=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 be(e){let r=e.replace(/^(Webkit|Moz|ms)(?=[A-Z])/,"");return Re.has(r.charAt(0).toLowerCase()+r.slice(1))}function Ee(e,r){return typeof r=="number"&&r!==0&&!be(e)?`${r}px`:String(r).trim()}function ie(e,r){if(e.style.cssText="",!!r){for(let[t,o]of Object.entries(r))if(!(o==null||o==="")){if(t.startsWith("--")){e.style.setProperty(t,String(o));continue}e.style[t]=Ee(t,o)}}}var Q=require("@flopay/shared"),we=require("@flopay/shared");function le(e){let r=(0,Q.resolveCardSetupTheme)(e);return{...r,surface:r.surface,overlayTheme:r.overlayTheme}}var S=require("@flopay/shared");var a=require("react/jsx-runtime");var Pe={panel:{background:"white"},spinnerTrackColor:"#e5e7eb",spinnerAccentColor:"#4A49FF",labelColors:{processing:"#374151",success:"#16a34a",error:"#dc2626"},noteColor:"#6b7280"};function ue({status:e,errorMessage:r,authorized:t=!1,processingLabel:o="PROCESSING...",successLabel:i,errorLabel:E="PAYMENT FAILED",successNote:u="You will be automatically redirected, do not close or navigate away from this window.",theme:m=Pe}){let w={fontSize:13,color:m.noteColor,fontWeight:400,maxWidth:260,lineHeight:1.4,margin:0};return(0,a.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,a.jsxs)("div",{"data-testid":"flopay-processing-overlay-panel",style:{borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.18)",...m.panel,padding:"2rem 2.5rem",textAlign:"center",minWidth:240,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[(0,a.jsxs)("div",{style:{width:48,height:48,position:"relative"},children:[e==="processing"&&(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:m.spinnerTrackColor,strokeWidth:"3"}),(0,a.jsx)("path",{d:"M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z",fill:m.spinnerAccentColor})]}),e==="success"&&(0,a.jsx)("div",{style:{animation:"flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)"},children:(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"#22c55e"}),(0,a.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,a.jsx)("div",{style:{animation:"flopay-shake 0.4s ease"},children:(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"#ef4444"}),(0,a.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,a.jsxs)("span",{style:{fontSize:14,fontWeight:600,letterSpacing:"0.05em",color:m.labelColors[e]},children:[e==="processing"&&o,e==="success"&&(i??(t?"PAYMENT AUTHORISED":"PAYMENT SUCCESSFUL")),e==="error"&&E]}),e==="success"&&u!==null&&(0,a.jsx)("p",{style:w,children:u}),e==="error"&&r&&(0,a.jsx)("p",{style:w,children:r}),(0,a.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 c=require("react");var H=require("react"),ce=typeof window>"u"?H.useEffect:H.useLayoutEffect;var re=require("react/jsx-runtime"),ee=new WeakSet;function de({capture:e,html:r,messageToken:t,expectedOrigin:o,expiresAt:i,verificationRequired:E,theme:u,submitLabel:m,containerStyle:w,onReady:_,onError:M,onValidation:V}){let T=(0,c.useRef)(null),D=(0,c.useRef)(_),k=(0,c.useRef)(M),f=(0,c.useRef)(V);D.current=_,k.current=M,f.current=V;let P=(0,c.useRef)(u);P.current=u;let y=(0,c.useRef)(null),g=m??void 0,x=(0,c.useRef)(g);x.current=g;let O=(0,c.useRef)(void 0);return(0,c.useEffect)(()=>{let h=T.current;if(!h)return;let d=!0,Y=!1,F=()=>{!d||Y||(Y=!0,D.current?.())},v=e.on("ready",()=>{F()}),I=e.on("error",R=>{k.current?.(R.message??"There was a problem loading the secure card form.")}),X=e.on("validation",R=>{f.current?.(R.message??null)}),N=x.current??(ee.has(e)?null:void 0),G={html:r,...t?{messageToken:t}:{},...o?{expectedOrigin:o}:{},...typeof i=="string"?{expiresAt:i}:{},...E?{verificationRequired:!0}:{},...P.current?{theme:P.current}:{},...N===void 0?{}:{submitLabel:N}};return y.current=P.current??null,O.current=x.current,x.current!==void 0&&ee.add(e),e.mount(h,G).then(()=>{F()}).catch(R=>{d&&k.current?.(R instanceof Error?R.message:"Failed to load the secure card form.")}),()=>{d=!1,v(),I(),X(),e.unmount()}},[e,r,t,o,i,E]),ce(()=>{let h=T.current;h&&ie(h,w)},[w]),(0,c.useEffect)(()=>{u!==void 0&&(u===null&&y.current===null||(y.current=u,e.applyTheme?.(u)))},[e,u]),(0,c.useEffect)(()=>{g!==O.current&&(O.current=g,g!==void 0&&ee.add(e),e.setSubmitLabel?.(g??null))},[e,g]),(0,re.jsx)("div",{ref:T,"data-testid":"flopay-vault-card-fields"})}var C=require("react/jsx-runtime"),B=class extends l.FloPayError{constructor(r,t,o){super(r,t,o),this.name="FloPayCardSetupError",this.retryable=o.retryable}};function fe(e,r={}){let t=e instanceof l.FloPayError?e:void 0,o=t?.statusCode,i=r.retryable??(t?.type==="network_error"||t?.type==="rate_limit_error"||typeof o=="number"&&o>=500||t?.code==="vault_capture_timeout"||!t);return new B(t?.message??(e instanceof Error?e.message:"Failed to load the secure card form."),t?.type??"api_error",{code:r.code??t?.code??"card_setup_load_failed",retryable:i,...t?.param?{param:t.param}:{},...o===void 0?{}:{statusCode:o}})}function me({sessionId:e,nonce:r,billingApiUrl:t,telemetry:o,theme:i="modern-light",containerStyle:E,appearance:u,buttonsStyles:m,loading:w=null,onReady:_,onComplete:M,onDecline:V,onCancel:T,onValidation:D,onError:k}){let[f,P]=(0,n.useState)(null),[y,g]=(0,n.useState)(null),[x,O]=(0,n.useState)(null),[h,d]=(0,n.useState)(null),[Y,F]=(0,n.useState)(null),v=(0,n.useRef)(!1),I=(0,n.useRef)(!1),{vaultTheme:X,surface:N,overlayTheme:G}=(0,n.useMemo)(()=>le({theme:i,appearance:u,buttonsStyles:m}),[i,u,m]),R=(0,n.useMemo)(()=>(0,K.mergeCardSetupSurface)(N,E),[N,E]),te=(0,n.useRef)(_),j=(0,n.useRef)(k),oe=(0,n.useRef)(M),ne=(0,n.useRef)(V),ae=(0,n.useRef)(T),se=(0,n.useRef)(D),U=(0,n.useRef)(!1),Z=(0,n.useRef)(!1),$=(0,n.useRef)(0);return te.current=_,j.current=k,oe.current=M,ne.current=V,ae.current=T,se.current=D,(0,n.useEffect)(()=>{let s=$.current+1;return $.current=s,()=>{queueMicrotask(()=>{$.current===s&&(U.current||Z.current||(Z.current=!0,(0,S.invokeMerchantCallback)(()=>{ae.current?.({status:"cancelled",sessionId:e})})))})}},[e]),(0,n.useEffect)(()=>{let s=!0,A=(0,l.resolveBillingApiUrl)(t),W=new q.PaymentAPI(A,{telemetry:o});return P(null),g(null),O(null),U.current=!1,Z.current=!1,(async()=>{try{if(!e.trim())throw new l.FloPayError("FloPayCardSetup requires a sessionId.","validation_error",{code:"MissingCheckoutSessionId",param:"sessionId"});if(!r.trim())throw new l.FloPayError("FloPayCardSetup requires a session nonce.","validation_error",{code:"MissingCheckoutSessionToken",param:"nonce"});let z=await W.getUnifiedCheckoutSession(e,r);if(!s)return;let b=z.data.session;if(!b||!(0,l.isCardSetupCheckoutSession)(b))throw new l.FloPayError("FloPayCardSetup only accepts a zero-amount, productless setup session.","validation_error",{code:"InvalidCardSetupSession",param:"sessionId"});let p=b.vault;(0,l.isMountableVaultBlock)(p)||(p=await W.getVaultCapture(e,r));let L=(0,l.resolveVaultMountOptions)(p,{billingApiUrl:A,sessionId:e,nonce:r});if(!L)throw new l.FloPayError("FloPay: this setup session has no vault card capability. Upgrade the billing backend integration.","api_error",{code:"UnsupportedBackendVaultCapability"});if(!s)return;g(L),P(new q.PciVaultCardCapture({sessionId:e,operation:"card_setup",telemetry:o}))}catch(z){if(!s)return;let b=fe(z);U.current=!0,O(b),(0,S.invokeMerchantCallback)(()=>j.current?.(b))}})(),()=>{s=!1,W.destroy()}},[t,r,e,o]),(0,n.useEffect)(()=>{if(!f)return;let s=!1;I.current=!1,v.current=!1;let A=f.on("submitting",()=>{v.current=!0,F(null),d("processing")}),W=f.on("complete",p=>{U.current=!0,v.current=!1,d("success"),(async()=>(await new Promise(L=>setTimeout(L,600)),!I.current&&(I.current=!0,(0,S.invokeMerchantCallback)(()=>{oe.current?.({status:"succeeded",sessionId:e,...p.paymentMethod?{paymentMethod:p.paymentMethod}:{}})}),s||d(null))))()}),z=f.on("decline",p=>{U.current=!0,v.current=!1,F(p.message??null),d("error"),(0,S.invokeMerchantCallback)(()=>{ne.current?.({status:"declined",sessionId:e,...p.declineReason?{reason:p.declineReason}:{},...p.message?{message:p.message}:{}})}),(async()=>(await new Promise(L=>setTimeout(L,400)),s||d(null)))()}),b=f.on("challenge_dismissed",()=>{d(null)});return()=>{s=!0,A(),W(),z(),b()}},[f,e]),x?(0,C.jsx)("div",{role:"alert",children:x.message}):!f||!y?.html?(0,C.jsx)(C.Fragment,{children:w}):(0,C.jsxs)(C.Fragment,{children:[h&&(0,C.jsx)(ue,{status:h,errorMessage:Y,processingLabel:"SAVING CARD...",successLabel:"CARD SAVED",errorLabel:"CARD NOT SAVED",successNote:null,...G?{theme:G}:{}}),(0,C.jsx)(de,{capture:f,html:y.html,messageToken:y.messageToken,expectedOrigin:y.expectedOrigin,expiresAt:y.expiresAt,verificationRequired:y.verificationRequired,theme:X,containerStyle:R,onReady:()=>{(0,S.invokeMerchantCallback)(()=>te.current?.())},onValidation:s=>{(0,S.invokeMerchantCallback)(()=>se.current?.(s))},onError:s=>{if(!s)return;v.current&&(v.current=!1,F(s),d("error"),setTimeout(()=>d(null),400));let A=fe(new Error(s),{code:"card_setup_widget_failed",retryable:!0});(0,S.invokeMerchantCallback)(()=>j.current?.(A))}})]})}0&&(module.exports={FloPayCardSetup,FloPayCardSetupError});
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,12 +1,6 @@
1
1
  /**
2
- * Stripe-free entry for card-setup surfaces (`@flopay/react/card-setup`).
3
- *
4
- * The main entry's module graph reaches `@flopay/js`'s Stripe adapter, whose
5
- * eager `@stripe/stripe-js` import starts downloading the js.stripe.com
6
- * script at evaluation time — deliberate for checkout, wrong for pages that
7
- * only manage saved cards. Import `FloPayCardSetup` from here to keep such
8
- * pages free of Stripe network activity by construction. The main entry still
9
- * re-exports the component for back-compat, but bundlers that evaluate the
10
- * whole main entry will pull Stripe with it.
2
+ * Entry for card-setup surfaces (`@flopay/react/card-setup`): the card setup that mounts from
3
+ * the Flo-hosted runtime, with nothing else from the main entry.
11
4
  */
12
- export { FloPayCardSetup, type FloPayCardSetupCancelEvent, type FloPayCardSetupCompleteEvent, type FloPayCardSetupDeclineEvent, FloPayCardSetupError, type FloPayCardSetupProps, } from './flopay-card-setup.js';
5
+ export type { FloPayRuntimeCardSetupProps as FloPayCardSetupProps, FloPayRuntimeSetupCancelEvent as FloPayCardSetupCancelEvent, FloPayRuntimeSetupCompleteEvent as FloPayCardSetupCompleteEvent, FloPayRuntimeSetupDeclineEvent as FloPayCardSetupDeclineEvent, FloPayRuntimeSetupError as FloPayCardSetupError, } from './flopay-runtime-card-setup.js';
6
+ export { FloPayRuntimeCardSetup as FloPayCardSetup } from './flopay-runtime-card-setup.js';
@@ -1 +1 @@
1
- import{h as e,j as t}from"./chunk-ITRFSHZP.mjs";export{t as FloPayCardSetup,e as FloPayCardSetupError};
1
+ import{c as e}from"./chunk-XRYDC367.mjs";export{e as FloPayCardSetup};
@@ -0,0 +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};
@@ -0,0 +1 @@
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};
@@ -3,23 +3,23 @@ import type { ButtonsLayoutStyles, FloPayAppearance, SavedCardDisplay, ThemeId,
3
3
  import { FloPayError } from '@flopay/shared';
4
4
  import type { CSSProperties, ReactElement } from 'react';
5
5
  /** Verified terminal result from a no-charge setup, as 1.x's `FloPayCardSetup` reports it. */
6
- interface FloPayRuntimeSetupCompleteEvent {
6
+ export interface FloPayRuntimeSetupCompleteEvent {
7
7
  status: 'succeeded';
8
8
  sessionId: string;
9
9
  paymentMethod?: SavedCardDisplay;
10
10
  }
11
- interface FloPayRuntimeSetupDeclineEvent {
11
+ export interface FloPayRuntimeSetupDeclineEvent {
12
12
  status: 'declined';
13
13
  sessionId: string;
14
14
  reason?: string;
15
15
  message?: string;
16
16
  }
17
- interface FloPayRuntimeSetupCancelEvent {
17
+ export interface FloPayRuntimeSetupCancelEvent {
18
18
  status: 'cancelled';
19
19
  sessionId: string;
20
20
  }
21
21
  /** A structured setup failure: type, code, retryable and, where supplied, param and statusCode. */
22
- type FloPayRuntimeSetupError = FloPayError & {
22
+ export type FloPayRuntimeSetupError = FloPayError & {
23
23
  retryable: boolean;
24
24
  };
25
25
  /** The props of the hosted card setup and payment method setup, the same as 1.x's, plus the runtime. */
@@ -56,4 +56,3 @@ export declare function RuntimeSetup({ kind, props, }: {
56
56
  }): ReactElement;
57
57
  /** Card setup that runs from the Flo-hosted runtime (`setup: 'card'`), with 1.x's callbacks. */
58
58
  export declare function FloPayRuntimeCardSetup(props: FloPayRuntimeCardSetupProps): ReactElement;
59
- export {};
@@ -39,6 +39,8 @@ export interface FloPayRuntimeCheckoutProps {
39
39
  runtimeTimeoutMs?: number;
40
40
  onEvent?: (event: CheckoutRuntimeEvent) => void;
41
41
  onError?: (error: FloPayError) => void;
42
+ /** Further mount options, passed to the runtime as given (by value). A change mounts again. */
43
+ extraMountOptions?: Record<string, unknown>;
42
44
  }
43
45
  /**
44
46
  * A card checkout that runs from the Flo-hosted runtime. The component holds no checkout
@@ -0,0 +1,75 @@
1
+ import type { CheckoutRuntimeAutomaticPayment } from '@flopay/js';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ import type { FloPayRuntimeCardSetupProps } from './flopay-runtime-card-setup.js';
4
+ import { FloPayRuntimeCardSetup } from './flopay-runtime-card-setup.js';
5
+ import type { FloPayRuntimeCheckoutProps as RuntimeCheckoutCoreProps } from './flopay-runtime-checkout.js';
6
+ import { FloPayRuntimePaymentMethodSetup } from './flopay-runtime-payment-method-setup.js';
7
+ /** The payment methods a checkout can hide, by method (never by processor). */
8
+ export type HiddenPaymentMethod = 'card' | 'paypal' | 'apple_pay' | 'google_pay' | 'apms';
9
+ export interface FloPayCheckoutProps extends Omit<RuntimeCheckoutCoreProps, 'publishableKey' | 'runtimeUrl' | 'extraMountOptions'> {
10
+ /** Falls back to the one `FloPayProvider` gives. */
11
+ publishableKey?: string;
12
+ /** The Flo-origin runtime script. Falls back to the one `FloPayProvider` gives. */
13
+ runtimeUrl?: string;
14
+ /** Payment methods the runtime hides, by method. Left out, nothing is hidden. */
15
+ hiddenPaymentMethods?: HiddenPaymentMethod[];
16
+ /** `false` hides PayPal, the same as listing `paypal` in `hiddenPaymentMethods`. */
17
+ showPayPal?: boolean;
18
+ theme?: string | Record<string, unknown>;
19
+ showCardBrandIcons?: boolean;
20
+ showCardFieldLabels?: boolean;
21
+ cardFieldLabels?: Record<string, string>;
22
+ cardFieldPlaceholders?: Record<string, string>;
23
+ enabledPaymentMethods?: string[];
24
+ initialPayPalOrderId?: string;
25
+ /** The 1.x callbacks: each gets its runtime event's payload unchanged. */
26
+ onComplete?(event: unknown): void;
27
+ onDecline?(event: unknown): void;
28
+ onCancel?(event: unknown): void;
29
+ onInstrument?(event: unknown): void;
30
+ onCardFieldsReady?(event: unknown): void;
31
+ onCardFieldsFailed?(event: unknown): void;
32
+ }
33
+ /** The all-in-one checkout, mounted from the hosted runtime. */
34
+ export declare function FloPayCheckout(props: FloPayCheckoutProps): ReactElement;
35
+ export type SplitCardFormProps = FloPayCheckoutProps;
36
+ /** The split card form: the same hosted checkout, with its props passed through. */
37
+ export declare function SplitCardForm(props: SplitCardFormProps): ReactElement;
38
+ export type FloPayCardSetupProps = FloPayRuntimeCardSetupProps;
39
+ /** Card setup, mounted from the hosted runtime (`setup: 'card'`). */
40
+ export declare const FloPayCardSetup: typeof FloPayRuntimeCardSetup;
41
+ export type FloPayPaymentMethodSetupProps = FloPayRuntimeCardSetupProps;
42
+ /** Payment method setup, mounted from the hosted runtime (`setup: 'payment_method'`). */
43
+ export declare const FloPayPaymentMethodSetup: typeof FloPayRuntimePaymentMethodSetup;
44
+ export interface FloPayProviderProps {
45
+ /** The publishable key the components below use when they are not given one. */
46
+ publishableKey?: string;
47
+ /** The Flo-origin runtime script the components below use when they are not given one. */
48
+ runtimeUrl?: string;
49
+ /** Accepted so 1.x pages keep compiling; 2.0 holds no FloPay instance. */
50
+ flopay?: null;
51
+ children?: ReactNode;
52
+ }
53
+ /** Hands the publishable key and runtime URL to the components below it. It loads nothing. */
54
+ export declare function FloPayProvider({ publishableKey, runtimeUrl, children, }: FloPayProviderProps): ReactElement;
55
+ export type DirectPayPalButtonProps = Omit<FloPayCheckoutProps, 'hiddenPaymentMethods' | 'showPayPal'>;
56
+ /** The PayPal button: the hosted checkout with every method but PayPal hidden. */
57
+ export declare function DirectPayPalButton(props: DirectPayPalButtonProps): ReactElement;
58
+ export type VaultCardFieldsProps = Omit<FloPayCheckoutProps, 'hiddenPaymentMethods' | 'showPayPal'>;
59
+ /** The hosted card fields: the hosted checkout with every method but the card hidden. */
60
+ export declare function VaultCardFields(props: VaultCardFieldsProps): ReactElement;
61
+ export interface FloPayAutomaticPaymentButtonProps extends Omit<FloPayCheckoutProps, 'automaticPayment'> {
62
+ /** `automatic` (the default) or `confirm`; both pay only on the buyer's click. */
63
+ mode?: CheckoutRuntimeAutomaticPayment['mode'];
64
+ /** Called in this page when the buyer clicks, as in 1.x. */
65
+ getSession?: CheckoutRuntimeAutomaticPayment['getSession'];
66
+ /** A completed saved payment, with the runtime's payload unchanged. */
67
+ onSuccess?(event: FloPayAutomaticPaymentSuccessEvent): void;
68
+ }
69
+ /** The runtime's `complete` payload for a saved payment, as given. */
70
+ export interface FloPayAutomaticPaymentSuccessEvent {
71
+ sessionId: string;
72
+ [key: string]: unknown;
73
+ }
74
+ /** The saved-payment button: the runtime shows the pay control and runs the saved payment. */
75
+ export declare function FloPayAutomaticPaymentButton({ mode, getSession, onSuccess, onComplete, ...rest }: FloPayAutomaticPaymentButtonProps): ReactElement;