| @@ -1,3 +1,2 @@ | ||
| 1 | -import{P as U}from"./chunks/payment-loader.js?ver=1.3.21";const r=jQuery;r(()=>{const a=window.fluentcart_checkout_info;a.baseUrl;const E=a.paymentMode,M=a.orderHash;a.rest_url;const $=a==null?void 0:a.rest.nonce;a.ajaxurl;const b=a.variationId;a.order_information_url;const j=a.custom_checkout_url,d=window.fluentcart.$t;let u=r(r("form[data-fluent-cart-checkout-page-checkout-form]")[0]);const m=async _=>{_!==void 0&&_.preventDefault();const l=jQuery(".fct-loader"),i=f.getPaymentMethod(),x=window["is_"+i+"_ready"];if(i!=="offline_payment"&&!x)return console.warn("Dev Warn FCT: Payment method is not ready yet!"),window.dispatchEvent(new CustomEvent("fluent_cart_validate_checkout_"+i)),!1;const H=j,y=new URLSearchParams(window.location.search);let L=y.get("license_key")||"",Q=y.get("coupon")||"";return l.addClass("active"),await jQuery.post(H,{order_hash:M,mode:E,payment_method:i,variation_id:b,license_key:L,coupon:Q,_wpnonce:$}).then(t=>{var o;return t.actionName==="custom"?window.dispatchEvent(new CustomEvent("fluent_cart_payment_next_action_"+t.nextAction,{detail:{response:t}})):t.redirect_to?((void 0).buttonState("order_processing",d("Please wait..."),(o=t.data)==null?void 0:o.buttonState),window.location.href=t==null?void 0:t.redirect_to):(t==null?void 0:t.status)==="failed"?alert((t==null?void 0:t.message)||d("Payment failed. Please try again.")):l.removeClass("active"),t}).catch(t=>{var o,h,w,g,v,k,P,S,O,N,J,C;if(l.removeClass("active"),(h=(o=t==null?void 0:t.responseJSON)==null?void 0:o.data)!=null&&h.message)console.log((g=(w=t==null?void 0:t.responseJSON)==null?void 0:w.data)==null?void 0:g.message);else if((v=t==null?void 0:t.responseJSON)!=null&&v.message)console.log((k=t==null?void 0:t.responseJSON)==null?void 0:k.message);else if((S=(P=t==null?void 0:t.responseJSON)==null?void 0:P.data)!=null&&S.errors){const e=(N=(O=t==null?void 0:t.responseJSON)==null?void 0:O.data)==null?void 0:N.errors;let n="";for(const c in e)e.hasOwnProperty(c)&&(n+=`${c}: ${e[c]} | |
| 2 | -`);console.log(n)}else if((J=t==null?void 0:t.responseJSON)!=null&&J.errors){const e=(C=t==null?void 0:t.responseJSON)==null?void 0:C.errors;let n="";for(const c in e)e.hasOwnProperty(c)&&(n+=`${c}: ${e[c]} | |
| 3 | -`);console.log(n)}else console.log("An error occurred while processing the payment. Please try again.")})};u.on("submit",m);const f=new U({form:u[0],orderHandler:m,customPayment:!0});f.load()}); | |
| 1 | +import{P as b}from"./chunks/payment-loader.js?ver=1.7.0";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()}); | |