Changeset 3783722
- Timestamp:
- 11/04/2026 11:04:51 AM (13 hours ago)
- Location:
- paysafe-checkout
- Files:
-
- 156 added
- 32 edited
-
tags/4.3.12 (added)
-
tags/4.3.12/CHANGELOG.md (added)
-
tags/4.3.12/LICENSE.txt (added)
-
tags/4.3.12/Paysafe-Checkout-for-WooCommerce-Merchant-Guide.pdf (added)
-
tags/4.3.12/README.md (added)
-
tags/4.3.12/admin (added)
-
tags/4.3.12/admin/pages (added)
-
tags/4.3.12/admin/pages/admin_options.php (added)
-
tags/4.3.12/assets (added)
-
tags/4.3.12/assets/admin (added)
-
tags/4.3.12/assets/admin/admin-paysafe.css (added)
-
tags/4.3.12/assets/admin/gen (added)
-
tags/4.3.12/assets/admin/gen/admin-paysafe.js (added)
-
tags/4.3.12/assets/css (added)
-
tags/4.3.12/assets/css/blocks-paysafe.css (added)
-
tags/4.3.12/assets/css/general-paysafe.css (added)
-
tags/4.3.12/assets/img (added)
-
tags/4.3.12/assets/img/amex.png (added)
-
tags/4.3.12/assets/img/card-brands.svg (added)
-
tags/4.3.12/assets/img/cvv.svg (added)
-
tags/4.3.12/assets/img/maestro.png (added)
-
tags/4.3.12/assets/img/mastercard.png (added)
-
tags/4.3.12/assets/img/paysafe-ach.svg (added)
-
tags/4.3.12/assets/img/paysafe-apple-pay.svg (added)
-
tags/4.3.12/assets/img/paysafe-eft.svg (added)
-
tags/4.3.12/assets/img/paysafe-google-pay.svg (added)
-
tags/4.3.12/assets/img/paysafe-icon.png (added)
-
tags/4.3.12/assets/img/paysafe-neteller.svg (added)
-
tags/4.3.12/assets/img/paysafe-paybybank.svg (added)
-
tags/4.3.12/assets/img/paysafe-paypal.svg (added)
-
tags/4.3.12/assets/img/paysafe-pcard.svg (added)
-
tags/4.3.12/assets/img/paysafe-pcash.svg (added)
-
tags/4.3.12/assets/img/paysafe-sightline.svg (added)
-
tags/4.3.12/assets/img/paysafe-skrill.svg (added)
-
tags/4.3.12/assets/img/paysafe-venmo.svg (added)
-
tags/4.3.12/assets/img/paysafe-vippreferred.svg (added)
-
tags/4.3.12/assets/img/visa.png (added)
-
tags/4.3.12/assets/js (added)
-
tags/4.3.12/assets/js/blocks (added)
-
tags/4.3.12/assets/js/blocks/blocks-ach.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-ach.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-apple_pay.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-apple_pay.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-eft.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-eft.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-google_pay.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-google_pay.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-neteller.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-neteller.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-pay_by_bank.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-pay_by_bank.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafe.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafe.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafecard.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafecard.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafecash.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafecash.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafepaypal.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-paysafepaypal.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-sightline.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-sightline.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-skrill.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-skrill.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-venmo.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-venmo.js (added)
-
tags/4.3.12/assets/js/blocks/blocks-vippreferred.asset.php (added)
-
tags/4.3.12/assets/js/blocks/blocks-vippreferred.js (added)
-
tags/4.3.12/assets/js/legacy (added)
-
tags/4.3.12/assets/js/legacy/add-payment-method.asset.php (added)
-
tags/4.3.12/assets/js/legacy/add-payment-method.js (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-apple-express.asset.php (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-apple-express.js (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-apple-product.asset.php (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-apple-product.js (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-google-express.asset.php (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-google-express.js (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-google-product.asset.php (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe-google-product.js (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe.asset.php (added)
-
tags/4.3.12/assets/js/legacy/legacy-paysafe.js (added)
-
tags/4.3.12/assets/js/legacy/my-account-order-pay.asset.php (added)
-
tags/4.3.12/assets/js/legacy/my-account-order-pay.js (added)
-
tags/4.3.12/i18n (added)
-
tags/4.3.12/i18n/languages (added)
-
tags/4.3.12/i18n/languages/paysafe-checkout.pot (added)
-
tags/4.3.12/includes (added)
-
tags/4.3.12/includes/api (added)
-
tags/4.3.12/includes/api/class-paysafe-admin-rest-controller.php (added)
-
tags/4.3.12/includes/api/class-wc-api-paysafe-base.php (added)
-
tags/4.3.12/includes/api/class-wc-api-paysafe-card.php (added)
-
tags/4.3.12/includes/api/class-wc-api-paysafe-general.php (added)
-
tags/4.3.12/includes/blocks (added)
-
tags/4.3.12/includes/blocks/WC_Gateway_Paysafe_Blocks_Support.php (added)
-
tags/4.3.12/includes/exception (added)
-
tags/4.3.12/includes/exception/class-wc-exception-paysafe.php (added)
-
tags/4.3.12/includes/gateway (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-apple-pay.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-google-pay.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-ach.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-base.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-card.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-cash.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-eft.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-neteller.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-paybybank.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-paypal.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-sightline.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-skrill.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-venmo.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe-vippreferred.php (added)
-
tags/4.3.12/includes/gateway/class-wc-gateway-paysafe.php (added)
-
tags/4.3.12/paysafe-checkout.php (added)
-
tags/4.3.12/paysafe-sdk (added)
-
tags/4.3.12/paysafe-sdk/Connectors (added)
-
tags/4.3.12/paysafe-sdk/Connectors/PaysafeApiBaseConnector.php (added)
-
tags/4.3.12/paysafe-sdk/Connectors/PaysafeApiCardConnector.php (added)
-
tags/4.3.12/paysafe-sdk/Connectors/PaysafeApiGeneralConnector.php (added)
-
tags/4.3.12/paysafe-sdk/Exceptions (added)
-
tags/4.3.12/paysafe-sdk/Exceptions/PaysafeApiException.php (added)
-
tags/4.3.12/paysafe-sdk/Logging (added)
-
tags/4.3.12/paysafe-sdk/Logging/Filters (added)
-
tags/4.3.12/paysafe-sdk/Logging/Filters/PaysafeEmailCensorshipFilter.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/Filters/PaysafeIPCensorshipFilter.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/Filters/PaysafePANCensorshipFilter.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/Interfaces (added)
-
tags/4.3.12/paysafe-sdk/Logging/Interfaces/PaysafeLogCensorshipFilterInterface.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/Interfaces/PaysafeLoggerInterface.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/PaysafeLogCensorship.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/PaysafeLogger.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/PaysafeLoggerAdapter.php (added)
-
tags/4.3.12/paysafe-sdk/Logging/PaysafeLoggerProvider.php (added)
-
tags/4.3.12/paysafe-sdk/Result (added)
-
tags/4.3.12/paysafe-sdk/Result/PaysafeApiResult.php (added)
-
tags/4.3.12/readme.txt (added)
-
tags/4.3.12/resources (added)
-
tags/4.3.12/resources/html (added)
-
tags/4.3.12/resources/html/checkout (added)
-
tags/4.3.12/resources/html/checkout/express-apple-google-combo-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/hosted-apple-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/hosted-google-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/hosted-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/hosted-product-page-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-apple-pay-express-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-google-pay-express-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-paybybank-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-paypal-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-sightline-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-venmo-payment-form.php (added)
-
tags/4.3.12/resources/html/checkout/legacy-vippreferred-payment-form.php (added)
-
tags/4.3.12/resources/html/general (added)
-
tags/4.3.12/resources/html/general/test-mode-notice.php (added)
-
tags/4.3.12/resources/html/my-account (added)
-
tags/4.3.12/resources/html/my-account/payment-methods (added)
-
tags/4.3.12/resources/html/my-account/payment-methods/add-paysafe-payment-method-form.php (added)
-
tags/4.3.12/settings (added)
-
tags/4.3.12/settings/PaysafeSettings.php (added)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-ach.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-ach.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-apple_pay.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-apple_pay.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-eft.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-eft.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-google_pay.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-google_pay.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-neteller.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-neteller.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-pay_by_bank.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-pay_by_bank.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafe.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafe.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafecard.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafecard.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafecash.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafecash.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafepaypal.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-paysafepaypal.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-sightline.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-sightline.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-skrill.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-skrill.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-venmo.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-venmo.js (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-vippreferred.asset.php (modified) (1 diff)
-
trunk/assets/js/blocks/blocks-vippreferred.js (modified) (1 diff)
-
trunk/i18n/languages/paysafe-checkout.pot (modified) (2 diffs)
-
trunk/paysafe-checkout.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
paysafe-checkout/trunk/CHANGELOG.md
r3756379 r3783722 1 = 4.3.12, 2026-10-26= 2 * Dependency updates 3 1 4 = 4.3.11, 2026-10-14 = 2 5 * Integration changes for Neteller in Paysafe Checkout -
paysafe-checkout/trunk/assets/js/blocks/blocks-ach.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 7d7f49106a45cba67dfe');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'e8ff85281cb89146d39b'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-ach.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(n){const a=t[n];if(void 0!==a)return a.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="ach",g=(0,a.getSetting)(h+"_data",{});var y;y=g.nonce,c=y||"";let f={};const w=e=>{const{eventRegistration:t,emitResponse:n}=e,{onCheckoutSuccess:a}=t;return(0,o.useEffect)(()=>{const e=a(e=>function(e,t,n,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=n.log_order_fail_endpoint||null,y=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(g,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(y,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,n,a,o,i,r,c,h){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(g,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(w.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(w.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(w.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(w.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(w.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),m(g,n,e),"Result failure"}const r={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(g,n,e.error_message),l(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,r,c,h,f,e,i,g):function(e,t,n,a,o,i,r,c,h){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:n,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=u(e);m(g,n,a),l(y,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(a);if(m(g,n,e),t)l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(y,e,[]),d(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(y,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(g,n,a),l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(g,n,t),l(y,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,r,c,h,f,e,i,g)}return e}(e,f,g,{displayPaymentMethods:["ach"],paymentMethodDetails:{ach:{accountId:g.account_id}}},!1,n));return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],a]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,r.jsx)("hr",{})),e.test_mode&&n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(g)},b={name:h,paymentMethodId:h,label:function(e,t){const n=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:n}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(g.title,g.icon),content:(0,r.jsx)(w,{}),edit:(0,r.jsx)(w,{}),canMakePayment:e=>(f=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,n.registerPaymentMethod)(b)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=n(),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),n=e(e=>{e.exports=window.React});const a=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const g="ach",y=(0,i.getSetting)(g+"_data",{});var f;f=y.nonce,l=f||"";let w={};const b=e=>{const{eventRegistration:s,emitResponse:n}=e,{onCheckoutSuccess:o}=s;return(0,r.useEffect)(()=>{const e=o(e=>function(e,t,s,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=s.log_order_fail_endpoint||null,y=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(g,r,(0,a.__)("Payment amount missing","paysafe-checkout")),d(y,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,n,o,i,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(g,s,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=n),n&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),u(g,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(g,s,e.error_message),d(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,n,r,c,l,f,e,i,g):function(e,t,s,n,o,i,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let n=_(e);u(g,s,n),d(y,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(n);if(u(g,s,e),t)d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),d(y,e,[]),p(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(y,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let n="";n=t?(0,a.__)("Payment session expired","paysafe-checkout"):e,u(g,s,n),d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");u(g,s,t),d(y,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,n,r,c,l,f,e,i,g)}return e}(e,w,y,{displayPaymentMethods:["ach"],paymentMethodDetails:{ach:{accountId:y.account_id}}},!1,n));return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],o]),function(e,s=""){let n=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,t().jsx)("hr",{})),e.test_mode&&n.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&n.push(s),n}(y)},T={name:g,paymentMethodId:g,label:function(e,s){const n=(0,c.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:n}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:n})]})}(y.title,y.icon),content:(0,t().jsx)(b,{}),edit:(0,t().jsx)(b,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,o.registerPaymentMethod)(T)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-apple_pay.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 76333c8c4e6b05ce0dd9');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'c4547ab1d5a2469d84ff'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-apple_pay.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var a=s(609),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,a=window.wc.wcBlocksRegistry,n=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(a){const n=t[a];if(void 0!==n)return n.exports;const o=t[a]={exports:{}};return e[a](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s,a){return{error_code:e&&e.code?e.code:0,error_message:e&&e.message?e.message:"",display_message:e&&e.displayMessage?e.displayMessage:"",detailed_message:e&&e.detailedMessage?e.detailedMessage:"",correlationId:e&&e.correlationId?e.correlationId:"-",store_currency:t&&t.currency_code?t.currency_code:"-",cart_currency:a&&a.cartTotals&&a.cartTotals.currency_code?a.cartTotals.currency_code:"-",account_ids:s&&s.accounts?s.accounts:{},wp_version:(0,n.getSetting)("wpVersion",""),woo_version:(0,n.getSetting)("wcVersion",""),paysafe_version:t&&t.paysafe_version?t.paysafe_version:"-"}}function _(e,t,a,n,o,i){const r=!0===t.log_errors&&t.log_error_endpoint||null,c="GOOGLEPAY"===e?"google_pay":"apple_pay",d=parseInt(a.cartTotals.total_price);if(!d)return l(r,"ERROR: Express checkout order amount is not set",[]),void o((0,s.__)("ERROR: Express checkout order amount is not set","paysafe-checkout"));let u="",_="",m="",y="",h="";a&&a.billingAddress&&a.billingAddress.postcode&&(u=a.billingAddress.address_1,_=a.billingAddress.city,m=a.billingAddress.postcode,y=a.billingAddress.state,h=a.billingAddress.country);const g=a.cartTotals.currency_code,f=t.express_merchant_ref_num||c+"_"+Date.now(),w={transactionSource:"WooCommerceJs",amount:d,transactionType:"PAYMENT",currency:g,merchantRefNum:f,environment:t.test_mode?"TEST":"LIVE",paymentType:e,accountId:t.account_id};"APPLEPAY"===e&&(w.applePay={requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]},t.apple_pay_issuer_country&&(w.applePay.country=t.apple_pay_issuer_country)),"GOOGLEPAY"===e&&(w.googlePay={requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]},w.threeDs={merchantUrl:t.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},t.google_pay_issuer_country&&(w.googlePay.country=t.google_pay_issuer_country)),h&&m&&u&&_&&y&&(w.customerDetails={billingDetails:{country:h,zip:m,street:u,city:_,state:y}}),n.tokenize(w).then(a=>{const i=a.token||null;if(!i){const e=(0,s.__)("ERROR: Express checkout couldn't tokenize the payment information","paysafe-checkout");return l(r,e,[]),void o(e)}const u={gateway_id:c,nonce:t.nonce},_=p(t.express_checkout_endpoint);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(u)}).then(e=>e.json()).then(a=>{if("success"===a.status){const c=a.order_id||null;if(!c)return l(r,"ERROR: Express checkout couldn't create Order",[]),void o((0,s.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"));const u={orderId:c,paymentMethod:e,transactionType:"PAYMENT",paymentHandleToken:i,amount:d,customerOperation:"",merchantRefNum:f,nonce:t.nonce},_=p(t.register_url);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(u)}).then(e=>e.json()).then(e=>{"success"===e.status?n.complete("success"):(o("ERROR: Express checkout payment failed"+(e.message?" ("+e.message+")":"")),n.complete("fail")),window.location=e.redirect_url}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;l(r,t,[]),o(t),n.complete("fail")})}else o((0,s.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"))}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;l(r,t,[]),o(t),n.complete("fail")})}).catch(e=>{let t="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:"");e.displayMessage&&(t=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),l(r,t,[]),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?i():t&&o(t)})}function m(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function y(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const g="apple_pay",f=(0,n.getSetting)("apple_pay_data",{});var w;w=f.nonce,c=w||"";const P=(0,n.getSetting)("google_pay_data",{}),b="paysafe_js"===f.integration_type;let k,R,E=!1;f.is_apple_pay_express_enabled&&f.is_google_pay_express_enabled&&(E=!0);let T={},A=!1;const S=function(e,t,a){if(!jQuery("#paysafe-hosted-apple-pay-payment-form").length)return;if(A)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){S(e,t,a)},1e3);A=!0;const n={currencyCode:f.currency_code,environment:f.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",accounts:{default:f.account_id,applePay:f.account_id},fields:{applePay:{selector:"#paysafe-apple-pay",type:"buy",label:(0,s.__)("Pay with Apple Pay","paysafe-checkout"),color:"black",buttonWidth:"240px",buttonHeight:"55px"}}};null!=f.initialization_timeout&&Number(f.initialization_timeout)>=1e3&&(n.initializationTimeout=Number(f.initialization_timeout)),f.apple_pay_issuer_country&&(n.fields.applePay.country=f.apple_pay_issuer_country),E&&(n.accounts.googlePay=P.account_id,n.fields.googlePay={selector:"#paysafe-google-pay",type:"buy",color:"black",label:(0,s.__)("Google Pay","paysafe-checkout"),buttonWidth:"240px",buttonHeight:"55px"},P.google_pay_issuer_country&&(n.fields.googlePay.country=P.google_pay_issuer_country),P.google_pay_merchant_id&&(n.fields.googlePay.merchantId=P.google_pay_merchant_id));let o=!1;(function(e,t,a,n){const o=!0===e.log_errors&&e.log_error_endpoint||null;return void 0===n&&(n=!1),null!=e.initialization_timeout&&Number(e.initialization_timeout)>=1e3&&(t.initializationTimeout=Number(e.initialization_timeout)),paysafe.fields.setup(e.authorization,t).then(e=>e.show().then(t=>t.card&&!t.card.error||t.applePay&&!t.applePay.error||t.googlePay&&!t.googlePay.error?e:void 0)).catch(i=>{if(i.error&&(i=i.error),!n){const n="ERROR "+i.code+": "+i.detailedMessage,r=u(i,e,t,a);l(o,n,r),d(h(i.code,(0,s.__)("The payment initialization failed. Please reload the page and try again.","paysafe-checkout")),!0)}return Promise.reject(i)})})(f,n,T,!0).then(s=>{R?.abort(),R=new AbortController,document.getElementById("paysafe-apple-pay").addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),e(),o=!0,_("APPLEPAY",f,T,s,a,t)},{signal:R.signal}),E&&(k?.abort(),k=new AbortController,document.getElementById("paysafe-google-pay").addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),e(),o=!0,_("GOOGLEPAY",P,T,s,a,t)},{signal:k.signal}))}).catch(e=>{!function(e,t,a,n,o,i,r){e.error&&(e=e.error);const c=!0===t.log_errors&&t.log_error_endpoint||null;let d="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:e.message?e.message:"");e.displayMessage&&(d=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),l(c,d,u(e,t,a,n)),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?r():i(o&&d?d:(0,s.__)("Error! Unable to set up Express Checkout at this moment. Please, try again later.","paysafe-checkout")+(e.code?" ("+e.code+")":""))}(e,f,n,T,o,a,t),o=!1})},N=e=>{const{eventRegistration:t,emitResponse:a}=e,{onCheckoutSuccess:n}=t;return(0,o.useEffect)(()=>{const e=n(e=>{const t={applePay:{accountId:f.account_id,label:"apple_pay"}};return f.apple_pay_issuer_country&&(t.applePay.country=f.apple_pay_issuer_country),function(e,t,a,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",u=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=a.log_order_fail_endpoint||null,g=!0===a.log_errors&&a.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(_,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},_={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,a,n,o,i,r,c,u){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(_,a,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=n),n&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:u.billing_zip,country:u.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:u.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),u.billing_street&&(w.customerDetails.billingDetails.street=u.billing_street),u.billing_street2&&(w.customerDetails.billingDetails.street2=u.billing_street2),u.billing_city&&(w.customerDetails.billingDetails.city=u.billing_city),u.billing_state&&(w.customerDetails.billingDetails.state=u.billing_state),u.billing_phone&&(w.customerDetails.billingDetails.phone=u.billing_phone),f.tokenize(w).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),m(_,a,e),"Result failure"}const r={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(_,a,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=y(e);m(_,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(g,n,[]),d(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=y(e);m(_,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(g,n,[]),d(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,n,r,c,u,f,e,i,_):function(e,t,a,n,o,i,r,c,u){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:u.billing_zip,country:u.billing_country},u.billing_street&&(f.billingAddress.street=u.billing_street),u.billing_street2&&(f.billingAddress.street2=u.billing_street2),u.billing_city&&(f.billingAddress.city=u.billing_city),u.billing_state&&(f.billingAddress.state=u.billing_state),u.billing_phone&&(f.billingAddress.phone=u.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let n=y(e);m(_,a,n),l(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=y(n);if(m(_,a,e),t)l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),l(g,e,[]),d(h(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let n="";n=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(_,a,n),l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(_,a,t),l(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,n,r,c,u,f,e,i,_)}return e}(e,T,f,{displayPaymentMethods:["applePay"],paymentMethodDetails:t,settings:{add_customer_when_single_use_token:!0,add_billing_when_single_use_token:!0}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],n]),function(e,t=""){let a=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,r.jsx)("hr",{})),e.test_mode&&a.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&a.push(t),a}(f)},C=e=>{const{eventRegistration:t,onClick:a,onClose:n,onError:c}=e,{onCheckoutSuccess:l}=t,{subscribe:d,select:p}=window.wp.data,{checkoutStore:u}=window.wc.wcBlocksData;let _=p(u).isCalculating();return(0,o.useEffect)(()=>{d(()=>{const e=p(u).isCalculating();e!==_&&(A=!!e,_=e)})},[[],{},d]),(0,o.useEffect)(()=>{S(a,n,c);const e=l(e=>e);return()=>{e()}},[[],{},l]),function(e,t=""){let a=[(0,r.jsx)("div",{children:(0,i.decodeEntities)((0,s.__)("Easy and secure payments with Paysafe","paysafe-checkout"))})];return e.test_mode&&(a.push((0,r.jsx)("hr",{})),a.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),a.push((0,r.jsx)("p",{}))),t&&a.push(t),a}(f,wp.element.RawHTML({children:f.integration_hosted_form}))};if(async function(){if(window.ApplePaySession&&ApplePaySession.canMakePayments())return!0;if(window.PaymentRequest)try{const e=new PaymentRequest([{supportedMethods:"https://apple.com/apple-pay",data:{version:3,merchantIdentifier:"your.merchant.id",merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard","amex"],countryCode:"US"}}],{total:{label:"Check",amount:{currency:"USD",value:"0.00"}}});return await e.canMakePayment()}catch(e){return!1}return!1})if(b){const e={name:g,title:"Apple Pay Express Checkout",description:f.description,gatewayId:"paysafe",label:function(){const e=(0,s.__)("Paysafe Express Payment","paysafe-checkout");return(0,r.jsx)("div",{className:"paysafe-gateway-title",children:(0,r.jsx)("span",{children:e})})}(),content:(0,r.jsx)(C,{}),edit:(0,r.jsx)(C,{}),canMakePayment:e=>(T=e,!0),paymentMethodId:g,supports:{features:f.supports}};(0,a.registerExpressPaymentMethod)(e)}else{const e={name:g,paymentMethodId:g,label:function(e,t){const a=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:a}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:a})]})}(f.title,f.icon),content:(0,r.jsx)(N,{}),edit:(0,r.jsx)(N,{}),canMakePayment:e=>(T=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:f.supports}};(0,a.registerPaymentMethod)(e)}})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=a(),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),a=e(e=>{e.exports=window.React});const n=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function u(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,n.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function _(e,t,s,a){return{error_code:e&&e.code?e.code:0,error_message:e&&e.message?e.message:"",display_message:e&&e.displayMessage?e.displayMessage:"",detailed_message:e&&e.detailedMessage?e.detailedMessage:"",correlationId:e&&e.correlationId?e.correlationId:"-",store_currency:t&&t.currency_code?t.currency_code:"-",cart_currency:a&&a.cartTotals&&a.cartTotals.currency_code?a.cartTotals.currency_code:"-",account_ids:s&&s.accounts?s.accounts:{},wp_version:(0,i.getSetting)("wpVersion",""),woo_version:(0,i.getSetting)("wcVersion",""),paysafe_version:t&&t.paysafe_version?t.paysafe_version:"-"}}function m(e,t,s,a,o,i){const r=!0===t.log_errors&&t.log_error_endpoint||null,c="GOOGLEPAY"===e?"google_pay":"apple_pay",l=parseInt(s.cartTotals.total_price);if(!l)return d(r,"ERROR: Express checkout order amount is not set",[]),void o((0,n.__)("ERROR: Express checkout order amount is not set","paysafe-checkout"));let p="",_="",m="",y="",h="";s&&s.billingAddress&&s.billingAddress.postcode&&(p=s.billingAddress.address_1,_=s.billingAddress.city,m=s.billingAddress.postcode,y=s.billingAddress.state,h=s.billingAddress.country);const g=s.cartTotals.currency_code,f=t.express_merchant_ref_num||c+"_"+Date.now(),w={transactionSource:"WooCommerceJs",amount:l,transactionType:"PAYMENT",currency:g,merchantRefNum:f,environment:t.test_mode?"TEST":"LIVE",paymentType:e,accountId:t.account_id};"APPLEPAY"===e&&(w.applePay={requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]},t.apple_pay_issuer_country&&(w.applePay.country=t.apple_pay_issuer_country)),"GOOGLEPAY"===e&&(w.googlePay={requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]},w.threeDs={merchantUrl:t.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},t.google_pay_issuer_country&&(w.googlePay.country=t.google_pay_issuer_country)),h&&m&&p&&_&&y&&(w.customerDetails={billingDetails:{country:h,zip:m,street:p,city:_,state:y}}),a.tokenize(w).then(s=>{const i=s.token||null;if(!i){const e=(0,n.__)("ERROR: Express checkout couldn't tokenize the payment information","paysafe-checkout");return d(r,e,[]),void o(e)}const p={gateway_id:c,nonce:t.nonce},_=u(t.express_checkout_endpoint);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(p)}).then(e=>e.json()).then(s=>{if("success"===s.status){const c=s.order_id||null;if(!c)return d(r,"ERROR: Express checkout couldn't create Order",[]),void o((0,n.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"));const p={orderId:c,paymentMethod:e,transactionType:"PAYMENT",paymentHandleToken:i,amount:l,customerOperation:"",merchantRefNum:f,nonce:t.nonce},_=u(t.register_url);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(p)}).then(e=>e.json()).then(e=>{"success"===e.status?a.complete("success"):(o("ERROR: Express checkout payment failed"+(e.message?" ("+e.message+")":"")),a.complete("fail")),window.location=e.redirect_url}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;d(r,t,[]),o(t),a.complete("fail")})}else o((0,n.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"))}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;d(r,t,[]),o(t),a.complete("fail")})}).catch(e=>{let t="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:"");e.displayMessage&&(t=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),d(r,t,[]),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?i():t&&o(t)})}function y(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function h(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function g(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,n.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,n.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,n.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,n.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,n.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const f="apple_pay",w=(0,i.getSetting)("apple_pay_data",{});var P;P=w.nonce,l=P||"";const b=(0,i.getSetting)("google_pay_data",{}),k="paysafe_js"===w.integration_type;let R,E,T=!1;w.is_apple_pay_express_enabled&&w.is_google_pay_express_enabled&&(T=!0);let A={},S=!1;const N=function(e,t,s){if(!jQuery("#paysafe-hosted-apple-pay-payment-form").length)return;if(S)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){N(e,t,s)},1e3);S=!0;const a={currencyCode:w.currency_code,environment:w.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",accounts:{default:w.account_id,applePay:w.account_id},fields:{applePay:{selector:"#paysafe-apple-pay",type:"buy",label:(0,n.__)("Pay with Apple Pay","paysafe-checkout"),color:"black",buttonWidth:"240px",buttonHeight:"55px"}}};null!=w.initialization_timeout&&Number(w.initialization_timeout)>=1e3&&(a.initializationTimeout=Number(w.initialization_timeout)),w.apple_pay_issuer_country&&(a.fields.applePay.country=w.apple_pay_issuer_country),T&&(a.accounts.googlePay=b.account_id,a.fields.googlePay={selector:"#paysafe-google-pay",type:"buy",color:"black",label:(0,n.__)("Google Pay","paysafe-checkout"),buttonWidth:"240px",buttonHeight:"55px"},b.google_pay_issuer_country&&(a.fields.googlePay.country=b.google_pay_issuer_country),b.google_pay_merchant_id&&(a.fields.googlePay.merchantId=b.google_pay_merchant_id));let o=!1;(function(e,t,s,a){const o=!0===e.log_errors&&e.log_error_endpoint||null;return void 0===a&&(a=!1),null!=e.initialization_timeout&&Number(e.initialization_timeout)>=1e3&&(t.initializationTimeout=Number(e.initialization_timeout)),paysafe.fields.setup(e.authorization,t).then(e=>e.show().then(t=>t.card&&!t.card.error||t.applePay&&!t.applePay.error||t.googlePay&&!t.googlePay.error?e:void 0)).catch(i=>{if(i.error&&(i=i.error),!a){const a="ERROR "+i.code+": "+i.detailedMessage,r=_(i,e,t,s);d(o,a,r),p(g(i.code,(0,n.__)("The payment initialization failed. Please reload the page and try again.","paysafe-checkout")),!0)}return Promise.reject(i)})})(w,a,A,!0).then(a=>{E?.abort(),E=new AbortController,document.getElementById("paysafe-apple-pay").addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),e(),o=!0,m("APPLEPAY",w,A,a,s,t)},{signal:E.signal}),T&&(R?.abort(),R=new AbortController,document.getElementById("paysafe-google-pay").addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),e(),o=!0,m("GOOGLEPAY",b,A,a,s,t)},{signal:R.signal}))}).catch(e=>{!function(e,t,s,a,o,i,r){e.error&&(e=e.error);const c=!0===t.log_errors&&t.log_error_endpoint||null;let l="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:e.message?e.message:"");e.displayMessage&&(l=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),d(c,l,_(e,t,s,a)),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?r():i(o&&l?l:(0,n.__)("Error! Unable to set up Express Checkout at this moment. Please, try again later.","paysafe-checkout")+(e.code?" ("+e.code+")":""))}(e,w,a,A,o,s,t),o=!1})},C=e=>{const{eventRegistration:s,emitResponse:a}=e,{onCheckoutSuccess:o}=s;return(0,r.useEffect)(()=>{const e=o(e=>{const t={applePay:{accountId:w.account_id,label:"apple_pay"}};return w.apple_pay_issuer_country&&(t.applePay.country=w.apple_pay_issuer_country),function(e,t,s,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=s.log_order_fail_endpoint||null,m=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&y(_,r,(0,n.__)("Payment amount missing","paysafe-checkout")),d(m,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},_={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,a,o,i,r,c,l){const _=e.log_order_fail_endpoint||null,m=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void y(_,s,(0,n.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),y(_,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=u(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(y(_,s,e.error_message),d(m,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=h(e);y(_,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(m,a,[]),p(g(e.code,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=h(e);y(_,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(m,a,[]),p(g(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,a,r,c,l,f,e,i,_):function(e,t,s,a,o,i,r,c,l){const _=e.log_order_fail_endpoint||null,m=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=u(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,n.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(m,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=h(e);y(_,s,a),d(m,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(g(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=h(a);if(y(_,s,e),t)d(m,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(g(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),d(m,e,[]),p(g(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(m,(0,n.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,n.__)("Payment session expired","paysafe-checkout"):e,y(_,s,a),d(m,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,n.__)("Payment amount risk assessment failed","paysafe-checkout");y(_,s,t),d(m,(0,n.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,n.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,a,r,c,l,f,e,i,_)}return e}(e,A,w,{displayPaymentMethods:["applePay"],paymentMethodDetails:t,settings:{add_customer_when_single_use_token:!0,add_billing_when_single_use_token:!0}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]),function(e,s=""){let a=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,t().jsx)("hr",{})),e.test_mode&&a.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&a.push(s),a}(w)},M=e=>{const{eventRegistration:s,onClick:a,onClose:o,onError:i}=e,{onCheckoutSuccess:l}=s,{subscribe:d,select:p}=window.wp.data,{checkoutStore:u}=window.wc.wcBlocksData;let _=p(u).isCalculating();return(0,r.useEffect)(()=>{d(()=>{const e=p(u).isCalculating();e!==_&&(S=!!e,_=e)})},[[],{},d]),(0,r.useEffect)(()=>{N(a,o,i);const e=l(e=>e);return()=>{e()}},[[],{},l]),function(e,s=""){let a=[(0,t().jsx)("div",{children:(0,c.decodeEntities)((0,n.__)("Easy and secure payments with Paysafe","paysafe-checkout"))})];return e.test_mode&&(a.push((0,t().jsx)("hr",{})),a.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),a.push((0,t().jsx)("p",{}))),s&&a.push(s),a}(w,wp.element.RawHTML({children:w.integration_hosted_form}))};if(async function(){if(window.ApplePaySession&&ApplePaySession.canMakePayments())return!0;if(window.PaymentRequest)try{const e=new PaymentRequest([{supportedMethods:"https://apple.com/apple-pay",data:{version:3,merchantIdentifier:"your.merchant.id",merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard","amex"],countryCode:"US"}}],{total:{label:"Check",amount:{currency:"USD",value:"0.00"}}});return await e.canMakePayment()}catch(e){return!1}return!1})if(k){const e={name:f,title:"Apple Pay Express Checkout",description:w.description,gatewayId:"paysafe",label:function(){const e=(0,n.__)("Paysafe Express Payment","paysafe-checkout");return(0,t().jsx)("div",{className:"paysafe-gateway-title",children:(0,t().jsx)("span",{children:e})})}(),content:(0,t().jsx)(M,{}),edit:(0,t().jsx)(M,{}),canMakePayment:e=>(A=e,!0),paymentMethodId:f,supports:{features:w.supports}};(0,o.registerExpressPaymentMethod)(e)}else{const e={name:f,paymentMethodId:f,label:function(e,s){const a=(0,c.decodeEntities)(e)||(0,n.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:a}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:a})]})}(w.title,w.icon),content:(0,t().jsx)(C,{}),edit:(0,t().jsx)(C,{}),canMakePayment:e=>(A=e,!0),ariaLabel:(0,n.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:w.supports}};(0,o.registerPaymentMethod)(e)}})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-eft.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 415013fa08a54070b818');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '8cff4a01b4729643318e'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-eft.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(n){const a=t[n];if(void 0!==a)return a.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="eft",g=(0,a.getSetting)(h+"_data",{});var y;y=g.nonce,c=y||"";let f={};const w=e=>{const{eventRegistration:t,emitResponse:n}=e,{onCheckoutSuccess:a}=t;return(0,o.useEffect)(()=>{const e=a(e=>function(e,t,n,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=n.log_order_fail_endpoint||null,y=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(g,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(y,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,n,a,o,i,r,c,h){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(g,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(w.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(w.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(w.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(w.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(w.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),m(g,n,e),"Result failure"}const r={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(g,n,e.error_message),l(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,r,c,h,f,e,i,g):function(e,t,n,a,o,i,r,c,h){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:n,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=u(e);m(g,n,a),l(y,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(a);if(m(g,n,e),t)l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(y,e,[]),d(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(y,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(g,n,a),l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(g,n,t),l(y,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,r,c,h,f,e,i,g)}return e}(e,f,g,{displayPaymentMethods:["eft"],paymentMethodDetails:{eft:{accountId:g.account_id}}},!1,n));return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],a]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,r.jsx)("hr",{})),e.test_mode&&n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(g)},b={name:h,paymentMethodId:h,label:function(e,t){const n=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:n}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(g.title,g.icon),content:(0,r.jsx)(w,{}),edit:(0,r.jsx)(w,{}),canMakePayment:e=>(f=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,n.registerPaymentMethod)(b)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=n(),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),n=e(e=>{e.exports=window.React});const a=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const g="eft",y=(0,i.getSetting)(g+"_data",{});var f;f=y.nonce,l=f||"";let w={};const b=e=>{const{eventRegistration:s,emitResponse:n}=e,{onCheckoutSuccess:o}=s;return(0,r.useEffect)(()=>{const e=o(e=>function(e,t,s,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=s.log_order_fail_endpoint||null,y=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(g,r,(0,a.__)("Payment amount missing","paysafe-checkout")),d(y,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,n,o,i,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(g,s,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=n),n&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),u(g,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(g,s,e.error_message),d(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,n,r,c,l,f,e,i,g):function(e,t,s,n,o,i,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let n=_(e);u(g,s,n),d(y,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(n);if(u(g,s,e),t)d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),d(y,e,[]),p(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(y,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let n="";n=t?(0,a.__)("Payment session expired","paysafe-checkout"):e,u(g,s,n),d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");u(g,s,t),d(y,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,n,r,c,l,f,e,i,g)}return e}(e,w,y,{displayPaymentMethods:["eft"],paymentMethodDetails:{eft:{accountId:y.account_id}}},!1,n));return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],o]),function(e,s=""){let n=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,t().jsx)("hr",{})),e.test_mode&&n.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&n.push(s),n}(y)},T={name:g,paymentMethodId:g,label:function(e,s){const n=(0,c.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:n}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:n})]})}(y.title,y.icon),content:(0,t().jsx)(b,{}),edit:(0,t().jsx)(b,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,o.registerPaymentMethod)(T)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-google_pay.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' bb38b667f248e16f732b');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'aacac5d88aaf7ad3402b'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-google_pay.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(n){const a=t[n];if(void 0!==a)return a.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s,n){return{error_code:e&&e.code?e.code:0,error_message:e&&e.message?e.message:"",display_message:e&&e.displayMessage?e.displayMessage:"",detailed_message:e&&e.detailedMessage?e.detailedMessage:"",correlationId:e&&e.correlationId?e.correlationId:"-",store_currency:t&&t.currency_code?t.currency_code:"-",cart_currency:n&&n.cartTotals&&n.cartTotals.currency_code?n.cartTotals.currency_code:"-",account_ids:s&&s.accounts?s.accounts:{},wp_version:(0,a.getSetting)("wpVersion",""),woo_version:(0,a.getSetting)("wcVersion",""),paysafe_version:t&&t.paysafe_version?t.paysafe_version:"-"}}function _(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function m(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function g(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const y="google_pay",h=(0,a.getSetting)("google_pay_data",{});var f;f=h.nonce,c=f||"";const w="paysafe_js"===h.integration_type;let R,b=!1;h.is_apple_pay_express_enabled&&h.is_google_pay_express_enabled&&(b=!0);let k=!0,E={},T=!1;const P=function(e,t,n){if(!jQuery("#paysafe-hosted-google-pay-payment-form").length)return;if(h.is_apple_pay_express_enabled&&h.is_google_pay_express_enabled)return;if(T)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){P(e,t,n)},1e3);T=!0;let a={currencyCode:h.currency_code,environment:h.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",accounts:{default:h.account_id,googlePay:h.account_id},fields:{googlePay:{selector:"#paysafe-google-pay",type:"buy",color:"black",label:(0,s.__)("Google Pay","paysafe-checkout")}}};null!=h.initialization_timeout&&Number(h.initialization_timeout)>=1e3&&(a.initializationTimeout=Number(h.initialization_timeout)),h.google_pay_issuer_country&&(a.fields.googlePay.country=h.google_pay_issuer_country),h.google_pay_merchant_id&&(a.fields.googlePay.merchantId=h.google_pay_merchant_id);let o=!1;(function(e,t,n,a){const o=!0===e.log_errors&&e.log_error_endpoint||null;return void 0===a&&(a=!1),null!=e.initialization_timeout&&Number(e.initialization_timeout)>=1e3&&(t.initializationTimeout=Number(e.initialization_timeout)),paysafe.fields.setup(e.authorization,t).then(e=>e.show().then(t=>t.card&&!t.card.error||t.applePay&&!t.applePay.error||t.googlePay&&!t.googlePay.error?e:void 0)).catch(i=>{if(i.error&&(i=i.error),!a){const a="ERROR "+i.code+": "+i.detailedMessage,r=u(i,e,t,n);l(o,a,r),d(g(i.code,(0,s.__)("The payment initialization failed. Please reload the page and try again.","paysafe-checkout")),!0)}return Promise.reject(i)})})(h,a,E,!0).then(a=>{R?.abort(),R=new AbortController,document.getElementById("paysafe-google-pay").addEventListener("click",function(i){i.preventDefault(),i.stopPropagation(),e(),o=!0,function(e,t,n,a,o,i){const r=!0===t.log_errors&&t.log_error_endpoint||null,c="google_pay",d=parseInt(n.cartTotals.total_price);if(!d)return l(r,"ERROR: Express checkout order amount is not set",[]),void o((0,s.__)("ERROR: Express checkout order amount is not set","paysafe-checkout"));let u="",_="",m="",g="",y="";n&&n.billingAddress&&n.billingAddress.postcode&&(u=n.billingAddress.address_1,_=n.billingAddress.city,m=n.billingAddress.postcode,g=n.billingAddress.state,y=n.billingAddress.country);const h=n.cartTotals.currency_code,f=t.express_merchant_ref_num||c+"_"+Date.now(),w={transactionSource:"WooCommerceJs",amount:d,transactionType:"PAYMENT",currency:h,merchantRefNum:f,environment:t.test_mode?"TEST":"LIVE",paymentType:e,accountId:t.account_id,googlePay:{requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]}};w.threeDs={merchantUrl:t.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},t.google_pay_issuer_country&&(w.googlePay.country=t.google_pay_issuer_country),y&&m&&u&&_&&g&&(w.customerDetails={billingDetails:{country:y,zip:m,street:u,city:_,state:g}}),a.tokenize(w).then(n=>{const i=n.token||null;if(!i){const e=(0,s.__)("ERROR: Express checkout couldn't tokenize the payment information","paysafe-checkout");return l(r,e,[]),void o(e)}const u={gateway_id:c,nonce:t.nonce},_=p(t.express_checkout_endpoint);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(u)}).then(e=>e.json()).then(n=>{if("success"===n.status){const c=n.order_id||null;if(!c)return l(r,"ERROR: Express checkout couldn't create Order",[]),void o((0,s.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"));const u={orderId:c,paymentMethod:e,transactionType:"PAYMENT",paymentHandleToken:i,amount:d,customerOperation:"",merchantRefNum:f,nonce:t.nonce},_=p(t.register_url);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(u)}).then(e=>e.json()).then(e=>{"success"===e.status?a.complete("success"):(o("ERROR: Express checkout payment failed"+(e.message?" ("+e.message+")":"")),a.complete("fail")),window.location=e.redirect_url}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;l(r,t,[]),o(t),a.complete("fail")})}else o((0,s.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"))}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;l(r,t,[]),o(t),a.complete("fail")})}).catch(e=>{let t="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:"");e.displayMessage&&(t=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),l(r,t,[]),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?i():t&&o(t)})}("GOOGLEPAY",h,E,a,n,t)},{signal:R.signal})}).catch(e=>{9023===parseInt(e.code)&&(k=!1),function(e,t,n,a,o,i,r){e.error&&(e=e.error);const c=!0===t.log_errors&&t.log_error_endpoint||null;let d="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:e.message?e.message:"");e.displayMessage&&(d=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),l(c,d,u(e,t,n,a)),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?r():i(o&&d?d:(0,s.__)("Error! Unable to set up Express Checkout at this moment. Please, try again later.","paysafe-checkout")+(e.code?" ("+e.code+")":""))}(e,h,a,E,o,n,t),o=!1})},A=e=>{const{eventRegistration:t,emitResponse:n}=e,{onCheckoutSuccess:a}=t;return(0,o.useEffect)(()=>{const e=a(e=>{const t={googlePay:{accountId:h.account_id,label:"google_pay",requestBillingAddress:!0,requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]}};return h.google_pay_issuer_country&&(t.googlePay.country=h.google_pay_issuer_country),h.google_pay_merchant_id&&(t.googlePay.merchantId=h.google_pay_merchant_id),function(e,t,n,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",u=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=n.log_order_fail_endpoint||null,h=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&_(y,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(h,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,n,a,o,i,r,c,u){const y=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void _(y,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:u.billing_zip,country:u.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:u.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),u.billing_street&&(w.customerDetails.billingDetails.street=u.billing_street),u.billing_street2&&(w.customerDetails.billingDetails.street2=u.billing_street2),u.billing_city&&(w.customerDetails.billingDetails.city=u.billing_city),u.billing_state&&(w.customerDetails.billingDetails.state=u.billing_state),u.billing_phone&&(w.customerDetails.billingDetails.phone=u.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),_(y,n,e),"Result failure"}const r={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(_(y,n,e.error_message),l(h,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=m(e);_(y,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(h,a,[]),d(g(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=m(e);_(y,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(h,a,[]),d(g(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,r,c,u,f,e,i,y):function(e,t,n,a,o,i,r,c,u){const y=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:u.billing_zip,country:u.billing_country},u.billing_street&&(f.billingAddress.street=u.billing_street),u.billing_street2&&(f.billingAddress.street2=u.billing_street2),u.billing_city&&(f.billingAddress.city=u.billing_city),u.billing_state&&(f.billingAddress.state=u.billing_state),u.billing_phone&&(f.billingAddress.phone=u.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:n,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(h,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=m(e);_(y,n,a),l(h,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(g(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=m(a);if(_(y,n,e),t)l(h,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(g(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(h,e,[]),d(g(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(h,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,_(y,n,a),l(h,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");_(y,n,t),l(h,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,r,c,u,f,e,i,y)}return e}(e,E,h,{displayPaymentMethods:["googlePay"],paymentMethodDetails:t,settings:{add_customer_when_single_use_token:!0,add_billing_when_single_use_token:!0}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],a]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,r.jsx)("hr",{})),e.test_mode&&n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(h)},S=e=>{const{eventRegistration:t,onClick:n,onClose:a,onError:c}=e,{onCheckoutSuccess:l}=t,{subscribe:d,select:p}=window.wp.data,{checkoutStore:u}=window.wc.wcBlocksData;let _=p(u).isCalculating();return(0,o.useEffect)(()=>{d(()=>{const e=p(u).isCalculating();e!==_&&(T=!!e,_=e)})},[[],{},d]),(0,o.useEffect)(()=>{P(n,a,c);const e=l(e=>e);return()=>{e()}},[[],{},l]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,i.decodeEntities)((0,s.__)("Easy and secure payments with Paysafe","paysafe-checkout"))})];return e.test_mode&&(n.push((0,r.jsx)("hr",{})),n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),n.push((0,r.jsx)("p",{}))),t&&n.push(t),n}(h,wp.element.RawHTML({children:h.integration_hosted_form}))};if(w){const e={name:y,title:"Google Pay Express Checkout",description:h.description,gatewayId:"paysafe",label:function(){const e=(0,s.__)("Paysafe Express Payment","paysafe-checkout");return(0,r.jsx)("div",{className:"paysafe-gateway-title",children:(0,r.jsx)("span",{children:e})})}(),content:(0,r.jsx)(S,{}),edit:(0,r.jsx)(S,{}),canMakePayment:e=>(E=e,k?!b:(T=!1,!1)),paymentMethodId:y,supports:{features:h.supports}};(0,n.registerExpressPaymentMethod)(e)}else{const e={name:y,paymentMethodId:y,label:function(e,t){const n=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:n}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(h.title,h.icon),content:(0,r.jsx)(A,{}),edit:(0,r.jsx)(A,{}),canMakePayment:e=>(E=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:h.supports}};(0,n.registerPaymentMethod)(e)}})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=a(),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),a=e(e=>{e.exports=window.React});const n=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function u(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,n.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function _(e,t,s,a){return{error_code:e&&e.code?e.code:0,error_message:e&&e.message?e.message:"",display_message:e&&e.displayMessage?e.displayMessage:"",detailed_message:e&&e.detailedMessage?e.detailedMessage:"",correlationId:e&&e.correlationId?e.correlationId:"-",store_currency:t&&t.currency_code?t.currency_code:"-",cart_currency:a&&a.cartTotals&&a.cartTotals.currency_code?a.cartTotals.currency_code:"-",account_ids:s&&s.accounts?s.accounts:{},wp_version:(0,i.getSetting)("wpVersion",""),woo_version:(0,i.getSetting)("wcVersion",""),paysafe_version:t&&t.paysafe_version?t.paysafe_version:"-"}}function m(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function g(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function y(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,n.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,n.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,n.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,n.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,n.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="google_pay",f=(0,i.getSetting)("google_pay_data",{});var w;w=f.nonce,l=w||"";const R="paysafe_js"===f.integration_type;let b,k=!1;f.is_apple_pay_express_enabled&&f.is_google_pay_express_enabled&&(k=!0);let E=!0,T={},P=!1;const A=function(e,t,s){if(!jQuery("#paysafe-hosted-google-pay-payment-form").length)return;if(f.is_apple_pay_express_enabled&&f.is_google_pay_express_enabled)return;if(P)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){A(e,t,s)},1e3);P=!0;let a={currencyCode:f.currency_code,environment:f.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",accounts:{default:f.account_id,googlePay:f.account_id},fields:{googlePay:{selector:"#paysafe-google-pay",type:"buy",color:"black",label:(0,n.__)("Google Pay","paysafe-checkout")}}};null!=f.initialization_timeout&&Number(f.initialization_timeout)>=1e3&&(a.initializationTimeout=Number(f.initialization_timeout)),f.google_pay_issuer_country&&(a.fields.googlePay.country=f.google_pay_issuer_country),f.google_pay_merchant_id&&(a.fields.googlePay.merchantId=f.google_pay_merchant_id);let o=!1;(function(e,t,s,a){const o=!0===e.log_errors&&e.log_error_endpoint||null;return void 0===a&&(a=!1),null!=e.initialization_timeout&&Number(e.initialization_timeout)>=1e3&&(t.initializationTimeout=Number(e.initialization_timeout)),paysafe.fields.setup(e.authorization,t).then(e=>e.show().then(t=>t.card&&!t.card.error||t.applePay&&!t.applePay.error||t.googlePay&&!t.googlePay.error?e:void 0)).catch(i=>{if(i.error&&(i=i.error),!a){const a="ERROR "+i.code+": "+i.detailedMessage,r=_(i,e,t,s);d(o,a,r),p(y(i.code,(0,n.__)("The payment initialization failed. Please reload the page and try again.","paysafe-checkout")),!0)}return Promise.reject(i)})})(f,a,T,!0).then(a=>{b?.abort(),b=new AbortController,document.getElementById("paysafe-google-pay").addEventListener("click",function(i){i.preventDefault(),i.stopPropagation(),e(),o=!0,function(e,t,s,a,o,i){const r=!0===t.log_errors&&t.log_error_endpoint||null,c="google_pay",l=parseInt(s.cartTotals.total_price);if(!l)return d(r,"ERROR: Express checkout order amount is not set",[]),void o((0,n.__)("ERROR: Express checkout order amount is not set","paysafe-checkout"));let p="",_="",m="",g="",y="";s&&s.billingAddress&&s.billingAddress.postcode&&(p=s.billingAddress.address_1,_=s.billingAddress.city,m=s.billingAddress.postcode,g=s.billingAddress.state,y=s.billingAddress.country);const h=s.cartTotals.currency_code,f=t.express_merchant_ref_num||c+"_"+Date.now(),w={transactionSource:"WooCommerceJs",amount:l,transactionType:"PAYMENT",currency:h,merchantRefNum:f,environment:t.test_mode?"TEST":"LIVE",paymentType:e,accountId:t.account_id,googlePay:{requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]}};w.threeDs={merchantUrl:t.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},t.google_pay_issuer_country&&(w.googlePay.country=t.google_pay_issuer_country),y&&m&&p&&_&&g&&(w.customerDetails={billingDetails:{country:y,zip:m,street:p,city:_,state:g}}),a.tokenize(w).then(s=>{const i=s.token||null;if(!i){const e=(0,n.__)("ERROR: Express checkout couldn't tokenize the payment information","paysafe-checkout");return d(r,e,[]),void o(e)}const p={gateway_id:c,nonce:t.nonce},_=u(t.express_checkout_endpoint);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(p)}).then(e=>e.json()).then(s=>{if("success"===s.status){const c=s.order_id||null;if(!c)return d(r,"ERROR: Express checkout couldn't create Order",[]),void o((0,n.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"));const p={orderId:c,paymentMethod:e,transactionType:"PAYMENT",paymentHandleToken:i,amount:l,customerOperation:"",merchantRefNum:f,nonce:t.nonce},_=u(t.register_url);fetch(_,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(p)}).then(e=>e.json()).then(e=>{"success"===e.status?a.complete("success"):(o("ERROR: Express checkout payment failed"+(e.message?" ("+e.message+")":"")),a.complete("fail")),window.location=e.redirect_url}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;d(r,t,[]),o(t),a.complete("fail")})}else o((0,n.__)("ERROR: Express checkout couldn't create the order","paysafe-checkout"))}).catch(e=>{const t="ERROR "+e.code+": "+e.detailedMessage;d(r,t,[]),o(t),a.complete("fail")})}).catch(e=>{let t="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:"");e.displayMessage&&(t=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),d(r,t,[]),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?i():t&&o(t)})}("GOOGLEPAY",f,T,a,s,t)},{signal:b.signal})}).catch(e=>{9023===parseInt(e.code)&&(E=!1),function(e,t,s,a,o,i,r){e.error&&(e=e.error);const c=!0===t.log_errors&&t.log_error_endpoint||null;let l="ERROR "+e.code+(e.detailedMessage?": "+e.detailedMessage:e.message?e.message:"");e.displayMessage&&(l=e.displayMessage+(e.detailedMessage?": "+e.detailedMessage:"")),d(c,l,_(e,t,s,a)),e.detailedMessage&&e.detailedMessage.includes("User aborted payment")?r():i(o&&l?l:(0,n.__)("Error! Unable to set up Express Checkout at this moment. Please, try again later.","paysafe-checkout")+(e.code?" ("+e.code+")":""))}(e,f,a,T,o,s,t),o=!1})},S=e=>{const{eventRegistration:s,emitResponse:a}=e,{onCheckoutSuccess:o}=s;return(0,r.useEffect)(()=>{const e=o(e=>{const t={googlePay:{accountId:f.account_id,label:"google_pay",requestBillingAddress:!0,requiredBillingContactFields:["name","phone","email","postalAddress"],requiredShippingContactFields:["name","phone","email","postalAddress"]}};return f.google_pay_issuer_country&&(t.googlePay.country=f.google_pay_issuer_country),f.google_pay_merchant_id&&(t.googlePay.merchantId=f.google_pay_merchant_id),function(e,t,s,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=s.log_order_fail_endpoint||null,h=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(_,r,(0,n.__)("Payment amount missing","paysafe-checkout")),d(h,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},_={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,a,o,i,r,c,l){const _=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(_,s,(0,n.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),m(_,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=u(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(_,s,e.error_message),d(h,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=g(e);m(_,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(h,a,[]),p(y(e.code,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=g(e);m(_,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(h,a,[]),p(y(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,a,r,c,l,f,e,i,_):function(e,t,s,a,o,i,r,c,l){const _=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=u(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,n.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(h,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=g(e);m(_,s,a),d(h,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(y(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=g(a);if(m(_,s,e),t)d(h,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(y(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),d(h,e,[]),p(y(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(h,(0,n.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,n.__)("Payment session expired","paysafe-checkout"):e,m(_,s,a),d(h,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,n.__)("Payment amount risk assessment failed","paysafe-checkout");m(_,s,t),d(h,(0,n.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,n.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,a,r,c,l,f,e,i,_)}return e}(e,T,f,{displayPaymentMethods:["googlePay"],paymentMethodDetails:t,settings:{add_customer_when_single_use_token:!0,add_billing_when_single_use_token:!0}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]),function(e,s=""){let a=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,t().jsx)("hr",{})),e.test_mode&&a.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&a.push(s),a}(f)},N=e=>{const{eventRegistration:s,onClick:a,onClose:o,onError:i}=e,{onCheckoutSuccess:l}=s,{subscribe:d,select:p}=window.wp.data,{checkoutStore:u}=window.wc.wcBlocksData;let _=p(u).isCalculating();return(0,r.useEffect)(()=>{d(()=>{const e=p(u).isCalculating();e!==_&&(P=!!e,_=e)})},[[],{},d]),(0,r.useEffect)(()=>{A(a,o,i);const e=l(e=>e);return()=>{e()}},[[],{},l]),function(e,s=""){let a=[(0,t().jsx)("div",{children:(0,c.decodeEntities)((0,n.__)("Easy and secure payments with Paysafe","paysafe-checkout"))})];return e.test_mode&&(a.push((0,t().jsx)("hr",{})),a.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),a.push((0,t().jsx)("p",{}))),s&&a.push(s),a}(f,wp.element.RawHTML({children:f.integration_hosted_form}))};if(R){const e={name:h,title:"Google Pay Express Checkout",description:f.description,gatewayId:"paysafe",label:function(){const e=(0,n.__)("Paysafe Express Payment","paysafe-checkout");return(0,t().jsx)("div",{className:"paysafe-gateway-title",children:(0,t().jsx)("span",{children:e})})}(),content:(0,t().jsx)(N,{}),edit:(0,t().jsx)(N,{}),canMakePayment:e=>(T=e,E?!k:(P=!1,!1)),paymentMethodId:h,supports:{features:f.supports}};(0,o.registerExpressPaymentMethod)(e)}else{const e={name:h,paymentMethodId:h,label:function(e,s){const a=(0,c.decodeEntities)(e)||(0,n.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:a}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:a})]})}(f.title,f.icon),content:(0,t().jsx)(S,{}),edit:(0,t().jsx)(S,{}),canMakePayment:e=>(T=e,!0),ariaLabel:(0,n.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:f.supports}};(0,o.registerPaymentMethod)(e)}})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-neteller.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 6a346f29cbebc4c98d9e');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '897df4134221ce3fc439'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-neteller.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(n){const a=t[n];if(void 0!==a)return a.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="neteller",g=(0,a.getSetting)(h+"_data",{});var y;y=g.nonce,c=y||"";let f={};const w=e=>{const{eventRegistration:t,emitResponse:n}=e,{onCheckoutSuccess:a}=t;return(0,o.useEffect)(()=>{const e=a(e=>function(e,t,n,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=n.log_order_fail_endpoint||null,y=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(g,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(y,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,n,a,o,i,r,c,h){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(g,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(w.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(w.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(w.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(w.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(w.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),m(g,n,e),"Result failure"}const r={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(g,n,e.error_message),l(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,r,c,h,f,e,i,g):function(e,t,n,a,o,i,r,c,h){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:n,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=u(e);m(g,n,a),l(y,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(a);if(m(g,n,e),t)l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(y,e,[]),d(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(y,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(g,n,a),l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(g,n,t),l(y,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,r,c,h,f,e,i,g)}return e}(e,f,g,{displayPaymentMethods:["neteller"],paymentMethodDetails:{neteller:{accountId:g.account_id,consumerIdLocked:!1}}},!1,n));return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],a]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,r.jsx)("hr",{})),e.test_mode&&n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(g)},b={name:h,paymentMethodId:h,label:function(e,t){const n=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:n}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(g.title,g.icon),content:(0,r.jsx)(w,{}),edit:(0,r.jsx)(w,{}),canMakePayment:e=>(f=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,n.registerPaymentMethod)(b)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=n(),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),n=e(e=>{e.exports=window.React});const a=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const g="neteller",y=(0,i.getSetting)(g+"_data",{});var f;f=y.nonce,l=f||"";let w={};const b=e=>{const{eventRegistration:s,emitResponse:n}=e,{onCheckoutSuccess:o}=s;return(0,r.useEffect)(()=>{const e=o(e=>function(e,t,s,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=s.log_order_fail_endpoint||null,y=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(g,r,(0,a.__)("Payment amount missing","paysafe-checkout")),d(y,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,n,o,i,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(g,s,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=n),n&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),u(g,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(g,s,e.error_message),d(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,n,r,c,l,f,e,i,g):function(e,t,s,n,o,i,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let n=_(e);u(g,s,n),d(y,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(n);if(u(g,s,e),t)d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),d(y,e,[]),p(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(y,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let n="";n=t?(0,a.__)("Payment session expired","paysafe-checkout"):e,u(g,s,n),d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");u(g,s,t),d(y,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,n,r,c,l,f,e,i,g)}return e}(e,w,y,{displayPaymentMethods:["neteller"],paymentMethodDetails:{neteller:{accountId:y.account_id,consumerIdLocked:!1}}},!1,n));return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],o]),function(e,s=""){let n=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,t().jsx)("hr",{})),e.test_mode&&n.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&n.push(s),n}(y)},k={name:g,paymentMethodId:g,label:function(e,s){const n=(0,c.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:n}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:n})]})}(y.title,y.icon),content:(0,t().jsx)(b,{}),edit:(0,t().jsx)(b,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,o.registerPaymentMethod)(k)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-pay_by_bank.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 27de9e1116b6fe0e0b39');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '53f842048aa7edb78422'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-pay_by_bank.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,n,a){var t=a(609),s=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function r(e,n,a){var t,r={},l=null,d=null;for(t in void 0!==a&&(l=""+a),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)o.call(n,t)&&!c.hasOwnProperty(t)&&(r[t]=n[t]);if(e&&e.defaultProps)for(t in n=e.defaultProps)void 0===r[t]&&(r[t]=n[t]);return{$$typeof:s,type:e,key:l,ref:d,props:r,_owner:i.current}}n.jsx=r,n.jsxs=r},848(e,n,a){e.exports=a(20)},609(e){e.exports=window.React}};const n={},a=window.wp.i18n,t=window.wc.wcBlocksRegistry,s=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var c=function a(t){const s=n[t];if(void 0!==s)return s.exports;const o=n[t]={exports:{}};return e[t](o,o.exports,a),o.exports}(848);let r="";function l(e,n,a){if(e){const t=new URL(e,window.location.origin);if(t.origin!==window.location.origin)return;fetch(t.pathname+t.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:n,context:a,nonce:r})}).catch(()=>{})}}function d(e,n){n=!!n;let a=document.getElementsByClassName("woocommerce-error");if(a=a.length>0?a[0]:null,!a){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),n=e.length>0?e[0]:null;n&&(a=document.createElement("ul"),a.className="woocommerce-error",n.appendChild(a))}if(a){let t=document.createElement("li"),s=(e||"").replace(/<br\s*\/?>/gi,"\n");!t||n?(t.setAttribute("id","paysafe-fatal-error-message"),t.textContent=s,a.appendChild(t),window.scrollTo({top:0,left:0,behavior:"smooth"})):t.textContent=s}}function p(e){const n=new URL(e,window.location.href);if(n.origin===window.location.origin)return n.pathname+n.search+n.hash;d((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+n.toString(),!0)}function u(e,n,a){if(a&&e){const t=new URL(e,window.location.origin);if(t.origin!==window.location.origin)return;fetch(t.pathname+t.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:n,reason:a,nonce:r})}).catch(()=>{})}}function m(e){let n="";return e&&(e.code&&(n+=e.code+" "),e.message&&(n+=e.message+" "),e.detailedMessage&&(n=e.detailedMessage),e.displayMessage&&(n=e.displayMessage)),n}function f(e,n){if(void 0===e&&(e=null),void 0===n&&(n=""),null===e)return n;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return n}const y="pay_by_bank",_=(0,s.getSetting)(y+"_data",{});var h;h=_.nonce,r=h||"";const b=!0===_.log_errors&&_.log_error_endpoint||null;let g={};const x=e=>{const{eventRegistration:n,emitResponse:t}=e,{onPaymentSetup:s,onCheckoutSuccess:r}=n;return(0,o.useEffect)(()=>{const e=s(async()=>{let e=document.getElementById("paybybank_consumeridInput"),n=e&&e.value&&e.value.length,s=document.getElementById("paybybank_dobInput"),o=s&&s.value&&s.value.length;return n&&o?{type:t.responseTypes.SUCCESS}:(l(b,(0,a.__)("The payment process failed. SSN and Date of Birth must be set!","paysafe-checkout"),{}),{type:t.responseTypes.ERROR,message:(0,a.__)("The payment process failed. SSN and Date of Birth must be set!","paysafe-checkout")})});return()=>{e()}},[t.responseTypes.ERROR,t.responseTypes.SUCCESS,s]),(0,o.useEffect)(()=>{const e=r(e=>{let n=_.consumer_id_encrypted;n||(n=function(e){const n=(1n<<64n)-1n,a=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],t=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],s=(e,a)=>(e>>BigInt(a)|e<<BigInt(64-a))&n,o=(e,n)=>e>>BigInt(n),i=(e,n,a)=>e&n^~e&a,c=(e,n,a)=>e&n^e&a^n&a,r=e=>s(e,28)^s(e,34)^s(e,39),l=e=>s(e,14)^s(e,18)^s(e,41),d=e=>s(e,1)^s(e,8)^o(e,7),p=e=>s(e,19)^s(e,61)^o(e,6),u=Array.from((new TextEncoder).encode(e)),m=8n*BigInt(u.length);for(u.push(128);u.length%128!=112;)u.push(0);const f=m>>64n,y=m&n;for(let e=7;e>=0;e--)u.push(Number(f>>BigInt(8*e)&0xffn));for(let e=7;e>=0;e--)u.push(Number(y>>BigInt(8*e)&0xffn));for(let e=0;e<u.length;e+=128){const s=new Array(80).fill(0n);for(let n=0;n<16;n++){let a=0n;for(let t=0;t<8;t++)a=a<<8n|BigInt(u[e+8*n+t]);s[n]=a}for(let e=16;e<80;e++)s[e]=p(s[e-2])+s[e-7]+d(s[e-15])+s[e-16]&n;let[o,m,f,y,_,h,b,g]=a;for(let e=0;e<80;e++){const a=g+l(_)+i(_,h,b)+t[e]+s[e]&n,d=r(o)+c(o,m,f)&n;g=b,b=h,h=_,_=y+a&n,y=f,f=m,m=o,o=a+d&n}a[0]=a[0]+o&n,a[1]=a[1]+m&n,a[2]=a[2]+f&n,a[3]=a[3]+y&n,a[4]=a[4]+_&n,a[5]=a[5]+h&n,a[6]=a[6]+b&n,a[7]=a[7]+g&n}return a.map(e=>e.toString(16).padStart(16,"0")).join("").substring(0,50)}(g.billingAddress.email));let s=document.getElementById("paybybank_consumeridInput"),o=s&&s.value&&s.value.length?s.value:"",i=document.getElementById("paybybank_dobInput"),c=i&&i.value&&i.value.length?i.value:"",r="",y="",h="";if(c){const e=new Date(c);isNaN(e.getTime())||(r=e.getFullYear(),y=e.getMonth()+1,h=e.getDate())}let b={firstName:g.billingAddress.first_name,lastName:g.billingAddress.last_name,email:g.billingAddress.email,identityDocuments:[{type:"SOCIAL_SECURITY",documentNumber:o}],dateOfBirth:{year:r,month:y,day:h}};return g.billingAddress.phone&&(b.phone=g.billingAddress.phone),function(e,n,t,s,o,i){void 0===s&&(s={}),void 0===s.settings&&(s.settings={}),o=!!o;let c=e.orderId;c||(c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",y=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=t.log_order_fail_endpoint||null,h=!0===t.log_errors&&t.log_error_endpoint||null,b=parseInt(n.cartTotals.total_price);if(!c||!b)return c&&u(_,c,(0,a.__)("Payment amount missing","paysafe-checkout")),l(h,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=n.cartTotals.currency_code;const i={firstName:n.billingAddress.first_name,lastName:n.billingAddress.last_name,email:n.billingAddress.email},_={billing_street:n.billingAddress.address_1,billing_street2:n.billingAddress.address_2,billing_city:n.billingAddress.city,billing_zip:n.billingAddress.postcode,billing_state:n.billingAddress.state,billing_country:n.billingAddress.country,billing_phone:s&&s.additional&&s.additional.phone?s.additional.phone:n.billingAddress.phone||""};o?function(e,n,t,s,o,i,c,r,y){const _=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===n.hosted_payment_instance)return void u(_,t,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const b=n.hosted_payment_instance,g={transactionSource:void 0===n.transactionSource?"WooCommerceJs":n.transactionSource,amount:i,transactionType:"PAYMENT",currency:c,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};s&&n.use_single_use_customer_token&&(g.singleUseCustomerToken=s),s&&n.payment_toke_from&&(g.paymentTokenFrom=n.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(g.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),g.customerDetails={holderName:r.firstName+" "+r.lastName,billingDetails:{nickName:"Home",zip:y.billing_zip,country:y.billing_country},profile:{firstName:r.firstName,lastName:r.lastName,email:r.email,locale:e.locale,phone:y.billing_phone}},n.customerDetails&&n.customerDetails.holderName&&n.customerDetails.holderName&&(g.customerDetails.holderName=n.customerDetails.holderName),y.billing_street&&(g.customerDetails.billingDetails.street=y.billing_street),y.billing_street2&&(g.customerDetails.billingDetails.street2=y.billing_street2),y.billing_city&&(g.customerDetails.billingDetails.city=y.billing_city),y.billing_state&&(g.customerDetails.billingDetails.state=y.billing_state),y.billing_phone&&(g.customerDetails.billingDetails.phone=y.billing_phone),b.tokenize(g).then(s=>{if(!s||!s.token){let e="";throw s&&s.error&&(e+=s.error.message?s.error.message:s.error),s&&s.error_message&&(e+=s.error_message),u(_,t,e),"Result failure"}const c={orderId:t,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:s.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};n.save_card&&(c.save_card=!0);const r=p(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(c)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(_,t,e.error_message),l(h,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let n=m(e);u(_,t,n);const s="ERROR "+e.code+": "+e.detailedMessage;l(h,s,[]),d(f(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let n=m(e);u(_,t,n);const s="ERROR "+e.code+": "+e.detailedMessage;l(h,s,[]),d(f(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(t,s,c,r,y,b,e,i,_):function(e,n,t,s,o,i,c,r,y){const _=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null,b={transactionSource:void 0===n.transactionSource?"WooCommerceCheckout":n.transactionSource,amount:i,transactionType:"PAYMENT",currency:c,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:n.displayPaymentMethods,paymentMethodDetails:n.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),s&&(b.singleUseCustomerToken=s,n.customer&&(b.customer=n.customer)),s&&!n.settings.add_customer_when_single_use_token||(n.customer?b.customer=n.customer:b.customer=r),s&&!n.settings.add_billing_when_single_use_token||(b.billingAddress={nickName:"Home",zip:y.billing_zip,country:y.billing_country},y.billing_street&&(b.billingAddress.street=y.billing_street),y.billing_street2&&(b.billingAddress.street2=y.billing_street2),y.billing_city&&(b.billingAddress.city=y.billing_city),y.billing_state&&(b.billingAddress.state=y.billing_state),y.billing_phone&&(b.billingAddress.phone=y.billing_phone)),n.settings.use_external_simulator&&e.test_mode&&(b.simulator="EXTERNAL"),n.shippingAddress&&(b.shippingAddress=n.shippingAddress);let g=null;paysafe.checkout.setup(e.authorization,b,function(n,s,o){if(o&&o.paymentHandleToken){const s={orderId:t,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:b.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(s)}).then(e=>e.json()).then(e=>{"success"===e.status?n.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(h,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?n.showFailureScreen(e.error_message):n.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),g=e.redirect_url}).catch(e=>{let s=m(e);u(_,t,s),l(h,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),n.showFailureScreen(f(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=m(s);if(u(_,t,e),n)l(h,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),n.showFailureScreen(f(s.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");s&&s.code&&s.detailedMessage&&(e+="<br /> "+s.code+" "+s.detailedMessage),l(h,e,[]),d(f(s.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,n){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(h,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:n}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==g)return void(window.location=g);window.location.reload()}else{let s="";s=n?(0,a.__)("Payment session expired","paysafe-checkout"):e,u(_,t,s),l(h,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:n}),window.location.reload()}},function(e,n,s){if(n===i)e.accept();else{let n=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");u(_,t,n),l(h,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(t,s,c,r,y,b,e,i,_)}return e}(e,g,_,{displayPaymentMethods:["pay_by_bank"],paymentMethodDetails:{payByBank:{accountId:_.account_id,consumerId:n}},customer:b},!1,t)});return()=>{e()}},[t.responseTypes.ERROR,t.responseTypes.SUCCESS,"",[],r]),function(e,n=""){let t=[(0,c.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&t.push((0,c.jsx)("hr",{})),e.test_mode&&t.push((0,c.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,c.jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),n&&t.push(n),t}(_,(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,c.jsx)("label",{id:"paybybank_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paybybank_consumeridInput",children:(0,a.__)("SSN","paysafe-checkout")}),(0,c.jsx)("div",{id:"paybybank_consumerid",className:"paysafe-input-field",children:(0,c.jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paybybank_consumerid_input",id:"paybybank_consumeridInput",placeholder:(0,a.__)("Your SSN","paysafe-checkout"),min:"2",minLength:"2"})}),(0,c.jsx)("p",{id:"paybybank_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,a.__)("Enter the consumer id from your Pay By Bank account","paysafe-checkout")})]}),(0,c.jsxs)("div",{id:"paysafe-hosted-payment-form2",className:"paysafe-hosted-payment-form",children:[(0,c.jsx)("label",{id:"paybybank_dob_label",className:"paysafe-general-form-label",htmlFor:"paybybank_dobInput",children:(0,a.__)("Date of birth","paysafe-checkout")}),(0,c.jsx)("div",{id:"paybybank_dob",className:"paysafe-input-field",children:(0,c.jsx)("input",{type:"date",className:"paysafe-input-field-input",name:"paybybank_dob_input",id:"paybybank_dobInput",placeholder:(0,a.__)("Your Date of birth","paysafe-checkout"),min:"2",minLength:"2"})}),(0,c.jsx)("p",{id:"paybybank_dob_spacer",className:"paysafe-general-form-spacer",children:(0,a.__)("Enter your Date of Birth for your Pay By Bank account","paysafe-checkout")})]})]}))},k={name:y,paymentMethodId:y,label:function(e,n){const t=(0,i.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,c.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,c.jsx)("span",{children:t}),(0,c.jsx)("img",{className:"paysafe-gateway-image",src:n,alt:t})]})}(_.title,_.icon),content:(0,c.jsx)(x,{}),edit:(0,c.jsx)(x,{}),canMakePayment:e=>(g=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:_.supports}};(0,t.registerPaymentMethod)(k)})();1 (()=>{"use strict";const e=e=>{var n;return()=>{if(e){var a=e;e=0,n={exports:{}},a.call(n.exports,n,n.exports)}return n.exports}};var n=e((e,n)=>{var a=t(),s=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function r(e,n,a){var t,r={},l=null,d=null;for(t in void 0!==a&&(l=""+a),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)o.call(n,t)&&!c.hasOwnProperty(t)&&(r[t]=n[t]);if(e&&e.defaultProps)for(t in n=e.defaultProps)void 0===r[t]&&(r[t]=n[t]);return{$$typeof:s,type:e,key:l,ref:d,props:r,_owner:i.current}}n.jsx=r,n.jsxs=r}),a=e(e=>{e.exports=n()}),t=e(e=>{e.exports=window.React});const s=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,c=window.wp.element,r=window.wp.htmlEntities;a();let l="";function d(e,n,a){if(e){const t=new URL(e,window.location.origin);if(t.origin!==window.location.origin)return;fetch(t.pathname+t.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:n,context:a,nonce:l})}).catch(()=>{})}}function p(e,n){n=!!n;let a=document.getElementsByClassName("woocommerce-error");if(a=a.length>0?a[0]:null,!a){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),n=e.length>0?e[0]:null;n&&(a=document.createElement("ul"),a.className="woocommerce-error",n.appendChild(a))}if(a){let t=document.createElement("li"),s=(e||"").replace(/<br\s*\/?>/gi,"\n");!t||n?(t.setAttribute("id","paysafe-fatal-error-message"),t.textContent=s,a.appendChild(t),window.scrollTo({top:0,left:0,behavior:"smooth"})):t.textContent=s}}function m(e){const n=new URL(e,window.location.href);if(n.origin===window.location.origin)return n.pathname+n.search+n.hash;p((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+n.toString(),!0)}function u(e,n,a){if(a&&e){const t=new URL(e,window.location.origin);if(t.origin!==window.location.origin)return;fetch(t.pathname+t.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:n,reason:a,nonce:l})}).catch(()=>{})}}function f(e){let n="";return e&&(e.code&&(n+=e.code+" "),e.message&&(n+=e.message+" "),e.detailedMessage&&(n=e.detailedMessage),e.displayMessage&&(n=e.displayMessage)),n}function y(e,n){if(void 0===e&&(e=null),void 0===n&&(n=""),null===e)return n;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return n}const _="pay_by_bank",h=(0,i.getSetting)(_+"_data",{});var b;b=h.nonce,l=b||"";const g=!0===h.log_errors&&h.log_error_endpoint||null;let x={};const k=e=>{const{eventRegistration:a,emitResponse:t}=e,{onPaymentSetup:o,onCheckoutSuccess:i}=a;return(0,c.useEffect)(()=>{const e=o(async()=>{let e=document.getElementById("paybybank_consumeridInput"),n=e&&e.value&&e.value.length,a=document.getElementById("paybybank_dobInput"),o=a&&a.value&&a.value.length;return n&&o?{type:t.responseTypes.SUCCESS}:(d(g,(0,s.__)("The payment process failed. SSN and Date of Birth must be set!","paysafe-checkout"),{}),{type:t.responseTypes.ERROR,message:(0,s.__)("The payment process failed. SSN and Date of Birth must be set!","paysafe-checkout")})});return()=>{e()}},[t.responseTypes.ERROR,t.responseTypes.SUCCESS,o]),(0,c.useEffect)(()=>{const e=i(e=>{let n=h.consumer_id_encrypted;n||(n=function(e){const n=(1n<<64n)-1n,a=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],t=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],s=(e,a)=>(e>>BigInt(a)|e<<BigInt(64-a))&n,o=(e,n)=>e>>BigInt(n),i=(e,n,a)=>e&n^~e&a,c=(e,n,a)=>e&n^e&a^n&a,r=e=>s(e,28)^s(e,34)^s(e,39),l=e=>s(e,14)^s(e,18)^s(e,41),d=e=>s(e,1)^s(e,8)^o(e,7),p=e=>s(e,19)^s(e,61)^o(e,6),m=Array.from((new TextEncoder).encode(e)),u=8n*BigInt(m.length);for(m.push(128);m.length%128!=112;)m.push(0);const f=u>>64n,y=u&n;for(let e=7;e>=0;e--)m.push(Number(f>>BigInt(8*e)&0xffn));for(let e=7;e>=0;e--)m.push(Number(y>>BigInt(8*e)&0xffn));for(let e=0;e<m.length;e+=128){const s=new Array(80).fill(0n);for(let n=0;n<16;n++){let a=0n;for(let t=0;t<8;t++)a=a<<8n|BigInt(m[e+8*n+t]);s[n]=a}for(let e=16;e<80;e++)s[e]=p(s[e-2])+s[e-7]+d(s[e-15])+s[e-16]&n;let[o,u,f,y,_,h,b,g]=a;for(let e=0;e<80;e++){const a=g+l(_)+i(_,h,b)+t[e]+s[e]&n,d=r(o)+c(o,u,f)&n;g=b,b=h,h=_,_=y+a&n,y=f,f=u,u=o,o=a+d&n}a[0]=a[0]+o&n,a[1]=a[1]+u&n,a[2]=a[2]+f&n,a[3]=a[3]+y&n,a[4]=a[4]+_&n,a[5]=a[5]+h&n,a[6]=a[6]+b&n,a[7]=a[7]+g&n}return a.map(e=>e.toString(16).padStart(16,"0")).join("").substring(0,50)}(x.billingAddress.email));let a=document.getElementById("paybybank_consumeridInput"),o=a&&a.value&&a.value.length?a.value:"",i=document.getElementById("paybybank_dobInput"),c=i&&i.value&&i.value.length?i.value:"",r="",l="",_="";if(c){const e=new Date(c);isNaN(e.getTime())||(r=e.getFullYear(),l=e.getMonth()+1,_=e.getDate())}let b={firstName:x.billingAddress.first_name,lastName:x.billingAddress.last_name,email:x.billingAddress.email,identityDocuments:[{type:"SOCIAL_SECURITY",documentNumber:o}],dateOfBirth:{year:r,month:l,day:_}};return x.billingAddress.phone&&(b.phone=x.billingAddress.phone),function(e,n,a,t,o,i){void 0===t&&(t={}),void 0===t.settings&&(t.settings={}),o=!!o;let c=e.orderId;c||(c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=a.log_order_fail_endpoint||null,h=!0===a.log_errors&&a.log_error_endpoint||null,b=parseInt(n.cartTotals.total_price);if(!c||!b)return c&&u(_,c,(0,s.__)("Payment amount missing","paysafe-checkout")),d(h,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=n.cartTotals.currency_code;const i={firstName:n.billingAddress.first_name,lastName:n.billingAddress.last_name,email:n.billingAddress.email},_={billing_street:n.billingAddress.address_1,billing_street2:n.billingAddress.address_2,billing_city:n.billingAddress.city,billing_zip:n.billingAddress.postcode,billing_state:n.billingAddress.state,billing_country:n.billingAddress.country,billing_phone:t&&t.additional&&t.additional.phone?t.additional.phone:n.billingAddress.phone||""};o?function(e,n,a,t,o,i,c,r,l){const _=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===n.hosted_payment_instance)return void u(_,a,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const b=n.hosted_payment_instance,g={transactionSource:void 0===n.transactionSource?"WooCommerceJs":n.transactionSource,amount:i,transactionType:"PAYMENT",currency:c,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};t&&n.use_single_use_customer_token&&(g.singleUseCustomerToken=t),t&&n.payment_toke_from&&(g.paymentTokenFrom=n.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(g.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),g.customerDetails={holderName:r.firstName+" "+r.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:r.firstName,lastName:r.lastName,email:r.email,locale:e.locale,phone:l.billing_phone}},n.customerDetails&&n.customerDetails.holderName&&n.customerDetails.holderName&&(g.customerDetails.holderName=n.customerDetails.holderName),l.billing_street&&(g.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(g.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(g.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(g.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(g.customerDetails.billingDetails.phone=l.billing_phone),b.tokenize(g).then(t=>{if(!t||!t.token){let e="";throw t&&t.error&&(e+=t.error.message?t.error.message:t.error),t&&t.error_message&&(e+=t.error_message),u(_,a,e),"Result failure"}const c={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:t.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};n.save_card&&(c.save_card=!0);const r=m(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(c)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(_,a,e.error_message),d(h,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let n=f(e);u(_,a,n);const t="ERROR "+e.code+": "+e.detailedMessage;d(h,t,[]),p(y(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let n=f(e);u(_,a,n);const t="ERROR "+e.code+": "+e.detailedMessage;d(h,t,[]),p(y(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,t,c,r,l,b,e,i,_):function(e,n,a,t,o,i,c,r,l){const _=e.log_order_fail_endpoint||null,h=!0===e.log_errors&&e.log_error_endpoint||null,b={transactionSource:void 0===n.transactionSource?"WooCommerceCheckout":n.transactionSource,amount:i,transactionType:"PAYMENT",currency:c,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:n.displayPaymentMethods,paymentMethodDetails:n.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),t&&(b.singleUseCustomerToken=t,n.customer&&(b.customer=n.customer)),t&&!n.settings.add_customer_when_single_use_token||(n.customer?b.customer=n.customer:b.customer=r),t&&!n.settings.add_billing_when_single_use_token||(b.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(b.billingAddress.street=l.billing_street),l.billing_street2&&(b.billingAddress.street2=l.billing_street2),l.billing_city&&(b.billingAddress.city=l.billing_city),l.billing_state&&(b.billingAddress.state=l.billing_state),l.billing_phone&&(b.billingAddress.phone=l.billing_phone)),n.settings.use_external_simulator&&e.test_mode&&(b.simulator="EXTERNAL"),n.shippingAddress&&(b.shippingAddress=n.shippingAddress);let g=null;paysafe.checkout.setup(e.authorization,b,function(n,t,o){if(o&&o.paymentHandleToken){const t={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:b.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{"success"===e.status?n.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(h,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?n.showFailureScreen(e.error_message):n.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),g=e.redirect_url}).catch(e=>{let t=f(e);u(_,a,t),d(h,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),n.showFailureScreen(y(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=f(t);if(u(_,a,e),n)d(h,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),n.showFailureScreen(y(t.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");t&&t.code&&t.detailedMessage&&(e+="<br /> "+t.code+" "+t.detailedMessage),d(h,e,[]),p(y(t.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,n){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(h,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:n}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==g)return void(window.location=g);window.location.reload()}else{let t="";t=n?(0,s.__)("Payment session expired","paysafe-checkout"):e,u(_,a,t),d(h,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:n}),window.location.reload()}},function(e,n,t){if(n===i)e.accept();else{let n=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");u(_,a,n),d(h,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,t,c,r,l,b,e,i,_)}return e}(e,x,h,{displayPaymentMethods:["pay_by_bank"],paymentMethodDetails:{payByBank:{accountId:h.account_id,consumerId:n}},customer:b},!1,t)});return()=>{e()}},[t.responseTypes.ERROR,t.responseTypes.SUCCESS,"",[],i]),function(e,a=""){let t=[(0,n().jsx)("div",{children:(0,r.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&t.push((0,n().jsx)("hr",{})),e.test_mode&&t.push((0,n().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,n().jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),a&&t.push(a),t}(h,(0,n().jsxs)("div",{children:[(0,n().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,n().jsx)("label",{id:"paybybank_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paybybank_consumeridInput",children:(0,s.__)("SSN","paysafe-checkout")}),(0,n().jsx)("div",{id:"paybybank_consumerid",className:"paysafe-input-field",children:(0,n().jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paybybank_consumerid_input",id:"paybybank_consumeridInput",placeholder:(0,s.__)("Your SSN","paysafe-checkout"),min:"2",minLength:"2"})}),(0,n().jsx)("p",{id:"paybybank_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter the consumer id from your Pay By Bank account","paysafe-checkout")})]}),(0,n().jsxs)("div",{id:"paysafe-hosted-payment-form2",className:"paysafe-hosted-payment-form",children:[(0,n().jsx)("label",{id:"paybybank_dob_label",className:"paysafe-general-form-label",htmlFor:"paybybank_dobInput",children:(0,s.__)("Date of birth","paysafe-checkout")}),(0,n().jsx)("div",{id:"paybybank_dob",className:"paysafe-input-field",children:(0,n().jsx)("input",{type:"date",className:"paysafe-input-field-input",name:"paybybank_dob_input",id:"paybybank_dobInput",placeholder:(0,s.__)("Your Date of birth","paysafe-checkout"),min:"2",minLength:"2"})}),(0,n().jsx)("p",{id:"paybybank_dob_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter your Date of Birth for your Pay By Bank account","paysafe-checkout")})]})]}))},w={name:_,paymentMethodId:_,label:function(e,a){const t=(0,r.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,n().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,n().jsx)("span",{children:t}),(0,n().jsx)("img",{className:"paysafe-gateway-image",src:a,alt:t})]})}(h.title,h.icon),content:(0,n().jsx)(k,{}),edit:(0,n().jsx)(k,{}),canMakePayment:e=>(x=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:h.supports}};(0,o.registerPaymentMethod)(w)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafe.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '2 1899449efcd97f43e8f');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '298965a25aaaa4b194b9'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafe.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var a=s(609),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,a=window.wc.wcBlocksRegistry,n=window.wp.htmlEntities,o=window.wc.wcSettings,i=window.wp.element;var r=function s(a){const n=t[a];if(void 0!==n)return n.exports;const o=t[a]={exports:{}};return e[a](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function p(e,t,a,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",p=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",m=a.log_order_fail_endpoint||null,f=!0===a.log_errors&&a.log_error_endpoint||null,g=parseInt(t.cartTotals.total_price);if(!r||!g)return r&&y(m,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(f,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},m={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,a,n,o,i,r,c,p){const m=e.log_order_fail_endpoint||null,f=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void y(m,a,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const g=t.hosted_payment_instance,v={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(v.singleUseCustomerToken=n),n&&t.payment_toke_from&&(v.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(v.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),v.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:p.billing_zip,country:p.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:p.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(v.customerDetails.holderName=t.customerDetails.holderName),p.billing_street&&(v.customerDetails.billingDetails.street=p.billing_street),p.billing_street2&&(v.customerDetails.billingDetails.street2=p.billing_street2),p.billing_city&&(v.customerDetails.billingDetails.city=p.billing_city),p.billing_state&&(v.customerDetails.billingDetails.state=p.billing_state),p.billing_phone&&(v.customerDetails.billingDetails.phone=p.billing_phone),g.tokenize(v).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),y(m,a,e),"Result failure"}const r={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=u(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(y(m,a,e.error_message),l(f,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);y(m,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(f,n,[]),d(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);y(m,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(f,n,[]),d(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,n,r,c,p,g,e,i,m):function(e,t,a,n,o,i,r,c,p){const m=e.log_order_fail_endpoint||null,f=!0===e.log_errors&&e.log_error_endpoint||null,g={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(g.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(g.singleUseCustomerToken=n,t.customer&&(g.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?g.customer=t.customer:g.customer=c),n&&!t.settings.add_billing_when_single_use_token||(g.billingAddress={nickName:"Home",zip:p.billing_zip,country:p.billing_country},p.billing_street&&(g.billingAddress.street=p.billing_street),p.billing_street2&&(g.billingAddress.street2=p.billing_street2),p.billing_city&&(g.billingAddress.city=p.billing_city),p.billing_state&&(g.billingAddress.state=p.billing_state),p.billing_phone&&(g.billingAddress.phone=p.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(g.simulator="EXTERNAL"),t.shippingAddress&&(g.shippingAddress=t.shippingAddress);let v=null;paysafe.checkout.setup(e.authorization,g,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:g.merchantRefNum,nonce:e.nonce},i=u(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(f,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),v=e.redirect_url}).catch(e=>{let n=_(e);y(m,a,n),l(f,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(n);if(y(m,a,e),t)l(f,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),l(f,e,[]),d(h(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(f,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==v)return void(window.location=v);window.location.reload()}else{let n="";n=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,y(m,a,n),l(f,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");y(m,a,t),l(f,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,n,r,c,p,g,e,i,m)}return e}function u(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,a,n){const i=!0===e.log_errors&&e.log_error_endpoint||null;return void 0===n&&(n=!1),null!=e.initialization_timeout&&Number(e.initialization_timeout)>=1e3&&(t.initializationTimeout=Number(e.initialization_timeout)),paysafe.fields.setup(e.authorization,t).then(e=>e.show().then(t=>t.card&&!t.card.error||t.applePay&&!t.applePay.error||t.googlePay&&!t.googlePay.error?e:void 0)).catch(r=>{if(r.error&&(r=r.error),!n){const n="ERROR "+r.code+": "+r.detailedMessage,c=function(e,t,s,a){return{error_code:e&&e.code?e.code:0,error_message:e&&e.message?e.message:"",display_message:e&&e.displayMessage?e.displayMessage:"",detailed_message:e&&e.detailedMessage?e.detailedMessage:"",correlationId:e&&e.correlationId?e.correlationId:"-",store_currency:t&&t.currency_code?t.currency_code:"-",cart_currency:a&&a.cartTotals&&a.cartTotals.currency_code?a.cartTotals.currency_code:"-",account_ids:s&&s.accounts?s.accounts:{},wp_version:(0,o.getSetting)("wpVersion",""),woo_version:(0,o.getSetting)("wcVersion",""),paysafe_version:t&&t.paysafe_version?t.paysafe_version:"-"}}(r,e,t,a);l(i,n,c),d(h(r.code,(0,s.__)("The payment initialization failed. Please reload the page and try again.","paysafe-checkout")),!0)}return Promise.reject(r)})}function y(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const f="paysafe",g=(0,o.getSetting)("paysafe_data",{});var v;v=g.nonce,c=v||"";const T=!0===g.log_errors&&g.log_error_endpoint||null,w="paysafe_js"===g.integration_type;let k,R=!!g.cvv_verification,b={};const N=function(){if(!jQuery("#paysafe-hosted-payment-form").length)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){N()},1e3);S=!1;const e={currencyCode:g.currency_code,environment:g.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",fields:{cardNumber:{selector:"#cardNumber",placeholder:"Card number",separator:" "},expiryDate:{selector:"#expiryDate",placeholder:"MM/YY"},cvv:{selector:"#cvv",placeholder:"CVV",optional:!1}},style:{input:{"font-family":"sans-serif","font-weight":"normal","font-size":"16px"}},accounts:{default:g.account_id}};null!=g.initialization_timeout&&Number(g.initialization_timeout)>=1e3&&(e.initializationTimeout=Number(g.initialization_timeout)),m(g,e,b).then(e=>{k=e})};let E=null,S=!1;const P=function(){if(!jQuery("#cvv-verification-container").length)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){P()},1e3);S=!0,E=null;const e={currencyCode:g.currency_code,environment:g.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",fields:{cardNumber:{selector:"#cardNumber",placeholder:"Card number",separator:" ",optional:!0},expiryDate:{selector:"#expiryDate",placeholder:"MM/YY",optional:!0},cvv:{selector:"#cvv",placeholder:"CVV",optional:!R}},accounts:{default:g.account_id}};null!=g.initialization_timeout&&Number(g.initialization_timeout)>=1e3&&(e.initializationTimeout=Number(g.initialization_timeout)),"undefined"!=typeof paysafe&&void 0!==paysafe.fields&&m(g,e,b).then(e=>{E=e}).catch(e=>{9073===parseInt(e.code)&&R&&(R=!1,P())})},C=e=>{const{eventRegistration:t,emitResponse:a}=e,{onCheckoutSuccess:o,onPaymentSetup:c}=t;(0,i.useEffect)(()=>{R&&(S=!1),w&&N();const e=c(async e=>{if(w){if(k){if(k.areAllFieldsValid()){let e=document.getElementById("holderNameInput");return e&&e.value&&e.value.length&&e.value.length>=2&&e.value.length<=160?{type:a.responseTypes.SUCCESS}:(l(T,(0,s.__)("The payment process failed. Card holder name must have between 2 and 160 characters!","paysafe-checkout"),{tokenization_stage:2}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Card holder name must have between 2 and 160 characters!","paysafe-checkout")})}return l(T,(0,s.__)("The payment process failed. Card holder name or card details failed verification!","paysafe-checkout"),{tokenization_stage:2}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please enter your card details and try again","paysafe-checkout")}}return l(T,(0,s.__)("The payment process failed.","paysafe-checkout"),{tokenization_stage:3}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please reload the page and try again.","paysafe-checkout")}}});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,c]),(0,i.useEffect)(()=>{const e=o(e=>{const t={displayPaymentMethods:["card"],paymentMethodDetails:{card:{accountId:g.account_id}}};if(w){let e=document.getElementById("paysafe_hosted_save_card");e&&e.checked&&(t.save_card=!0),t.hosted_payment_instance=k}return p(e,b,g,t,w,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]);let d=[];return g.description&&d.push((0,r.jsx)("div",{children:(0,n.decodeEntities)(g.description||"")})),g.description&&g.test_mode&&d.push((0,r.jsx)("hr",{})),g.test_mode&&d.push((0,r.jsxs)("div",{style:{textAlign:"justify",marginTop:"5px"},children:[(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST MODE. Use the test Visa card 4000000000001091 with any expiry date, CVC, email, or OTP token. Important notice: Please use only TEST CARDS for testing. You can find other test cards ","paysafe-checkout")}),(0,r.jsxs)("a",{href:"https://developer.paysafe.com/en/api-docs/cards/test-and-go-live/test-cards/",target:"_blank",children:[(0,s.__)("here. ","paysafe-checkout")," "]})]})),g.test_mode&&w&&d.push((0,r.jsx)("p",{})),w?d.push(wp.element.RawHTML({children:g.integration_hosted_form})):g.is_subscription_payment&&d.push((0,r.jsxs)("p",{style:{fontSize:"0.8em",marginBottom:"0"},children:[(0,r.jsx)("b",{children:(0,s.__)("Note:","paysafe-checkout")}),(0,s.__)("This order includes a subscription.","paysafe-checkout"),(0,s.__)("By proceeding with payment, your card details will be securely saved for future recurring payments.","paysafe-checkout"),(0,r.jsx)("br",{}),(0,s.__)("Card data is stored and processed securely by Paysafe in compliance with PCI DSS standards and according to the merchant’s","paysafe-checkout")," ",(0,s.__)("Terms and Conditions","paysafe-checkout")," ",(0,s.__)("and","paysafe-checkout")," ",(0,s.__)("Privacy Policy.","paysafe-checkout")]})),d},x=e=>{const{eventRegistration:t,emitResponse:a}=e,{onCheckoutSuccess:n,onPaymentSetup:o}=t;return(0,i.useEffect)(()=>{S||(S=!0,P());const e=o(()=>{if(R){if(!E)return l(T,(0,s.__)("The payment process failed.","paysafe-checkout"),{tokenization_stage:3}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please reload the page and try again.","paysafe-checkout")};if(!E.areAllFieldsValid())return l(T,(0,s.__)("The payment process failed. No CVV entered","paysafe-checkout"),{tokenization_stage:2}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please enter your saved card CVV and try again","paysafe-checkout")}}});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,o]),(0,i.useEffect)(()=>{const e=n(e=>{const t=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.redirect?e.processingResponse.paymentDetails.redirect:null;if(t)return window.location=t,{type:a.responseTypes.SUCCESS};const s={hosted_payment_instance:E,use_single_use_customer_token:!0,payment_toke_from:e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.paysafe_token?e.processingResponse.paymentDetails.paysafe_token:""};return p(e,b,g,s,!0,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],n]),R&&"undefined"!=typeof paysafe&&void 0!==paysafe.fields?[(0,r.jsxs)("div",{id:"cvv-verification-container",children:[(0,r.jsx)("b",{children:(0,s.__)("CVV","paysafe-checkout")}),(0,r.jsx)("div",{id:"holderName",className:"paysafe-input-field optional-field",style:{display:"none"}}),(0,r.jsx)("div",{id:"cardNumber",className:"paysafe-input-field optional-field",style:{display:"none"}}),(0,r.jsx)("div",{id:"expiryDate",className:"paysafe-input-field optional-field",style:{display:"none"}}),(0,r.jsxs)("div",{className:"paysafe-cc-form-exp-cvv-row",children:[(0,r.jsx)("div",{className:"paysafe-cc-form-exp-cvv-box1"}),(0,r.jsx)("div",{className:"paysafe-cc-form-exp-cvv-box2",children:(0,r.jsx)("div",{id:"cvv",className:"paysafe-input-field"})}),(0,r.jsx)("div",{className:"paysafe-cc-form-exp-cvv-box3",children:(0,r.jsx)("img",{className:"paysafe-cc-form-cvv-image",src:g.paysafe_base_url+"assets/img/cvv.svg",alt:"CVV"})})]})]})]:[(0,r.jsxs)("div",{id:"cvv-verification-container",children:[(0,r.jsx)("div",{id:"holderName",className:"paysafe-input-field optional-field"}),(0,r.jsx)("div",{id:"cardNumber",className:"paysafe-input-field optional-field"}),(0,r.jsx)("div",{id:"expiryDate",className:"paysafe-input-field optional-field"}),(0,r.jsx)("div",{id:"cvv",className:"paysafe-input-field optional-field"})]})]},D={name:f,paymentMethodId:f,label:function(e,t){const a=(0,n.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:a}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:a})]})}(g.title,g.icon),content:(0,r.jsx)(C,{}),edit:(0,r.jsx)(C,{}),savedTokenComponent:(0,r.jsx)(x,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,a.registerPaymentMethod)(D)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=a(),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),a=e(e=>{e.exports=window.React});const n=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wp.htmlEntities,r=window.wc.wcSettings,c=window.wp.element;s();let l="";function d(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function u(e,t,s,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",u=s.log_order_fail_endpoint||null,y=!0===s.log_errors&&s.log_error_endpoint||null,g=parseInt(t.cartTotals.total_price);if(!r||!g)return r&&_(u,r,(0,n.__)("Payment amount missing","paysafe-checkout")),d(y,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},u={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,a,o,i,r,c,l){const u=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void _(u,s,(0,n.__)("Hosted payment instance is not set","paysafe-checkout"));const g=t.hosted_payment_instance,v={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(v.singleUseCustomerToken=a),a&&t.payment_toke_from&&(v.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(v.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),v.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(v.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(v.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(v.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(v.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(v.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(v.customerDetails.billingDetails.phone=l.billing_phone),g.tokenize(v).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),_(u,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(_(u,s,e.error_message),d(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=h(e);_(u,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(y,a,[]),p(f(e.code,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=h(e);_(u,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(y,a,[]),p(f(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,a,r,c,l,g,e,i,u):function(e,t,s,a,o,i,r,c,l){const u=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,g={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(g.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(g.singleUseCustomerToken=a,t.customer&&(g.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?g.customer=t.customer:g.customer=c),a&&!t.settings.add_billing_when_single_use_token||(g.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(g.billingAddress.street=l.billing_street),l.billing_street2&&(g.billingAddress.street2=l.billing_street2),l.billing_city&&(g.billingAddress.city=l.billing_city),l.billing_state&&(g.billingAddress.state=l.billing_state),l.billing_phone&&(g.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(g.simulator="EXTERNAL"),t.shippingAddress&&(g.shippingAddress=t.shippingAddress);let v=null;paysafe.checkout.setup(e.authorization,g,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:g.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,n.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(y,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),v=e.redirect_url}).catch(e=>{let a=h(e);_(u,s,a),d(y,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(f(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=h(a);if(_(u,s,e),t)d(y,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(f(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),d(y,e,[]),p(f(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(y,(0,n.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==v)return void(window.location=v);window.location.reload()}else{let a="";a=t?(0,n.__)("Payment session expired","paysafe-checkout"):e,_(u,s,a),d(y,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,n.__)("Payment amount risk assessment failed","paysafe-checkout");_(u,s,t),d(y,(0,n.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,n.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,a,r,c,l,g,e,i,u)}return e}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,n.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function y(e,t,s,a){const o=!0===e.log_errors&&e.log_error_endpoint||null;return void 0===a&&(a=!1),null!=e.initialization_timeout&&Number(e.initialization_timeout)>=1e3&&(t.initializationTimeout=Number(e.initialization_timeout)),paysafe.fields.setup(e.authorization,t).then(e=>e.show().then(t=>t.card&&!t.card.error||t.applePay&&!t.applePay.error||t.googlePay&&!t.googlePay.error?e:void 0)).catch(i=>{if(i.error&&(i=i.error),!a){const a="ERROR "+i.code+": "+i.detailedMessage,c=function(e,t,s,a){return{error_code:e&&e.code?e.code:0,error_message:e&&e.message?e.message:"",display_message:e&&e.displayMessage?e.displayMessage:"",detailed_message:e&&e.detailedMessage?e.detailedMessage:"",correlationId:e&&e.correlationId?e.correlationId:"-",store_currency:t&&t.currency_code?t.currency_code:"-",cart_currency:a&&a.cartTotals&&a.cartTotals.currency_code?a.cartTotals.currency_code:"-",account_ids:s&&s.accounts?s.accounts:{},wp_version:(0,r.getSetting)("wpVersion",""),woo_version:(0,r.getSetting)("wcVersion",""),paysafe_version:t&&t.paysafe_version?t.paysafe_version:"-"}}(i,e,t,s);d(o,a,c),p(f(i.code,(0,n.__)("The payment initialization failed. Please reload the page and try again.","paysafe-checkout")),!0)}return Promise.reject(i)})}function _(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function h(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function f(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,n.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,n.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,n.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,n.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,n.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const g="paysafe",v=(0,r.getSetting)("paysafe_data",{});var T;T=v.nonce,l=T||"";const w=!0===v.log_errors&&v.log_error_endpoint||null,k="paysafe_js"===v.integration_type;let R,b=!!v.cvv_verification,N={};const E=function(){if(!jQuery("#paysafe-hosted-payment-form").length)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){E()},1e3);P=!1;const e={currencyCode:v.currency_code,environment:v.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",fields:{cardNumber:{selector:"#cardNumber",placeholder:"Card number",separator:" "},expiryDate:{selector:"#expiryDate",placeholder:"MM/YY"},cvv:{selector:"#cvv",placeholder:"CVV",optional:!1}},style:{input:{"font-family":"sans-serif","font-weight":"normal","font-size":"16px"}},accounts:{default:v.account_id}};null!=v.initialization_timeout&&Number(v.initialization_timeout)>=1e3&&(e.initializationTimeout=Number(v.initialization_timeout)),y(v,e,N).then(e=>{R=e})};let S=null,P=!1;const C=function(){if(!jQuery("#cvv-verification-container").length)return;if("undefined"==typeof paysafe||void 0===paysafe.fields)return void setTimeout(function(){C()},1e3);P=!0,S=null;const e={currencyCode:v.currency_code,environment:v.test_mode?"TEST":"LIVE",transactionSource:"WooCommerceJs",fields:{cardNumber:{selector:"#cardNumber",placeholder:"Card number",separator:" ",optional:!0},expiryDate:{selector:"#expiryDate",placeholder:"MM/YY",optional:!0},cvv:{selector:"#cvv",placeholder:"CVV",optional:!b}},accounts:{default:v.account_id}};null!=v.initialization_timeout&&Number(v.initialization_timeout)>=1e3&&(e.initializationTimeout=Number(v.initialization_timeout)),"undefined"!=typeof paysafe&&void 0!==paysafe.fields&&y(v,e,N).then(e=>{S=e}).catch(e=>{9073===parseInt(e.code)&&b&&(b=!1,C())})},x=e=>{const{eventRegistration:s,emitResponse:a}=e,{onCheckoutSuccess:o,onPaymentSetup:r}=s;(0,c.useEffect)(()=>{b&&(P=!1),k&&E();const e=r(async e=>{if(k){if(R){if(R.areAllFieldsValid()){let e=document.getElementById("holderNameInput");return e&&e.value&&e.value.length&&e.value.length>=2&&e.value.length<=160?{type:a.responseTypes.SUCCESS}:(d(w,(0,n.__)("The payment process failed. Card holder name must have between 2 and 160 characters!","paysafe-checkout"),{tokenization_stage:2}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Card holder name must have between 2 and 160 characters!","paysafe-checkout")})}return d(w,(0,n.__)("The payment process failed. Card holder name or card details failed verification!","paysafe-checkout"),{tokenization_stage:2}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please enter your card details and try again","paysafe-checkout")}}return d(w,(0,n.__)("The payment process failed.","paysafe-checkout"),{tokenization_stage:3}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please reload the page and try again.","paysafe-checkout")}}});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,r]),(0,c.useEffect)(()=>{const e=o(e=>{const t={displayPaymentMethods:["card"],paymentMethodDetails:{card:{accountId:v.account_id}}};if(k){let e=document.getElementById("paysafe_hosted_save_card");e&&e.checked&&(t.save_card=!0),t.hosted_payment_instance=R}return u(e,N,v,t,k,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]);let l=[];return v.description&&l.push((0,t().jsx)("div",{children:(0,i.decodeEntities)(v.description||"")})),v.description&&v.test_mode&&l.push((0,t().jsx)("hr",{})),v.test_mode&&l.push((0,t().jsxs)("div",{style:{textAlign:"justify",marginTop:"5px"},children:[(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST MODE. Use the test Visa card 4000000000001091 with any expiry date, CVC, email, or OTP token. Important notice: Please use only TEST CARDS for testing. You can find other test cards ","paysafe-checkout")}),(0,t().jsxs)("a",{href:"https://developer.paysafe.com/en/api-docs/cards/test-and-go-live/test-cards/",target:"_blank",children:[(0,n.__)("here. ","paysafe-checkout")," "]})]})),v.test_mode&&k&&l.push((0,t().jsx)("p",{})),k?l.push(wp.element.RawHTML({children:v.integration_hosted_form})):v.is_subscription_payment&&l.push((0,t().jsxs)("p",{style:{fontSize:"0.8em",marginBottom:"0"},children:[(0,t().jsx)("b",{children:(0,n.__)("Note:","paysafe-checkout")}),(0,n.__)("This order includes a subscription.","paysafe-checkout"),(0,n.__)("By proceeding with payment, your card details will be securely saved for future recurring payments.","paysafe-checkout"),(0,t().jsx)("br",{}),(0,n.__)("Card data is stored and processed securely by Paysafe in compliance with PCI DSS standards and according to the merchant’s","paysafe-checkout")," ",(0,n.__)("Terms and Conditions","paysafe-checkout")," ",(0,n.__)("and","paysafe-checkout")," ",(0,n.__)("Privacy Policy.","paysafe-checkout")]})),l},D=e=>{const{eventRegistration:s,emitResponse:a}=e,{onCheckoutSuccess:o,onPaymentSetup:i}=s;return(0,c.useEffect)(()=>{P||(P=!0,C());const e=i(()=>{if(b){if(!S)return d(w,(0,n.__)("The payment process failed.","paysafe-checkout"),{tokenization_stage:3}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please reload the page and try again.","paysafe-checkout")};if(!S.areAllFieldsValid())return d(w,(0,n.__)("The payment process failed. No CVV entered","paysafe-checkout"),{tokenization_stage:2}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please enter your saved card CVV and try again","paysafe-checkout")}}});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,i]),(0,c.useEffect)(()=>{const e=o(e=>{const t=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.redirect?e.processingResponse.paymentDetails.redirect:null;if(t)return window.location=t,{type:a.responseTypes.SUCCESS};const s={hosted_payment_instance:S,use_single_use_customer_token:!0,payment_toke_from:e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.paysafe_token?e.processingResponse.paymentDetails.paysafe_token:""};return u(e,N,v,s,!0,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]),b&&"undefined"!=typeof paysafe&&void 0!==paysafe.fields?[(0,t().jsxs)("div",{id:"cvv-verification-container",children:[(0,t().jsx)("b",{children:(0,n.__)("CVV","paysafe-checkout")}),(0,t().jsx)("div",{id:"holderName",className:"paysafe-input-field optional-field",style:{display:"none"}}),(0,t().jsx)("div",{id:"cardNumber",className:"paysafe-input-field optional-field",style:{display:"none"}}),(0,t().jsx)("div",{id:"expiryDate",className:"paysafe-input-field optional-field",style:{display:"none"}}),(0,t().jsxs)("div",{className:"paysafe-cc-form-exp-cvv-row",children:[(0,t().jsx)("div",{className:"paysafe-cc-form-exp-cvv-box1"}),(0,t().jsx)("div",{className:"paysafe-cc-form-exp-cvv-box2",children:(0,t().jsx)("div",{id:"cvv",className:"paysafe-input-field"})}),(0,t().jsx)("div",{className:"paysafe-cc-form-exp-cvv-box3",children:(0,t().jsx)("img",{className:"paysafe-cc-form-cvv-image",src:v.paysafe_base_url+"assets/img/cvv.svg",alt:"CVV"})})]})]})]:[(0,t().jsxs)("div",{id:"cvv-verification-container",children:[(0,t().jsx)("div",{id:"holderName",className:"paysafe-input-field optional-field"}),(0,t().jsx)("div",{id:"cardNumber",className:"paysafe-input-field optional-field"}),(0,t().jsx)("div",{id:"expiryDate",className:"paysafe-input-field optional-field"}),(0,t().jsx)("div",{id:"cvv",className:"paysafe-input-field optional-field"})]})]},A={name:g,paymentMethodId:g,label:function(e,s){const a=(0,i.decodeEntities)(e)||(0,n.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:a}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:a})]})}(v.title,v.icon),content:(0,t().jsx)(x,{}),edit:(0,t().jsx)(x,{}),savedTokenComponent:(0,t().jsx)(D,{}),canMakePayment:e=>(N=e,!0),ariaLabel:(0,n.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:v.supports}};(0,o.registerPaymentMethod)(A)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafecard.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 51335fbea3f884d4f080');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'ac68daf38c5d11568e5d'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafecard.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,n,t){var a=t(609),s=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function r(e,n,t){var a,r={},l=null,d=null;for(a in void 0!==t&&(l=""+t),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)o.call(n,a)&&!i.hasOwnProperty(a)&&(r[a]=n[a]);if(e&&e.defaultProps)for(a in n=e.defaultProps)void 0===r[a]&&(r[a]=n[a]);return{$$typeof:s,type:e,key:l,ref:d,props:r,_owner:c.current}}n.jsx=r,n.jsxs=r},848(e,n,t){e.exports=t(20)},609(e){e.exports=window.React}};const n={},t=window.wp.i18n,a=window.wc.wcBlocksRegistry,s=window.wc.wcSettings,o=window.wp.element,c=window.wp.htmlEntities;var i=function t(a){const s=n[a];if(void 0!==s)return s.exports;const o=n[a]={exports:{}};return e[a](o,o.exports,t),o.exports}(848);let r="";function l(e,n,t){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:n,context:t,nonce:r})}).catch(()=>{})}}function d(e,n){n=!!n;let t=document.getElementsByClassName("woocommerce-error");if(t=t.length>0?t[0]:null,!t){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),n=e.length>0?e[0]:null;n&&(t=document.createElement("ul"),t.className="woocommerce-error",n.appendChild(t))}if(t){let a=document.createElement("li"),s=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||n?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=s,t.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=s}}function p(e){const n=new URL(e,window.location.href);if(n.origin===window.location.origin)return n.pathname+n.search+n.hash;d((0,t.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+n.toString(),!0)}function m(e,n,t){if(t&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:n,reason:t,nonce:r})}).catch(()=>{})}}function u(e){let n="";return e&&(e.code&&(n+=e.code+" "),e.message&&(n+=e.message+" "),e.detailedMessage&&(n=e.detailedMessage),e.displayMessage&&(n=e.displayMessage)),n}function f(e,n){if(void 0===e&&(e=null),void 0===n&&(n=""),null===e)return n;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,t.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,t.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,t.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,t.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,t.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return n}const h="paysafecard",_=(0,s.getSetting)(h+"_data",{});var g;g=_.nonce,r=g||"";let b={};const y=e=>{const{eventRegistration:n,emitResponse:a}=e,{onCheckoutSuccess:s}=n;return(0,o.useEffect)(()=>{const e=s(e=>{let n=_.consumer_id_encrypted;return n||(n=function(e){const n=(1n<<64n)-1n,t=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],a=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],s=(e,t)=>(e>>BigInt(t)|e<<BigInt(64-t))&n,o=(e,n)=>e>>BigInt(n),c=(e,n,t)=>e&n^~e&t,i=(e,n,t)=>e&n^e&t^n&t,r=e=>s(e,28)^s(e,34)^s(e,39),l=e=>s(e,14)^s(e,18)^s(e,41),d=e=>s(e,1)^s(e,8)^o(e,7),p=e=>s(e,19)^s(e,61)^o(e,6),m=Array.from((new TextEncoder).encode(e)),u=8n*BigInt(m.length);for(m.push(128);m.length%128!=112;)m.push(0);const f=u>>64n,h=u&n;for(let e=7;e>=0;e--)m.push(Number(f>>BigInt(8*e)&0xffn));for(let e=7;e>=0;e--)m.push(Number(h>>BigInt(8*e)&0xffn));for(let e=0;e<m.length;e+=128){const s=new Array(80).fill(0n);for(let n=0;n<16;n++){let t=0n;for(let a=0;a<8;a++)t=t<<8n|BigInt(m[e+8*n+a]);s[n]=t}for(let e=16;e<80;e++)s[e]=p(s[e-2])+s[e-7]+d(s[e-15])+s[e-16]&n;let[o,u,f,h,_,g,b,y]=t;for(let e=0;e<80;e++){const t=y+l(_)+c(_,g,b)+a[e]+s[e]&n,d=r(o)+i(o,u,f)&n;y=b,b=g,g=_,_=h+t&n,h=f,f=u,u=o,o=t+d&n}t[0]=t[0]+o&n,t[1]=t[1]+u&n,t[2]=t[2]+f&n,t[3]=t[3]+h&n,t[4]=t[4]+_&n,t[5]=t[5]+g&n,t[6]=t[6]+b&n,t[7]=t[7]+y&n}return t.map(e=>e.toString(16).padStart(16,"0")).join("").substring(0,50)}(b.billingAddress.email)),function(e,n,a,s,o,c){void 0===s&&(s={}),void 0===s.settings&&(s.settings={}),o=!!o;let i=e.orderId;i||(i=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=a.log_order_fail_endpoint||null,g=!0===a.log_errors&&a.log_error_endpoint||null,b=parseInt(n.cartTotals.total_price);if(!i||!b)return i&&m(_,i,(0,t.__)("Payment amount missing","paysafe-checkout")),l(g,(0,t.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:c.responseTypes.ERROR,message:(0,t.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=n.cartTotals.currency_code;const c={firstName:n.billingAddress.first_name,lastName:n.billingAddress.last_name,email:n.billingAddress.email},_={billing_street:n.billingAddress.address_1,billing_street2:n.billingAddress.address_2,billing_city:n.billingAddress.city,billing_zip:n.billingAddress.postcode,billing_state:n.billingAddress.state,billing_country:n.billingAddress.country,billing_phone:s&&s.additional&&s.additional.phone?s.additional.phone:n.billingAddress.phone||""};o?function(e,n,a,s,o,c,i,r,h){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===n.hosted_payment_instance)return void m(_,a,(0,t.__)("Hosted payment instance is not set","paysafe-checkout"));const b=n.hosted_payment_instance,y={transactionSource:void 0===n.transactionSource?"WooCommerceJs":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};s&&n.use_single_use_customer_token&&(y.singleUseCustomerToken=s),s&&n.payment_toke_from&&(y.paymentTokenFrom=n.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(y.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),y.customerDetails={holderName:r.firstName+" "+r.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:r.firstName,lastName:r.lastName,email:r.email,locale:e.locale,phone:h.billing_phone}},n.customerDetails&&n.customerDetails.holderName&&n.customerDetails.holderName&&(y.customerDetails.holderName=n.customerDetails.holderName),h.billing_street&&(y.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(y.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(y.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(y.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(y.customerDetails.billingDetails.phone=h.billing_phone),b.tokenize(y).then(s=>{if(!s||!s.token){let e="";throw s&&s.error&&(e+=s.error.message?s.error.message:s.error),s&&s.error_message&&(e+=s.error_message),m(_,a,e),"Result failure"}const i={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:s.token,amount:c,customerOperation:"",merchantRefNum:o,nonce:e.nonce};n.save_card&&(i.save_card=!0);const r=p(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(_,a,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let n=u(e);m(_,a,n);const s="ERROR "+e.code+": "+e.detailedMessage;l(g,s,[]),d(f(e.code,(0,t.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let n=u(e);m(_,a,n);const s="ERROR "+e.code+": "+e.detailedMessage;l(g,s,[]),d(f(e.code,(0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,s,i,r,h,b,e,c,_):function(e,n,a,s,o,c,i,r,h){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,b={transactionSource:void 0===n.transactionSource?"WooCommerceCheckout":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:n.displayPaymentMethods,paymentMethodDetails:n.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),s&&(b.singleUseCustomerToken=s,n.customer&&(b.customer=n.customer)),s&&!n.settings.add_customer_when_single_use_token||(n.customer?b.customer=n.customer:b.customer=r),s&&!n.settings.add_billing_when_single_use_token||(b.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(b.billingAddress.street=h.billing_street),h.billing_street2&&(b.billingAddress.street2=h.billing_street2),h.billing_city&&(b.billingAddress.city=h.billing_city),h.billing_state&&(b.billingAddress.state=h.billing_state),h.billing_phone&&(b.billingAddress.phone=h.billing_phone)),n.settings.use_external_simulator&&e.test_mode&&(b.simulator="EXTERNAL"),n.shippingAddress&&(b.shippingAddress=n.shippingAddress);let y=null;paysafe.checkout.setup(e.authorization,b,function(n,s,o){if(o&&o.paymentHandleToken){const s={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:b.merchantRefNum,nonce:e.nonce},c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(s)}).then(e=>e.json()).then(e=>{"success"===e.status?n.showSuccessScreen((0,t.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,t.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?n.showFailureScreen(e.error_message):n.showFailureScreen((0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),y=e.redirect_url}).catch(e=>{let s=u(e);m(_,a,s),l(g,(0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),n.showFailureScreen(f(e.code,(0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(s);if(m(_,a,e),n)l(g,(0,t.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),n.showFailureScreen(f(s.code,(0,t.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,t.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");s&&s.code&&s.detailedMessage&&(e+="<br /> "+s.code+" "+s.detailedMessage),l(g,e,[]),d(f(s.code,(0,t.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,n){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,t.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:n}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==y)return void(window.location=y);window.location.reload()}else{let s="";s=n?(0,t.__)("Payment session expired","paysafe-checkout"):e,m(_,a,s),l(g,(0,t.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:n}),window.location.reload()}},function(e,n,s){if(n===c)e.accept();else{let n=(0,t.__)("Payment amount risk assessment failed","paysafe-checkout");m(_,a,n),l(g,(0,t.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,t.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,s,i,r,h,b,e,c,_)}return e}(e,b,_,{displayPaymentMethods:["paysafecard"],paymentMethodDetails:{paysafecard:{accountId:_.account_id,consumerId:n}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],s]),function(e,n=""){let a=[(0,i.jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,i.jsx)("hr",{})),e.test_mode&&a.push((0,i.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,i.jsx)("span",{children:(0,t.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),n&&a.push(n),a}(_)},x={name:h,paymentMethodId:h,label:function(e,n){const a=(0,c.decodeEntities)(e)||(0,t.__)("Paysafe Checkout","paysafe-checkout");return(0,i.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,i.jsx)("span",{children:a}),(0,i.jsx)("img",{className:"paysafe-gateway-image",src:n,alt:a})]})}(_.title,_.icon),content:(0,i.jsx)(y,{}),edit:(0,i.jsx)(y,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,t.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:_.supports}};(0,a.registerPaymentMethod)(x)})();1 (()=>{"use strict";const e=e=>{var n;return()=>{if(e){var t=e;e=0,n={exports:{}},t.call(n.exports,n,n.exports)}return n.exports}};var n=e((e,n)=>{var t=a(),s=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function r(e,n,t){var a,r={},l=null,d=null;for(a in void 0!==t&&(l=""+t),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)o.call(n,a)&&!i.hasOwnProperty(a)&&(r[a]=n[a]);if(e&&e.defaultProps)for(a in n=e.defaultProps)void 0===r[a]&&(r[a]=n[a]);return{$$typeof:s,type:e,key:l,ref:d,props:r,_owner:c.current}}n.jsx=r,n.jsxs=r}),t=e(e=>{e.exports=n()}),a=e(e=>{e.exports=window.React});const s=window.wp.i18n,o=window.wc.wcBlocksRegistry,c=window.wc.wcSettings,i=window.wp.element,r=window.wp.htmlEntities;t();let l="";function d(e,n,t){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:n,context:t,nonce:l})}).catch(()=>{})}}function p(e,n){n=!!n;let t=document.getElementsByClassName("woocommerce-error");if(t=t.length>0?t[0]:null,!t){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),n=e.length>0?e[0]:null;n&&(t=document.createElement("ul"),t.className="woocommerce-error",n.appendChild(t))}if(t){let a=document.createElement("li"),s=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||n?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=s,t.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=s}}function m(e){const n=new URL(e,window.location.href);if(n.origin===window.location.origin)return n.pathname+n.search+n.hash;p((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+n.toString(),!0)}function u(e,n,t){if(t&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:n,reason:t,nonce:l})}).catch(()=>{})}}function f(e){let n="";return e&&(e.code&&(n+=e.code+" "),e.message&&(n+=e.message+" "),e.detailedMessage&&(n=e.detailedMessage),e.displayMessage&&(n=e.displayMessage)),n}function h(e,n){if(void 0===e&&(e=null),void 0===n&&(n=""),null===e)return n;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return n}const _="paysafecard",g=(0,c.getSetting)(_+"_data",{});var b;b=g.nonce,l=b||"";let y={};const x=e=>{const{eventRegistration:t,emitResponse:a}=e,{onCheckoutSuccess:o}=t;return(0,i.useEffect)(()=>{const e=o(e=>{let n=g.consumer_id_encrypted;return n||(n=function(e){const n=(1n<<64n)-1n,t=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],a=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],s=(e,t)=>(e>>BigInt(t)|e<<BigInt(64-t))&n,o=(e,n)=>e>>BigInt(n),c=(e,n,t)=>e&n^~e&t,i=(e,n,t)=>e&n^e&t^n&t,r=e=>s(e,28)^s(e,34)^s(e,39),l=e=>s(e,14)^s(e,18)^s(e,41),d=e=>s(e,1)^s(e,8)^o(e,7),p=e=>s(e,19)^s(e,61)^o(e,6),m=Array.from((new TextEncoder).encode(e)),u=8n*BigInt(m.length);for(m.push(128);m.length%128!=112;)m.push(0);const f=u>>64n,h=u&n;for(let e=7;e>=0;e--)m.push(Number(f>>BigInt(8*e)&0xffn));for(let e=7;e>=0;e--)m.push(Number(h>>BigInt(8*e)&0xffn));for(let e=0;e<m.length;e+=128){const s=new Array(80).fill(0n);for(let n=0;n<16;n++){let t=0n;for(let a=0;a<8;a++)t=t<<8n|BigInt(m[e+8*n+a]);s[n]=t}for(let e=16;e<80;e++)s[e]=p(s[e-2])+s[e-7]+d(s[e-15])+s[e-16]&n;let[o,u,f,h,_,g,b,y]=t;for(let e=0;e<80;e++){const t=y+l(_)+c(_,g,b)+a[e]+s[e]&n,d=r(o)+i(o,u,f)&n;y=b,b=g,g=_,_=h+t&n,h=f,f=u,u=o,o=t+d&n}t[0]=t[0]+o&n,t[1]=t[1]+u&n,t[2]=t[2]+f&n,t[3]=t[3]+h&n,t[4]=t[4]+_&n,t[5]=t[5]+g&n,t[6]=t[6]+b&n,t[7]=t[7]+y&n}return t.map(e=>e.toString(16).padStart(16,"0")).join("").substring(0,50)}(y.billingAddress.email)),function(e,n,t,a,o,c){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let i=e.orderId;i||(i=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=t.log_order_fail_endpoint||null,g=!0===t.log_errors&&t.log_error_endpoint||null,b=parseInt(n.cartTotals.total_price);if(!i||!b)return i&&u(_,i,(0,s.__)("Payment amount missing","paysafe-checkout")),d(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:c.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=n.cartTotals.currency_code;const c={firstName:n.billingAddress.first_name,lastName:n.billingAddress.last_name,email:n.billingAddress.email},_={billing_street:n.billingAddress.address_1,billing_street2:n.billingAddress.address_2,billing_city:n.billingAddress.city,billing_zip:n.billingAddress.postcode,billing_state:n.billingAddress.state,billing_country:n.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:n.billingAddress.phone||""};o?function(e,n,t,a,o,c,i,r,l){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===n.hosted_payment_instance)return void u(_,t,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const b=n.hosted_payment_instance,y={transactionSource:void 0===n.transactionSource?"WooCommerceJs":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&n.use_single_use_customer_token&&(y.singleUseCustomerToken=a),a&&n.payment_toke_from&&(y.paymentTokenFrom=n.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(y.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),y.customerDetails={holderName:r.firstName+" "+r.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:r.firstName,lastName:r.lastName,email:r.email,locale:e.locale,phone:l.billing_phone}},n.customerDetails&&n.customerDetails.holderName&&n.customerDetails.holderName&&(y.customerDetails.holderName=n.customerDetails.holderName),l.billing_street&&(y.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(y.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(y.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(y.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(y.customerDetails.billingDetails.phone=l.billing_phone),b.tokenize(y).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),u(_,t,e),"Result failure"}const i={orderId:t,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:c,customerOperation:"",merchantRefNum:o,nonce:e.nonce};n.save_card&&(i.save_card=!0);const r=m(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(_,t,e.error_message),d(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let n=f(e);u(_,t,n);const a="ERROR "+e.code+": "+e.detailedMessage;d(g,a,[]),p(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let n=f(e);u(_,t,n);const a="ERROR "+e.code+": "+e.detailedMessage;d(g,a,[]),p(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(t,a,i,r,l,b,e,c,_):function(e,n,t,a,o,c,i,r,l){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,b={transactionSource:void 0===n.transactionSource?"WooCommerceCheckout":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:n.displayPaymentMethods,paymentMethodDetails:n.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(b.singleUseCustomerToken=a,n.customer&&(b.customer=n.customer)),a&&!n.settings.add_customer_when_single_use_token||(n.customer?b.customer=n.customer:b.customer=r),a&&!n.settings.add_billing_when_single_use_token||(b.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(b.billingAddress.street=l.billing_street),l.billing_street2&&(b.billingAddress.street2=l.billing_street2),l.billing_city&&(b.billingAddress.city=l.billing_city),l.billing_state&&(b.billingAddress.state=l.billing_state),l.billing_phone&&(b.billingAddress.phone=l.billing_phone)),n.settings.use_external_simulator&&e.test_mode&&(b.simulator="EXTERNAL"),n.shippingAddress&&(b.shippingAddress=n.shippingAddress);let y=null;paysafe.checkout.setup(e.authorization,b,function(n,a,o){if(o&&o.paymentHandleToken){const a={orderId:t,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:b.merchantRefNum,nonce:e.nonce},c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?n.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?n.showFailureScreen(e.error_message):n.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),y=e.redirect_url}).catch(e=>{let a=f(e);u(_,t,a),d(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),n.showFailureScreen(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=f(a);if(u(_,t,e),n)d(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),n.showFailureScreen(h(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),d(g,e,[]),p(h(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,n){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:n}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==y)return void(window.location=y);window.location.reload()}else{let a="";a=n?(0,s.__)("Payment session expired","paysafe-checkout"):e,u(_,t,a),d(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:n}),window.location.reload()}},function(e,n,a){if(n===c)e.accept();else{let n=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");u(_,t,n),d(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(t,a,i,r,l,b,e,c,_)}return e}(e,y,g,{displayPaymentMethods:["paysafecard"],paymentMethodDetails:{paysafecard:{accountId:g.account_id,consumerId:n}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]),function(e,t=""){let a=[(0,n().jsx)("div",{children:(0,r.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,n().jsx)("hr",{})),e.test_mode&&a.push((0,n().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,n().jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&a.push(t),a}(g)},w={name:_,paymentMethodId:_,label:function(e,t){const a=(0,r.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,n().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,n().jsx)("span",{children:a}),(0,n().jsx)("img",{className:"paysafe-gateway-image",src:t,alt:a})]})}(g.title,g.icon),content:(0,n().jsx)(x,{}),edit:(0,n().jsx)(x,{}),canMakePayment:e=>(y=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,o.registerPaymentMethod)(w)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafecash.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 46c26701ce6ec50ecd85');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '3869f8f93a6d666d41d0'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafecash.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,n,t){var a=t(609),s=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function r(e,n,t){var a,r={},l=null,d=null;for(a in void 0!==t&&(l=""+t),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)o.call(n,a)&&!i.hasOwnProperty(a)&&(r[a]=n[a]);if(e&&e.defaultProps)for(a in n=e.defaultProps)void 0===r[a]&&(r[a]=n[a]);return{$$typeof:s,type:e,key:l,ref:d,props:r,_owner:c.current}}n.jsx=r,n.jsxs=r},848(e,n,t){e.exports=t(20)},609(e){e.exports=window.React}};const n={},t=window.wp.i18n,a=window.wc.wcBlocksRegistry,s=window.wc.wcSettings,o=window.wp.element,c=window.wp.htmlEntities;var i=function t(a){const s=n[a];if(void 0!==s)return s.exports;const o=n[a]={exports:{}};return e[a](o,o.exports,t),o.exports}(848);let r="";function l(e,n,t){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:n,context:t,nonce:r})}).catch(()=>{})}}function d(e,n){n=!!n;let t=document.getElementsByClassName("woocommerce-error");if(t=t.length>0?t[0]:null,!t){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),n=e.length>0?e[0]:null;n&&(t=document.createElement("ul"),t.className="woocommerce-error",n.appendChild(t))}if(t){let a=document.createElement("li"),s=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||n?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=s,t.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=s}}function p(e){const n=new URL(e,window.location.href);if(n.origin===window.location.origin)return n.pathname+n.search+n.hash;d((0,t.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+n.toString(),!0)}function m(e,n,t){if(t&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:n,reason:t,nonce:r})}).catch(()=>{})}}function u(e){let n="";return e&&(e.code&&(n+=e.code+" "),e.message&&(n+=e.message+" "),e.detailedMessage&&(n=e.detailedMessage),e.displayMessage&&(n=e.displayMessage)),n}function f(e,n){if(void 0===e&&(e=null),void 0===n&&(n=""),null===e)return n;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,t.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,t.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,t.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,t.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,t.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return n}const h="paysafecash",_=(0,s.getSetting)(h+"_data",{});var g;g=_.nonce,r=g||"";let b={};const y=e=>{const{eventRegistration:n,emitResponse:a}=e,{onCheckoutSuccess:s}=n;return(0,o.useEffect)(()=>{const e=s(e=>{let n=_.consumer_id_encrypted;return n||(n=function(e){const n=(1n<<64n)-1n,t=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],a=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],s=(e,t)=>(e>>BigInt(t)|e<<BigInt(64-t))&n,o=(e,n)=>e>>BigInt(n),c=(e,n,t)=>e&n^~e&t,i=(e,n,t)=>e&n^e&t^n&t,r=e=>s(e,28)^s(e,34)^s(e,39),l=e=>s(e,14)^s(e,18)^s(e,41),d=e=>s(e,1)^s(e,8)^o(e,7),p=e=>s(e,19)^s(e,61)^o(e,6),m=Array.from((new TextEncoder).encode(e)),u=8n*BigInt(m.length);for(m.push(128);m.length%128!=112;)m.push(0);const f=u>>64n,h=u&n;for(let e=7;e>=0;e--)m.push(Number(f>>BigInt(8*e)&0xffn));for(let e=7;e>=0;e--)m.push(Number(h>>BigInt(8*e)&0xffn));for(let e=0;e<m.length;e+=128){const s=new Array(80).fill(0n);for(let n=0;n<16;n++){let t=0n;for(let a=0;a<8;a++)t=t<<8n|BigInt(m[e+8*n+a]);s[n]=t}for(let e=16;e<80;e++)s[e]=p(s[e-2])+s[e-7]+d(s[e-15])+s[e-16]&n;let[o,u,f,h,_,g,b,y]=t;for(let e=0;e<80;e++){const t=y+l(_)+c(_,g,b)+a[e]+s[e]&n,d=r(o)+i(o,u,f)&n;y=b,b=g,g=_,_=h+t&n,h=f,f=u,u=o,o=t+d&n}t[0]=t[0]+o&n,t[1]=t[1]+u&n,t[2]=t[2]+f&n,t[3]=t[3]+h&n,t[4]=t[4]+_&n,t[5]=t[5]+g&n,t[6]=t[6]+b&n,t[7]=t[7]+y&n}return t.map(e=>e.toString(16).padStart(16,"0")).join("").substring(0,50)}(b.billingAddress.email)),function(e,n,a,s,o,c){void 0===s&&(s={}),void 0===s.settings&&(s.settings={}),o=!!o;let i=e.orderId;i||(i=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=a.log_order_fail_endpoint||null,g=!0===a.log_errors&&a.log_error_endpoint||null,b=parseInt(n.cartTotals.total_price);if(!i||!b)return i&&m(_,i,(0,t.__)("Payment amount missing","paysafe-checkout")),l(g,(0,t.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:c.responseTypes.ERROR,message:(0,t.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=n.cartTotals.currency_code;const c={firstName:n.billingAddress.first_name,lastName:n.billingAddress.last_name,email:n.billingAddress.email},_={billing_street:n.billingAddress.address_1,billing_street2:n.billingAddress.address_2,billing_city:n.billingAddress.city,billing_zip:n.billingAddress.postcode,billing_state:n.billingAddress.state,billing_country:n.billingAddress.country,billing_phone:s&&s.additional&&s.additional.phone?s.additional.phone:n.billingAddress.phone||""};o?function(e,n,a,s,o,c,i,r,h){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===n.hosted_payment_instance)return void m(_,a,(0,t.__)("Hosted payment instance is not set","paysafe-checkout"));const b=n.hosted_payment_instance,y={transactionSource:void 0===n.transactionSource?"WooCommerceJs":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};s&&n.use_single_use_customer_token&&(y.singleUseCustomerToken=s),s&&n.payment_toke_from&&(y.paymentTokenFrom=n.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(y.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),y.customerDetails={holderName:r.firstName+" "+r.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:r.firstName,lastName:r.lastName,email:r.email,locale:e.locale,phone:h.billing_phone}},n.customerDetails&&n.customerDetails.holderName&&n.customerDetails.holderName&&(y.customerDetails.holderName=n.customerDetails.holderName),h.billing_street&&(y.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(y.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(y.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(y.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(y.customerDetails.billingDetails.phone=h.billing_phone),b.tokenize(y).then(s=>{if(!s||!s.token){let e="";throw s&&s.error&&(e+=s.error.message?s.error.message:s.error),s&&s.error_message&&(e+=s.error_message),m(_,a,e),"Result failure"}const i={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:s.token,amount:c,customerOperation:"",merchantRefNum:o,nonce:e.nonce};n.save_card&&(i.save_card=!0);const r=p(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(_,a,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let n=u(e);m(_,a,n);const s="ERROR "+e.code+": "+e.detailedMessage;l(g,s,[]),d(f(e.code,(0,t.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let n=u(e);m(_,a,n);const s="ERROR "+e.code+": "+e.detailedMessage;l(g,s,[]),d(f(e.code,(0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,s,i,r,h,b,e,c,_):function(e,n,a,s,o,c,i,r,h){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,b={transactionSource:void 0===n.transactionSource?"WooCommerceCheckout":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:n.displayPaymentMethods,paymentMethodDetails:n.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),s&&(b.singleUseCustomerToken=s,n.customer&&(b.customer=n.customer)),s&&!n.settings.add_customer_when_single_use_token||(n.customer?b.customer=n.customer:b.customer=r),s&&!n.settings.add_billing_when_single_use_token||(b.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(b.billingAddress.street=h.billing_street),h.billing_street2&&(b.billingAddress.street2=h.billing_street2),h.billing_city&&(b.billingAddress.city=h.billing_city),h.billing_state&&(b.billingAddress.state=h.billing_state),h.billing_phone&&(b.billingAddress.phone=h.billing_phone)),n.settings.use_external_simulator&&e.test_mode&&(b.simulator="EXTERNAL"),n.shippingAddress&&(b.shippingAddress=n.shippingAddress);let y=null;paysafe.checkout.setup(e.authorization,b,function(n,s,o){if(o&&o.paymentHandleToken){const s={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:b.merchantRefNum,nonce:e.nonce},c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(s)}).then(e=>e.json()).then(e=>{"success"===e.status?n.showSuccessScreen((0,t.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,t.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?n.showFailureScreen(e.error_message):n.showFailureScreen((0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),y=e.redirect_url}).catch(e=>{let s=u(e);m(_,a,s),l(g,(0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),n.showFailureScreen(f(e.code,(0,t.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(s);if(m(_,a,e),n)l(g,(0,t.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),n.showFailureScreen(f(s.code,(0,t.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,t.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");s&&s.code&&s.detailedMessage&&(e+="<br /> "+s.code+" "+s.detailedMessage),l(g,e,[]),d(f(s.code,(0,t.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,n){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,t.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:n}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==y)return void(window.location=y);window.location.reload()}else{let s="";s=n?(0,t.__)("Payment session expired","paysafe-checkout"):e,m(_,a,s),l(g,(0,t.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:n}),window.location.reload()}},function(e,n,s){if(n===c)e.accept();else{let n=(0,t.__)("Payment amount risk assessment failed","paysafe-checkout");m(_,a,n),l(g,(0,t.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,t.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,s,i,r,h,b,e,c,_)}return e}(e,b,_,{displayPaymentMethods:["paysafecash"],paymentMethodDetails:{paysafecash:{accountId:_.account_id,consumerId:n}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],s]),function(e,n=""){let a=[(0,i.jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,i.jsx)("hr",{})),e.test_mode&&a.push((0,i.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,i.jsx)("span",{children:(0,t.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),n&&a.push(n),a}(_)},x={name:h,paymentMethodId:h,label:function(e,n){const a=(0,c.decodeEntities)(e)||(0,t.__)("Paysafe Checkout","paysafe-checkout");return(0,i.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,i.jsx)("span",{children:a}),(0,i.jsx)("img",{className:"paysafe-gateway-image",src:n,alt:a})]})}(_.title,_.icon),content:(0,i.jsx)(y,{}),edit:(0,i.jsx)(y,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,t.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:_.supports}};(0,a.registerPaymentMethod)(x)})();1 (()=>{"use strict";const e=e=>{var n;return()=>{if(e){var t=e;e=0,n={exports:{}},t.call(n.exports,n,n.exports)}return n.exports}};var n=e((e,n)=>{var t=a(),s=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function r(e,n,t){var a,r={},l=null,d=null;for(a in void 0!==t&&(l=""+t),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)o.call(n,a)&&!i.hasOwnProperty(a)&&(r[a]=n[a]);if(e&&e.defaultProps)for(a in n=e.defaultProps)void 0===r[a]&&(r[a]=n[a]);return{$$typeof:s,type:e,key:l,ref:d,props:r,_owner:c.current}}n.jsx=r,n.jsxs=r}),t=e(e=>{e.exports=n()}),a=e(e=>{e.exports=window.React});const s=window.wp.i18n,o=window.wc.wcBlocksRegistry,c=window.wc.wcSettings,i=window.wp.element,r=window.wp.htmlEntities;t();let l="";function d(e,n,t){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:n,context:t,nonce:l})}).catch(()=>{})}}function p(e,n){n=!!n;let t=document.getElementsByClassName("woocommerce-error");if(t=t.length>0?t[0]:null,!t){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),n=e.length>0?e[0]:null;n&&(t=document.createElement("ul"),t.className="woocommerce-error",n.appendChild(t))}if(t){let a=document.createElement("li"),s=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||n?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=s,t.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=s}}function m(e){const n=new URL(e,window.location.href);if(n.origin===window.location.origin)return n.pathname+n.search+n.hash;p((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+n.toString(),!0)}function u(e,n,t){if(t&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:n,reason:t,nonce:l})}).catch(()=>{})}}function f(e){let n="";return e&&(e.code&&(n+=e.code+" "),e.message&&(n+=e.message+" "),e.detailedMessage&&(n=e.detailedMessage),e.displayMessage&&(n=e.displayMessage)),n}function h(e,n){if(void 0===e&&(e=null),void 0===n&&(n=""),null===e)return n;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return n}const _="paysafecash",g=(0,c.getSetting)(_+"_data",{});var b;b=g.nonce,l=b||"";let y={};const x=e=>{const{eventRegistration:t,emitResponse:a}=e,{onCheckoutSuccess:o}=t;return(0,i.useEffect)(()=>{const e=o(e=>{let n=g.consumer_id_encrypted;return n||(n=function(e){const n=(1n<<64n)-1n,t=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],a=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],s=(e,t)=>(e>>BigInt(t)|e<<BigInt(64-t))&n,o=(e,n)=>e>>BigInt(n),c=(e,n,t)=>e&n^~e&t,i=(e,n,t)=>e&n^e&t^n&t,r=e=>s(e,28)^s(e,34)^s(e,39),l=e=>s(e,14)^s(e,18)^s(e,41),d=e=>s(e,1)^s(e,8)^o(e,7),p=e=>s(e,19)^s(e,61)^o(e,6),m=Array.from((new TextEncoder).encode(e)),u=8n*BigInt(m.length);for(m.push(128);m.length%128!=112;)m.push(0);const f=u>>64n,h=u&n;for(let e=7;e>=0;e--)m.push(Number(f>>BigInt(8*e)&0xffn));for(let e=7;e>=0;e--)m.push(Number(h>>BigInt(8*e)&0xffn));for(let e=0;e<m.length;e+=128){const s=new Array(80).fill(0n);for(let n=0;n<16;n++){let t=0n;for(let a=0;a<8;a++)t=t<<8n|BigInt(m[e+8*n+a]);s[n]=t}for(let e=16;e<80;e++)s[e]=p(s[e-2])+s[e-7]+d(s[e-15])+s[e-16]&n;let[o,u,f,h,_,g,b,y]=t;for(let e=0;e<80;e++){const t=y+l(_)+c(_,g,b)+a[e]+s[e]&n,d=r(o)+i(o,u,f)&n;y=b,b=g,g=_,_=h+t&n,h=f,f=u,u=o,o=t+d&n}t[0]=t[0]+o&n,t[1]=t[1]+u&n,t[2]=t[2]+f&n,t[3]=t[3]+h&n,t[4]=t[4]+_&n,t[5]=t[5]+g&n,t[6]=t[6]+b&n,t[7]=t[7]+y&n}return t.map(e=>e.toString(16).padStart(16,"0")).join("").substring(0,50)}(y.billingAddress.email)),function(e,n,t,a,o,c){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let i=e.orderId;i||(i=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",_=t.log_order_fail_endpoint||null,g=!0===t.log_errors&&t.log_error_endpoint||null,b=parseInt(n.cartTotals.total_price);if(!i||!b)return i&&u(_,i,(0,s.__)("Payment amount missing","paysafe-checkout")),d(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:c.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=n.cartTotals.currency_code;const c={firstName:n.billingAddress.first_name,lastName:n.billingAddress.last_name,email:n.billingAddress.email},_={billing_street:n.billingAddress.address_1,billing_street2:n.billingAddress.address_2,billing_city:n.billingAddress.city,billing_zip:n.billingAddress.postcode,billing_state:n.billingAddress.state,billing_country:n.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:n.billingAddress.phone||""};o?function(e,n,t,a,o,c,i,r,l){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===n.hosted_payment_instance)return void u(_,t,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const b=n.hosted_payment_instance,y={transactionSource:void 0===n.transactionSource?"WooCommerceJs":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&n.use_single_use_customer_token&&(y.singleUseCustomerToken=a),a&&n.payment_toke_from&&(y.paymentTokenFrom=n.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(y.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),y.customerDetails={holderName:r.firstName+" "+r.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:r.firstName,lastName:r.lastName,email:r.email,locale:e.locale,phone:l.billing_phone}},n.customerDetails&&n.customerDetails.holderName&&n.customerDetails.holderName&&(y.customerDetails.holderName=n.customerDetails.holderName),l.billing_street&&(y.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(y.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(y.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(y.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(y.customerDetails.billingDetails.phone=l.billing_phone),b.tokenize(y).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),u(_,t,e),"Result failure"}const i={orderId:t,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:c,customerOperation:"",merchantRefNum:o,nonce:e.nonce};n.save_card&&(i.save_card=!0);const r=m(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(_,t,e.error_message),d(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let n=f(e);u(_,t,n);const a="ERROR "+e.code+": "+e.detailedMessage;d(g,a,[]),p(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let n=f(e);u(_,t,n);const a="ERROR "+e.code+": "+e.detailedMessage;d(g,a,[]),p(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(t,a,i,r,l,b,e,c,_):function(e,n,t,a,o,c,i,r,l){const _=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,b={transactionSource:void 0===n.transactionSource?"WooCommerceCheckout":n.transactionSource,amount:c,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:n.displayPaymentMethods,paymentMethodDetails:n.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(b.singleUseCustomerToken=a,n.customer&&(b.customer=n.customer)),a&&!n.settings.add_customer_when_single_use_token||(n.customer?b.customer=n.customer:b.customer=r),a&&!n.settings.add_billing_when_single_use_token||(b.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(b.billingAddress.street=l.billing_street),l.billing_street2&&(b.billingAddress.street2=l.billing_street2),l.billing_city&&(b.billingAddress.city=l.billing_city),l.billing_state&&(b.billingAddress.state=l.billing_state),l.billing_phone&&(b.billingAddress.phone=l.billing_phone)),n.settings.use_external_simulator&&e.test_mode&&(b.simulator="EXTERNAL"),n.shippingAddress&&(b.shippingAddress=n.shippingAddress);let y=null;paysafe.checkout.setup(e.authorization,b,function(n,a,o){if(o&&o.paymentHandleToken){const a={orderId:t,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:b.merchantRefNum,nonce:e.nonce},c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?n.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?n.showFailureScreen(e.error_message):n.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),y=e.redirect_url}).catch(e=>{let a=f(e);u(_,t,a),d(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),n.showFailureScreen(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=f(a);if(u(_,t,e),n)d(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),n.showFailureScreen(h(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),d(g,e,[]),p(h(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,n){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:n}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==y)return void(window.location=y);window.location.reload()}else{let a="";a=n?(0,s.__)("Payment session expired","paysafe-checkout"):e,u(_,t,a),d(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:n}),window.location.reload()}},function(e,n,a){if(n===c)e.accept();else{let n=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");u(_,t,n),d(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(t,a,i,r,l,b,e,c,_)}return e}(e,y,g,{displayPaymentMethods:["paysafecash"],paymentMethodDetails:{paysafecash:{accountId:g.account_id,consumerId:n}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],o]),function(e,t=""){let a=[(0,n().jsx)("div",{children:(0,r.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,n().jsx)("hr",{})),e.test_mode&&a.push((0,n().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,n().jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&a.push(t),a}(g)},w={name:_,paymentMethodId:_,label:function(e,t){const a=(0,r.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,n().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,n().jsx)("span",{children:a}),(0,n().jsx)("img",{className:"paysafe-gateway-image",src:t,alt:a})]})}(g.title,g.icon),content:(0,n().jsx)(x,{}),edit:(0,n().jsx)(x,{}),canMakePayment:e=>(y=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,o.registerPaymentMethod)(w)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafepaypal.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' b9e22e811d5911b66135');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '1d4b51c8d7c0c1f5a02f'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-paysafepaypal.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var a=s(609),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,p=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:p,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,a=window.wc.wcBlocksRegistry,n=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(a){const n=t[a];if(void 0!==n)return n.exports;const o=t[a]={exports:{}};return e[a](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function d(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="paysafepaypal",y=(0,n.getSetting)(h+"_data",{});var g;g=y.nonce,c=g||"";const f=!0===y.log_errors&&y.log_error_endpoint||null;let w={},b=!1;const T=e=>{const{eventRegistration:t,emitResponse:a}=e,{onPaymentSetup:n,onCheckoutSuccess:c}=t;return b||(b=!0,setTimeout(()=>{let e=document.getElementById("paysafepaypal_consumeridInput");e&&(e.value=y.consumer_id)},100)),(0,o.useEffect)(()=>{const e=n(async()=>{let e=document.getElementById("paysafepaypal_consumeridInput");return e&&e.value&&e.value.length?{type:a.responseTypes.SUCCESS}:(l(f,(0,s.__)("The payment process failed. You have to specify your PayPal email address!","paysafe-checkout"),{}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. You have to specify your PayPal email address!","paysafe-checkout")})});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,n]),(0,o.useEffect)(()=>{const e=c(e=>{let t=document.getElementById("paysafepaypal_consumeridInput"),n=t&&t.value&&t.value.length?t.value:"";return function(e,t,a,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=a.log_order_fail_endpoint||null,g=!0===a.log_errors&&a.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(y,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,a,n,o,i,r,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(y,a,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=n),n&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(w.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(w.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(w.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(w.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(w.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(w).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),m(y,a,e),"Result failure"}const r={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=d(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(y,a,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(y,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(g,n,[]),p(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(y,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(g,n,[]),p(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,n,r,c,h,f,e,i,y):function(e,t,a,n,o,i,r,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=d(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let n=u(e);m(y,a,n),l(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(n);if(m(y,a,e),t)l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),l(g,e,[]),p(_(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let n="";n=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(y,a,n),l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(y,a,t),l(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,n,r,c,h,f,e,i,y)}return e}(e,w,y,{displayPaymentMethods:["paypal"],paymentMethodDetails:{paypal:{accountId:y.account_id,consumerId:n}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],c]),function(e,t=""){let a=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,r.jsx)("hr",{})),e.test_mode&&a.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&a.push(t),a}(y,(0,r.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,r.jsx)("label",{id:"paysafepaypal_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paysafepaypal_consumeridInput",children:(0,s.__)("PayPal email address","paysafe-checkout")}),(0,r.jsx)("div",{id:"paysafepaypal_consumerid",className:"paysafe-input-field",children:(0,r.jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paysafepaypal_consumerid_input",id:"paysafepaypal_consumeridInput",placeholder:(0,s.__)("Your PayPal email address","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,r.jsx)("p",{id:"paysafepaypal_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter the email from your PayPal account","paysafe-checkout")})]}))},k={name:h,paymentMethodId:h,label:function(e,t){const a=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:a}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:a})]})}(y.title,y.icon),content:(0,r.jsx)(T,{}),edit:(0,r.jsx)(T,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,a.registerPaymentMethod)(k)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=a(),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,p=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:p,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),a=e(e=>{e.exports=window.React});const n=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function p(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,n.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,n.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,n.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,n.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,n.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,n.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const y="paysafepaypal",g=(0,i.getSetting)(y+"_data",{});var f;f=g.nonce,l=f||"";const w=!0===g.log_errors&&g.log_error_endpoint||null;let b={},T=!1;const k=e=>{const{eventRegistration:s,emitResponse:a}=e,{onPaymentSetup:o,onCheckoutSuccess:i}=s;return T||(T=!0,setTimeout(()=>{let e=document.getElementById("paysafepaypal_consumeridInput");e&&(e.value=g.consumer_id)},100)),(0,r.useEffect)(()=>{const e=o(async()=>{let e=document.getElementById("paysafepaypal_consumeridInput");return e&&e.value&&e.value.length?{type:a.responseTypes.SUCCESS}:(p(w,(0,n.__)("The payment process failed. You have to specify your PayPal email address!","paysafe-checkout"),{}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. You have to specify your PayPal email address!","paysafe-checkout")})});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,o]),(0,r.useEffect)(()=>{const e=i(e=>{let t=document.getElementById("paysafepaypal_consumeridInput"),s=t&&t.value&&t.value.length?t.value:"";return function(e,t,s,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=s.log_order_fail_endpoint||null,g=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(y,r,(0,n.__)("Payment amount missing","paysafe-checkout")),p(g,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,a,o,i,r,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(y,s,(0,n.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),u(y,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(y,s,e.error_message),p(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);u(y,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;p(g,a,[]),d(h(e.code,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);u(y,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;p(g,a,[]),d(h(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,a,r,c,l,f,e,i,y):function(e,t,s,a,o,i,r,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,n.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(p(g,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=_(e);u(y,s,a),p(g,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(a);if(u(y,s,e),t)p(g,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),p(g,e,[]),d(h(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":p(g,(0,n.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,n.__)("Payment session expired","paysafe-checkout"):e,u(y,s,a),p(g,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,n.__)("Payment amount risk assessment failed","paysafe-checkout");u(y,s,t),p(g,(0,n.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,n.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,a,r,c,l,f,e,i,y)}return e}(e,b,g,{displayPaymentMethods:["paypal"],paymentMethodDetails:{paypal:{accountId:g.account_id,consumerId:s}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],i]),function(e,s=""){let a=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,t().jsx)("hr",{})),e.test_mode&&a.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&a.push(s),a}(g,(0,t().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,t().jsx)("label",{id:"paysafepaypal_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paysafepaypal_consumeridInput",children:(0,n.__)("PayPal email address","paysafe-checkout")}),(0,t().jsx)("div",{id:"paysafepaypal_consumerid",className:"paysafe-input-field",children:(0,t().jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paysafepaypal_consumerid_input",id:"paysafepaypal_consumeridInput",placeholder:(0,n.__)("Your PayPal email address","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,t().jsx)("p",{id:"paysafepaypal_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,n.__)("Enter the email from your PayPal account","paysafe-checkout")})]}))},P={name:y,paymentMethodId:y,label:function(e,s){const a=(0,c.decodeEntities)(e)||(0,n.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:a}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:a})]})}(g.title,g.icon),content:(0,t().jsx)(k,{}),edit:(0,t().jsx)(k,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,n.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,o.registerPaymentMethod)(P)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-sightline.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' d41e4811e7afa764442c');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'e6179a9ef339c841b38c'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-sightline.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)i.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:o.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,i=window.wp.element,o=window.wp.htmlEntities;var r=function s(n){const a=t[n];if(void 0!==a)return a.exports;const i=t[n]={exports:{}};return e[n](i,i.exports,s),i.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const _="sightline",g=(0,a.getSetting)(_+"_data",{});var y;y=g.nonce,c=y||"";const f=!0===g.log_errors&&g.log_error_endpoint||null;let b={};const w=e=>{const{eventRegistration:t,emitResponse:n}=e,{onPaymentSetup:a,onCheckoutSuccess:c}=t;return(0,i.useEffect)(()=>{const e=a(async()=>{let e=document.getElementById("sightline_consumeridInput");return e&&e.value&&e.value.length&&e.value.length>=2&&e.value.length<=50?{type:n.responseTypes.SUCCESS}:(l(f,(0,s.__)("The payment process failed. Play+ (Sightline) consumer id must have between 2 and 50 characters!","paysafe-checkout"),{}),{type:n.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Play+ (Sightline) consumer id must have between 2 and 50 characters!","paysafe-checkout")})});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,a]),(0,i.useEffect)(()=>{const e=c(e=>{let t=document.getElementById("sightline_consumeridInput"),a=t&&t.value&&t.value.length&&t.value.length>=2&&t.value.length<=50?t.value:"";return function(e,t,n,a,i,o){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),i=!!i;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",_=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=n.log_order_fail_endpoint||null,y=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(g,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(y,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:o.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const o={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};i?function(e,t,n,a,i,o,r,c,_){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(g,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,b={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:o,transactionType:"PAYMENT",currency:r,merchantRefNum:i,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(b.singleUseCustomerToken=a),a&&t.payment_toke_from&&(b.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),b.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:_.billing_zip,country:_.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:_.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(b.customerDetails.holderName=t.customerDetails.holderName),_.billing_street&&(b.customerDetails.billingDetails.street=_.billing_street),_.billing_street2&&(b.customerDetails.billingDetails.street2=_.billing_street2),_.billing_city&&(b.customerDetails.billingDetails.city=_.billing_city),_.billing_state&&(b.customerDetails.billingDetails.state=_.billing_state),_.billing_phone&&(b.customerDetails.billingDetails.phone=_.billing_phone),f.tokenize(b).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),m(g,n,e),"Result failure"}const r={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:o,customerOperation:"",merchantRefNum:i,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(g,n,e.error_message),l(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(g,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(y,a,[]),d(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,r,c,_,f,e,o,g):function(e,t,n,a,i,o,r,c,_){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:o,transactionType:"PAYMENT",currency:r,merchantRefNum:i,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:_.billing_zip,country:_.billing_country},_.billing_street&&(f.billingAddress.street=_.billing_street),_.billing_street2&&(f.billingAddress.street2=_.billing_street2),_.billing_city&&(f.billingAddress.city=_.billing_city),_.billing_state&&(f.billingAddress.state=_.billing_state),_.billing_phone&&(f.billingAddress.phone=_.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let b=null;paysafe.checkout.setup(e.authorization,f,function(t,a,i){if(i&&i.paymentHandleToken){const a={orderId:n,paymentMethod:i.paymentMethod,transactionType:i.transactionType,paymentHandleToken:i.paymentHandleToken,amount:i.amount,customerOperation:i.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},o=p(e.register_url);fetch(o,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),b=e.redirect_url}).catch(e=>{let a=u(e);m(g,n,a),l(y,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(a);if(m(g,n,e),t)l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(y,e,[]),d(h(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(y,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==b)return void(window.location=b);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(g,n,a),l(y,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===o)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(g,n,t),l(y,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,r,c,_,f,e,o,g)}return e}(e,b,g,{displayPaymentMethods:["sightline"],paymentMethodDetails:{sightline:{accountId:g.account_id,consumerId:""+a}},shippingAddress:{city:b.billingAddress.city,country:b.billingAddress.country,recipientName:b.billingAddress.first_name+" "+b.billingAddress.last_name,state:b.billingAddress.state,street:b.billingAddress.address_1,street2:b.billingAddress.address_2,zip:b.billingAddress.postcode}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],c]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,o.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,r.jsx)("hr",{})),e.test_mode&&n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(g,(0,r.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,r.jsx)("label",{id:"sightline_consumerid_label",className:"paysafe-general-form-label",htmlFor:"sightline_consumeridInput",children:(0,s.__)("Play+ (Sightline) Loyalty Membership Number","paysafe-checkout")}),(0,r.jsx)("div",{id:"sightline_consumerid",className:"paysafe-input-field",children:(0,r.jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"sightline_consumerid_input",id:"sightline_consumeridInput",placeholder:(0,s.__)("Your Play+ (Sightline) Loyalty Membership Number","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,r.jsx)("p",{id:"sightline_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter the Loyalty Membership Number from your Play+ (Sightline) account","paysafe-checkout")})]}))},T={name:_,paymentMethodId:_,label:function(e,t){const n=(0,o.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:n}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(g.title,g.icon),content:(0,r.jsx)(w,{}),edit:(0,r.jsx)(w,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,n.registerPaymentMethod)(T)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=n(),a=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),o=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,d=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)i.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:d,props:c,_owner:o.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),n=e(e=>{e.exports=window.React});const a=window.wp.i18n,i=window.wc.wcBlocksRegistry,o=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function h(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const g="sightline",y=(0,o.getSetting)(g+"_data",{});var f;f=y.nonce,l=f||"";const b=!0===y.log_errors&&y.log_error_endpoint||null;let w={};const T=e=>{const{eventRegistration:s,emitResponse:n}=e,{onPaymentSetup:i,onCheckoutSuccess:o}=s;return(0,r.useEffect)(()=>{const e=i(async()=>{let e=document.getElementById("sightline_consumeridInput");return e&&e.value&&e.value.length&&e.value.length>=2&&e.value.length<=50?{type:n.responseTypes.SUCCESS}:(d(b,(0,a.__)("The payment process failed. Play+ (Sightline) consumer id must have between 2 and 50 characters!","paysafe-checkout"),{}),{type:n.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Play+ (Sightline) consumer id must have between 2 and 50 characters!","paysafe-checkout")})});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,i]),(0,r.useEffect)(()=>{const e=o(e=>{let t=document.getElementById("sightline_consumeridInput"),s=t&&t.value&&t.value.length&&t.value.length>=2&&t.value.length<=50?t.value:"";return function(e,t,s,n,i,o){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),i=!!i;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",g=s.log_order_fail_endpoint||null,y=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(g,r,(0,a.__)("Payment amount missing","paysafe-checkout")),d(y,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:o.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const o={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},g={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};i?function(e,t,s,n,i,o,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(g,s,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,b={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:o,transactionType:"PAYMENT",currency:r,merchantRefNum:i,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(b.singleUseCustomerToken=n),n&&t.payment_toke_from&&(b.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),b.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(b.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(b.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(b.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(b.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(b.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(b.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(b).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),u(g,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:o,customerOperation:"",merchantRefNum:i,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(g,s,e.error_message),d(y,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=h(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(_(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=h(e);u(g,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;d(y,n,[]),p(_(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,n,r,c,l,f,e,o,g):function(e,t,s,n,i,o,r,c,l){const g=e.log_order_fail_endpoint||null,y=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:o,transactionType:"PAYMENT",currency:r,merchantRefNum:i,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let b=null;paysafe.checkout.setup(e.authorization,f,function(t,n,i){if(i&&i.paymentHandleToken){const n={orderId:s,paymentMethod:i.paymentMethod,transactionType:i.transactionType,paymentHandleToken:i.paymentHandleToken,amount:i.amount,customerOperation:i.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},o=m(e.register_url);fetch(o,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),b=e.redirect_url}).catch(e=>{let n=h(e);u(g,s,n),d(y,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=h(n);if(u(g,s,e),t)d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),d(y,e,[]),p(_(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(y,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==b)return void(window.location=b);window.location.reload()}else{let n="";n=t?(0,a.__)("Payment session expired","paysafe-checkout"):e,u(g,s,n),d(y,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===o)e.accept();else{let t=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");u(g,s,t),d(y,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,n,r,c,l,f,e,o,g)}return e}(e,w,y,{displayPaymentMethods:["sightline"],paymentMethodDetails:{sightline:{accountId:y.account_id,consumerId:""+s}},shippingAddress:{city:w.billingAddress.city,country:w.billingAddress.country,recipientName:w.billingAddress.first_name+" "+w.billingAddress.last_name,state:w.billingAddress.state,street:w.billingAddress.address_1,street2:w.billingAddress.address_2,zip:w.billingAddress.postcode}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],o]),function(e,s=""){let n=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,t().jsx)("hr",{})),e.test_mode&&n.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&n.push(s),n}(y,(0,t().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,t().jsx)("label",{id:"sightline_consumerid_label",className:"paysafe-general-form-label",htmlFor:"sightline_consumeridInput",children:(0,a.__)("Play+ (Sightline) Loyalty Membership Number","paysafe-checkout")}),(0,t().jsx)("div",{id:"sightline_consumerid",className:"paysafe-input-field",children:(0,t().jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"sightline_consumerid_input",id:"sightline_consumeridInput",placeholder:(0,a.__)("Your Play+ (Sightline) Loyalty Membership Number","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,t().jsx)("p",{id:"sightline_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,a.__)("Enter the Loyalty Membership Number from your Play+ (Sightline) account","paysafe-checkout")})]}))},k={name:g,paymentMethodId:g,label:function(e,s){const n=(0,c.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:n}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:n})]})}(y.title,y.icon),content:(0,t().jsx)(T,{}),edit:(0,t().jsx)(T,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,i.registerPaymentMethod)(k)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-skrill.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' d7dc2a9b26211e0039b8');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'f73afedd86c0006648ab'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-skrill.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var a=s(609),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,a=window.wc.wcBlocksRegistry,n=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(a){const n=t[a];if(void 0!==n)return n.exports;const o=t[a]={exports:{}};return e[a](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function p(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="skrill",y=(0,n.getSetting)(h+"_data",{});var g;g=y.nonce,c=g||"";const f=!0===y.log_errors&&y.log_error_endpoint||null;let k={},w=!1;const b=e=>{const{eventRegistration:t,emitResponse:a}=e,{onPaymentSetup:n,onCheckoutSuccess:c}=t;return w||(w=!0,setTimeout(()=>{let e=document.getElementById("paysafeskrill_consumeridInput");e&&(e.value=y.consumer_id)},100)),(0,o.useEffect)(()=>{const e=n(async()=>{let e=document.getElementById("paysafeskrill_consumeridInput");return e&&e.value&&e.value.length?{type:a.responseTypes.SUCCESS}:(l(f,(0,s.__)("The payment process failed. You have to specify your Skrill email address!","paysafe-checkout"),{}),{type:a.responseTypes.ERROR,message:(0,s.__)("The payment process failed. You have to specify your Skrill email address!","paysafe-checkout")})});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,n]),(0,o.useEffect)(()=>{const e=c(e=>{let t=document.getElementById("paysafeskrill_consumeridInput"),n=t&&t.value&&t.value.length?t.value:"";return function(e,t,a,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=a.log_order_fail_endpoint||null,g=!0===a.log_errors&&a.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(y,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,a,n,o,i,r,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(y,a,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,k={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(k.singleUseCustomerToken=n),n&&t.payment_toke_from&&(k.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(k.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),k.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(k.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(k.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(k.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(k.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(k.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(k.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(k).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),m(y,a,e),"Result failure"}const r={orderId:a,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=p(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(y,a,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(y,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(g,n,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(y,a,t);const n="ERROR "+e.code+": "+e.detailedMessage;l(g,n,[]),d(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(a,n,r,c,h,f,e,i,y):function(e,t,a,n,o,i,r,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let k=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:a,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=p(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),k=e.redirect_url}).catch(e=>{let n=u(e);m(y,a,n),l(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(n);if(m(y,a,e),t)l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),l(g,e,[]),d(_(n.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==k)return void(window.location=k);window.location.reload()}else{let n="";n=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(y,a,n),l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(y,a,t),l(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(a,n,r,c,h,f,e,i,y)}return e}(e,k,y,{displayPaymentMethods:["skrill"],paymentMethodDetails:{skrill:{accountId:y.account_id,consumerId:n,emailSubject:y.details.subject,emailMessage:y.details.message}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],c]),function(e,t=""){let a=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,r.jsx)("hr",{})),e.test_mode&&a.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&a.push(t),a}(y,(0,r.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,r.jsx)("label",{id:"paysafeskrill_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paysafeskrill_consumeridInput",children:(0,s.__)("Skrill email address","paysafe-checkout")}),(0,r.jsx)("div",{id:"paysafeskrill_consumerid",className:"paysafe-input-field",children:(0,r.jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paysafeskrill_consumerid_input",id:"paysafeskrill_consumeridInput",placeholder:(0,s.__)("Your Skrill email address","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,r.jsx)("p",{id:"paysafeskrill_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter the email from your Skrill account","paysafe-checkout")})]}))},T={name:h,paymentMethodId:h,label:function(e,t){const a=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:a}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:a})]})}(y.title,y.icon),content:(0,r.jsx)(b,{}),edit:(0,r.jsx)(b,{}),canMakePayment:e=>(k=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,a.registerPaymentMethod)(T)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=a(),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var a,c={},l=null,d=null;for(a in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(c[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===c[a]&&(c[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),a=e(e=>{e.exports=window.React});const n=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function d(e,t,s){if(e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let a=document.createElement("li"),n=(e||"").replace(/<br\s*\/?>/gi,"\n");!a||t?(a.setAttribute("id","paysafe-fatal-error-message"),a.textContent=n,s.appendChild(a),window.scrollTo({top:0,left:0,behavior:"smooth"})):a.textContent=n}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,n.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const a=new URL(e,window.location.origin);if(a.origin!==window.location.origin)return;fetch(a.pathname+a.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,n.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,n.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,n.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,n.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,n.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const y="skrill",g=(0,i.getSetting)(y+"_data",{});var f;f=g.nonce,l=f||"";const k=!0===g.log_errors&&g.log_error_endpoint||null;let w={},b=!1;const T=e=>{const{eventRegistration:s,emitResponse:a}=e,{onPaymentSetup:o,onCheckoutSuccess:i}=s;return b||(b=!0,setTimeout(()=>{let e=document.getElementById("paysafeskrill_consumeridInput");e&&(e.value=g.consumer_id)},100)),(0,r.useEffect)(()=>{const e=o(async()=>{let e=document.getElementById("paysafeskrill_consumeridInput");return e&&e.value&&e.value.length?{type:a.responseTypes.SUCCESS}:(d(k,(0,n.__)("The payment process failed. You have to specify your Skrill email address!","paysafe-checkout"),{}),{type:a.responseTypes.ERROR,message:(0,n.__)("The payment process failed. You have to specify your Skrill email address!","paysafe-checkout")})});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,o]),(0,r.useEffect)(()=>{const e=i(e=>{let t=document.getElementById("paysafeskrill_consumeridInput"),s=t&&t.value&&t.value.length?t.value:"";return function(e,t,s,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=s.log_order_fail_endpoint||null,g=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(y,r,(0,n.__)("Payment amount missing","paysafe-checkout")),d(g,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,a,o,i,r,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(y,s,(0,n.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,k={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(k.singleUseCustomerToken=a),a&&t.payment_toke_from&&(k.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(k.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),k.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(k.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(k.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(k.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(k.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(k.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(k.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(k).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),u(y,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(y,s,e.error_message),d(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);u(y,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(g,a,[]),p(h(e.code,(0,n.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);u(y,s,t);const a="ERROR "+e.code+": "+e.detailedMessage;d(g,a,[]),p(h(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,a,r,c,l,f,e,i,y):function(e,t,s,a,o,i,r,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let k=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,n.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(d(g,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),k=e.redirect_url}).catch(e=>{let a=_(e);u(y,s,a),d(g,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,n.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(a);if(u(y,s,e),t)d(g,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),d(g,e,[]),p(h(a.code,(0,n.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":d(g,(0,n.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==k)return void(window.location=k);window.location.reload()}else{let a="";a=t?(0,n.__)("Payment session expired","paysafe-checkout"):e,u(y,s,a),d(g,(0,n.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,n.__)("Payment amount risk assessment failed","paysafe-checkout");u(y,s,t),d(g,(0,n.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,n.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,a,r,c,l,f,e,i,y)}return e}(e,w,g,{displayPaymentMethods:["skrill"],paymentMethodDetails:{skrill:{accountId:g.account_id,consumerId:s,emailSubject:g.details.subject,emailMessage:g.details.message}}},!1,a)});return()=>{e()}},[a.responseTypes.ERROR,a.responseTypes.SUCCESS,"",[],i]),function(e,s=""){let a=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&a.push((0,t().jsx)("hr",{})),e.test_mode&&a.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,n.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&a.push(s),a}(g,(0,t().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,t().jsx)("label",{id:"paysafeskrill_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paysafeskrill_consumeridInput",children:(0,n.__)("Skrill email address","paysafe-checkout")}),(0,t().jsx)("div",{id:"paysafeskrill_consumerid",className:"paysafe-input-field",children:(0,t().jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paysafeskrill_consumerid_input",id:"paysafeskrill_consumeridInput",placeholder:(0,n.__)("Your Skrill email address","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,t().jsx)("p",{id:"paysafeskrill_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,n.__)("Enter the email from your Skrill account","paysafe-checkout")})]}))},R={name:y,paymentMethodId:y,label:function(e,s){const a=(0,c.decodeEntities)(e)||(0,n.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:a}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:a})]})}(g.title,g.icon),content:(0,t().jsx)(T,{}),edit:(0,t().jsx)(T,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,n.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,o.registerPaymentMethod)(R)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-venmo.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 1bf70622944bdd7b9509');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '3cd5b7574f1f81484df1'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-venmo.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,p=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:p,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,o=window.wp.element,i=window.wp.htmlEntities;var r=function s(n){const a=t[n];if(void 0!==a)return a.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function d(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function u(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="venmo",y=(0,a.getSetting)(h+"_data",{});var g;g=y.nonce,c=g||"";const f=!0===y.log_errors&&y.log_error_endpoint||null;let w={},b=!1;const T=e=>{const{eventRegistration:t,emitResponse:n}=e,{onPaymentSetup:a,onCheckoutSuccess:c}=t;return b||(b=!0,setTimeout(()=>{let e=document.getElementById("paysafevenmo_consumeridInput");e&&(e.value=y.consumer_id)},100)),(0,o.useEffect)(()=>{const e=a(async()=>{let e=document.getElementById("paysafevenmo_consumeridInput");return e&&e.value&&e.value.length?{type:n.responseTypes.SUCCESS}:(l(f,(0,s.__)("The payment process failed. You have to specify your Venmo email address!","paysafe-checkout"),{}),{type:n.responseTypes.ERROR,message:(0,s.__)("The payment process failed. You have to specify your Venmo email address!","paysafe-checkout")})});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,a]),(0,o.useEffect)(()=>{const e=c(e=>{let t=document.getElementById("paysafevenmo_consumeridInput"),a=t&&t.value&&t.value.length?t.value:"";return function(e,t,n,a,o,i){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=n.log_order_fail_endpoint||null,g=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&m(y,r,(0,s.__)("Payment amount missing","paysafe-checkout")),l(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,n,a,o,i,r,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(y,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=a),a&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(w.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(w.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(w.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(w.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(w.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(w).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),m(y,n,e),"Result failure"}const r={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=d(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(y,n,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=u(e);m(y,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(g,a,[]),p(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=u(e);m(y,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(g,a,[]),p(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,r,c,h,f,e,i,y):function(e,t,n,a,o,i,r,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:n,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=d(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let a=u(e);m(y,n,a),l(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=u(a);if(m(y,n,e),t)l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(g,e,[]),p(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,m(y,n,a),l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===i)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");m(y,n,t),l(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,r,c,h,f,e,i,y)}return e}(e,w,y,{displayPaymentMethods:["venmo"],paymentMethodDetails:{venmo:{accountId:y.account_id,consumerId:""+a}}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],c]),function(e,t=""){let n=[(0,r.jsx)("div",{children:(0,i.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,r.jsx)("hr",{})),e.test_mode&&n.push((0,r.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,r.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(y,(0,r.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,r.jsx)("label",{id:"paysafevenmo_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paysafevenmo_consumeridInput",children:(0,s.__)("Venmo email address","paysafe-checkout")}),(0,r.jsx)("div",{id:"paysafevenmo_consumerid",className:"paysafe-input-field",children:(0,r.jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paysafevenmo_consumerid_input",id:"paysafevenmo_consumeridInput",placeholder:(0,s.__)("Your Venmo email address","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,r.jsx)("p",{id:"paysafevenmo_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter the email from your Venmo account","paysafe-checkout")})]}))},k={name:h,paymentMethodId:h,label:function(e,t){const n=(0,i.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,r.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,r.jsx)("span",{children:n}),(0,r.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(y.title,y.icon),content:(0,r.jsx)(T,{}),edit:(0,r.jsx)(T,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,n.registerPaymentMethod)(k)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=n(),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,p=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!r.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:p,props:c,_owner:i.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),n=e(e=>{e.exports=window.React});const a=window.wp.i18n,o=window.wc.wcBlocksRegistry,i=window.wc.wcSettings,r=window.wp.element,c=window.wp.htmlEntities;s();let l="";function p(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function m(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const y="venmo",g=(0,i.getSetting)(y+"_data",{});var f;f=g.nonce,l=f||"";const w=!0===g.log_errors&&g.log_error_endpoint||null;let b={},T=!1;const k=e=>{const{eventRegistration:s,emitResponse:n}=e,{onPaymentSetup:o,onCheckoutSuccess:i}=s;return T||(T=!0,setTimeout(()=>{let e=document.getElementById("paysafevenmo_consumeridInput");e&&(e.value=g.consumer_id)},100)),(0,r.useEffect)(()=>{const e=o(async()=>{let e=document.getElementById("paysafevenmo_consumeridInput");return e&&e.value&&e.value.length?{type:n.responseTypes.SUCCESS}:(p(w,(0,a.__)("The payment process failed. You have to specify your Venmo email address!","paysafe-checkout"),{}),{type:n.responseTypes.ERROR,message:(0,a.__)("The payment process failed. You have to specify your Venmo email address!","paysafe-checkout")})});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,o]),(0,r.useEffect)(()=>{const e=i(e=>{let t=document.getElementById("paysafevenmo_consumeridInput"),s=t&&t.value&&t.value.length?t.value:"";return function(e,t,s,n,o,i){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let r=e.orderId;r||(r=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=s.log_order_fail_endpoint||null,g=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!r||!f)return r&&u(y,r,(0,a.__)("Payment amount missing","paysafe-checkout")),p(g,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:i.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const i={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,n,o,i,r,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(y,s,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,w={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(w.singleUseCustomerToken=n),n&&t.payment_toke_from&&(w.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(w.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),w.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(w.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(w.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(w.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(w.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(w.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(w.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(w).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),u(y,s,e),"Result failure"}const r={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:i,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(r.save_card=!0);const c=m(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(r)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(y,s,e.error_message),p(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);u(y,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;p(g,n,[]),d(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);u(y,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;p(g,n,[]),d(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,n,r,c,l,f,e,i,y):function(e,t,s,n,o,i,r,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:i,transactionType:"PAYMENT",currency:r,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let w=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},i=m(e.register_url);fetch(i,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(p(g,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),w=e.redirect_url}).catch(e=>{let n=_(e);u(y,s,n),p(g,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(n);if(u(y,s,e),t)p(g,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),p(g,e,[]),d(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":p(g,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==w)return void(window.location=w);window.location.reload()}else{let n="";n=t?(0,a.__)("Payment session expired","paysafe-checkout"):e,u(y,s,n),p(g,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===i)e.accept();else{let t=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");u(y,s,t),p(g,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,n,r,c,l,f,e,i,y)}return e}(e,b,g,{displayPaymentMethods:["venmo"],paymentMethodDetails:{venmo:{accountId:g.account_id,consumerId:""+s}}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],i]),function(e,s=""){let n=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,t().jsx)("hr",{})),e.test_mode&&n.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&n.push(s),n}(g,(0,t().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,t().jsx)("label",{id:"paysafevenmo_consumerid_label",className:"paysafe-general-form-label",htmlFor:"paysafevenmo_consumeridInput",children:(0,a.__)("Venmo email address","paysafe-checkout")}),(0,t().jsx)("div",{id:"paysafevenmo_consumerid",className:"paysafe-input-field",children:(0,t().jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"paysafevenmo_consumerid_input",id:"paysafevenmo_consumeridInput",placeholder:(0,a.__)("Your Venmo email address","paysafe-checkout"),min:"2",minLength:"2",max:"50",maxLength:"50"})}),(0,t().jsx)("p",{id:"paysafevenmo_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,a.__)("Enter the email from your Venmo account","paysafe-checkout")})]}))},R={name:y,paymentMethodId:y,label:function(e,s){const n=(0,c.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:n}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:n})]})}(g.title,g.icon),content:(0,t().jsx)(k,{}),edit:(0,t().jsx)(k,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,o.registerPaymentMethod)(R)})(); -
paysafe-checkout/trunk/assets/js/blocks/blocks-vippreferred.asset.php
r3756379 r3783722 1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => ' 4ab2f16be441b37bf817');1 <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '99468c6264e38bf553cd'); -
paysafe-checkout/trunk/assets/js/blocks/blocks-vippreferred.js
r3756379 r3783722 1 (()=>{"use strict"; var e={20(e,t,s){var n=s(609),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,p=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!i.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:p,props:c,_owner:r.current}}t.jsx=c,t.jsxs=c},848(e,t,s){e.exports=s(20)},609(e){e.exports=window.React}};const t={},s=window.wp.i18n,n=window.wc.wcBlocksRegistry,a=window.wc.wcSettings,o=window.wp.element,r=window.wp.htmlEntities;var i=function s(n){const a=t[n];if(void 0!==a)return a.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);let c="";function l(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:c})}).catch(()=>{})}}function p(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function d(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;p((0,s.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function u(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:c})}).catch(()=>{})}}function m(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function _(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,s.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,s.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,s.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,s.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,s.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const h="vippreferred",y=(0,a.getSetting)(h+"_data",{});var g;g=y.nonce,c=g||"";const f=!0===y.log_errors&&y.log_error_endpoint||null;let b={},w=!1;const v=e=>{const{eventRegistration:t,emitResponse:n}=e,{onPaymentSetup:a,onCheckoutSuccess:c}=t;return w||(w=!0,setTimeout(()=>{let e=document.getElementById("vippreferred_phonenumberInput");e&&(e.value=b&&b.billingAddress&&b.billingAddress.phone?b.billingAddress.phone:"")},100)),(0,o.useEffect)(()=>{const e=a(async()=>{let e=document.getElementById("vippreferred_consumeridInput"),t=e&&e.value&&e.value.length&&9===e.value.length,a=document.getElementById("vippreferred_phonenumberInput"),o=a&&a.value&&a.value.length&&a.value.length>=9;return t&&o?{type:n.responseTypes.SUCCESS}:(l(f,"The payment process validation failed. Customer`s phone number must be provided!",{}),{type:n.responseTypes.ERROR,message:(0,s.__)("The payment process validation failed. Your phone number must be provided!","paysafe-checkout")})});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,a]),(0,o.useEffect)(()=>{const e=c(e=>{let t=document.getElementById("vippreferred_consumeridInput"),a=t&&t.value&&t.value.length&&9===t.value.length?t.value:"",o=document.getElementById("vippreferred_phonenumberInput"),r=o&&o.value&&o.value.length&&o.value.length>=9?o.value:"";return function(e,t,n,a,o,r){void 0===a&&(a={}),void 0===a.settings&&(a.settings={}),o=!!o;let i=e.orderId;i||(i=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",h=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=n.log_order_fail_endpoint||null,g=!0===n.log_errors&&n.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!i||!f)return i&&u(y,i,(0,s.__)("Payment amount missing","paysafe-checkout")),l(g,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:r.responseTypes.ERROR,message:(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const r={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:a&&a.additional&&a.additional.phone?a.additional.phone:t.billingAddress.phone||""};o?function(e,t,n,a,o,r,i,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void u(y,n,(0,s.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,b={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:r,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};a&&t.use_single_use_customer_token&&(b.singleUseCustomerToken=a),a&&t.payment_toke_from&&(b.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),b.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:h.billing_zip,country:h.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:h.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(b.customerDetails.holderName=t.customerDetails.holderName),h.billing_street&&(b.customerDetails.billingDetails.street=h.billing_street),h.billing_street2&&(b.customerDetails.billingDetails.street2=h.billing_street2),h.billing_city&&(b.customerDetails.billingDetails.city=h.billing_city),h.billing_state&&(b.customerDetails.billingDetails.state=h.billing_state),h.billing_phone&&(b.customerDetails.billingDetails.phone=h.billing_phone),f.tokenize(b).then(a=>{if(!a||!a.token){let e="";throw a&&a.error&&(e+=a.error.message?a.error.message:a.error),a&&a.error_message&&(e+=a.error_message),u(y,n,e),"Result failure"}const i={orderId:n,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:a.token,amount:r,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(i.save_card=!0);const c=d(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(u(y,n,e.error_message),l(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=m(e);u(y,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(g,a,[]),p(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=m(e);u(y,n,t);const a="ERROR "+e.code+": "+e.detailedMessage;l(g,a,[]),p(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(n,a,i,c,h,f,e,r,y):function(e,t,n,a,o,r,i,c,h){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:r,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),a&&(f.singleUseCustomerToken=a,t.customer&&(f.customer=t.customer)),a&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),a&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:h.billing_zip,country:h.billing_country},h.billing_street&&(f.billingAddress.street=h.billing_street),h.billing_street2&&(f.billingAddress.street2=h.billing_street2),h.billing_city&&(f.billingAddress.city=h.billing_city),h.billing_state&&(f.billingAddress.state=h.billing_state),h.billing_phone&&(f.billingAddress.phone=h.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let b=null;paysafe.checkout.setup(e.authorization,f,function(t,a,o){if(o&&o.paymentHandleToken){const a={orderId:n,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},r=d(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,s.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),b=e.redirect_url}).catch(e=>{let a=m(e);u(y,n,a),l(g,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(_(e.code,(0,s.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=m(a);if(u(y,n,e),t)l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");a&&a.code&&a.detailedMessage&&(e+="<br /> "+a.code+" "+a.detailedMessage),l(g,e,[]),p(_(a.code,(0,s.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":l(g,(0,s.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==b)return void(window.location=b);window.location.reload()}else{let a="";a=t?(0,s.__)("Payment session expired","paysafe-checkout"):e,u(y,n,a),l(g,(0,s.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,a){if(t===r)e.accept();else{let t=(0,s.__)("Payment amount risk assessment failed","paysafe-checkout");u(y,n,t),l(g,(0,s.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,s.__)("Amount is not the value expected","paysafe-checkout"))}})}(n,a,i,c,h,f,e,r,y)}return e}(e,b,y,{transactionSource:"WooCommerce",displayPaymentMethods:["vippreferred"],paymentMethodDetails:{vippreferred:{accountId:y.account_id,consumerId:a}},customer:{firstName:b.billingAddress.first_name,lastName:b.billingAddress.last_name,email:b.billingAddress.email,phone:r},additional:{phone:r},settings:{add_customer_when_single_use_token:!0,add_billing_when_single_use_token:!0,use_external_simulator:!0}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],c]),function(e,t=""){let n=[(0,i.jsx)("div",{children:(0,r.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,i.jsx)("hr",{})),e.test_mode&&n.push((0,i.jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,i.jsx)("span",{children:(0,s.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),t&&n.push(t),n}(y,(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,i.jsx)("label",{id:"vippreferred_consumerid_label",className:"paysafe-general-form-label",htmlFor:"vippreferred_consumeridInput",children:(0,s.__)("Your social security number","paysafe-checkout")}),(0,i.jsx)("div",{id:"vippreferred_consumerid",className:"paysafe-input-field",children:(0,i.jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"vippreferred_consumerid_input",id:"vippreferred_consumeridInput",placeholder:(0,s.__)("Your social security number","paysafe-checkout"),min:"9",minLength:"9",max:"9",maxLength:"9"})}),(0,i.jsx)("p",{id:"vippreferred_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter your social security number","paysafe-checkout")})]}),(0,i.jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,i.jsx)("label",{id:"vippreferred_phonenumber_label",className:"paysafe-general-form-label",htmlFor:"vippreferred_phonenumberInput",children:(0,s.__)("Your phone number","paysafe-checkout")}),(0,i.jsx)("div",{id:"vippreferred_phonenumber",className:"paysafe-input-field",children:(0,i.jsx)("input",{type:"tel",className:"paysafe-input-field-input",name:"vippreferred_phonenumber_input",id:"vippreferred_phonenumberInput",placeholder:(0,s.__)("Your phone number","paysafe-checkout")})}),(0,i.jsx)("p",{id:"vippreferred_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,s.__)("Enter your phone number","paysafe-checkout")})]})]}))},k={name:h,paymentMethodId:h,label:function(e,t){const n=(0,r.decodeEntities)(e)||(0,s.__)("Paysafe Checkout","paysafe-checkout");return(0,i.jsxs)("div",{className:"paysafe-gateway-title",children:[(0,i.jsx)("span",{children:n}),(0,i.jsx)("img",{className:"paysafe-gateway-image",src:t,alt:n})]})}(y.title,y.icon),content:(0,i.jsx)(v,{}),edit:(0,i.jsx)(v,{}),canMakePayment:e=>(b=e,!0),ariaLabel:(0,s.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:y.supports}};(0,n.registerPaymentMethod)(k)})();1 (()=>{"use strict";const e=e=>{var t;return()=>{if(e){var s=e;e=0,t={exports:{}},s.call(t.exports,t,t.exports)}return t.exports}};var t=e((e,t)=>{var s=n(),a=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,c={},l=null,p=null;for(n in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!i.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:l,ref:p,props:c,_owner:r.current}}t.jsx=c,t.jsxs=c}),s=e(e=>{e.exports=t()}),n=e(e=>{e.exports=window.React});const a=window.wp.i18n,o=window.wc.wcBlocksRegistry,r=window.wc.wcSettings,i=window.wp.element,c=window.wp.htmlEntities;s();let l="";function p(e,t,s){if(e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({message:t,context:s,nonce:l})}).catch(()=>{})}}function d(e,t){t=!!t;let s=document.getElementsByClassName("woocommerce-error");if(s=s.length>0?s[0]:null,!s){let e=document.getElementsByClassName("woocommerce-notices-wrapper"),t=e.length>0?e[0]:null;t&&(s=document.createElement("ul"),s.className="woocommerce-error",t.appendChild(s))}if(s){let n=document.createElement("li"),a=(e||"").replace(/<br\s*\/?>/gi,"\n");!n||t?(n.setAttribute("id","paysafe-fatal-error-message"),n.textContent=a,s.appendChild(n),window.scrollTo({top:0,left:0,behavior:"smooth"})):n.textContent=a}}function u(e){const t=new URL(e,window.location.href);if(t.origin===window.location.origin)return t.pathname+t.search+t.hash;d((0,a.__)("Blocked non-same-origin endpoint","paysafe-checkout")+" "+t.toString(),!0)}function m(e,t,s){if(s&&e){const n=new URL(e,window.location.origin);if(n.origin!==window.location.origin)return;fetch(n.pathname+n.search,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify({order_id:t,reason:s,nonce:l})}).catch(()=>{})}}function _(e){let t="";return e&&(e.code&&(t+=e.code+" "),e.message&&(t+=e.message+" "),e.detailedMessage&&(t=e.detailedMessage),e.displayMessage&&(t=e.displayMessage)),t}function h(e,t){if(void 0===e&&(e=null),void 0===t&&(t=""),null===e)return t;switch(String(e)){case"5100":case"5101":case"5103":case"5104":case"5105":case"5106":case"5107":case"5108":case"5111":case"5112":case"5113":case"5114":case"5115":case"5116":case"5117":case"5118":case"5120":case"5121":case"5124":case"5125":return(0,a.__)("Payment authentication was not completed. Please try again or use a different payment method.","paysafe-checkout");case"9028":case"9073":case"9084":return(0,a.__)("A connection issue occurred. Please reload the page and try again.","paysafe-checkout");case"9014":case"9066":case"9071":case"9191":case"9077":case"9080":case"9085":case"9088":case"9091":case"9165":case"9166":return(0,a.__)("This payment method is not supported on this device. Please use another payment method.","paysafe-checkout");case"9086":case"9180":return(0,a.__)("Apple Pay is not supported on this device. Please use another payment method.","paysafe-checkout");case"9195":case"9197":case"9189":case"9190":case"9193":case"9194":case"9206":return(0,a.__)("Google Pay is not supported on this device. Please use another payment method.","paysafe-checkout")}return t}const y="vippreferred",g=(0,r.getSetting)(y+"_data",{});var f;f=g.nonce,l=f||"";const b=!0===g.log_errors&&g.log_error_endpoint||null;let w={},v=!1;const k=e=>{const{eventRegistration:s,emitResponse:n}=e,{onPaymentSetup:o,onCheckoutSuccess:r}=s;return v||(v=!0,setTimeout(()=>{let e=document.getElementById("vippreferred_phonenumberInput");e&&(e.value=w&&w.billingAddress&&w.billingAddress.phone?w.billingAddress.phone:"")},100)),(0,i.useEffect)(()=>{const e=o(async()=>{let e=document.getElementById("vippreferred_consumeridInput"),t=e&&e.value&&e.value.length&&9===e.value.length,s=document.getElementById("vippreferred_phonenumberInput"),o=s&&s.value&&s.value.length&&s.value.length>=9;return t&&o?{type:n.responseTypes.SUCCESS}:(p(b,"The payment process validation failed. Customer`s phone number must be provided!",{}),{type:n.responseTypes.ERROR,message:(0,a.__)("The payment process validation failed. Your phone number must be provided!","paysafe-checkout")})});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,o]),(0,i.useEffect)(()=>{const e=r(e=>{let t=document.getElementById("vippreferred_consumeridInput"),s=t&&t.value&&t.value.length&&9===t.value.length?t.value:"",o=document.getElementById("vippreferred_phonenumberInput"),r=o&&o.value&&o.value.length&&o.value.length>=9?o.value:"";return function(e,t,s,n,o,r){void 0===n&&(n={}),void 0===n.settings&&(n.settings={}),o=!!o;let i=e.orderId;i||(i=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.order_id?e.processingResponse.paymentDetails.order_id:0);const c=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.single_use_token?e.processingResponse.paymentDetails.single_use_token:"",l=e&&e.processingResponse&&e.processingResponse.paymentDetails&&e.processingResponse.paymentDetails.merch_ref_num?e.processingResponse.paymentDetails.merch_ref_num:"",y=s.log_order_fail_endpoint||null,g=!0===s.log_errors&&s.log_error_endpoint||null,f=parseInt(t.cartTotals.total_price);if(!i||!f)return i&&m(y,i,(0,a.__)("Payment amount missing","paysafe-checkout")),p(g,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout"),[]),{type:r.responseTypes.ERROR,message:(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")};{let e=t.cartTotals.currency_code;const r={firstName:t.billingAddress.first_name,lastName:t.billingAddress.last_name,email:t.billingAddress.email},y={billing_street:t.billingAddress.address_1,billing_street2:t.billingAddress.address_2,billing_city:t.billingAddress.city,billing_zip:t.billingAddress.postcode,billing_state:t.billingAddress.state,billing_country:t.billingAddress.country,billing_phone:n&&n.additional&&n.additional.phone?n.additional.phone:t.billingAddress.phone||""};o?function(e,t,s,n,o,r,i,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null;if(void 0===t.hosted_payment_instance)return void m(y,s,(0,a.__)("Hosted payment instance is not set","paysafe-checkout"));const f=t.hosted_payment_instance,b={transactionSource:void 0===t.transactionSource?"WooCommerceJs":t.transactionSource,amount:r,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE",profile:{email:e.user_email}},paymentType:"CARD",accountId:e.account_id};n&&t.use_single_use_customer_token&&(b.singleUseCustomerToken=n),n&&t.payment_toke_from&&(b.paymentTokenFrom=t.payment_toke_from),e.merchant_descriptor&&e.merchant_phone&&(b.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),b.customerDetails={holderName:c.firstName+" "+c.lastName,billingDetails:{nickName:"Home",zip:l.billing_zip,country:l.billing_country},profile:{firstName:c.firstName,lastName:c.lastName,email:c.email,locale:e.locale,phone:l.billing_phone}},t.customerDetails&&t.customerDetails.holderName&&t.customerDetails.holderName&&(b.customerDetails.holderName=t.customerDetails.holderName),l.billing_street&&(b.customerDetails.billingDetails.street=l.billing_street),l.billing_street2&&(b.customerDetails.billingDetails.street2=l.billing_street2),l.billing_city&&(b.customerDetails.billingDetails.city=l.billing_city),l.billing_state&&(b.customerDetails.billingDetails.state=l.billing_state),l.billing_phone&&(b.customerDetails.billingDetails.phone=l.billing_phone),f.tokenize(b).then(n=>{if(!n||!n.token){let e="";throw n&&n.error&&(e+=n.error.message?n.error.message:n.error),n&&n.error_message&&(e+=n.error_message),m(y,s,e),"Result failure"}const i={orderId:s,paymentMethod:"CARD",transactionType:"PAYMENT",paymentHandleToken:n.token,amount:r,customerOperation:"",merchantRefNum:o,nonce:e.nonce};t.save_card&&(i.save_card=!0);const c=u(e.register_url);fetch(c,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{"error"===e.status||e.error_message?(m(y,s,e.error_message),p(g,e.error_message,{tokenization_stage:1}),window.location=e.redirect_url):window.location=e.redirect_url}).catch(e=>{let t=_(e);m(y,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;p(g,n,[]),d(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again.","paysafe-checkout")),!0)})}).catch(e=>{let t=_(e);m(y,s,t);const n="ERROR "+e.code+": "+e.detailedMessage;p(g,n,[]),d(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")),!0)})}(s,n,i,c,l,f,e,r,y):function(e,t,s,n,o,r,i,c,l){const y=e.log_order_fail_endpoint||null,g=!0===e.log_errors&&e.log_error_endpoint||null,f={transactionSource:void 0===t.transactionSource?"WooCommerceCheckout":t.transactionSource,amount:r,transactionType:"PAYMENT",currency:i,merchantRefNum:o,environment:e.test_mode?"TEST":"LIVE",displayPaymentMethods:t.displayPaymentMethods,paymentMethodDetails:t.paymentMethodDetails,threeDs:{merchantUrl:e.checkout_url,deviceChannel:"BROWSER",messageCategory:"PAYMENT",authenticationPurpose:"PAYMENT_TRANSACTION",transactionIntent:"GOODS_OR_SERVICE_PURCHASE"},locale:e.locale};e.merchant_descriptor&&e.merchant_phone&&(f.merchantDescriptor={dynamicDescriptor:e.merchant_descriptor,phone:e.merchant_phone}),n&&(f.singleUseCustomerToken=n,t.customer&&(f.customer=t.customer)),n&&!t.settings.add_customer_when_single_use_token||(t.customer?f.customer=t.customer:f.customer=c),n&&!t.settings.add_billing_when_single_use_token||(f.billingAddress={nickName:"Home",zip:l.billing_zip,country:l.billing_country},l.billing_street&&(f.billingAddress.street=l.billing_street),l.billing_street2&&(f.billingAddress.street2=l.billing_street2),l.billing_city&&(f.billingAddress.city=l.billing_city),l.billing_state&&(f.billingAddress.state=l.billing_state),l.billing_phone&&(f.billingAddress.phone=l.billing_phone)),t.settings.use_external_simulator&&e.test_mode&&(f.simulator="EXTERNAL"),t.shippingAddress&&(f.shippingAddress=t.shippingAddress);let b=null;paysafe.checkout.setup(e.authorization,f,function(t,n,o){if(o&&o.paymentHandleToken){const n={orderId:s,paymentMethod:o.paymentMethod,transactionType:o.transactionType,paymentHandleToken:o.paymentHandleToken,amount:o.amount,customerOperation:o.customerOperation,merchantRefNum:f.merchantRefNum,nonce:e.nonce},r=u(e.register_url);fetch(r,{method:"POST",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)}).then(e=>e.json()).then(e=>{"success"===e.status?t.showSuccessScreen((0,a.__)("Your goods are now purchased. Expect them to be delivered in next 5 business days.","paysafe-checkout")):(p(g,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),e),e.error_message?t.showFailureScreen(e.error_message):t.showFailureScreen((0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"))),b=e.redirect_url}).catch(e=>{let n=_(e);m(y,s,n),p(g,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout"),[]),t.showFailureScreen(h(e.code,(0,a.__)("The payment process failed. Please close this popup and try again","paysafe-checkout")))})}else{let e=_(n);if(m(y,s,e),t)p(g,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout")+" "+e,{pace:3}),t.showFailureScreen(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")));else{let e=(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout");n&&n.code&&n.detailedMessage&&(e+="<br /> "+n.code+" "+n.detailedMessage),p(g,e,[]),d(h(n.code,(0,a.__)("The payment was declined. Please, try again with the same or another payment method.","paysafe-checkout")),!0)}}},function(e,t){if(e)switch(e){case"PAYMENT_HANDLE_NOT_CREATED":p(g,(0,a.__)("Payment failed. Popup was closed without a correct end message!","paysafe-checkout"),{stage:e,expired:t}),window.location.reload();break;case"PAYMENT_HANDLE_CREATED":case"PAYMENT_HANDLE_REDIRECT":case"PAYMENT_HANDLE_PAYABLE":if(null!==b)return void(window.location=b);window.location.reload()}else{let n="";n=t?(0,a.__)("Payment session expired","paysafe-checkout"):e,m(y,s,n),p(g,(0,a.__)("Payment failed. Showing failure screen.","paysafe-checkout"),{stage:e,expired:t}),window.location.reload()}},function(e,t,n){if(t===r)e.accept();else{let t=(0,a.__)("Payment amount risk assessment failed","paysafe-checkout");m(y,s,t),p(g,(0,a.__)("Amount is not the value expected","paysafe-checkout"),[]),e.decline((0,a.__)("Amount is not the value expected","paysafe-checkout"))}})}(s,n,i,c,l,f,e,r,y)}return e}(e,w,g,{transactionSource:"WooCommerce",displayPaymentMethods:["vippreferred"],paymentMethodDetails:{vippreferred:{accountId:g.account_id,consumerId:s}},customer:{firstName:w.billingAddress.first_name,lastName:w.billingAddress.last_name,email:w.billingAddress.email,phone:r},additional:{phone:r},settings:{add_customer_when_single_use_token:!0,add_billing_when_single_use_token:!0,use_external_simulator:!0}},!1,n)});return()=>{e()}},[n.responseTypes.ERROR,n.responseTypes.SUCCESS,"",[],r]),function(e,s=""){let n=[(0,t().jsx)("div",{children:(0,c.decodeEntities)(e.description||"")})];return e.description&&e.test_mode&&n.push((0,t().jsx)("hr",{})),e.test_mode&&n.push((0,t().jsx)("div",{style:{textAlign:"justify",marginTop:"10px"},children:(0,t().jsx)("span",{children:(0,a.__)("Paysafe Checkout is in TEST mode. Use the built-in simulator to test payments.","paysafe-checkout")})})),s&&n.push(s),n}(g,(0,t().jsxs)("div",{children:[(0,t().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,t().jsx)("label",{id:"vippreferred_consumerid_label",className:"paysafe-general-form-label",htmlFor:"vippreferred_consumeridInput",children:(0,a.__)("Your social security number","paysafe-checkout")}),(0,t().jsx)("div",{id:"vippreferred_consumerid",className:"paysafe-input-field",children:(0,t().jsx)("input",{type:"text",className:"paysafe-input-field-input",name:"vippreferred_consumerid_input",id:"vippreferred_consumeridInput",placeholder:(0,a.__)("Your social security number","paysafe-checkout"),min:"9",minLength:"9",max:"9",maxLength:"9"})}),(0,t().jsx)("p",{id:"vippreferred_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,a.__)("Enter your social security number","paysafe-checkout")})]}),(0,t().jsxs)("div",{id:"paysafe-hosted-payment-form",className:"paysafe-hosted-payment-form",children:[(0,t().jsx)("label",{id:"vippreferred_phonenumber_label",className:"paysafe-general-form-label",htmlFor:"vippreferred_phonenumberInput",children:(0,a.__)("Your phone number","paysafe-checkout")}),(0,t().jsx)("div",{id:"vippreferred_phonenumber",className:"paysafe-input-field",children:(0,t().jsx)("input",{type:"tel",className:"paysafe-input-field-input",name:"vippreferred_phonenumber_input",id:"vippreferred_phonenumberInput",placeholder:(0,a.__)("Your phone number","paysafe-checkout")})}),(0,t().jsx)("p",{id:"vippreferred_consumerid_spacer",className:"paysafe-general-form-spacer",children:(0,a.__)("Enter your phone number","paysafe-checkout")})]})]}))},T={name:y,paymentMethodId:y,label:function(e,s){const n=(0,c.decodeEntities)(e)||(0,a.__)("Paysafe Checkout","paysafe-checkout");return(0,t().jsxs)("div",{className:"paysafe-gateway-title",children:[(0,t().jsx)("span",{children:n}),(0,t().jsx)("img",{className:"paysafe-gateway-image",src:s,alt:n})]})}(g.title,g.icon),content:(0,t().jsx)(k,{}),edit:(0,t().jsx)(k,{}),canMakePayment:e=>(w=e,!0),ariaLabel:(0,a.__)("Paysafe Checkout","paysafe-checkout"),supports:{features:g.supports}};(0,o.registerPaymentMethod)(T)})(); -
paysafe-checkout/trunk/i18n/languages/paysafe-checkout.pot
r3756379 r3783722 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Paysafe Checkout 4.3.1 1\n"5 "Project-Id-Version: Paysafe Checkout 4.3.12\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/paysafe-checkout\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026-1 0-20T09:08:12+00:00\n"12 "POT-Creation-Date: 2026-11-04T09:02:45+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" -
paysafe-checkout/trunk/paysafe-checkout.php
r3756379 r3783722 10 10 * Requires at least: 6.3 11 11 * Requires PHP: 8.1 12 * Version: 4.3.1 112 * Version: 4.3.12 13 13 * Author: Paysafe 14 14 * Author URI: https://www.paysafe.com/ … … 31 31 32 32 // main definitions used through the plugin 33 define('PAYSAFE_WOO_VERSION', '4.3.1 1');33 define('PAYSAFE_WOO_VERSION', '4.3.12'); 34 34 define('PAYSAFE_WOO_PLUGIN_PATH', dirname(__FILE__)); 35 35 define('PAYSAFE_WOO_PLUGIN_URL', plugin_dir_url(__FILE__)); -
paysafe-checkout/trunk/readme.txt
r3756379 r3783722 5 5 Tested up to: 7.0 6 6 Requires PHP: 8.1 7 Stable tag: 4.3.1 17 Stable tag: 4.3.12 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 97 97 == Changelog == 98 98 99 = 4.3.11, 2026-10-14= 100 * Integration changes for Neteller in Paysafe Checkout 101 * Improved error handling 99 = 4.3.12, 2026-10-26= 100 * Dependency updates 102 101 103 102 [See full changelog for details](https://raw.githubusercontent.com/paysafegroup/paysafe-checkout-woocommerce/refs/heads/main/CHANGELOG.md).
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)