PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.3
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.3
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 trunk All 48 releases
fluent-cart / assets / custom-payment-page.js

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

3 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{P as $}from"./chunks/payment-loader.js?ver=1.5.3";const r=jQuery;r(()=>{const a=window.fluentcart_checkout_info;a.baseUrl;const P=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 E=a.custom_checkout_url,d=window.fluentcart.$t;let u=r(r("form[data-fluent-cart-checkout-page-checkout-form]")[0]),n=!1;const m=async _=>{if(_!==void 0&&_.preventDefault(),n)return!1;const o=jQuery(".fct-loader"),e=f.getPaymentMethod(),J=window["is_"+e+"_ready"];if(e!=="offline_payment"&&!J)return window.dispatchEvent(new CustomEvent("fluent_cart_validate_checkout_"+e)),!1;const C=E,y=new URLSearchParams(window.location.search);let M=y.get("license_key")||"",j=y.get("coupon")||"";o.addClass("active"),n=!0;try{return await jQuery.post(C,{order_hash:O,mode:P,payment_method:e,variation_id:N,license_key:M,coupon:j,_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)||d("Payment failed. Please try again.")):o.removeClass("active"),t)).catch(t=>{var h,w,v,g,s,k;o.removeClass("active");let c="";if((w=(h=t==null?void 0:t.responseJSON)==null?void 0:h.data)!=null&&w.message)c=t.responseJSON.data.message;else if((v=t==null?void 0:t.responseJSON)!=null&&v.message)c=t.responseJSON.message;else{const i=((s=(g=t==null?void 0:t.responseJSON)==null?void 0:g.data)==null?void 0:s.errors)||((k=t==null?void 0:t.responseJSON)==null?void 0:k.errors)||{};for(const l in i)i.hasOwnProperty(l)&&(c+=`${l}: ${i[l]}
2 `)}alert(c||d("Payment failed. Please try again."))})}finally{n=!1}};u.on("submit",m);const f=new $({form:u[0],orderHandler:m,customPayment:!0});f.load()});
3