@flopay/react 1.14.0 → 1.14.2
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 +10 -1
- package/dist/chunk-MSABDKVT.mjs +22 -0
- package/dist/index.cjs +9 -9
- package/dist/index.mjs +7 -7
- package/dist/payment-method-setup-entry.cjs +3 -3
- package/dist/payment-method-setup-entry.mjs +1 -1
- package/dist/payment-method-setup-stripe-ULXLO3FW.mjs +1 -0
- package/package.json +3 -3
- package/dist/chunk-H4MQCBX4.mjs +0 -22
- package/dist/payment-method-setup-stripe-6O2YE4RY.mjs +0 -1
package/README.md
CHANGED
|
@@ -121,6 +121,10 @@ The payment-method list is gateway-driven: the billing API sends `gateways.strip
|
|
|
121
121
|
|
|
122
122
|
- `showStripe` (default `true`) toggles Stripe wallets and alternative methods; `showPayPal` (default `true`) toggles PayPal. Turning both off with no PayPal gateway is reported through `onError` as a `validation_error` instead of rendering an empty form.
|
|
123
123
|
- In `layout="buttons"`, **Credit / Debit Card** opens the inline card form. Cancelling a wallet or PayPal silently returns to the chooser. A technical failure after the click (including popup blocking, or a provider closing without a result) restores the chooser, focuses a retry control for that method, shows safe method-specific copy such as `We couldn't open Google Pay. Try again or choose another payment method.`, and calls `onError` with a `FloPayError`. A method that is unavailable before the click just disappears.
|
|
124
|
+
- **Wallet availability.** Every enabled express wallet, Apple Pay and Google Pay included, is requested from Stripe as `'auto'`, never `'always'`, so Stripe's own device and wallet-setup checks decide whether its button is shown. A wallet appears only when Stripe's availability result reports it available for this buyer; when Stripe reports none of the enabled wallets, the wallet row collapses and PayPal and card stay. `FloPayPaymentMethodSetup` and the Vue components use the same rule.
|
|
125
|
+
- **Stalled wallet clicks.** Stripe allows a wallet click about one second, so the SDK gives `onBeforeButtonClick` (and any session patch it returns) a 900 ms budget. When that budget runs out, the click is rejected once, `onError` receives one `external_payment_method_failed` whose `details.providerCode` is `express_checkout_click_timeout`, and the buyer sees the usual retry copy with a wallet retry. Whatever the stalled hook does later (succeeds, throws, or its session patch fails) is ignored for that click.
|
|
126
|
+
- **Vetoing a wallet click.** When `onBeforeButtonClick` returns `false`, the click is rejected and stays silent: no `onError` and no telemetry error.
|
|
127
|
+
- **Popup blocks in in-app browsers.** In an in-app browser (Instagram, a generic Android WebView), a failure the SDK positively classifies as a blocked popup collapses the wallet row for the rest of that checkout mount, because no wallet sheet can open there; PayPal (its redirect tile) and card stay available. A fresh checkout mount offers wallets again. Outside in-app browsers the same block keeps the wallet row and its retry, and a cancellation, an unclassified failure, a stalled click, or the small-window refusal below never collapses it. Apple Pay and Google Pay have no redirect path.
|
|
124
128
|
- **Small desktop windows.** Desktop Chrome refuses to open the Google Pay sheet when the browser window cannot fit it (about 680 by 640 CSS pixels of content; a docked DevTools pane counts) and reports only a cancel. In such a window the SDK denies the Payment Request API to the frames Stripe creates, so Google Pay opens in Google's own window, as it does on mobile and in Safari or Firefox. The choice is made when the wallet row mounts and re-evaluated on resize while no wallet attempt or payment is in flight. Should Chrome still refuse a sheet, `onError` receives `external_payment_method_failed` with `details.providerCode` `wallet_sheet_window_too_small` and the buyer is asked to enlarge the window or choose another method.
|
|
125
129
|
- Wallet confirmation has one 25-second SDK budget inside the provider's 30-second callback deadline. If a wallet omits required buyer identity, the authorization is failed promptly, the SDK collects the missing email, and the buyer reopens the wallet to continue.
|
|
126
130
|
- **Confirmation recovery.** Google Pay and Apple Pay authentication can outlive the SDK's observation window. The SDK never cancels that provider promise: it reads the original intent's status and settles once. A successful intent continues to payment exactly once; a cancelled or failed intent offers a wallet retry; an intent still needing action, or a status that cannot be read, keeps payment locked and offers only **Check payment status**. A retry after a lost intent-create response reuses the same authorization attempt id, so no second intent can be created.
|
|
@@ -776,7 +780,7 @@ and optional `presentationMode`. `providerCode` is sanitized and falls back to
|
|
|
776
780
|
`external_payment_method_failed`; raw provider messages, URLs, user agents,
|
|
777
781
|
credentials, payment identifiers, and customer data are never exposed.
|
|
778
782
|
|
|
779
|
-
|
|
783
|
+
The SDK owns two `providerCode` values. The first is `wallet_sheet_window_too_small`. Desktop
|
|
780
784
|
Chrome refuses to open the Google Pay sheet when the browser window cannot fit
|
|
781
785
|
it (roughly less than 680 by 640 CSS pixels of content, so a docked DevTools
|
|
782
786
|
pane counts) and reports that to the page as a plain cancel. When a Google Pay
|
|
@@ -786,6 +790,11 @@ losing focus in such a viewport, the SDK reports it through `onError` with this
|
|
|
786
790
|
method, instead of silently redrawing the wallet buttons. A buyer who dismisses
|
|
787
791
|
a sheet that did open still gets the silent reset.
|
|
788
792
|
|
|
793
|
+
The second SDK-owned `providerCode` is `express_checkout_click_timeout`: the
|
|
794
|
+
merchant's `onBeforeButtonClick` hook, or the session patch it returned, did not
|
|
795
|
+
finish within the 900 ms a wallet click allows, so the click was rejected. It is
|
|
796
|
+
reported once per click; a late result from that hook is ignored.
|
|
797
|
+
|
|
789
798
|
A `validation_error` is also reported when both `showStripe` and `showPayPal` are false with no PayPal gateway, or when a session advertises no supported gateway. When saving the AVS billing address is rejected with a `4xx`, `onError` receives the parsed billing API error while the message shows inline; the buyer corrects it for the next attempt.
|
|
790
799
|
|
|
791
800
|
`FloPayCardSetup` reports failures to `onError` as `FloPayCardSetupError`, which adds `retryable`. Network, rate-limit, `5xx`, card-form timeout, and unexpected failures are retryable; validation failures are not.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{a as U,b as N,h as D,j as H,l as X}from"./chunk-VK67324N.mjs";import{PaymentAPI as he}from"@flopay/js/card-setup";import{FloPayError as ge,getStripeMethodDisplayName as Se,resolveSetupFutureUsage as be,toStripeAppearance as ve}from"@flopay/shared";import{Elements as Ee,ExpressCheckoutElement as ke,PaymentElement as xe,useElements as we,useStripe as Re}from"@stripe/react-stripe-js";import{loadStripe as _e}from"@stripe/stripe-js";import{useCallback as Q,useMemo as Pe,useRef as Ce,useState as S}from"react";import{getStripeMethodDisplayName as z,hasVendoredStripeMethodLogo as le,resolveStripeMethodBrandVariant as de,stripeExpressMethodToOptionKey as ce}from"@flopay/shared";import{useState as ue}from"react";var Y={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 fe,jsx as s,jsxs as L}from"react/jsx-runtime";var ye=`
|
|
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
|
+
`,me=44;function K(){return s("style",{children:ye})}function W(e,o){let t=e.availablePaymentMethods;return t&&o.some(r=>t[r])?"ready":"unavailable"}function $({state:e,placeholderTestId:o,borderRadius:t=8,children:r}){return e==="unavailable"||e==="load_error"?null:L("div",{style:{position:"relative",minHeight:44},children:[s("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"}}),s("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 De(e){return e!=="unavailable"&&e!=="load_error"}function j({method:e,themeId:o,submitting:t=!1,disabled:r=!1,highlighted:l=!1,hasNextStep:d=!1,onClick:i,backgroundColor:f,borderColor:c,textColor:h,borderRadius:g,fontFamily:w}){let u=de(e,o),b=Y[e],[E,v]=ue(!1),y=!!b&&!E,k=u?.backgroundColor??f??"#ffffff",R=u?.borderColor??c??"#d1d5db",_=u?.textColor??h??"#262833";return s("button",{type:"button","data-testid":`flopay-stripe-method-button-${e}`,"data-method":e,onClick:()=>{!t&&!r&&i()},disabled:t||r,"aria-busy":t||void 0,style:{position:"relative",width:"100%",boxSizing:"border-box",height:me,padding:"0 1rem",backgroundColor:k,color:_,border:`1px solid ${R}`,borderRadius:g??8,fontSize:"0.95rem",fontWeight:600,fontFamily:w,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?s("span",{style:{margin:"0 auto"},children:`Connecting to ${z(e)}\u2026`}):L(fe,{children:[L("span",{style:{display:"inline-flex",alignItems:"center",gap:le(e)?8:0},children:[y?s("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&&u?.logoSvg?s("span",{"aria-hidden":"true",style:{width:30,height:20,flexShrink:0,display:"inline-flex",borderRadius:3,overflow:"hidden"},dangerouslySetInnerHTML:{__html:u.logoSvg}}):null,s("span",{children:z(e)})]}),d&&s("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:_,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:s("path",{d:"M9 18l6-6-6-6"})})]})})}function G(e){let o=new Set(e.map(ce));return Object.fromEntries(["applePay","googlePay","paypal","link","amazonPay","klarna"].map(t=>[t,o.has(t)?"auto":"never"]))}var V={buttonType:{applePay:"plain",googlePay:"plain"},layout:{maxColumns:1,overflow:"never"}},q={type:"accordion",defaultCollapsed:!1,radios:"never"};function J({testId:e,attributes:o,disabled:t,onClick:r,color:l,borderRadius:d,style:i,children:f}){return s("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:d,fontSize:"1rem",fontWeight:600,cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"opacity 120ms ease-out",...i??{}},children:f})}import{Fragment as ee,jsx as m,jsxs as I}from"react/jsx-runtime";var te={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"}},B=new Map;function Me(e){let o=B.get(e);if(o)return o;let t=_e(e).catch(r=>{throw B.delete(e),r});return B.set(e,t),t}function Te(e){return e?ve(e):void 0}function Le(e){return D(e)||e.code==="setup_intent_authentication_failure"||e.code==="payment_method_provider_decline"}function Z(e){return e==="paypal"?"PayPal":Se(e)}function Be(){return typeof window>"u"?"":window.location.href}var Ie={position:"absolute",width:"100%",height:0,overflow:"hidden",visibility:"hidden",pointerEvents:"none"};function qe(e){let{publishableKey:o,method:t,currency:r,futureUse:l,futureUseUnsupported:d,appearance:i}=e,[f]=S(()=>Me(o)),c=Pe(()=>{let h=Te(i),g=be({futureUse:l,futureUseUnsupported:d},t,"setup");return{mode:"setup",currency:r.toLowerCase(),paymentMethodTypes:te[t]?.types??[t],...g?{setupFutureUsage:g}:{},...h?{appearance:h}:{}}},[i,r,l,d,t]);return m(Ee,{stripe:f,options:c,children:m(Ae,{...e})})}function Ae({method:e,category:o,sessionId:t,nonce:r,billingApiUrl:l,telemetry:d,appearance:i,themeId:f,buttonsLayout:c,onSubmitting:h,onConfirmed:g,onDeclined:w,onFailed:u,onValidation:b,onUnavailable:E}){let v=Re(),y=we(),[k,R]=S(!1),[_,A]=S("loading"),[oe,re]=S(!1),[P,ae]=S(!1),C=Ce(!1),[x]=S(()=>H()),[ne,se]=S(!1),M=Q((a,p)=>{if(N(a,{inAppBrowser:x.inAppBrowser,handoffObserved:!1}).popupBlocked){se(!0),u(new Error(U(Z(e),!0,x.inAppBrowser)),{code:"popup_blocked",retryable:!0});return}u(p.message===void 0?a:new Error(p.message),{code:p.code,retryable:!0})},[x.inAppBrowser,e,u]),F=Q(async()=>{if(!(!v||!y||C.current)){C.current=!0,R(!0);try{let a=await y.submit();if(a.error){b(a.error.message??null);return}h();let p=await new he(l,{telemetry:d}).createSessionIntent(t,r,{provider:"stripe",paymentMethodCategory:o,paymentMethodType:e,paymentMethodId:null,intentKind:"setup"});if(p.provider!=="stripe"||p.intentKind!=="setup")throw new ge("The billing API returned a non-setup intent.","api_error",{code:"InvalidSessionIntentResponse"});let n=await v.confirmSetup({elements:y,clientSecret:p.clientSecret,confirmParams:{return_url:Be()},redirect:"if_required"});if(n.error){Le(n.error)?w({...n.error.decline_code||n.error.code?{reason:n.error.decline_code??n.error.code}:{},...n.error.message?{message:n.error.message}:{}}):M(n.error,{code:"payment_method_setup_provider_failed",message:n.error.message??"The payment method could not be saved."});return}g()}catch(a){M(a,{code:"payment_method_setup_failed"})}finally{C.current=!1,R(!1)}}},[l,o,y,e,r,g,w,h,b,M,t,v,d]),T=te[e]?.wallet,ie=T==="paypal"&&X(x,"auto",ne?"blocked":x.popupCapability)==="redirect",O=i?.variables?.borderRadius??c?.cardButton?.borderRadius??8;if(o==="wallet"&&T&&!ie)return I(ee,{children:[m(K,{}),m($,{state:_,borderRadius:O,children:m(ke,{options:{...V,paymentMethods:G([e])},onReady:a=>{let p=W(a,[T]);A(p),p==="unavailable"&&E()},onLoadError:()=>{A("load_error"),E()},onConfirm:()=>{F()}})})]});let pe=Z(e);return I(ee,{children:[oe?m(j,{method:e,themeId:f,hasNextStep:!0,highlighted:P,disabled:k,onClick:()=>ae(a=>!a),backgroundColor:c?.cardButton?.backgroundColor,borderColor:c?.cardInputBorder,textColor:c?.cardButton?.color,borderRadius:O}):null,I("div",{"data-testid":`flopay-stripe-method-form-${e}`,"aria-hidden":!P,style:P?{display:"flex",flexDirection:"column"}:Ie,children:[m(xe,{options:{layout:q},onReady:()=>re(!0),onLoadError:()=>E(),onChange:a=>{a.complete&&b(null)}}),m(J,{testId:`flopay-payment-method-save-${e}`,attributes:{"data-flopay-payment-method-save":e},disabled:!v||!y||k||!P,onClick:()=>{F()},color:i?.variables?.colorPrimary??"#4A49FF",borderRadius:i?.variables?.borderRadius??"8px",style:c?.submitButton,children:k?"Saving\u2026":`Save ${pe}`})]})]})}export{me as a,K as b,W as c,$ as d,De as e,j as f,G as g,V as h,q as i,J as j,qe as k};
|