← Back
Editing: settings-payments-main.js
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[1226],{10149:(e,t,n)=>{n.d(t,{A:()=>i});var s=n(39793),o=n(5573),i=(0,s.jsx)(o.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(o.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})})},95241:(e,t,n)=>{n.d(t,{CX:()=>m,Ci:()=>u,kE:()=>_}),n(51609);var s=n(27723),o=n(221),i=n(70344),a=n(42597),c=n(32710),r=n(29767),l=n(17205),d=n(39793);const m="test_account",_="business_verification",u=[{id:"payment_methods",order:1,type:"backend",label:(0,s.__)("Choose your payment methods","woocommerce"),content:(0,d.jsx)(a.A,{})},{id:"wpcom_connection",order:2,type:"backend",label:(0,s.sprintf)((0,s.__)("Connect with %s","woocommerce"),"WordPress.com"),content:(0,d.jsx)(o.A,{}),dependencies:["payment_methods"]},{id:"activate_payments",order:3,type:"frontend",label:(0,s.__)("Activate payments","woocommerce"),subSteps:[{id:"test_or_live_account",order:1,type:"frontend",label:(0,s.__)("Test or live account","woocommerce"),dependencies:["wpcom_connection"],content:(0,d.jsx)(r.A,{})},{id:m,order:2,type:"backend",label:(0,s.__)("Ready to test payments","woocommerce"),dependencies:["test_or_live_account"],content:(0,d.jsx)(c.A,{})},{id:_,order:3,type:"backend",label:(0,s.__)("Activate payments","woocommerce"),dependencies:["test_or_live_account"],content:(0,d.jsx)(i.A,{})}]},{id:"finish",order:4,type:"frontend",label:(0,s.__)("Submit for verification","woocommerce"),dependencies:[_],content:(0,d.jsx)(l.A,{})}];(0,s.__)("Choose your payment methods","woocommerce"),a.A,(0,s.sprintf)((0,s.__)("Connect with %s","woocommerce"),"WordPress.com"),o.A,(0,s.__)("Activate payments","woocommerce"),i.A},30968:(e,t,n)=>{n.r(t),n.d(t,{SettingsPaymentsMain:()=>ue,default:()=>pe});var s=n(51609),o=n.n(s),i=n(27723),a=n(40314),c=n(47143),r=n(86087),l=n(1455),d=n.n(l),m=n(96476),_=n(14440);var u=n(64218),p=n(56427),g=n(18537),h=n(39793);const w=()=>(0,h.jsxs)("div",{className:"other-payment-gateways__content__grid-item",children:[(0,h.jsx)("div",{className:"grid-item-placeholder__img"}),(0,h.jsxs)("div",{className:"other-payment-gateways__content__grid-item__content grid-item-placeholder__content",children:[(0,h.jsx)("span",{className:"grid-item-placeholder__title"}),(0,h.jsx)("span",{className:"grid-item-placeholder__description"}),(0,h.jsx)("div",{className:"grid-item-placeholder__actions"})]})]});var y=n(98846),v=n(70288),x=n(534);const f=({variant:e,suggestionId:t})=>{const[n,s]=(0,r.useState)(!1),o=(0,r.useRef)(null),a=e=>{const n=e.target.closest(".woocommerce-official-extension-badge__container");o.current&&n!==o.current||(s(e=>!e),(0,x.TH)("official_badge_click",{suggestion_id:t}))},c=e=>{"Escape"===e.key&&n?(e.stopPropagation(),s(!1),o.current?.focus()):"Enter"!==e.key&&" "!==e.key||e.target!==o.current||(e.preventDefault(),a(e))};return(0,h.jsx)(y.Pill,{className:"woocommerce-official-extension-badge",children:(0,h.jsxs)("span",{className:"woocommerce-official-extension-badge__container",tabIndex:0,role:"button",ref:o,onClick:a,onKeyDown:c,children:[(0,h.jsx)("img",{src:v.GZ+"images/icons/official-extension.svg",alt:(0,i.__)("Official WooCommerce extension badge","woocommerce")}),"expanded"===e&&(0,h.jsx)("span",{children:(0,i.__)("Official","woocommerce")}),n&&(0,h.jsx)(p.Popover,{className:"woocommerce-official-extension-badge-popover",placement:"top-start",offset:4,variant:"unstyled",focusOnMount:!0,noArrow:!0,shift:!0,onFocusOutside:()=>{s(!1)},onKeyDown:c,children:(0,h.jsx)("div",{className:"components-popover__content-container",onKeyDown:c,children:(0,h.jsx)("p",{children:(0,r.createInterpolateElement)((0,i.__)("This is an Official WooCommerce payment extension. <learnMoreLink />","woocommerce"),{learnMoreLink:(0,h.jsx)(_.N,{href:"https://woocommerce.com/learn-more-about-official-partner-badging/",rel:"noopener noreferrer",openInNewTab:!0,onClick:()=>{(0,x.TH)("official_badge_learn_more_click",{suggestion_id:t})},children:(0,i.__)("Learn more","woocommerce")})})})})})]})})};var b=n(11789),j=n(74515);const k=({status:e,message:t,popoverContent:n})=>{const[s,o]=(0,r.useState)(!1),a=(0,r.useRef)(null),c=e=>{const t=e.target.closest(".woocommerce-status-badge__icon-container");a.current&&t!==a.current||o(e=>!e)},l=e=>{"Escape"===e.key&&s?(e.stopPropagation(),o(!1),a.current?.focus()):"Enter"!==e.key&&" "!==e.key||e.target!==a.current||(e.preventDefault(),c(e))};return(0,h.jsxs)(y.Pill,{className:`woocommerce-status-badge ${(()=>{switch(e){case"active":case"has_incentive":return"woocommerce-status-badge--success";case"needs_setup":case"test_mode":case"test_account":case"not_supported":return"woocommerce-status-badge--warning";case"recommended":case"inactive":return"woocommerce-status-badge--info";default:return""}})()}`,children:[t||(()=>{switch(e){case"active":return(0,i.__)("Active","woocommerce");case"inactive":return(0,i.__)("Inactive","woocommerce");case"needs_setup":return(0,i.__)("Action needed","woocommerce");case"test_mode":return(0,i.__)("Test mode","woocommerce");case"test_account":return(0,i.__)("Test account","woocommerce");case"recommended":return(0,i.__)("Recommended","woocommerce");case"not_supported":return(0,i.__)("Not supported","woocommerce");default:return""}})(),n&&(0,h.jsxs)("span",{className:"woocommerce-status-badge__icon-container",tabIndex:0,role:"button","aria-haspopup":"dialog","aria-expanded":s,"aria-label":(0,i.__)("More information","woocommerce"),ref:a,onClick:c,onKeyDown:l,children:[(0,h.jsx)(b.A,{className:"woocommerce-status-badge-icon",size:16,icon:j.A}),s&&(0,h.jsx)(p.Popover,{className:"woocommerce-status-badge-popover",placement:"top-start",offset:4,variant:"unstyled",focusOnMount:!0,noArrow:!0,shift:!0,onFocusOutside:()=>{o(!1)},onKeyDown:l,children:(0,h.jsx)("div",{className:"components-popover__content-container",onKeyDown:l,children:n})})]})]})},N=({incentive:e})=>(0,h.jsx)(k,{status:"has_incentive",message:e.badge,popoverContent:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{className:"woocommerce-incentive-popover__title",children:e.title}),(0,h.jsx)("p",{className:"woocommerce-incentive-popover__terms",children:(0,r.createInterpolateElement)((0,i.__)("See <termsLink /> for details.","woocommerce"),{termsLink:(0,h.jsx)(_.N,{href:e.tc_url,rel:"noopener noreferrer",openInNewTab:!0,children:(0,i.__)("Terms and Conditions","woocommerce")})})})]})}),P=({suggestions:e,suggestionCategories:t,installingPlugin:n,setUpPlugin:s,isFetching:o,morePaymentOptionsLink:a})=>{const c=new URLSearchParams(window.location.search),l="expanded"===c.get("other_pes_section"),[d,m]=(0,r.useState)(l),[_,y]=(0,r.useState)(""),v=(0,r.useRef)({}),b=(e,t)=>{const n=e.target.closest(".other-payment-gateways__content__title__icon-container"),s=v.current[t]??null;s&&n!==s||y(t===_?"":t)},j=()=>{y("")},k=(e,t)=>{"Escape"===e.key&&t===_?(e.stopPropagation(),y(""),v.current[t]?.focus()):"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),b(e,t))},P=(0,r.useMemo)(()=>t.map(t=>({category:t,suggestions:e.filter(e=>e._type===t.id)})),[e,t]),S=(0,r.useMemo)(()=>o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"other-payment-gateways__header__title-image-placeholder"}),(0,h.jsx)("div",{className:"other-payment-gateways__header__title-image-placeholder"}),(0,h.jsx)("div",{className:"other-payment-gateways__header__title-image-placeholder"})]}):P.map(({suggestions:e})=>0===e.length?null:e.map(e=>(0,h.jsx)("img",{src:e.icon,alt:e.title+" small logo",width:"24",height:"24",className:"other-payment-gateways__header__title-image"},e.id))),[P,o]),O=(0,r.useMemo)(()=>o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(w,{}),(0,h.jsx)(w,{}),(0,h.jsx)(w,{})]}):P.map(({category:e,suggestions:t})=>0===t.length?null:(0,h.jsxs)("div",{className:"other-payment-gateways__content__category-container",children:[(0,h.jsxs)("div",{className:"other-payment-gateways__content__title",children:[(0,h.jsx)("h3",{className:"other-payment-gateways__content__title__h3",children:(0,g.decodeEntities)(e.title)}),(0,h.jsxs)("span",{className:"other-payment-gateways__content__title__icon-container",onClick:t=>b(t,e.id),onKeyDown:t=>k(t,e.id),tabIndex:0,role:"button",ref:t=>{v.current[e.id]=t},children:[(0,h.jsx)(u.A,{icon:"info-outline",className:"other-payment-gateways__content__title__icon"}),e.id===_&&(0,h.jsx)(p.Popover,{className:"other-payment-gateways__content__title-popover",placement:"top-start",offset:4,variant:"unstyled",focusOnMount:!0,noArrow:!0,shift:!0,onFocusOutside:j,onKeyDown:t=>k(t,e.id),children:(0,h.jsx)("div",{className:"components-popover__content-container",onKeyDown:t=>k(t,e.id),children:(0,h.jsx)("p",{children:(0,g.decodeEntities)(e.description)})})})]})]}),(0,h.jsx)("div",{className:"other-payment-gateways__content__grid",children:t.map(e=>{const t="installed"===e.plugin.status,o=n===e.id;let a=o?(0,i.__)("Installing","woocommerce"):(0,i.__)("Install","woocommerce");return t&&(a=o?(0,i.__)("Activating","woocommerce"):(0,i.__)("Activate","woocommerce")),(0,h.jsxs)("div",{className:"other-payment-gateways__content__grid-item",children:[(0,h.jsx)("img",{className:"other-payment-gateways__content__grid-item-image",src:e.icon,alt:(0,g.decodeEntities)(e.title)+" logo"}),(0,h.jsxs)("div",{className:"other-payment-gateways__content__grid-item__content",children:[(0,h.jsxs)("span",{className:"other-payment-gateways__content__grid-item__content__title",children:[e.title,e?._incentive&&(0,h.jsx)(N,{incentive:e._incentive}),(0,h.jsx)(f,{variant:"expanded",suggestionId:e.id})]}),(0,h.jsx)("span",{className:"other-payment-gateways__content__grid-item__content__description",children:(0,g.decodeEntities)(e.description)}),(0,h.jsx)("div",{className:"other-payment-gateways__content__grid-item__content__actions",children:(0,h.jsx)(p.Button,{variant:"link",onClick:()=>s(e,null,"not_installed"===e.plugin.status?e._links?.attach?.href??null:null,"wc_settings_payments__other_payment_options"),isBusy:o,disabled:!!n,children:a})})]})]},e.id)})})]},e.id)),[P,n,s,o,_]);return(0,h.jsxs)("div",{className:"other-payment-gateways"+(d?" is-expanded":""),children:[(0,h.jsxs)("button",{className:"other-payment-gateways__header",onClick:()=>{const e=!d;(0,x.TH)("other_payment_options_section_click",{action:e?"expand":"collapse"}),m(e),c.set("other_pes_section",e?"expanded":"collapsed"),window.history.replaceState({},document.title,window.location.pathname+"?"+c.toString())},"aria-expanded":d,type:"button",children:[(0,h.jsxs)("span",{className:"other-payment-gateways__header__title",children:[(0,h.jsx)("span",{children:(0,i.__)("More payment options","woocommerce")}),!d&&(0,h.jsx)(h.Fragment,{children:S})]}),(0,h.jsx)(u.A,{className:"other-payment-gateways__header__arrow",icon:d?"chevron-up":"chevron-down"}),(0,h.jsx)("span",{className:"screen-reader-text",children:d?(0,i.__)("Collapse section","woocommerce"):(0,i.__)("Expand section","woocommerce")})]}),d&&(0,h.jsxs)("div",{className:"other-payment-gateways__content",children:[O,(0,h.jsx)("div",{className:"other-payment-gateways__content__external-icon",children:a})]})]})};var S=n(4921),O=n(15703),C=n(46608),I=n(85703),T=n(47119),E=n(29491),A=n(10149),M=n(29471);const D=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),B=({name:e,className:t,label:n,describedBy:o,options:a,onChange:c,value:l,placeholder:d,children:m})=>{const[_,u]=(0,s.useState)(""),[g,w]=(0,s.useState)(null),y=(0,E.useThrottle)((0,r.useCallback)((e,t)=>new Set(t.filter(t=>`${D(t.name??"")}`.toLowerCase().includes(D(e.toLowerCase())))),[]),200),x=""!==_?y(_,a)??new Set:new Set(a),{getToggleButtonProps:f,getMenuProps:j,getItemProps:k,isOpen:N,highlightedIndex:P,selectedItem:O,closeMenu:C,selectItem:I}=(0,T.WM)({initialSelectedItem:l,items:[...x],stateReducer:(e,t)=>{const n=[...x],{changes:s,type:o}=t,{selectedItem:i}=e;switch(o){case T.WM.stateChangeTypes.ToggleButtonBlur:return{...s,isOpen:e.isOpen,selectedItem:e.selectedItem};case T.WM.stateChangeTypes.ItemClick:return{...s,isOpen:!0,highlightedIndex:e.highlightedIndex};case T.WM.stateChangeTypes.ToggleButtonKeyDownArrowDown:return{selectedItem:n[i?Math.min(n.indexOf(i)+1,n.length-1):0],isOpen:!0};case T.WM.stateChangeTypes.ToggleButtonKeyDownArrowUp:return{selectedItem:n[i?Math.max(n.indexOf(i)-1,0):n.length-1],isOpen:!0};default:return s}}}),B=(0,s.useRef)(null),H=((e,t)=>{const n=t.find(t=>t.key===e);return n?.name?n.name:""})(l.key,a),R=O?O.key:"",L=(0,s.useRef)(null),F=(0,s.useRef)(null),U=(0,r.useCallback)(e=>{const t=L.current,n=t?.querySelector(`[data-index="${e}"]`);n&&n.scrollIntoView({block:"nearest"})},[L]),W=""!==_,G=j({className:"components-country-select-control__menu","aria-hidden":!N,ref:L}),K=(0,r.useCallback)(e=>{e.stopPropagation(),c(R),C()},[c,R,C]),z=(0,r.useCallback)(e=>{e.preventDefault(),""!==_&&u(""),null!==O&&setTimeout(()=>{U(a.indexOf(O))},10)},[_,O]),$=(0,r.useCallback)(e=>{const t=[...x],n=t.length;switch(e.key){case"ArrowDown":e.preventDefault(),w(e=>{const t=null===e||-1===e?0:Math.min(e+1,n-1);return setTimeout(()=>{U(t)},0),t});break;case"ArrowUp":e.preventDefault(),w(e=>{const t=null===e||-1===e?n-1:Math.max(e-1,0);return setTimeout(()=>{U(t)},0),t});break;case"Enter":{e.preventDefault();const s=null!==g&&g>=0&&g<n?t[g]:O;s&&c(s.key),C();break}case"Escape":e.preventDefault(),C()}},[x,g,O,c,C]);return(0,r.useEffect)(()=>{if(N){O?.key!==l.key&&I(l),setTimeout(()=>{F.current?.focus()},0);const e=Array.from(x).findIndex(e=>e.key===l.key);e>=0?(U(e),w(e)):w(0)}else w(null)},[N]),(0,h.jsxs)("div",{className:(0,S.A)("woopayments components-country-select-control",t),children:[(0,h.jsxs)(p.Button,{...f({"aria-label":n,"aria-labelledby":void 0,"aria-describedby":o||(H?(0,i.sprintf)((0,i.__)("Currently selected: %s","woocommerce"),H):(0,i.__)("No selection","woocommerce")),className:(0,S.A)("components-country-select-control__button",{placeholder:!H}),name:e}),children:[(0,h.jsxs)("span",{className:"components-country-select-control__button-value",children:[(0,h.jsx)("span",{className:"components-country-select-control__label",children:n}),H||d]}),(0,h.jsx)(b.A,{icon:A.A,className:"components-custom-select-control__button-icon"})]}),(0,h.jsx)("div",{...G,children:N&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"components-country-select-control__search wc-settings-prevent-change-event",children:[(0,h.jsx)("input",{className:"components-country-select-control__search--input",ref:F,type:"text",value:_,onChange:({target:e})=>u(e.value),onKeyDown:$,placeholder:(0,i.__)("Search","woocommerce"),"aria-label":(0,i.__)("Search countries","woocommerce")}),(0,h.jsx)("button",{className:"components-country-select-control__search--input-suffix",onClick:z,tabIndex:-1,"aria-label":W?(0,i.__)("Clear search","woocommerce"):(0,i.__)("Search","woocommerce"),children:(q=W,q?(0,h.jsx)("img",{src:v.GZ+"images/icons/clear.svg",alt:(0,i.__)("Clear search","woocommerce")}):(0,h.jsx)("img",{src:v.GZ+"images/icons/search.svg",alt:(0,i.__)("Search","woocommerce")}))})]}),(0,h.jsx)("div",{className:"components-country-select-control__list",children:[...x].map((e,t)=>(0,s.createElement)("div",{...k({item:e,index:t,key:e.key,className:(0,S.A)(e.className,"components-country-select-control__item",{"is-highlighted":null!==g?t===g:t===P}),"data-index":t,style:e.style}),key:e.key},e.key===R&&(0,h.jsx)(b.A,{icon:M.A,className:"components-country-select-control__item-icon"}),m?m(e):e.name))}),(0,h.jsx)("div",{className:"components-country-select-control__apply",children:(0,h.jsx)("button",{ref:B,className:"components-button is-primary",onClick:K,children:(0,i.__)("Apply","woocommerce")})})]})})]});var q};var H=n(80892),R=n(33068),L=n(31559),F=n(11105),U=n(52741);const W=({provider:e,pluginFile:t,isSuggestion:n,onToggle:s,links:o=[],canResetAccount:l=!1,setResetAccountModalVisible:d=()=>{},isEnabled:m=!1,canResetOnboarding:_=!1})=>{const{deactivatePlugin:u}=(0,c.useDispatch)(a.pluginsStore),[g,w]=(0,r.useState)(!1),[y,v]=(0,r.useState)(!1),[f,b]=(0,r.useState)(!1),{invalidateResolutionForStoreSelector:j,togglePaymentGateway:k,hidePaymentExtensionSuggestion:N}=(0,c.useDispatch)(a.paymentSettingsStore),{createErrorNotice:P,createSuccessNotice:S}=(0,c.useDispatch)("core/notices"),O={pricing:(0,i.__)("See pricing & fees","woocommerce"),about:(0,i.__)("Learn more","woocommerce"),terms:(0,i.__)("See Terms of Service","woocommerce"),support:(0,i.__)("Get support","woocommerce"),documentation:(0,i.__)("View documentation","woocommerce")},C=o.filter(e=>{switch(e._type){case"pricing":return!0;case"terms":case"about":return!m;case"documentation":case"support":return m;default:return!1}});return(0,h.jsxs)(h.Fragment,{children:[C.map(t=>{const n=O[t._type];return n?(0,h.jsx)("div",{className:"woocommerce-ellipsis-menu__content__item",children:(0,h.jsx)(p.Button,{target:"_blank",href:t.url,onClick:()=>{(0,x.g2)("context_link_click",e,{link_type:t._type,link_url:t.url})},children:n})},t._type):null}),!!C.length&&(0,h.jsx)(p.CardDivider,{}),n&&(0,h.jsx)("div",{className:"woocommerce-ellipsis-menu__content__item",children:(0,h.jsx)(p.Button,{onClick:()=>{(0,x.g2)("context_link_click",e,{link_type:"hide_suggestion"}),(()=>{const t=e._links?.hide?.href;t?(b(!0),N(t).then(()=>{j("getPaymentProviders"),b(!1),s()}).catch(()=>{P((0,i.__)("Failed to hide the payments extension suggestion.","woocommerce")),b(!1),s()})):P((0,i.__)("Failed to hide the payments extension suggestion.","woocommerce"))})()},isBusy:f,disabled:f,children:(0,i.__)("Hide suggestion","woocommerce")})},"hide-suggestion"),(l||_)&&(0,h.jsx)("div",{className:"woocommerce-ellipsis-menu__content__item",children:(0,h.jsx)(p.Button,{onClick:()=>{(0,x.g2)("context_link_click",e,{link_type:"reset_onboarding",with_account:l}),d(!0),s()},className:"components-button__danger",children:l?(0,i.__)("Reset account","woocommerce"):(0,i.__)("Reset onboarding","woocommerce")})},"reset-account"),!n&&!m&&(0,h.jsx)("div",{className:"woocommerce-ellipsis-menu__content__item",children:(0,h.jsx)(p.Button,{className:"components-button__danger",onClick:()=>{(0,x.g2)("context_link_click",e,{link_type:"deactivate_extension"}),w(!0),u(t).then(()=>{S((0,i.__)("The provider plugin was successfully deactivated.","woocommerce")),j("getPaymentProviders"),w(!1),s()}).catch(()=>{(0,x.g2)("extension_deactivation_failed",e,{reason:"error"}),P((0,i.__)("Failed to deactivate the provider plugin.","woocommerce")),w(!1),s()})},isBusy:g,disabled:!t||"woocommerce/woocommerce"===t||g,children:(0,i.__)("Deactivate","woocommerce")})},"deactivate"),!n&&m&&(0,h.jsx)("div",{className:"woocommerce-ellipsis-menu__content__item",children:(0,h.jsx)(p.Button,{className:"components-button__danger",onClick:()=>{(0,x.g2)("context_link_click",e,{link_type:"disable"}),(()=>{const t=window.woocommerce_admin.nonces?.gateway_toggle||"";if(!t)return(0,x.g2)("disable_failed",e,{reason:"missing_nonce"}),void P((0,i.__)("Failed to disable the payments provider.","woocommerce"));v(!0),k(e.id,window.woocommerce_admin.ajax_url,t).then(()=>{j("getPaymentProviders"),v(!1),s()}).catch(()=>{(0,x.g2)("disable_failed",e,{reason:"error"}),P((0,i.__)("Failed to disable the payments provider.","woocommerce")),v(!1),s()})})()},isBusy:y,disabled:y,children:(0,i.__)("Disable","woocommerce")})},"disable")]})};var G=n(69451);const K=({provider:e,label:t})=>{const[n,s]=(0,r.useState)(!1),o=(0,x.j4)(e.id)&&"gateway"===e._type&&e.state?.account_connected&&(e.onboarding?.state?.test_mode||!e.onboarding?.state?.completed)&&!!e.onboarding?._links?.reset?.href,i=!o&&(0,x.j4)(e.id)&&"gateway"===e._type&&!e.state?.account_connected&&e.onboarding?.state?.started&&!!e.onboarding?._links?.reset?.href;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(y.EllipsisMenu,{label:t,renderContent:({onToggle:t})=>(0,h.jsx)(W,{provider:e,pluginFile:e.plugin.file,isSuggestion:"suggestion"===e._type,links:e.links,onToggle:t,isEnabled:e.state?.enabled,canResetAccount:o,setResetAccountModalVisible:s,canResetOnboarding:i}),focusOnMount:"firstElement"}),(0,h.jsx)(G.Mk,{isOpen:n,onClose:()=>s(!1),hasAccount:e.state?.account_connected,isTestMode:e.onboarding?.state?.test_mode,resetUrl:e.onboarding?._links?.reset?.href})]})},z=({suggestion:e,installingPlugin:t,setUpPlugin:n,pluginInstalled:s,acceptIncentive:o,shouldHighlightIncentive:a=!1,...c})=>{const r=(0,x.O2)(e)?e._incentive:null;let l=(0,i.__)("Install","woocommerce");return s?l=(0,i.__)("Enable","woocommerce"):t===e.id&&(l=(0,i.__)("Installing","woocommerce")),(0,h.jsx)("div",{id:e.id,className:"transitions-disabled woocommerce-list__item woocommerce-list__item-enter-done "+((0,x.O2)(e)&&a?"has-incentive":""),...c,children:(0,h.jsxs)("div",{className:"woocommerce-list__item-inner",children:[(0,h.jsxs)("div",{className:"woocommerce-list__item-before",children:[(0,h.jsx)(L.Gh,{}),e.icon&&(0,h.jsx)("img",{className:"woocommerce-list__item-image",src:e.icon,alt:e.title+" logo"})]}),(0,h.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,h.jsxs)("span",{className:"woocommerce-list__item-title",children:[e.title," ",!(0,x.O2)(e)&&(0,x.j4)(e.id)&&(0,h.jsx)(k,{status:"recommended"}),r&&(0,h.jsx)(N,{incentive:r}),(0,h.jsx)(f,{variant:"expanded",suggestionId:e.id})]}),(0,h.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,U.A)((0,g.decodeEntities)(e.description))}),(0,x.j4)(e.id)&&(0,h.jsx)(F.WooPaymentsMethodsLogos,{maxElements:10,tabletWidthBreakpoint:1080,mobileWidthBreakpoint:768,isWooPayEligible:(0,x.bU)(e)})]}),(0,h.jsx)("div",{className:"woocommerce-list__item-buttons",children:(0,h.jsx)("div",{className:"woocommerce-list__item-buttons__actions",children:(0,h.jsx)(p.Button,{variant:"primary",onClick:()=>{s&&(0,x.g2)("enable_click",e,{incentive_id:r?r.promo_id:"none"}),r&&o(r.promo_id),n(e,e.onboarding?._links?.onboard?.href??null,s?null:e._links?.attach?.href??null,"wc_settings_payments__main_suggestion")},isBusy:t===e.id,disabled:!!t,children:l})})}),(0,h.jsx)("div",{className:"woocommerce-list__item-after",children:(0,h.jsx)("div",{className:"woocommerce-list__item-after__actions",children:(0,h.jsx)(K,{label:(0,i.__)("Payment provider actions","woocommerce"),provider:e})})})]})})};var $=n(58911),q=n(53802);const Z=({buttonText:e=(0,i.__)("Reactivate payments","woocommerce"),settingsHref:t})=>{const[n,s]=(0,r.useState)(!1),{createSuccessNotice:o,createErrorNotice:l}=(0,c.dispatch)("core/notices"),{invalidateResolutionForStoreSelector:m}=(0,c.useDispatch)(a.paymentSettingsStore);return(0,h.jsx)(p.Button,{variant:"primary",isBusy:n,disabled:n,onClick:e=>{e.preventDefault(),s(!0),(0,x.TH)("reactivate_payments_button_click",{provider_id:q.$8,provider_extension_slug:q.bw,suggestion_id:q.eD}),d()({path:"/wc/v3/payments/settings",method:"POST",data:{is_test_mode_enabled:!1}}).then(()=>{o((0,i.sprintf)((0,i.__)("%s is now processing live payments (real payment methods and charges).","woocommerce"),"WooPayments"),{type:"snackbar",explicitDismiss:!1}),m("getPaymentProviders"),s(!1)}).catch(()=>{s(!1),(0,x.TH)("reactivate_payments_error",{provider_id:q.$8,provider_extension_slug:q.bw,suggestion_id:q.eD}),l((0,i.sprintf)((0,i.__)("An error occurred. You will be redirected to the %s settings page to manage payments processing mode from there.","woocommerce"),"WooPayments"),{type:"snackbar",explicitDismiss:!0}),window.location.href=t})},href:t,children:e})},V=({gateway:e,installingPlugin:t,acceptIncentive:n,shouldHighlightIncentive:s,setIsOnboardingModalOpen:o,...a})=>{const c=(0,x.j4)(e.id),l=(0,x.O2)(e)?e._incentive:null,d=e.state.enabled&&(window.wcSettings?.admin?.woocommerce_checkout_block_compatibility?.incompatible_gateway_ids??[]).includes(e.id),m=(e.onboarding?.recommended_payment_methods??[]).length>0,u=!e.onboarding||(e.onboarding.state?.supported??!0),w=!e.state.account_connected||e.state.account_connected&&!e.onboarding?.state?.started||e.state.account_connected&&e.onboarding?.state?.started&&!e.onboarding?.state?.completed;return(0,h.jsx)("div",{id:e.id,className:`transitions-disabled woocommerce-list__item woocommerce-list__item-enter-done woocommerce-item__payment-gateway ${c?"woocommerce-item__woocommerce-payments":""} ${(0,x.O2)(e)&&s?"has-incentive":""}`,...a,children:(0,h.jsxs)("div",{className:"woocommerce-list__item-inner",children:[(0,h.jsxs)("div",{className:"woocommerce-list__item-before",children:[(0,h.jsx)(L.Gh,{}),e.icon&&(0,h.jsx)("img",{className:"woocommerce-list__item-image",src:e.icon,alt:e.title+" logo"})]}),(0,h.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,h.jsxs)("span",{className:"woocommerce-list__item-title",children:[e.title,l?(0,h.jsx)(N,{incentive:l}):(0,h.jsx)(k,{status:(()=>{if(w&&!u)return"not_supported";if(w||!e.state.enabled&&e.state.needs_setup)return"needs_setup";if(e.state.enabled){if(e.state.account_connected){if(e.onboarding?.state?.test_mode)return"test_account";if(e.state.test_mode)return"test_mode"}return"active"}return"inactive"})(),popoverContent:(()=>{if(w&&!u){const t=e.onboarding?.messages?.not_supported;if(t)return(0,h.jsx)("p",{children:t})}})()}),d&&(0,h.jsx)(k,{status:"not_supported",message:(0,i.__)("Limited compatibility","woocommerce"),popoverContent:(0,h.jsx)("p",{children:(0,r.createInterpolateElement)((0,i.__)("Payment methods from this provider will only appear on classic checkout. <a>Learn more</a>","woocommerce"),{a:(0,h.jsx)(_.N,{href:"https://woocommerce.com/document/woocommerce-store-editing/customizing-cart-and-checkout/#incompatible-extensions",rel:"noopener noreferrer",openInNewTab:!0,children:null})})})}),e._suggestion_id&&(0,h.jsx)(f,{variant:"expanded",suggestionId:e._suggestion_id}),e.supports?.includes("subscriptions")&&(0,h.jsx)(p.Tooltip,{placement:"top",text:(0,i.__)("Supports recurring payments","woocommerce"),children:(0,h.jsx)("img",{className:"woocommerce-list__item-recurring-payments-icon",src:v.GZ+"images/icons/recurring-payments.svg",alt:(0,i.__)("Icon to indicate support for recurring payments","woocommerce")})})]}),(0,h.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,U.A)((0,g.decodeEntities)(e.description))}),c&&(0,h.jsx)(F.WooPaymentsMethodsLogos,{maxElements:10,tabletWidthBreakpoint:1080,mobileWidthBreakpoint:768,isWooPayEligible:(0,x.bU)(e)})]}),(0,h.jsx)("div",{className:"woocommerce-list__item-buttons",children:(0,h.jsxs)("div",{className:"woocommerce-list__item-buttons__actions",children:[!e.state.enabled&&!w&&(0,h.jsx)($.S,{gatewayProvider:e,settingsHref:e.management._links.settings.href,onboardingHref:e.onboarding._links.onboard.href,isOffline:!1,gatewayHasRecommendedPaymentMethods:m,installingPlugin:t,incentive:l,acceptIncentive:n,setOnboardingModalOpen:o,onboardingType:e.onboarding.type}),!w&&(0,h.jsx)($.CS,{gatewayProvider:e,settingsHref:e.management._links.settings.href,isInstallingPlugin:!!t}),w&&(0,h.jsx)($.PE,{gatewayProvider:e,settingsHref:e.management._links.settings.href,onboardingHref:u&&e.onboarding&&e.onboarding._links?.onboard?.href||"#",gatewayHasRecommendedPaymentMethods:!!u&&m,installingPlugin:t,setOnboardingModalOpen:u?o:()=>{},disabled:!u,ariaLabel:u?void 0:e.onboarding?.messages?.not_supported,...u&&e.onboarding&&{onboardingType:e.onboarding?.type,incentive:l,acceptIncentive:n}}),(0,x.j4)(e.id)&&!e.state.dev_mode&&e.state.account_connected&&e.onboarding?.state?.completed&&e.onboarding?.state?.test_mode&&(0,h.jsx)($.LO,{acceptIncentive:n,installingPlugin:t,incentive:l,setOnboardingModalOpen:o,onboardingType:e.onboarding.type,disableTestAccountUrl:e.onboarding._links.disable_test_account?.href}),(0,x.j4)(e.id)&&!e.state.dev_mode&&e.state.account_connected&&e.onboarding?.state?.completed&&!e.onboarding?.state?.test_mode&&e.state.test_mode&&(0,h.jsx)(Z,{settingsHref:e.management._links.settings.href})]})}),(0,h.jsx)("div",{className:"woocommerce-list__item-after",children:(0,h.jsx)("div",{className:"woocommerce-list__item-after__actions",children:(0,h.jsx)(K,{label:(0,i.__)("Payment provider options","woocommerce"),provider:e})})})]})})},Q=({providers:e,installedPluginSlugs:t,installingPlugin:n,setUpPlugin:s,acceptIncentive:o,shouldHighlightIncentive:c,updateOrdering:r,setIsOnboardingModalOpen:l})=>{const d=(0,R.Zp)();return(0,h.jsx)(L.q6,{items:e,className:"settings-payment-gateways__list",setItems:r,children:e.map(e=>{switch(e._type){case a.PaymentsProviderType.Suggestion:const r=e,m=t.includes(e.plugin.slug);return(0,h.jsx)(L.Uq,{id:r.id,children:z({suggestion:r,installingPlugin:n,setUpPlugin:s,pluginInstalled:m,acceptIncentive:o,shouldHighlightIncentive:c})},r.id);case a.PaymentsProviderType.Gateway:const _=e;return(0,h.jsx)(L.Uq,{id:e.id,children:V({gateway:_,installingPlugin:n,acceptIncentive:o,shouldHighlightIncentive:c,setIsOnboardingModalOpen:l})},e.id);case a.PaymentsProviderType.OfflinePmsGroup:const p=e;return(0,h.jsx)(L.Uq,{id:p.id,children:(0,h.jsx)("div",{id:p.id,className:"transitions-disabled woocommerce-list__item clickable-list-item enter-done",onClick:()=>{d((0,x.Wg)(p.management._links.settings.href))},children:(0,h.jsxs)("div",{className:"woocommerce-list__item-inner",children:[(0,h.jsxs)("div",{className:"woocommerce-list__item-before",children:[(0,h.jsx)(L.Gh,{}),(0,h.jsx)("img",{src:p.icon,alt:p.title+" logo"})]}),(0,h.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,h.jsx)("span",{className:"woocommerce-list__item-title",children:p.title}),(0,h.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:{__html:p.description}})]}),(0,h.jsx)("div",{className:"woocommerce-list__item-after centered no-buttons",children:(0,h.jsx)("div",{className:"woocommerce-list__item-after__actions",children:(0,h.jsx)("a",{className:"woocommerce-list__item-after__actions__arrow",href:p.management._links.settings.href,"aria-label":p.title,children:(0,h.jsx)(u.A,{icon:(0,i.isRTL)()?"chevron-left":"chevron-right"})})})})]})})},p.id);default:return null}})})},Y=({providers:e,installedPluginSlugs:t,installingPlugin:n,setUpPlugin:s,acceptIncentive:o,shouldHighlightIncentive:l,updateOrdering:m,isFetching:_,businessRegistrationCountry:u,setBusinessRegistrationCountry:w,setIsOnboardingModalOpen:v})=>{const{invalidateResolution:f}=(0,c.useDispatch)(a.paymentSettingsStore),{invalidateResolution:b}=(0,c.useDispatch)(a.woopaymentsOnboardingStore),[j,k]=(0,r.useState)(!1),N=(0,r.useRef)(null),P=(window.wcSettings?.admin?.preloadSettings?.general?.woocommerce_default_country||"US").split(":")[0],T=(0,r.useMemo)(()=>Object.entries(window.wcSettings.countries||[]).map(([e,t])=>({key:e,name:(0,g.decodeEntities)(t),types:[]})).sort((e,t)=>e.name.localeCompare(t.name)),[]),E=P!==u,A=(0,S.A)("settings-payment-gateways__header-select-container",{"has-alert":E}),M=e=>{const t=e.target.closest(".settings-payment-gateways__header-select-container--indicator");N.current&&t!==N.current||((0,x.TH)("business_location_indicator_click",{store_country:P,business_country:u||"unknown"}),k(e=>!e))};return(0,r.useEffect)(()=>{if(!j)return;const e=e=>{"Escape"===e.key&&(e.stopPropagation(),k(!1),N.current?.focus())};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[j]),(0,h.jsxs)("div",{className:"settings-payment-gateways",children:[(0,h.jsxs)("div",{className:"settings-payment-gateways__header",children:[(0,h.jsx)("div",{className:"settings-payment-gateways__header-title",children:(0,i.__)("Payment providers","woocommerce")}),(0,h.jsxs)("div",{className:A,children:[(0,h.jsx)(B,{className:"woocommerce-select-control__country",label:(0,i.__)("Business location:","woocommerce"),placeholder:"",value:T.find(e=>e.key===u)??{key:"US",name:"United States (US)"},options:T,onChange:e=>{d()({path:a.WC_ADMIN_NAMESPACE+"/settings/payments/country",method:"POST",data:{location:e}}).then(()=>{w(e),window.wcSettings.admin.woocommerce_payments_nox_profile&&(window.wcSettings.admin.woocommerce_payments_nox_profile.business_country_code=e),f("getPaymentProviders",[e]),b("getOnboardingData",[])})}}),E&&(0,h.jsxs)("div",{className:"settings-payment-gateways__header-select-container--indicator",tabIndex:0,role:"button",ref:N,onClick:M,onKeyDown:e=>{if("Escape"===e.key&&j)e.stopPropagation(),k(!1),N.current?.focus();else if("Enter"===e.key||" "===e.key){if(e.target!==N.current)return;e.preventDefault(),M(e)}},children:[(0,h.jsx)("div",{className:"settings-payment-gateways__header-select-container--indicator-icon",children:(0,h.jsx)(C.A,{})}),j&&(0,h.jsx)(p.Popover,{className:"settings-payment-gateways__header-select-container--indicator-popover",placement:"top-end",offset:4,variant:"unstyled",focusOnMount:!0,noArrow:!0,shift:!0,onFocusOutside:()=>{k(!1)},children:(0,h.jsx)("div",{className:"components-popover__content-container",children:(0,h.jsx)("p",{children:(0,I.A)({mixedString:(0,i.__)("Your business location does not match your store location. {{link}}Edit store location.{{/link}}","woocommerce"),components:{link:(0,h.jsx)(y.Link,{href:(0,O.getAdminLink)("admin.php?page=wc-settings&tab=general"),target:"_blank",type:"external",onClick:()=>{(0,x.TH)("business_location_popover_edit_store_location_click",{store_country:P,business_country:u||"unknown"})}})}})})})})]})]})]}),_?(0,h.jsx)(H.i,{rows:5}):(0,h.jsx)(Q,{providers:e,installedPluginSlugs:t,installingPlugin:n,setUpPlugin:s,acceptIncentive:o,shouldHighlightIncentive:l,updateOrdering:m,setIsOnboardingModalOpen:v})]})},J=({incentive:e,provider:t,onboardingUrl:n,onDismiss:o,onAccept:a,setUpPlugin:c})=>{const[l,d]=(0,r.useState)(!1),[m,u]=(0,r.useState)(!1),[g,w]=(0,r.useState)(!1),y="wc_settings_payments__banner";return(0,s.useEffect)(()=>{(0,x.TH)("incentive_show",{incentive_id:e.promo_id,provider_id:t.id,suggestion_id:t._suggestion_id??"unknown",display_context:y})},[e,t]),l||(0,x.$8)(e,y)||m?null:(0,h.jsx)(p.Card,{className:"woocommerce-incentive-banner",isRounded:!0,children:(0,h.jsxs)("div",{className:"woocommerce-incentive-banner__content",children:[(0,h.jsx)("div",{className:"woocommerce-incentive-banner__image",children:(0,h.jsx)("img",{src:v.GZ+"images/settings-payments/incentives-illustration.svg",alt:(0,i.__)("Incentive illustration","woocommerce")})}),(0,h.jsxs)(p.CardBody,{className:"woocommerce-incentive-banner__body",children:[(0,h.jsx)(k,{status:"has_incentive",message:(0,i.__)("Limited time offer","woocommerce")}),(0,h.jsxs)("div",{className:"woocommerce-incentive-banner__copy",children:[(0,h.jsx)("h2",{children:e.title}),(0,h.jsx)("p",{children:e.description})]}),(0,h.jsx)("div",{className:"woocommerce-incentive-banner__terms",children:(0,r.createInterpolateElement)((0,i.__)("See <termsLink /> for details.","woocommerce"),{termsLink:(0,h.jsx)(_.N,{href:e.tc_url,rel:"noopener noreferrer",openInNewTab:!0,children:(0,i.__)("Terms and Conditions","woocommerce")})})}),(0,h.jsxs)("div",{className:"woocommerce-incentive-banner__actions",children:[(0,h.jsx)(p.Button,{variant:"primary",isBusy:l,disabled:l,onClick:()=>{(0,x.TH)("incentive_accept",{incentive_id:e.promo_id,provider_id:t.id,suggestion_id:t._suggestion_id??"unknown",display_context:y}),w(!0),a(e.promo_id),o(e._links.dismiss.href,y,!0),d(!0),c(t,n,"not_installed"===t.plugin.status?t._links?.attach?.href??null:null,"wc_settings_payments__incentive_banner"),w(!1)},children:e.cta_label}),(0,h.jsx)(p.Button,{variant:"tertiary",isBusy:g,disabled:g,onClick:()=>{w(!0),o(e._links.dismiss.href,y),w(!1),u(!0)},children:(0,i.__)("Dismiss","woocommerce")})]})]})]})})},X=({incentive:e,provider:t,onboardingUrl:n,onAccept:o,onDismiss:a,setUpPlugin:c})=>{const[l,d]=(0,r.useState)(!1),[m,u]=(0,r.useState)(!0),g="wc_settings_payments__modal",w=(0,x.$8)(e,g);(0,s.useEffect)(()=>{(0,x.TH)("incentive_show",{incentive_id:e.promo_id,provider_id:t.id,suggestion_id:t._suggestion_id??"unknown",display_context:g})},[e,t]);const y=()=>{u(!1)};return w?null:(0,h.jsx)(h.Fragment,{children:m&&(0,h.jsx)(p.Modal,{title:"",className:"woocommerce-incentive-modal",onRequestClose:()=>{a(e._links.dismiss.href,g),y()},children:(0,h.jsx)(p.Card,{className:"woocommerce-incentive-modal__card",children:(0,h.jsxs)("div",{className:"woocommerce-incentive-modal__content",children:[(0,h.jsx)(p.CardMedia,{className:"woocommerce-incentive-modal__media",children:(0,h.jsx)("img",{src:v.GZ+"images/settings-payments/incentives-illustration.svg",alt:(0,i.__)("Incentive illustration","woocommerce")})}),(0,h.jsxs)(p.CardBody,{className:"woocommerce-incentive-modal__body",children:[(0,h.jsx)("div",{children:(0,h.jsx)(k,{status:"has_incentive",message:(0,i.__)("Limited time offer","woocommerce")})}),(0,h.jsx)("h2",{children:e.title}),(0,h.jsx)("p",{children:e.description}),(0,h.jsx)("p",{className:"woocommerce-incentive-modal__terms",children:(0,r.createInterpolateElement)((0,i.__)("See <termsLink /> for details.","woocommerce"),{termsLink:(0,h.jsx)(_.N,{href:e.tc_url,rel:"noopener noreferrer",openInNewTab:!0,children:(0,i.__)("Terms and Conditions","woocommerce")})})}),(0,h.jsx)("div",{className:"woocommerce-incentive-model__actions",children:(0,h.jsx)(p.Button,{variant:"primary",isBusy:l,disabled:l,onClick:()=>{(0,x.TH)("incentive_accept",{incentive_id:e.promo_id,provider_id:t.id,suggestion_id:t._suggestion_id??"unknown",display_context:g}),d(!0),o(e.promo_id),a(e._links.dismiss.href,g,!0),y(),c(t,n,"not_installed"===t.plugin.status?t._links?.attach?.href??null:null,"wc_settings_payments__incentive_modal"),d(!1)},children:e.cta_label})})]})]})})})})};var ee=n(93832);function te({setIsOpen:e,children:t}){return(0,h.jsx)(p.Modal,{className:"settings-payments-onboarding-modal",isFullScreen:!0,__experimentalHideHeader:!0,onRequestClose:()=>e(!1),shouldCloseOnClickOutside:!1,children:t})}var ne=n(16215),se=n(56999),oe=n(95241),ie=n(66087),ae=n(20195),ce=n(10979),re=n.n(ce);const le=(0,r.forwardRef)(function({className:e,children:t,spokenMessage:n=t,politeness:s="polite",actions:o=[],onRemove:a=ie.noop,icon:c=null,explicitDismiss:l=!1,onDismiss:d=null,__unstableHTML:m=!1},_){function u(e){e&&e.preventDefault&&e.preventDefault(),d(),a()}d=d||ie.noop,function(e,t){const n="string"==typeof e?e:(0,r.renderToString)(e);(0,r.useEffect)(()=>{n&&(0,ae.speak)(n,t)},[n,t])}(n,s),(0,r.useEffect)(()=>{const e=setTimeout(()=>{l||(d(),a())},1e4);return()=>clearTimeout(e)},[l,d,a]);const g=(0,S.A)(e,"components-snackbar",{"components-snackbar-explicit-dismiss":!!l});o&&o.length>1&&(!0===globalThis.SCRIPT_DEBUG&&re()("Snackbar can only have 1 action, use Notice if your message require many messages"),o=[o[0]]);const w=(0,S.A)("components-snackbar__content",{"components-snackbar__content-with-icon":!!c});return!0===m&&(t=(0,h.jsx)(r.RawHTML,{children:t})),(0,h.jsx)("div",{ref:_,className:g,onClick:l?ie.noop:u,tabIndex:"0",role:l?"":"button",onKeyPress:l?ie.noop:u,"aria-label":l?"":(0,i.__)("Dismiss this notice","woocommerce"),children:(0,h.jsxs)("div",{className:w,children:[c&&(0,h.jsx)("div",{className:"components-snackbar__icon",children:c}),t,o.map(({label:e,onClick:t,url:n},s)=>(0,h.jsx)(p.Button,{href:n,isTertiary:!0,onClick:e=>function(e,t){e.stopPropagation(),a(),t&&t(e)}(e,t),className:"components-snackbar__action",children:e},s)),l&&(0,h.jsx)("span",{role:"button","aria-label":"Dismiss this notice",tabIndex:"0",className:"components-snackbar__dismiss-button",onClick:u,onKeyPress:u,children:"✕"})]})})}),de=({children:e,duration:t=4e3,className:n})=>{const[s,o]=(0,r.useState)(!1),[i,a]=(0,r.useState)(!1);(0,r.useEffect)(()=>{const e=setTimeout(()=>{o(!0);const e=setTimeout(()=>{a(!0)},t);return()=>clearTimeout(e)},100);return()=>{clearTimeout(e)}},[]);const c=["woopayments_onboarding_modal_snackbar_wrapper",n,s?"is-visible":"",i?"is-exiting":""].filter(Boolean).join(" ");return(0,h.jsx)("div",{className:c,children:(0,h.jsx)(le,{className:n+"__snackbar",children:e})})},me=()=>{const{snackbar:e}=(0,se.w)();return e.show?(0,h.jsx)(de,{className:e.className||"",duration:e.duration,children:e.message}):null};function _e({isOpen:e,setIsOpen:t,providerData:n}){const s=(0,R.zy)(),a=(0,m.getHistory)(),r="/woopayments/onboarding",{createErrorNotice:l}=(0,c.dispatch)("core/notices"),d=(0,ee.getQueryArg)(window.location.href,"wpcom_connection_return")||!1,_=n?.onboarding?.state?.wpcom_has_working_connection||!1,{sessionEntryPoint:u}=(0,se.w)();o().useEffect(()=>{const n=(0,m.getQuery)(),s=n.path&&n.path.includes(r);if(!s||e||!_&&d||((0,x.W7)("woopayments_onboarding_modal_opened",{source:u}),t(!0)),e&&!s){const e=(0,m.getNewPath)({path:r},r,{page:"wc-settings",tab:"checkout"});a.push(e)}!_&&d&&((0,x.W7)("woopayments_onboarding_wpcom_connection_cancelled",{source:u}),l((0,i.__)("Setup was cancelled!","woocommerce"),{type:"snackbar",explicitDismiss:!1}))},[s,e,t,d,_,l,a]);const p=()=>{(0,x.W7)("woopayments_onboarding_modal_closed",{source:u});const e=(0,m.getNewPath)({},"/wp-admin/admin.php",{page:"wc-settings",tab:"checkout"});a.push(e),t(!1)};return e?(0,h.jsx)(te,{setIsOpen:p,children:(0,h.jsxs)(se.X,{closeModal:p,onboardingSteps:oe.Ci,children:[(0,h.jsx)(ne.A,{}),(0,h.jsx)(me,{})]})}):null}const ue=()=>{const[e,t]=(0,r.useState)(null),[n,o]=(0,r.useState)(null),{installAndActivatePlugins:l}=(0,c.useDispatch)(a.pluginsStore),{updateProviderOrdering:u,attachPaymentExtensionSuggestion:p}=(0,c.useDispatch)(a.paymentSettingsStore),[g,w]=(0,r.useState)(null),[y,v]=(0,r.useState)(!1),[f,b]=(0,r.useState)(window.wcSettings?.admin?.woocommerce_payments_nox_profile?.business_country_code||null),[j,k]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(0,x.TH)("pageview");const e=new URLSearchParams(window.location.search);"true"===e.get("test_drive_error")&&w((0,i.sprintf)((0,i.__)("%s: An error occurred while setting up your sandbox account — please try again.","woocommerce"),"WooPayments")),"1"===e.get("wcpay-connect-jetpack-error")&&w((0,i.sprintf)((0,i.__)("%s: There was a problem connecting your WordPress.com account — please try again.","woocommerce"),"WooPayments")),"true"===e.get("wcpay-sandbox-success")&&v(!0)},[]);const N=(0,c.useSelect)(e=>e(a.pluginsStore).getInstalledPlugins(),[]),{invalidateResolutionForStoreSelector:S}=(0,c.useDispatch)(a.paymentSettingsStore),{providers:O,offlinePaymentGateways:C,suggestions:I,suggestionCategories:T,isFetching:E}=(0,c.useSelect)(e=>{const t=e(a.paymentSettingsStore);return{providers:t.getPaymentProviders(f),offlinePaymentGateways:t.getOfflinePaymentGateways(f),suggestions:t.getSuggestions(f),suggestionCategories:t.getSuggestionCategories(f),isFetching:t.isFetching()}},[f]),A=(0,s.useCallback)((e,t,n=!1)=>{d()({url:e,method:"POST",data:{context:t,do_not_track:n}})},[]),M=(0,s.useCallback)(e=>{d()({path:`/wc-analytics/admin/notes/experimental-activate-promo/${e}`,method:"POST"})},[]);(0,r.useEffect)(()=>{o(null)},[O]);const D=O.find(e=>"_incentive"in e),B=D?D._incentive:null;let H=!1,R=!1,L=!1;if(D&&B)if((0,x.sq)(B))if((0,x.$8)(B,"wc_settings_payments__modal")){if(!(0,x.$8)(B,"wc_settings_payments__banner")){const e=new Date;e.setDate(e.getDate()-30),(0,x.uH)(B,"wc_settings_payments__modal",e.getTime())?R=!0:L=!0}}else H=!0;else(0,x.uU)(B)&&((0,x.$8)(B,"wc_settings_payments__banner")?L=!0:R=!0);const F=(0,s.useRef)(!1);(0,r.useEffect)(()=>{if(E||!O.length||!I.length||F.current)return;F.current=!0;const e={woocommerce_payments_displayed:O.some(e=>(0,x.j4)(e.id))};I.forEach(t=>{e[t.id.replace(/-/g,"_")+"_displayed"]=!0}),O.filter(e=>"suggestion"===e._type).forEach(t=>{t._suggestion_id?e[t._suggestion_id.replace(/-/g,"_")+"_displayed"]=!0:t.plugin&&t.plugin.slug&&(e[t.plugin.slug.replace(/-/g,"_")+"_displayed"]=!0)}),(0,x.TH)("recommendations_pageview",e)},[I,O,E]);const U=(0,s.useCallback)((n,s,o,r="wc_settings_payments__main")=>{e||(n?.onboarding?._links?.preload?.href&&d()({url:n?.onboarding?._links?.preload.href,method:"POST",data:{location:f}}),t(n.id),(0,x.TH)("recommendations_setup",{extension_selected:n.plugin.slug,extension_action:"not_installed"===n.plugin.status?"install":"activate",provider_id:n.id,suggestion_id:n?._suggestion_id??"unknown",provider_extension_slug:n.plugin.slug,from:r,source:r}),l([n.plugin.slug]).then(async e=>{o&&p(o),function(e){const{createNotice:t}=(0,c.dispatch)("core/notices");!function(e){return!!e&&(e instanceof TypeError||"object"==typeof e&&!("message"in e&&e.message||"errors"in e&&e.errors&&Object.keys(e.errors).length||"code"in e||"error_data"in e)&&"undefined"!=typeof window&&!1===window.navigator?.onLine)}(e)?e.error_data&&e.errors&&Object.keys(e.errors).length?Object.keys(e.errors).forEach(n=>{t("error",e.errors[n].join(" "))}):e instanceof Error?e.message&&t("error",e.message):e.message&&t(e.code?"error":"success",e.message):t("error",(0,i.__)("Updating failed. You are probably offline.","woocommerce"))}(e),S("getPaymentProviders"),"not_installed"===n.plugin.status&&(0,x.TH)("provider_installed",{provider_id:n.id,suggestion_id:n?._suggestion_id??"unknown",provider_extension_slug:n.plugin.slug,from:r}),t(null);const l=(await(0,c.resolveSelect)(a.paymentSettingsStore).getPaymentProviders(f)).find(e=>e.id===n.id||e?._suggestion_id===n.id||e.plugin.slug===n.plugin.slug);if("native_in_context"===l?.onboarding?.type)(0,x.W7)("woopayments_onboarding_modal_opened",{from:r,source:q.Fx}),k(!0);else{if((l?.onboarding?.recommended_payment_methods??[]).length>0)return void(0,m.getHistory)().push((0,m.getNewPath)({},"/payment-methods"));s&&(window.location.href=s)}}).catch(e=>{const s=(0,x.jc)(e,"not_installed"===n.plugin.status?"install":"activate");(0,x.TH)("install"===s?"provider_extension_installation_failed":"provider_extension_activation_failed",{provider_id:n.id,suggestion_id:n?._suggestion_id??"unknown",provider_extension_slug:n.plugin.slug,from:r,source:q.Fx,reason:"error"}),(0,c.dispatch)("core/notices").createNotice("error",(0,x.fu)(s,n.title,e)),t(null)}))},[e,l,S,f]),W=(0,h.jsx)(_.N,{href:(0,x.B3)(f),onClick:()=>{const e=O.map(e=>e.plugin&&e.plugin.slug?e.plugin.slug.replace(/-/g,"_"):e._suggestion_id?e._suggestion_id.replace(/-/g,"_"):e.id);C.forEach(t=>{e.push(t.id)}),I.forEach(t=>{t.plugin&&t.plugin.slug?e.push(t.plugin.slug.replace(/-/g,"_")):e.push(t.id.replace(/-/g,"_"))});const t=[...new Set(e)];(0,x.TH)("recommendations_other_options",{available_payment_methods:t.join(", ")})},rel:"noopener noreferrer",openInNewTab:!0,children:(0,i.__)("More payment options","woocommerce")});return(0,h.jsxs)(h.Fragment,{children:[H&&D&&B&&(0,h.jsx)(X,{incentive:B,provider:D,onboardingUrl:D.onboarding?._links?.onboard?.href??null,onDismiss:A,onAccept:M,setUpPlugin:U}),g&&(0,h.jsxs)("div",{className:"notice notice-error is-dismissible wcpay-settings-notice",children:[(0,h.jsx)("p",{children:g}),(0,h.jsx)("button",{type:"button",className:"notice-dismiss",onClick:()=>{w(null)}})]}),R&&D&&B&&(0,h.jsx)(J,{incentive:B,provider:D,onboardingUrl:D.onboarding?._links?.onboard?.href??null,onDismiss:A,onAccept:M,setUpPlugin:U}),(0,h.jsxs)("div",{className:"settings-payments-main__container",children:[(0,h.jsx)(Y,{providers:n||O,installedPluginSlugs:N,installingPlugin:e,setUpPlugin:U,acceptIncentive:M,shouldHighlightIncentive:L,updateOrdering:function(e){const t=e.map(e=>e._order).sort((e,t)=>e-t),n={};e.forEach((e,s)=>{n[e.id]=t[s]}),u(n),o(e)},isFetching:E,businessRegistrationCountry:f,setBusinessRegistrationCountry:b,setIsOnboardingModalOpen:k}),!E&&0===I.length&&(0,h.jsx)("div",{className:"more-payment-options",children:W}),(E||I.length>0)&&(0,h.jsx)(P,{suggestions:I,suggestionCategories:T,installingPlugin:e,setUpPlugin:U,isFetching:E,morePaymentOptionsLink:W})]}),((0,x.ZT)(O)||(0,x.Pt)(O))&&(0,h.jsx)(_e,{isOpen:j,setIsOpen:k,providerData:(0,x.RY)(O)||{}}),(0,h.jsx)(G.lQ,{isOpen:y&&(0,x.Pt)(O),devMode:(0,x.MQ)(O),onClose:()=>v(!1)})]})},pe=ue},8181:(e,t,n)=>{t.A=function(e){var t=e.size,n=void 0===t?24:t,s=e.onClick,c=(e.icon,e.className),r=function(e,t){if(null==e)return{};var n,s,o=function(e,t){if(null==e)return{};var n,s,o={},i=Object.keys(e);for(s=0;s<i.length;s++)n=i[s],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)n=i[s],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i),l=["gridicon","gridicons-cross-small",c,!1,!1,!1].filter(Boolean).join(" ");return o.default.createElement("svg",a({className:l,height:n,width:n,onClick:s},r,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}),o.default.createElement("g",null,o.default.createElement("path",{d:"M17.705 7.705l-1.41-1.41L12 10.59 7.705 6.295l-1.41 1.41L10.59 12l-4.295 4.295 1.41 1.41L12 13.41l4.295 4.295 1.41-1.41L13.41 12l4.295-4.295z"})))};var s,o=(s=n(51609))&&s.__esModule?s:{default:s},i=["size","onClick","icon","className"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},a.apply(this,arguments)}},46608:(e,t,n)=>{t.A=function(e){var t=e.size,n=void 0===t?24:t,s=e.onClick,c=(e.icon,e.className),r=function(e,t){if(null==e)return{};var n,s,o=function(e,t){if(null==e)return{};var n,s,o={},i=Object.keys(e);for(s=0;s<i.length;s++)n=i[s],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)n=i[s],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,i),l=["gridicon","gridicons-info-outline",c,!!function(e){return 0==e%18}(n)&&"needs-offset",!1,!1].filter(Boolean).join(" ");return o.default.createElement("svg",a({className:l,height:n,width:n,onClick:s},r,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}),o.default.createElement("g",null,o.default.createElement("path",{d:"M13 9h-2V7h2v2zm0 2h-2v6h2v-6zm-1-7c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8m0-2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2z"})))};var s,o=(s=n(51609))&&s.__esModule?s:{default:s},i=["size","onClick","icon","className"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},a.apply(this,arguments)}}}]);
Save File
Cancel