PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / trunk
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler vtrunk
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / assets / custom-payment-page.js

custom-payment-page.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler trunk, at assets/custom-payment-page.js

3 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{P as b}from"./chunks/payment-loader.js?ver=1.6.6";const d=jQuery;d(()=>{const a=window.fluentcart_checkout_info;a.baseUrl;const E=a.paymentMode,O=a.orderHash;a.rest_url;const S=a==null?void 0:a.rest.nonce;a.ajaxurl;const N=a.variationId;a.order_information_url;const C=a.custom_checkout_url,u=window.fluentcart.$t;let f=d(d("form[data-fluent-cart-checkout-page-checkout-form]")[0]),n=!1;const m=async h=>{if(h!==void 0&&h.preventDefault(),n)return!1;const o=jQuery(".fct-loader"),e=_.getPaymentMethod(),J=window["is_"+e+"_ready"];if(e!=="offline_payment"&&!J)return window.dispatchEvent(new CustomEvent("fluent_cart_validate_checkout_"+e)),!1;n=!0;try{const i=[];if(window.dispatchEvent(new CustomEvent("fluent_cart_before_checkout_"+e,{detail:{waitFor:t=>i.push(Promise.resolve(t).catch(()=>!1))}})),i.length&&(await Promise.all(i)).includes(!1))return!1;const M=C,w=new URLSearchParams(window.location.search);let j=w.get("license_key")||"",$=w.get("coupon")||"";return o.addClass("active"),await jQuery.post(M,{order_hash:O,mode:E,payment_method:e,variation_id:N,license_key:j,coupon:$,_wpnonce:S}).then(t=>(t.actionName==="custom"?window.dispatchEvent(new CustomEvent("fluent_cart_payment_next_action_"+t.nextAction,{detail:{response:t}})):t.redirect_to?window.location.href=t==null?void 0:t.redirect_to:(t==null?void 0:t.status)==="failed"?alert((t==null?void 0:t.message)||u("Payment failed. Please try again.")):o.removeClass("active"),t)).catch(t=>{var y,s,v,g,P,k;o.removeClass("active");let c="";if((s=(y=t==null?void 0:t.responseJSON)==null?void 0:y.data)!=null&&s.message)c=t.responseJSON.data.message;else if((v=t==null?void 0:t.responseJSON)!=null&&v.message)c=t.responseJSON.message;else{const l=((P=(g=t==null?void 0:t.responseJSON)==null?void 0:g.data)==null?void 0:P.errors)||((k=t==null?void 0:t.responseJSON)==null?void 0:k.errors)||{};for(const r in l)l.hasOwnProperty(r)&&(c+=`${r}: ${l[r]}
2 `)}alert(c||u("Payment failed. Please try again."))})}finally{n=!1}};f.on("submit",m);const _=new b({form:f[0],orderHandler:m,customPayment:!0});_.load()});
3