PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 5.4.3
WooCommerce Square v5.4.3
5.4.3 5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / build / cash-app-pay.js
woocommerce-square / build Last commit date
assets 3 months ago fonts 2 years ago images 2 years ago cash-app-pay.asset.php 4 months ago cash-app-pay.js 4 months ago index.asset.php 4 months ago index.js 4 months ago onboarding.asset.php 2 months ago onboarding.css 2 months ago onboarding.js 5 months ago settings.asset.php 2 months ago settings.css 2 months ago settings.js 5 months ago
cash-app-pay.js
1 lines
1 (()=>{"use strict";const e=window.React,t=window.wp.htmlEntities,a=window.wc.wcBlocksRegistry,n=window.wp.i18n,o=window.wp.element,r=window.wc.wcSettings,s=window.wp.data,i="square_cash_app_pay",{PAYMENT_STORE_KEY:c}=window.wc.wcBlocksData;let d=null;const p=()=>{if(null!==d)return d;const e=(0,r.getSetting)("square_cash_app_pay_data",null);if(!e)throw new Error("Square Cash App Pay initialization data is not available");return d={title:e.title||"",description:e.description||"",applicationId:e.application_id||"",locationId:e.location_id||"",isSandbox:e.is_sandbox||!1,loggingEnabled:e.logging_enabled||!1,generalError:e.general_error||"",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{},isPayForOrderPage:e.is_pay_for_order_page||!1,orderId:e.order_id||"",orderKey:e.order_key||"",ajaxUrl:e.ajax_url||"",paymentRequestNonce:e.payment_request_nonce||"",continuationSessionNonce:e.continuation_session_nonce||"",gatewayIdDasherized:e.gateway_id_dasherized||"",buttonStyles:e.button_styles||{},isContinuation:e.is_continuation||!1,refereneceId:e.reference_id||""},d},l=e=>p().ajaxUrl.replace("%%endpoint%%",`square_cash_app_pay_${e}`),u=(e=!1)=>new Promise((t,a)=>{const n={security:p().continuationSessionNonce,clear:e};jQuery.post(l("set_continuation_session"),n,e=>e.success?t(e.data):a(e.data))}),w=(e,t="notice")=>{p().loggingEnabled&&("error"===t?console.error(e):console.log(e))},y="wc-square-cash-app-pay",m=a=>{const[n,r]=(0,o.useState)(null),[s,c]=(0,o.useState)(!1),[d,m]=(0,o.useState)(""),_=(0,o.useRef)(d),{applicationId:S,locationId:h,buttonStyles:g,referenceId:P,generalError:E,gatewayIdDasherized:C,description:q}=p(),{onSubmit:b,emitResponse:f,eventRegistration:A,billing:{cartTotal:v,currency:R},components:{LoadingMask:I},activePaymentMethod:k}=a,{onPaymentSetup:O}=A;return(0,o.useEffect)(()=>{_.current=d,d&&b()},[d,b]),(0,o.useEffect)(()=>O(()=>{if(!_.current)return{type:f.responseTypes.ERROR,message:E};const e={[`wc-${C}-payment-nonce`]:_.current||""};return{type:f.responseTypes.SUCCESS,meta:{paymentMethodData:e}}}),[f.responseTypes.SUCCESS,f.responseTypes.ERROR,O,d,C,E]),(0,o.useEffect)(()=>{if(c(!1),r(null),!window.Square)return;w("[Square Cash App Pay] Initializing Square Cash App Pay Button");const e=window.Square.payments(S,h);return e?(async function t(){c(!1);try{const a=await(async e=>{const t=await new Promise((e,t)=>{const a={security:p().paymentRequestNonce,is_pay_for_order_page:p().isPayForOrderPage||!1,order_id:p().orderId||0,...p().isPayForOrderPage&&p().orderKey&&{order_key:p().orderKey}};jQuery.post(l("get_payment_request"),a,a=>a.success?e(a.data):t(a.data))}),a=JSON.parse(t);return e.paymentRequest(a)})(e);window.wcSquareCashAppPay&&(await window.wcSquareCashAppPay.destroy(),window.wcSquareCashAppPay=null);const n=await e.cashAppPay(a,{redirectURL:window.location.href,referenceId:P});await n.attach(`#${y}`,g),n.addEventListener("ontokenization",async e=>{const{tokenResult:a,error:n}=e.detail;if(n)m(""),r(n.message);else if("OK"===a.status){const e=a.token;e||(m(""),r(E)),m(e)}else m(null),t()}),n.addEventListener("customerInteraction",e=>{if(e.detail&&e.detail.isMobile)return u()}),window.wcSquareCashAppPay=n,w("[Square Cash App Pay] Square Cash App Pay Button Loaded")}catch(e){r(E),console.error(e)}c(!0)}(),()=>(async()=>{window.wcSquareCashAppPay&&(await window.wcSquareCashAppPay.destroy(),window.wcSquareCashAppPay=null)})()):void 0},[v.value,R.code,S,h,E,P]),(0,o.useEffect)(()=>{const e=document.querySelector("button.wc-block-components-checkout-place-order-button");if(e)return k!==i||d||e.setAttribute("disabled","disabled"),()=>{e.removeAttribute("disabled")}},[k,d]),(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",null,(0,t.decodeEntities)(q||"")),n&&(0,e.createElement)("div",{className:"woocommerce-error"},n),!n&&(0,e.createElement)(I,{isLoading:!s,showSpinner:!0},(0,e.createElement)("div",{id:y})))},{title:_,applicationId:S,locationId:h}=p(),g=({RenderedComponent:t,isEdit:a,...n})=>a?null:(0,e.createElement)(t,{...n}),P={name:i,label:(0,e.createElement)(a=>{const{PaymentMethodLabel:n}=a.components;return(0,e.createElement)(n,{text:(0,t.decodeEntities)(_)})},null),paymentMethodId:i,ariaLabel:(0,n.__)("Cash App Pay payment method","woocommerce-square"),content:(0,e.createElement)(g,{RenderedComponent:m}),edit:(0,e.createElement)(g,{RenderedComponent:m,isEdit:!0}),canMakePayment:({billingData:e,cartTotals:t})=>{const a=S&&h,n="US"===e.country,o="USD"===t.currency_code,r=a&&n&&o;return r&&(()=>{const e=(0,s.select)(c).getAvailablePaymentMethods();Object.keys(e||{}).includes(i)&&p().isContinuation&&!window.wcSquareCashAppPaySelected&&(w("[Square Cash App Pay] Selecting Cash App Pay payment method"),(0,s.dispatch)(c).__internalSetActivePaymentMethod(i),window.wcSquareCashAppPaySelected=!0,u(!0))})(),r},supports:{features:p().supports||[],showSavedCards:p().showSavedCards||!1,showSaveOption:p().showSaveOption||!1}};(0,a.registerPaymentMethod)(P)})();