@flopay/react 1.20.15 → 2.0.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.
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,22 +0,0 @@
1
- import{a as X,b as Y,h as z,j as K,l as W}from"./chunk-VK67324N.mjs";import{PaymentAPI as ve}from"@flopay/js/card-setup";import{FloPayError as Ee,getStripeMethodDisplayName as ke,isSettledSessionIntent as xe,resolveSetupFutureUsage as Ce,settledSessionIntentError as we,toStripeAppearance as Pe}from"@flopay/shared";import{Elements as Re,ExpressCheckoutElement as _e,PaymentElement as Me,useElements as Te,useStripe as Le}from"@stripe/react-stripe-js";import{loadStripe as Ie}from"@stripe/stripe-js";import{useCallback as oe,useMemo as Be,useRef as Fe,useState as S}from"react";import{getStripeMethodDisplayName as j,hasVendoredStripeMethodLogo as ye,resolveStripeMethodBrandVariant as me,stripeExpressMethodToOptionKey as fe}from"@flopay/shared";import{useState as he}from"react";var $={alipay:"https://cdn.flopay.com/sdk-logos/v1/alipay.svg",bancontact:"https://cdn.flopay.com/sdk-logos/v1/bancontact.svg",blik:"https://cdn.flopay.com/sdk-logos/v1/blik.svg",eps:"https://cdn.flopay.com/sdk-logos/v1/eps.svg",giropay:"https://cdn.flopay.com/sdk-logos/v1/giropay.svg",ideal:"https://cdn.flopay.com/sdk-logos/v1/ideal.svg",klarna:"https://cdn.flopay.com/sdk-logos/v1/klarna.svg",p24:"https://cdn.flopay.com/sdk-logos/v1/p24.svg",sepa_debit:"https://cdn.flopay.com/sdk-logos/v1/sepa_debit.svg",wechat_pay:"https://cdn.flopay.com/sdk-logos/v1/wechat_pay.svg"};import{Fragment as be,jsx as n,jsxs as A}from"react/jsx-runtime";var ge=`
2
- .paypal-buttons { margin: 0 !important; vertical-align: top !important; }
3
- @keyframes flopay-spin { to { transform: rotate(360deg); } }
4
- @keyframes flopay-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
5
- @keyframes flopay-fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }
6
- @keyframes flopay-buttons-enter {
7
- 0% { opacity: 0; transform: translateX(-16px) scale(0.97); }
8
- 100% { opacity: 1; transform: translateX(0) scale(1); }
9
- }
10
- @keyframes flopay-buttons-exit {
11
- 0% { opacity: 1; transform: translateX(0) scale(1); }
12
- 100% { opacity: 0; transform: translateX(-16px) scale(0.97); }
13
- }
14
- @keyframes flopay-card-enter {
15
- 0% { opacity: 0; transform: translateX(16px) scale(0.97); }
16
- 100% { opacity: 1; transform: translateX(0) scale(1); }
17
- }
18
- @keyframes flopay-card-exit {
19
- 0% { opacity: 1; transform: translateX(0) scale(1); }
20
- 100% { opacity: 0; transform: translateX(16px) scale(0.97); }
21
- }
22
- `,Se=44;function G(){return n("style",{children:ge})}function V(e,o){let t=e.availablePaymentMethods;return t&&o.some(r=>t[r])?"ready":"unavailable"}function q({state:e,placeholderTestId:o,borderRadius:t=8,children:r}){return e==="unavailable"||e==="load_error"?null:A("div",{style:{position:"relative",minHeight:44},children:[n("div",{"data-testid":o,"aria-hidden":e==="ready",style:{position:"absolute",inset:0,height:44,borderRadius:t,background:"#e5e7eb",animation:e==="ready"?void 0:"flopay-pulse 1.5s ease-in-out infinite",opacity:e==="ready"?0:1,transform:e==="ready"?"scale(0.985)":"scale(1)",transition:"opacity 140ms ease-out, transform 140ms ease-out",pointerEvents:"none"}}),n("div",{style:{minHeight:44,opacity:e==="ready"?1:0,transform:e==="ready"?"translateY(0)":"translateY(2px)",transition:"opacity 140ms ease-out, transform 140ms ease-out",pointerEvents:e==="ready"?"auto":"none"},children:r})]})}function We(e){return e!=="unavailable"&&e!=="load_error"}function J({method:e,themeId:o,submitting:t=!1,disabled:r=!1,highlighted:l=!1,hasNextStep:p=!1,onClick:s,backgroundColor:f,borderColor:d,textColor:h,borderRadius:g,fontFamily:C}){let c=me(e,o),b=$[e],[E,v]=he(!1),y=!!b&&!E,k=c?.backgroundColor??f??"#ffffff",w=c?.borderColor??d??"#d1d5db",P=c?.textColor??h??"#262833";return n("button",{type:"button","data-testid":`flopay-stripe-method-button-${e}`,"data-method":e,onClick:()=>{!t&&!r&&s()},disabled:t||r,"aria-busy":t||void 0,style:{position:"relative",width:"100%",boxSizing:"border-box",height:Se,padding:"0 1rem",backgroundColor:k,color:P,border:`1px solid ${w}`,borderRadius:g??8,fontSize:"0.95rem",fontWeight:600,fontFamily:C,cursor:t||r?"not-allowed":"pointer",opacity:r&&!t?.55:1,animation:t?"flopay-pulse 1.5s ease-in-out infinite":void 0,display:"flex",alignItems:"center",justifyContent:"center",gap:8,transition:"transform 0.1s, opacity 140ms ease-out, border-color 140ms ease-out",boxShadow:l?"0 0 0 2px rgba(74, 73, 255, 0.15)":void 0},children:t?n("span",{style:{margin:"0 auto"},children:`Connecting to ${j(e)}\u2026`}):A(be,{children:[A("span",{style:{display:"inline-flex",alignItems:"center",gap:ye(e)?8:0},children:[y?n("img",{src:b,alt:"","aria-hidden":"true",onError:()=>v(!0),loading:"lazy",decoding:"async",width:30,height:20,style:{width:30,height:20,flexShrink:0,borderRadius:3,objectFit:"contain",display:"inline-flex"}}):null,!y&&c?.logoSvg?n("span",{"aria-hidden":"true",style:{width:30,height:20,flexShrink:0,display:"inline-flex",borderRadius:3,overflow:"hidden"},dangerouslySetInnerHTML:{__html:c.logoSvg}}):null,n("span",{children:j(e)})]}),p&&n("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:P,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",right:"1rem",top:"50%",transform:"translateY(-50%)",flexShrink:0,opacity:.7},"aria-hidden":"true",children:n("path",{d:"M9 18l6-6-6-6"})})]})})}function Q(e){let o=new Set(e.map(fe));return Object.fromEntries(["applePay","googlePay","paypal","link","amazonPay","klarna"].map(t=>[t,o.has(t)?"auto":"never"]))}var Z={buttonType:{applePay:"plain",googlePay:"plain"},layout:{maxColumns:1,overflow:"never"}},ee={type:"accordion",defaultCollapsed:!1,radios:"never"};function te({testId:e,attributes:o,disabled:t,onClick:r,color:l,borderRadius:p,style:s,children:f}){return n("button",{type:"button","data-testid":e,...o,onClick:r,disabled:t,style:{width:"100%",marginTop:"0.75rem",padding:"0.875rem",backgroundColor:l,color:"white",border:"none",borderRadius:p,fontSize:"1rem",fontWeight:600,cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"opacity 120ms ease-out",...s??{}},children:f})}import{Fragment as ae,jsx as m,jsxs as U}from"react/jsx-runtime";var ne={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"}},O=new Map;function Ae(e){let o=O.get(e);if(o)return o;let t=Ie(e).catch(r=>{throw O.delete(e),r});return O.set(e,t),t}function Oe(e){return e?Pe(e):void 0}function Ue(e){return z(e)||e.code==="setup_intent_authentication_failure"||e.code==="payment_method_provider_decline"}function re(e){return e==="paypal"?"PayPal":ke(e)}function Ne(){return typeof window>"u"?"":window.location.href}var De={position:"absolute",width:"100%",height:0,overflow:"hidden",visibility:"hidden",pointerEvents:"none"};function ot(e){let{publishableKey:o,method:t,currency:r,futureUse:l,futureUseUnsupported:p,appearance:s}=e,[f]=S(()=>Ae(o)),d=Be(()=>{let h=Oe(s),g=Ce({futureUse:l,futureUseUnsupported:p},t,"setup");return{mode:"setup",currency:r.toLowerCase(),allowedPaymentMethodTypes:ne[t]?.types??[t],...g?{setupFutureUsage:g}:{},...h?{appearance:h}:{}}},[s,r,l,p,t]);return m(Re,{stripe:f,options:d,children:m(He,{...e})})}function He({method:e,category:o,sessionId:t,nonce:r,billingApiUrl:l,telemetry:p,appearance:s,themeId:f,buttonsLayout:d,onSubmitting:h,onConfirmed:g,onDeclined:C,onFailed:c,onValidation:b,onUnavailable:E}){let v=Le(),y=Te(),[k,w]=S(!1),[P,N]=S("loading"),[se,ie]=S(!1),[R,le]=S(!1),T=Fe(!1),[x]=S(()=>K()),[pe,de]=S(!1),L=oe((a,u)=>{if(Y(a,{inAppBrowser:x.inAppBrowser,handoffObserved:!1}).popupBlocked){de(!0),c(new Error(X(re(e),!0,x.inAppBrowser)),{code:"popup_blocked",retryable:!0});return}c(u.message===void 0?a:new Error(u.message),{code:u.code,retryable:!0})},[x.inAppBrowser,e,c]),D=oe(async a=>{let u=!1,B=!1,F=()=>{!a||u||B||(B=!0,a.paymentFailed({reason:"fail"}))};if(!v||!y||T.current){F();return}T.current=!0,w(!0);try{let _=await y.submit();if(_.error){F(),b(_.error.message??null);return}h();let M=await new ve(l,{telemetry:p}).createSessionIntent(t,r,{provider:"stripe",paymentMethodCategory:o,paymentMethodType:e,paymentMethodId:null,intentKind:"setup"});if(xe(M))throw we(t);if(M.provider!=="stripe"||M.intentKind!=="setup")throw new Ee("The billing API returned a non-setup intent.","api_error",{code:"InvalidSessionIntentResponse"});u=!0;let i=await v.confirmSetup({elements:y,clientSecret:M.clientSecret,confirmParams:{return_url:Ne()},redirect:"if_required"});if(i.error){Ue(i.error)?C({...i.error.decline_code||i.error.code?{reason:i.error.decline_code??i.error.code}:{},...i.error.message?{message:i.error.message}:{}}):L(i.error,{code:"payment_method_setup_provider_failed",message:i.error.message??"The payment method could not be saved."});return}g()}catch(_){F(),L(_,{code:"payment_method_setup_failed"})}finally{T.current=!1,w(!1)}},[l,o,y,e,r,g,C,h,b,L,t,v,p]),I=ne[e]?.wallet,ce=I==="paypal"&&W(x,"auto",pe?"blocked":x.popupCapability)==="redirect",H=s?.variables?.borderRadius??d?.cardButton?.borderRadius??8;if(o==="wallet"&&I&&!ce)return U(ae,{children:[m(G,{}),m(q,{state:P,borderRadius:H,children:m(_e,{options:{...Z,paymentMethods:Q([e])},onReady:a=>{let u=V(a,[I]);N(u),u==="unavailable"&&E()},onLoadError:()=>{N("load_error"),E()},onConfirm:a=>{D(a)}})})]});let ue=re(e);return U(ae,{children:[se?m(J,{method:e,themeId:f,hasNextStep:!0,highlighted:R,disabled:k,onClick:()=>le(a=>!a),backgroundColor:d?.cardButton?.backgroundColor,borderColor:d?.cardInputBorder,textColor:d?.cardButton?.color,borderRadius:H}):null,U("div",{"data-testid":`flopay-stripe-method-form-${e}`,"aria-hidden":!R,style:R?{display:"flex",flexDirection:"column"}:De,children:[m(Me,{options:{layout:ee},onReady:()=>ie(!0),onLoadError:()=>E(),onChange:a=>{a.complete&&b(null)}}),m(te,{testId:`flopay-payment-method-save-${e}`,attributes:{"data-flopay-payment-method-save":e},disabled:!v||!y||k||!R,onClick:()=>{D()},color:s?.variables?.colorPrimary??"#4A49FF",borderRadius:s?.variables?.borderRadius??"8px",style:d?.submitButton,children:k?"Saving\u2026":`Save ${ue}`})]})]})}export{Se as a,G as b,V as c,q as d,We as e,J as f,Q as g,Z as h,ee as i,te as j,ot as k};
@@ -1,6 +0,0 @@
1
- import{useEffect as J,useRef as S}from"react";import{mergeCardSetupSurface as ie}from"@flopay/shared";var ge=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 Ce(e){let r=e.replace(/^(Webkit|Moz|ms)(?=[A-Z])/,"");return ge.has(r.charAt(0).toLowerCase()+r.slice(1))}function he(e,r){return typeof r=="number"&&r!==0&&!Ce(e)?`${r}px`:String(r).trim()}function se(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]=he(t,o)}}}import{useEffect as Se,useLayoutEffect as ve}from"react";var le=typeof window>"u"?Se:ve;import{jsx as H,jsxs as Re}from"react/jsx-runtime";var K=new WeakSet;function ue({capture:e,html:r,messageToken:t,expectedOrigin:o,expiresAt:d,verificationRequired:R,theme:a,submitLabel:p,containerStyle:b,onReady:_,onError:M,onValidation:V}){let x=S(null),D=S(_),P=S(M),u=S(V);D.current=_,P.current=M,u.current=V;let E=S(a);E.current=a;let f=S(null),m=p??void 0,w=S(m);w.current=m;let T=S(void 0);return J(()=>{let y=x.current;if(!y)return;let s=!0,Y=!1,k=()=>{!s||Y||(Y=!0,D.current?.())},g=e.on("ready",()=>{k()}),I=e.on("error",C=>{P.current?.(C.message??"There was a problem loading the secure card form.")}),X=e.on("validation",C=>{u.current?.(C.message??null)}),N=w.current??(K.has(e)?null:void 0),G={html:r,...t?{messageToken:t}:{},...o?{expectedOrigin:o}:{},...typeof d=="string"?{expiresAt:d}:{},...R?{verificationRequired:!0}:{},...E.current?{theme:E.current}:{},...N===void 0?{}:{submitLabel:N}};return f.current=E.current??null,T.current=w.current,w.current!==void 0&&K.add(e),e.mount(y,G).then(()=>{k()}).catch(C=>{s&&P.current?.(C instanceof Error?C.message:"Failed to load the secure card form.")}),()=>{s=!1,g(),I(),X(),e.unmount()}},[e,r,t,o,d,R]),le(()=>{let y=x.current;y&&se(y,b)},[b]),J(()=>{a!==void 0&&(a===null&&f.current===null||(f.current=a,e.applyTheme?.(a)))},[e,a]),J(()=>{m!==T.current&&(T.current=m,m!==void 0&&K.add(e),e.setSubmitLabel?.(m??null))},[e,m]),H("div",{ref:x,"data-testid":"flopay-vault-card-fields"})}function Ue({label:e}){return Re("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",margin:"0.5rem 0 0.75rem",color:"#999",fontSize:"0.85rem"},children:[H("div",{style:{flex:1,height:1,backgroundColor:"#ddd"}}),H("span",{children:e}),H("div",{style:{flex:1,height:1,backgroundColor:"#ddd"}})]})}import{PaymentAPI as xe,PciVaultCardCapture as Pe}from"@flopay/js/card-setup";import{FloPayError as F,isCardSetupCheckoutSession as Te,isMountableVaultBlock as ke,resolveBillingApiUrl as Oe,resolveVaultMountOptions as Ae}from"@flopay/shared";import{useEffect as Q,useMemo as fe,useRef as c,useState as B}from"react";import{computeCardSetupOverlayTheme as Ye,resolveCardSetupTheme as be}from"@flopay/shared";import{mergeButtonsStyles as qe}from"@flopay/shared";function ce(e){let r=be(e);return{...r,surface:r.surface,overlayTheme:r.overlayTheme}}import{invokeMerchantCallback as v}from"@flopay/shared";import{jsx as l,jsxs as L}from"react/jsx-runtime";var Ee={panel:{background:"white"},spinnerTrackColor:"#e5e7eb",spinnerAccentColor:"#4A49FF",labelColors:{processing:"#374151",success:"#16a34a",error:"#dc2626"},noteColor:"#6b7280"};function de({status:e,errorMessage:r,authorized:t=!1,processingLabel:o="PROCESSING...",successLabel:d,errorLabel:R="PAYMENT FAILED",successNote:a="You will be automatically redirected, do not close or navigate away from this window.",theme:p=Ee}){let b={fontSize:13,color:p.noteColor,fontWeight:400,maxWidth:260,lineHeight:1.4,margin:0};return l("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:L("div",{"data-testid":"flopay-processing-overlay-panel",style:{borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.18)",...p.panel,padding:"2rem 2.5rem",textAlign:"center",minWidth:240,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[L("div",{style:{width:48,height:48,position:"relative"},children:[e==="processing"&&L("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:[l("circle",{cx:"12",cy:"12",r:"10",stroke:p.spinnerTrackColor,strokeWidth:"3"}),l("path",{d:"M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z",fill:p.spinnerAccentColor})]}),e==="success"&&l("div",{style:{animation:"flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)"},children:L("svg",{"aria-hidden":"true",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l("circle",{cx:"12",cy:"12",r:"11",fill:"#22c55e"}),l("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"&&l("div",{style:{animation:"flopay-shake 0.4s ease"},children:L("svg",{"aria-hidden":"true",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l("circle",{cx:"12",cy:"12",r:"11",fill:"#ef4444"}),l("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"}})]})})]}),L("span",{style:{fontSize:14,fontWeight:600,letterSpacing:"0.05em",color:p.labelColors[e]},children:[e==="processing"&&o,e==="success"&&(d??(t?"PAYMENT AUTHORISED":"PAYMENT SUCCESSFUL")),e==="error"&&R]}),e==="success"&&a!==null&&l("p",{style:b,children:a}),e==="error"&&r&&l("p",{style:b,children:r}),l("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
- `})]})})}import{Fragment as ye,jsx as q,jsxs as Le}from"react/jsx-runtime";var ee=class extends F{constructor(r,t,o){super(r,t,o),this.name="FloPayCardSetupError",this.retryable=o.retryable}};function me(e,r={}){let t=e instanceof F?e:void 0,o=t?.statusCode,d=r.retryable??(t?.type==="network_error"||t?.type==="rate_limit_error"||typeof o=="number"&&o>=500||t?.code==="vault_capture_timeout"||!t);return new ee(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:d,...t?.param?{param:t.param}:{},...o===void 0?{}:{statusCode:o}})}function ar({sessionId:e,nonce:r,billingApiUrl:t,telemetry:o,theme:d="modern-light",containerStyle:R,appearance:a,buttonsStyles:p,loading:b=null,onReady:_,onComplete:M,onDecline:V,onCancel:x,onValidation:D,onError:P}){let[u,E]=B(null),[f,m]=B(null),[w,T]=B(null),[y,s]=B(null),[Y,k]=B(null),g=c(!1),I=c(!1),{vaultTheme:X,surface:N,overlayTheme:G}=fe(()=>ce({theme:d,appearance:a,buttonsStyles:p}),[d,a,p]),C=fe(()=>ie(N,R),[N,R]),re=c(_),j=c(P),te=c(M),oe=c(V),ne=c(x),ae=c(D),U=c(!1),Z=c(!1),$=c(0);return re.current=_,j.current=P,te.current=M,oe.current=V,ne.current=x,ae.current=D,Q(()=>{let n=$.current+1;return $.current=n,()=>{queueMicrotask(()=>{$.current===n&&(U.current||Z.current||(Z.current=!0,v(()=>{ne.current?.({status:"cancelled",sessionId:e})})))})}},[e]),Q(()=>{let n=!0,O=Oe(t),W=new xe(O,{telemetry:o});return E(null),m(null),T(null),U.current=!1,Z.current=!1,(async()=>{try{if(!e.trim())throw new F("FloPayCardSetup requires a sessionId.","validation_error",{code:"MissingCheckoutSessionId",param:"sessionId"});if(!r.trim())throw new F("FloPayCardSetup requires a session nonce.","validation_error",{code:"MissingCheckoutSessionToken",param:"nonce"});let z=await W.getUnifiedCheckoutSession(e,r);if(!n)return;let h=z.data.session;if(!h||!Te(h))throw new F("FloPayCardSetup only accepts a zero-amount, productless setup session.","validation_error",{code:"InvalidCardSetupSession",param:"sessionId"});let i=h.vault;ke(i)||(i=await W.getVaultCapture(e,r));let A=Ae(i,{billingApiUrl:O,sessionId:e,nonce:r});if(!A)throw new F("FloPay: this setup session has no vault card capability. Upgrade the billing backend integration.","api_error",{code:"UnsupportedBackendVaultCapability"});if(!n)return;m(A),E(new Pe({sessionId:e,operation:"card_setup",telemetry:o}))}catch(z){if(!n)return;let h=me(z);U.current=!0,T(h),v(()=>j.current?.(h))}})(),()=>{n=!1,W.destroy()}},[t,r,e,o]),Q(()=>{if(!u)return;let n=!1;I.current=!1,g.current=!1;let O=u.on("submitting",()=>{g.current=!0,k(null),s("processing")}),W=u.on("complete",i=>{U.current=!0,g.current=!1,s("success"),(async()=>(await new Promise(A=>setTimeout(A,600)),!I.current&&(I.current=!0,v(()=>{te.current?.({status:"succeeded",sessionId:e,...i.paymentMethod?{paymentMethod:i.paymentMethod}:{}})}),n||s(null))))()}),z=u.on("decline",i=>{U.current=!0,g.current=!1,k(i.message??null),s("error"),v(()=>{oe.current?.({status:"declined",sessionId:e,...i.declineReason?{reason:i.declineReason}:{},...i.message?{message:i.message}:{}})}),(async()=>(await new Promise(A=>setTimeout(A,400)),n||s(null)))()}),h=u.on("challenge_dismissed",()=>{s(null)});return()=>{n=!0,O(),W(),z(),h()}},[u,e]),w?q("div",{role:"alert",children:w.message}):!u||!f?.html?q(ye,{children:b}):Le(ye,{children:[y&&q(de,{status:y,errorMessage:Y,processingLabel:"SAVING CARD...",successLabel:"CARD SAVED",errorLabel:"CARD NOT SAVED",successNote:null,...G?{theme:G}:{}}),q(ue,{capture:u,html:f.html,messageToken:f.messageToken,expectedOrigin:f.expectedOrigin,expiresAt:f.expiresAt,verificationRequired:f.verificationRequired,theme:X,containerStyle:C,onReady:()=>{v(()=>re.current?.())},onValidation:n=>{v(()=>ae.current?.(n))},onError:n=>{if(!n)return;g.current&&(g.current=!1,k(n),s("error"),setTimeout(()=>s(null),400));let O=me(new Error(n),{code:"card_setup_widget_failed",retryable:!0});v(()=>j.current?.(O))}})]})}export{ie as a,ce as b,v as c,de as d,le as e,ue as f,Ue as g,ee as h,me as i,ar as j};
@@ -1 +0,0 @@
1
- import{a as Te,b as De,c as g,d as Le,f as Ne,g as We,i as w}from"./chunk-ITRFSHZP.mjs";import{PaymentAPI as ze,PciVaultCardCapture as ot}from"@flopay/js/card-setup";import{FloPayError as b,isCardSetupCheckoutSession as st,isMountableVaultBlock as it,resolveBillingApiUrl as Z,resolveVaultMountOptions as lt}from"@flopay/shared";import ut,{Suspense as $e,useCallback as k,useEffect as ee,useMemo as te,useRef as l,useState as P}from"react";import{clearSetupRedirectParams as Ye,readSetupRedirectReturn as qe}from"@flopay/js/card-setup";import{advertisedMethodKeys as X,advertisesAnyMethod as Ge,readSetupAdvertisement as Ke,setupOverlayLabels as je,stripeMethodCategory as N}from"@flopay/shared";import{Fragment as Je,jsx as d,jsxs as ne}from"react/jsx-runtime";var dt=15,ct=2e3;function pt(p){return{userId:p.customer?.id??"",email:p.customer?.email??""}}function re(p){return new Promise(h=>setTimeout(h,p))}async function mt(p,h,a){if(!h.trim())throw new b("FloPayPaymentMethodSetup requires a sessionId.","validation_error",{code:"MissingCheckoutSessionId",param:"sessionId"});if(!a.trim())throw new b("FloPayPaymentMethodSetup requires a session nonce.","validation_error",{code:"MissingCheckoutSessionToken",param:"nonce"});let u=await p.getUnifiedCheckoutSession(h,a),m=u.data.session;if(!m||!st(m))throw new b("FloPayPaymentMethodSetup only accepts a zero-amount, productless setup session.","validation_error",{code:"InvalidPaymentMethodSetupSession",param:"sessionId"});let o=Ke(u);if(!Ge(o)){let{skippedForMissingCurrency:f}=o,V=f.length>0?`FloPay: this setup session advertises only Stripe methods (${f.join(", ")}), and they need the session's currency, which the setup-session read did not carry.`:"FloPay: this setup session advertises no payment method.";throw new b(V,"validation_error",{code:"NoAdvertisedPaymentMethods",param:"sessionId"})}return{session:m,advertisement:o}}async function yt(p,h,a,u,m){let o=h.vault??null;it(o)||(o=await p.getVaultCapture(a,u));let f=lt(o,{billingApiUrl:m,sessionId:a,nonce:u});if(!f)throw new b("FloPay: this setup session has no vault card capability. Upgrade the billing backend integration.","api_error",{code:"UnsupportedBackendVaultCapability"});return f}var W=class extends ut.Component{constructor(){super(...arguments);this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(a){this.props.onFailed(a,{code:"payment_method_setup_load_failed",retryable:!1})}render(){return this.state.failed?null:this.props.children}};function Et({branches:{StripeSetupMethod:p,PayPalSetupMethod:h},sessionId:a,nonce:u,billingApiUrl:m,telemetry:o,theme:f="modern-light",containerStyle:V,appearance:ae,buttonsStyles:oe,loading:Qe=null,onReady:se,onComplete:ie,onDecline:le,onCancel:ue,onValidation:de,onError:ce}){let[Y]=P(qe),[x,q]=P(null),[Xe,G]=P(!1),[v,pe]=P(null),[F,me]=P(null),[ye,fe]=P(null),[I,c]=P(null),[K,j]=P(()=>new Set),M=l(K),H=l(null);H.current=x;let S=l(!1),z=l(!1),A=l(!1),$=l(!1),J=l(0),T=l(0),_=l(!1),{vaultTheme:Ze,surface:he,overlayTheme:ve,appearance:Se,buttonsLayout:ge}=te(()=>De({theme:f,appearance:ae,buttonsStyles:oe}),[f,ae,oe]),et=te(()=>Te(he,V),[he,V]),s=l({sessionId:a,nonce:u,billingApiUrl:m,telemetry:o,onReady:se,onComplete:ie,onDecline:le,onCancel:ue,onValidation:de,onError:ce});s.current={sessionId:a,nonce:u,billingApiUrl:m,telemetry:o,onReady:se,onComplete:ie,onDecline:le,onCancel:ue,onValidation:de,onError:ce},ee(()=>{_.current=!0;let e=J.current+1;return J.current=e,()=>{_.current=!1,T.current+=1,queueMicrotask(()=>{J.current===e&&(A.current||$.current||($.current=!0,g(()=>{s.current.onCancel?.({status:"cancelled",sessionId:a})})))})}},[a]);let E=k((e,t)=>{A.current=!0,S.current=!1,c({status:"success",wording:e,message:null}),(async()=>(await re(600),!z.current&&(z.current=!0,g(()=>{s.current.onComplete?.({status:"succeeded",sessionId:s.current.sessionId,...t?{paymentMethod:t}:{}})}),_.current&&c(null))))()},[]),U=k((e,t)=>{A.current=!0,S.current=!1,c({status:"error",wording:e,message:t.message??null}),g(()=>{s.current.onDecline?.({status:"declined",sessionId:s.current.sessionId,...t.reason?{reason:t.reason}:{},...t.message?{message:t.message}:{}})}),(async()=>(await re(400),_.current&&c(null)))()},[]),C=k((e,t)=>{S.current?(S.current=!1,c({status:"error",wording:e,message:t.message}),setTimeout(()=>{_.current&&c(null)},400)):c(null),g(()=>s.current.onError?.(t))},[]),D=k(async e=>{let t=T.current+1;T.current=t;let n=()=>!_.current||t!==T.current;S.current=!0,c({status:"processing",wording:"payment_method",message:null});let i=new ze(Z(s.current.billingApiUrl),{telemetry:s.current.telemetry});try{for(let r=0;r<dt;r+=1){if((r>0||e.waitFirst)&&await re(ct),n())return;let y=await i.getUnifiedCheckoutSession(s.current.sessionId,s.current.nonce);if(n())return;let R=y.data.session?.status;if(R==="complete"){G(!0),E("payment_method");return}if(R==="expired")throw new b("This setup session expired before the payment method was saved.","validation_error",{code:"payment_method_setup_expired"})}throw new b("The payment method could not be confirmed yet. Please try again.","api_error",{code:"payment_method_setup_unverified"})}catch(r){if(n())return;let y=r instanceof b&&r.code==="payment_method_setup_unverified";C("payment_method",w(r,y?{retryable:!0}:{}))}finally{i.destroy()}},[C,E]);ee(()=>{let e=!0,t=Z(m),n=new ze(t,{telemetry:o});q(null),G(!1),pe(null),me(null),fe(null);let i=new Set;return M.current=i,j(i),A.current=!1,$.current=!1,z.current=!1,(async()=>{try{let{session:r,advertisement:y}=await mt(n,a,u);if(!e)return;let R={advertisement:y,customer:pt(r),...r.futureUse?{futureUse:r.futureUse}:{},...r.futureUseUnsupported?{futureUseUnsupported:r.futureUseUnsupported}:{}};if(Y){if(Ye(),r.status==="complete"){G(!0),q(R),E("payment_method");return}Y.failed?U("payment_method",{reason:"redirect_failed"}):D({waitFirst:!0})}let Ie=y.card?await yt(n,r,a,u,t):null;if(!e)return;q(R),Ie&&(me(Ie),pe(new ot({sessionId:a,operation:"card_setup",telemetry:o})))}catch(r){if(!e)return;let y=w(r);A.current=!0,fe(y),g(()=>s.current.onError?.(y))}})(),()=>{e=!1,n.destroy()}},[m,u,Y,U,E,a,o,D]),ee(()=>{if(!v)return;S.current=!1;let e=v.on("submitting",()=>{S.current=!0,c({status:"processing",wording:"card",message:null})}),t=v.on("complete",r=>{E("card",r.paymentMethod)}),n=v.on("decline",r=>{U("card",{...r.declineReason?{reason:r.declineReason}:{},...r.message?{message:r.message}:{}})}),i=v.on("challenge_dismissed",()=>{c(null)});return()=>{e(),t(),n(),i()}},[v,U,E]);let Ce=k((e,t,n)=>{if(n.retryable){C("payment_method",w(t,n));return}if(M.current.has(e))return;let i=new Set(M.current);i.add(e),M.current=i,j(i);let r=H.current?.advertisement,y=r?X(r).some(R=>!i.has(R)):!1;C("payment_method",w(t,{code:n.code,retryable:y}))},[C]),Pe=te(()=>({onSubmitting:()=>{S.current=!0,c({status:"processing",wording:"payment_method",message:null})},onConfirmed:()=>{D({waitFirst:!1})},onDeclined:e=>U("payment_method",e),onValidation:e=>{g(()=>s.current.onValidation?.(e))},onAbandoned:()=>{S.current=!1,c(null)}}),[U,D]),be=l(Ce);be.current=Ce;let Fe=l(new Map),L=e=>{let t=Fe.current.get(e);if(t)return t;let n=(i,r)=>be.current(e,i,r);return Fe.current.set(e,n),n},Me=k(e=>{if(M.current.has(e))return;let t=new Set(M.current);t.add(e),M.current=t,j(t);let n=H.current?.advertisement;n&&X(n).some(r=>!t.has(r))||C("payment_method",w(new Error("FloPay: none of the advertised payment methods can be used here."),{code:"payment_method_setup_unavailable",retryable:!1}))},[C]),Re=l(Me);Re.current=Me;let we=l(new Map),_e=e=>{let t=we.current.get(e);if(t)return t;let n=()=>Re.current(e);return we.current.set(e,n),n},Ee=I?d(Le,{status:I.status,errorMessage:I.message,...je(I.wording),successNote:null,...ve?{theme:ve}:{}}):null;if(ye)return d("div",{role:"alert",children:ye.message});if(!x||Xe)return ne(Je,{children:[Ee,x?null:Qe]});let{advertisement:B,customer:tt,futureUse:Ue,futureUseUnsupported:ke}=x,Ae=Z(m),Be=o===void 0?{}:{telemetry:o},Q=B.stripe.filter(({method:e})=>!K.has(e)),O=K.has("paypal")?null:B.paypal,Oe=!!(B.card&&v&&F?.html),Ve=({method:e,publishableKey:t,currency:n})=>d("div",{"data-flopay-payment-method":e,style:{display:"contents"},children:d(W,{onFailed:L(e),children:d($e,{fallback:null,children:d(p,{method:e,category:N(e),publishableKey:t,currency:n,...Ue?{futureUse:Ue}:{},...ke?{futureUseUnsupported:ke}:{},sessionId:a,nonce:u,billingApiUrl:Ae,...Be,...Se?{appearance:Se}:{},...ge?{buttonsLayout:ge}:{},...typeof f=="string"?{themeId:f}:{},...Pe,onFailed:L(e),onUnavailable:_e(e)})})})},e),rt=Q.filter(({method:e})=>N(e)==="wallet"),nt=Q.filter(({method:e})=>N(e)!=="wallet"),xe=Q.length>0||O!==null;return ne(Je,{children:[Ee,xe?ne("div",{"data-flopay-payment-methods":"",style:{position:"relative",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[rt.map(Ve),O?d("div",{"data-flopay-payment-method":"paypal",children:d(W,{onFailed:L("paypal"),children:d($e,{fallback:null,children:d(h,{clientId:O.clientId,...O.environment?{environment:O.environment}:{},...B.currency?{currency:B.currency}:{},sessionId:a,nonce:u,billingApiUrl:Ae,customer:tt,...Be,...Pe,onFailed:L("paypal"),onUnavailable:_e("paypal")})})})}):null,nt.map(Ve)]}):null,Oe&&xe?d(We,{label:"or add a card"}):null,Oe&&v&&F?.html?d("div",{"data-flopay-payment-method":"card",children:d(Ne,{capture:v,html:F.html,messageToken:F.messageToken,expectedOrigin:F.expectedOrigin,expiresAt:F.expiresAt,verificationRequired:F.verificationRequired,theme:Ze,containerStyle:et,onReady:()=>{g(()=>s.current.onReady?.())},onValidation:e=>{g(()=>s.current.onValidation?.(e))},onError:e=>{e&&C("card",w(new Error(e),{code:"card_setup_widget_failed",retryable:!0}))}})}):null]})}export{Et as a};
@@ -1 +0,0 @@
1
- import{buildExternalMethodRecoveryMessage as o,classifyExternalMethodFailure as t,EXTERNAL_METHOD_CALLBACK_GRACE_MS as n,getProviderDeclineCode as a,getProviderErrorCode as i,isPayPalAcknowledgementDeadWindow as l,isPopupBlockedError as s,isProviderDecline as P,sanitizeExternalFailureCode as d}from"@flopay/shared";import{detectPayPalEnvironment as E}from"@flopay/shared";import{detectPayPalEnvironment as v}from"@flopay/shared";import{resolvePayPalPresentationMode as f,resolveStripePayPalPresentation as x}from"@flopay/shared";export{o as a,t as b,n as c,a as d,i as e,l as f,s as g,P as h,d as i,v as j,f as k,x as l};
package/dist/context.d.ts DELETED
@@ -1,46 +0,0 @@
1
- import type { FloPay } from '@flopay/js';
2
- import type { CheckoutMode, CheckoutSession, FloPayError, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
3
- import type { EmitFloInstrument } from './instruments.js';
4
- /** Internal context value for the FloPay provider. */
5
- export interface FloPayContextValue {
6
- flopay: FloPay | null;
7
- /**
8
- * Stripe FloPay instance used for the Stripe-rendered PayPal fallback. When
9
- * direct PayPal (`gateways.paypal`) is configured this isn't used for
10
- * rendering — DirectPayPalButton talks to PayPal directly — but the
11
- * Stripe-PayPal saved-PM redirect leg still relies on it.
12
- * `null` or absent means the Stripe-rendered PayPal fallback is unavailable.
13
- */
14
- paypalFlopay?: FloPay | null;
15
- billingApiUrl: string;
16
- /** Emit the privacy-safe merchant instrument projection. */
17
- emitInstrument?: EmitFloInstrument;
18
- }
19
- /** Internal context value for checkout state. */
20
- export interface CheckoutContextValue {
21
- session: CheckoutSession | null;
22
- loading: boolean;
23
- error: FloPayError | null;
24
- checkoutMode?: CheckoutMode;
25
- inlineSessionDraft?: InlineSessionDraft;
26
- applyInlineSessionPatch?: (patch: InlineSessionPatch) => Promise<{
27
- sessionId: string;
28
- session: CheckoutSession | null;
29
- }>;
30
- inlineSessionPatchProcessing?: boolean;
31
- /** True while catalog data is being attached to a detached shell. */
32
- claimPending?: boolean;
33
- /** @deprecated Catalog attachment no longer waits for buyer identity; always false/absent. */
34
- claimRequiresIdentity?: boolean;
35
- /**
36
- * Attach late buyer identity to a still-anonymous session
37
- * (`buyerIdentified: false`) via `PATCH /claim`. A no-op once the session is
38
- * identified. `SplitCardForm` falls back to this when the merchant composes
39
- * it as a custom-layout child without wiring `onBuyerIdentityReady`.
40
- */
41
- claimBuyerIdentity?: (identity: NonNullable<InlineSessionPatch['account']>) => Promise<void>;
42
- /** Resolves once the detached shell has its cart/catalog attached and is safe to charge. */
43
- waitForDataAttachment?: () => Promise<void>;
44
- }
45
- export declare const FloPayContext: import("react").Context<FloPayContextValue>;
46
- export declare const CheckoutContext: import("react").Context<CheckoutContextValue>;
@@ -1,155 +0,0 @@
1
- import type { CheckoutButtonMethod, CheckoutSession, DeclineEvent, FloInstrumentEvent, FloPayPaymentCancelEvent, GatewayEnvironment, InlineSessionPatch, PaymentResult, PayPalApprovalPresentation, PayPalProviderObjectType, TelemetryPresentationMode, TelemetryTerminalReason, TokenizedBody } from '@flopay/shared';
2
- import type React from 'react';
3
- import type { TelemetryCheckoutContext } from './telemetry-bridge.js';
4
- /**
5
- * Overrides that `SplitCardForm`'s tokenized-body dispatcher uses to apply a
6
- * `runBeforeButtonClick` patch to the in-flight processPayment call. Kept in
7
- * sync structurally with `TokenizedBodyOverrides` in `split-card-form.tsx`.
8
- */
9
- interface DirectPayPalTokenizedOverrides {
10
- accountPatch?: InlineSessionPatch['account'];
11
- sessionId?: string;
12
- nonce?: string;
13
- }
14
- /**
15
- * Internal handler signature aligned with `SplitCardForm`'s tokenized-body
16
- * dispatcher. Direct PayPal completes via the backend's process endpoint and
17
- * never produces a Stripe PaymentIntent, so we still forward a synthetic
18
- * `TokenizedBody` describing the captured order, optionally with the
19
- * session/account patch captured at click-time.
20
- */
21
- type DirectPayPalTokenizedHandler = (body: TokenizedBody, overrides?: DirectPayPalTokenizedOverrides) => void;
22
- /** Click-time `runBeforeButtonClick` result, structurally compatible with `SplitCardForm`. */
23
- interface DirectPayPalBeforeButtonClickResult {
24
- proceed: boolean;
25
- accountPatch?: InlineSessionPatch['account'];
26
- sessionId?: string;
27
- nonce?: string;
28
- }
29
- /**
30
- * Click-time gate. Mirrors `RunBeforeButtonClick` in `SplitCardForm`: lets the
31
- * consumer patch the session/account before PayPal creates the order, and lets
32
- * them abort the click entirely by returning `proceed: false`.
33
- */
34
- type DirectPayPalRunBeforeButtonClick = (method: CheckoutButtonMethod) => Promise<DirectPayPalBeforeButtonClickResult>;
35
- export type DirectPayPalInitializationState = 'loading' | 'retrying' | 'ready' | 'exhausted';
36
- interface DirectPayPalTechnicalFailureOptions {
37
- code?: string;
38
- popupBlocked?: boolean;
39
- telemetryReported?: boolean;
40
- provider?: 'paypal';
41
- paymentMethodCategory?: 'paypal';
42
- presentationMode?: TelemetryPresentationMode;
43
- terminalReason?: TelemetryTerminalReason;
44
- }
45
- type DirectPayPalTechnicalFailureHandler = (method: 'paypal', err: unknown, options?: DirectPayPalTechnicalFailureOptions) => void;
46
- export interface DirectPayPalButtonProps {
47
- /** Checkout session ID. */
48
- sessionId: string;
49
- /**
50
- * Session-bound checkout token returned by session creation. Forwarded as
51
- * `x-checkout-session-token` on every continuation request — required by
52
- * post-#640 backends. `FloPayCheckout` plumbs this prop automatically.
53
- */
54
- nonce?: string;
55
- /** Billing API base URL. */
56
- billingApiUrl: string;
57
- /** Buyer email. */
58
- email?: string;
59
- /** Buyer name already attached to the checkout, when available. */
60
- billingName?: string;
61
- /** Attaches buyer identity collected from PayPal before checkout continues. */
62
- onBuyerIdentityReady?: (identity: NonNullable<InlineSessionPatch['account']>) => void | Promise<void>;
63
- /** PayPal client identifier (`gateways.paypal.publishableKey`). */
64
- clientId: string;
65
- /** Gateway environment, drives the sandbox/live SDK script. */
66
- environment?: GatewayEnvironment;
67
- /** ISO 4217 currency code. */
68
- currency: string;
69
- /** Whether the session is a subscription (drives intent + flow selection). */
70
- isSubscription: boolean;
71
- /**
72
- * @deprecated Pass the backing {@link DirectPayPalButtonProps.session}; its
73
- * `gateways.paypal.providerObjectType` advertisement is authoritative. This
74
- * prop remains as a fallback for integrations that have not yet forwarded
75
- * the session. When neither source advertises a provider object, legacy
76
- * sessions continue to derive the flow from `isSubscription`.
77
- */
78
- providerObjectType?: PayPalProviderObjectType;
79
- /**
80
- * Backend-advertised approval presentation. The backing session value is
81
- * authoritative when both are supplied. No return URL can be provided here.
82
- */
83
- approvalPresentation?: PayPalApprovalPresentation;
84
- /**
85
- * If provided, called with the tokenized body once PayPal capture
86
- * completes. When omitted, the component processes payment internally.
87
- */
88
- onTokenizedBody?: DirectPayPalTokenizedHandler;
89
- /** Called when the full self-contained payment flow succeeds. */
90
- onComplete?: (result: PaymentResult) => void;
91
- /** Called when an error occurs. */
92
- onErrorChange?: (error: string | null) => void;
93
- /** Decline emitter (mirrors SplitCardForm semantics). */
94
- onDecline?: (decline: DeclineEvent) => void;
95
- /**
96
- * Called once when the buyer closes or leaves PayPal without approving (pop-up
97
- * or app switch). Never called for an approval, a decline or a technical failure.
98
- */
99
- onCancel?: (event: FloPayPaymentCancelEvent) => void;
100
- /** Called for post-click technical failures before PayPal authorization completes. */
101
- onTechnicalFailure?: DirectPayPalTechnicalFailureHandler;
102
- /** External processing state. */
103
- isProcessing?: boolean;
104
- /** Notify the parent of the loading state for placeholder swapping. */
105
- onLoadStateChange?: (ready: boolean) => void;
106
- /** Notify a PayPal-only wrapper about pre-render recovery state. */
107
- onInitializationStateChange?: (state: DirectPayPalInitializationState) => void;
108
- /** Disable the automatic retry for a buyer-initiated single manual attempt. */
109
- allowAutomaticRetry?: boolean;
110
- /** Tracks button-click for analytics. */
111
- onButtonClick?: (method: CheckoutButtonMethod) => void;
112
- /**
113
- * Click-time gate (runs before PayPal creates the order). When provided, the
114
- * returned patch is applied to the in-flight create-intent and tokenized
115
- * dispatch so callers using `onBeforeButtonClick` see the same session/email
116
- * the Stripe-rendered PayPal flow does.
117
- */
118
- runBeforeButtonClick?: DirectPayPalRunBeforeButtonClick;
119
- /** Backing session — used for self-contained accountData population. */
120
- session?: CheckoutSession | null;
121
- /**
122
- * Pre-existing PayPal Order id (or Subscription id when `isSubscription` is
123
- * true) to bind the button to. When set, the button skips its usual
124
- * session-scoped create-intent round-trip on click and feeds this
125
- * id straight into PayPal's create-order / create-subscription callback.
126
- *
127
- * Used by `SplitCardForm`'s `paypal_direct_required` retry path: backend
128
- * creates a fresh PayPal order after a stalled process attempt and returns
129
- * its id; the SDK re-renders this button bound to that id so the buyer can
130
- * confirm with one more click without the backend re-creating the order on
131
- * each retry.
132
- *
133
- * Changing this value remounts the PayPal SDK so the new createOrder
134
- * binding takes effect (PayPal's render() options aren't live-updatable).
135
- */
136
- existingOrderId?: string;
137
- /** Flo-owned privacy-safe telemetry is enabled by default; set `false` to opt out. */
138
- telemetry?: boolean;
139
- /**
140
- * When true, renders an on-screen lifecycle tracer panel above the button
141
- * (mount, loadScript, eligibility, render, errors). Intended for debugging
142
- * in-app browsers (Facebook IAB, etc.) where remote console access is
143
- * impractical. Off by default — leave disabled in production.
144
- */
145
- debug?: boolean;
146
- }
147
- interface InstrumentedDirectPayPalButtonProps extends DirectPayPalButtonProps {
148
- telemetryContext?: TelemetryCheckoutContext;
149
- onInstrument?: (event: FloInstrumentEvent) => void;
150
- }
151
- /** Public direct-PayPal surface: telemetry accepts only the boolean opt-out. */
152
- export declare function DirectPayPalButton(props: DirectPayPalButtonProps): React.ReactElement | null;
153
- /** Internal FloPayCheckout bridge for closed SDK-owned dimensions. */
154
- export declare function InstrumentedDirectPayPalButton(props: InstrumentedDirectPayPalButtonProps): React.ReactElement | null;
155
- export {};
@@ -1,21 +0,0 @@
1
- import type React from 'react';
2
- /**
3
- * The shared red error banner rendered across the checkout surfaces
4
- * (`role="alert"`, `data-testid="flopay-error"`). Consolidates what were four
5
- * copy-pasted inline blocks so the colours, warning icon, and a11y attributes
6
- * live in one place.
7
- *
8
- * - `margin` — per-call spacing (the call sites use `0.75rem 0 0`, `0.75rem 0`,
9
- * `0.25rem 0`, or none), passed straight to the container.
10
- * - `icon` — the warning glyph + flex layout. Card-form banners show it; the
11
- * simpler PayPal-only mode banner does not, so it opts out with `icon={false}`
12
- * to preserve its original icon-less, non-flex appearance.
13
- * - `styleOverride` — theme-driven overrides (`bStyles.errorBanner`), applied
14
- * last so they win, exactly as the inline versions did.
15
- */
16
- export declare function ErrorBanner({ children, margin, icon, styleOverride, }: {
17
- children: React.ReactNode;
18
- margin?: string | number;
19
- icon?: boolean;
20
- styleOverride?: React.CSSProperties;
21
- }): React.ReactElement;
@@ -1 +0,0 @@
1
- export { buildExternalMethodRecoveryMessage, classifyExternalMethodFailure, EXTERNAL_METHOD_CALLBACK_GRACE_MS, getProviderDeclineCode, getProviderErrorCode, isPayPalAcknowledgementDeadWindow, isPopupBlockedError, isProviderDecline, sanitizeExternalFailureCode, } from '@flopay/shared';
@@ -1,17 +0,0 @@
1
- import type { TelemetryPresentationMode } from '@flopay/shared';
2
- import type { PayPalBrowserEnvironment } from './in-app-browser.js';
3
- import type { PopupCapabilityOwner } from './popup-capability.js';
4
- import type { TelemetryBridge } from './telemetry-bridge.js';
5
- export interface ExternalMethodTelemetryContext {
6
- browser: PayPalBrowserEnvironment;
7
- capability: PopupCapabilityOwner;
8
- presentationMode: TelemetryPresentationMode;
9
- }
10
- export declare function decorateExternalMethodTelemetry<T extends object>(context: ExternalMethodTelemetryContext, input: T): T & {
11
- inAppBrowser: boolean;
12
- appFamily: PayPalBrowserEnvironment['appFamily'];
13
- popupCapability: ReturnType<PopupCapabilityOwner['current']>;
14
- presentationMode: TelemetryPresentationMode;
15
- };
16
- /** Delegates to a telemetry bridge while adding current external-surface dimensions. */
17
- export declare function decorateExternalMethodTelemetryBridge(telemetry: TelemetryBridge | undefined, context: ExternalMethodTelemetryContext): TelemetryBridge | undefined;
@@ -1,114 +0,0 @@
1
- import type { ButtonsLayoutStyles, FloPayAppearance, FloPayErrorType, SavedCardDisplay, ThemeId, VaultCardThemeColors } from '@flopay/shared';
2
- import { FloPayError } from '@flopay/shared';
3
- import type React from 'react';
4
- /** Verified terminal result from a no-charge card setup. */
5
- export interface FloPayCardSetupCompleteEvent {
6
- status: 'succeeded';
7
- sessionId: string;
8
- /** Present when the backend terminal message includes the saved-card display DTO. */
9
- paymentMethod?: SavedCardDisplay;
10
- }
11
- /** Provider-neutral terminal decline from card verification. */
12
- export interface FloPayCardSetupDeclineEvent {
13
- status: 'declined';
14
- sessionId: string;
15
- reason?: string;
16
- message?: string;
17
- }
18
- /** Abandoned setup result emitted when the component unmounts pre-terminally. */
19
- export interface FloPayCardSetupCancelEvent {
20
- status: 'cancelled';
21
- sessionId: string;
22
- }
23
- /** Structured technical/validation failure from the card-setup surface. */
24
- export declare class FloPayCardSetupError extends FloPayError {
25
- readonly retryable: boolean;
26
- constructor(message: string, type: FloPayErrorType, options: {
27
- code: string;
28
- retryable: boolean;
29
- param?: string;
30
- statusCode?: number;
31
- });
32
- }
33
- /** Props for the browser-only secure card-setup surface. */
34
- export interface FloPayCardSetupProps {
35
- /** Opaque id returned by the merchant-authenticated setup-session endpoint. */
36
- sessionId: string;
37
- /** Session-bound token returned alongside {@link FloPayCardSetupProps.sessionId}. */
38
- nonce: string;
39
- /** Billing API base URL. Defaults to the configured FloPay environment URL. */
40
- billingApiUrl?: string;
41
- /** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
42
- telemetry?: boolean;
43
- /**
44
- * Theme for FloPay's hosted, PCI-compliant card widget. Accepts the same
45
- * high-level {@link ThemeId} as `FloPayCheckout` (resolved through the same
46
- * bundle, so one value styles both surfaces identically) or raw
47
- * {@link VaultCardThemeColors} for full manual control. Defaults to
48
- * `'modern-light'`, which an unrecognized preset id also falls back to; pass
49
- * `'classic'` for the historic FloPay look.
50
- */
51
- theme?: ThemeId | VaultCardThemeColors;
52
- /**
53
- * Inline styles for the hosted-widget container. A named preset first gives
54
- * that container the same complete surface as the checkout's credit-card
55
- * pane (background, border, radius, shadow, padding), with any stored
56
- * `buttonsStyles.cardFormContainer` merged over it; each `containerStyle`
57
- * property then wins over that surface for the same property, a longhand
58
- * refines a surface shorthand (`borderColor` recolors the preset border), and
59
- * any `background*` member replaces the surface background entirely.
60
- * Raw colors add no surface. `'classic'` adds one only from a stored
61
- * `buttonsStyles.cardFormContainer`, merged beneath `containerStyle` the same
62
- * way; otherwise `containerStyle` applies alone.
63
- */
64
- containerStyle?: React.CSSProperties;
65
- /**
66
- * Appearance override, the same prop and type as `FloPayCheckout`'s (for
67
- * example a client's saved embed theme `appearance`). It replaces the preset's
68
- * appearance outright, as checkout does: its variables (primary color, text,
69
- * font, radius, …) drive the hosted card fields, the hosted submit button
70
- * and the outcome overlay. Ignored with raw {@link VaultCardThemeColors}; an
71
- * empty `{}` is the same as omitting it. Changes restyle in place.
72
- */
73
- appearance?: FloPayAppearance;
74
- /**
75
- * Buttons-layout style overrides, the same prop and type as
76
- * `FloPayCheckout`'s (for example a client's saved embed theme
77
- * `buttonsStyles`), merged over the preset's buttons layout the way checkout
78
- * merges them. `submitButton` and the `cardInput*` members style the hosted
79
- * card form, and `cardFormContainer` the pane around it and the outcome
80
- * overlay's panel. Ignored with raw {@link VaultCardThemeColors}; an empty
81
- * `{}` is the same as omitting it. Changes restyle in place.
82
- */
83
- buttonsStyles?: ButtonsLayoutStyles;
84
- /** Optional content shown while the session and hosted widget are loading. */
85
- loading?: React.ReactNode;
86
- /** Fired once the hosted widget has mounted and can accept card input. */
87
- onReady?: () => void;
88
- /** Fired only after the backend reports that the card is verified and usable. */
89
- onComplete?: (event: FloPayCardSetupCompleteEvent) => void;
90
- /** Fired when verification terminally declines; never paired with `onComplete`. */
91
- onDecline?: (event: FloPayCardSetupDeclineEvent) => void;
92
- /** Fired exactly once if the setup surface unmounts before a terminal outcome. */
93
- onCancel?: (event: FloPayCardSetupCancelEvent) => void;
94
- /** Live hosted-field validation message, or `null` when validation clears. */
95
- onValidation?: (message: string | null) => void;
96
- /** Fired for setup-session validation, transport, or hosted-widget failures. */
97
- onError?: (error: FloPayCardSetupError) => void;
98
- }
99
- /**
100
- * Unknown failures default to retryable. FloPay errors are retryable only for
101
- * network, rate-limit, 5xx, or vault-timeout failures unless explicitly
102
- * overridden by the caller. Shared with `FloPayPaymentMethodSetup`, which
103
- * reports the same structured errors for every method.
104
- */
105
- export declare function asCardSetupError(error: unknown, overrides?: {
106
- code?: string;
107
- retryable?: boolean;
108
- }): FloPayCardSetupError;
109
- /**
110
- * Mounts FloPay's hosted card capture for a setup session created by the
111
- * merchant's server. It has no customer-id, list, delete, purchase, or Stripe
112
- * Elements surface.
113
- */
114
- export declare function FloPayCardSetup({ sessionId, nonce, billingApiUrl, telemetry, theme, containerStyle, appearance, buttonsStyles, loading, onReady, onComplete, onDecline, onCancel, onValidation, onError, }: FloPayCardSetupProps): React.ReactElement;