function rtrim(str,chr){var rgxtrim=!chr?new RegExp("\\s+$"):new RegExp(chr+"+$");return str.replace(rgxtrim,"")}function showUserPrice(){$.ajax({type:"POST",url:"/ajax/coursePageAjax.php",dataType:"json",data:{requestType:"getUserLocation"},success:function(response){if(response["status"]=="SUCCESS"){$(".load-price").remove();if(response["response"]=="IN"){$(".indian-p").show();$(".inter-p").remove()}else{$(".inter-p").show();$(".indian-p").remove()}}else{$(".load-price").remove();$(".indian-p").show()}},error:function(jqXHR,exception,errorThrown){$(".load-price").remove();$(".indian-p").show()}})}$("document").ready(function(){$("body").on("click",".gfgpay",function(event){event.preventDefault();var thisBtn=$(this);$(this).prop("disabled","true");var formData=new FormData;formData.append("pid",$(this).attr("pid"));formData.append("ptype",$(this).attr("ptype"));formData.append("gtoken",$(this).attr("gtoken"));formData.append("utoken",$(this).attr("utoken"));formData.append("requestType","fetchDetails");$.ajax({type:"POST",url:"/ajax/gfgPayment.php",processData:false,contentType:false,data:formData,success:function(response){if(response["status"]=="SUCCESS"){$("#gfg-payment-confirm").remove();$(response["message"]).insertBefore("footer");$("#gfg-payment-confirm").modal("show")}else if(response["status"]=="error"){displayError("","",response["message"])}},error:function(jqXHR,exception){displayError(jqXHR,exception,"")},complete:function(response){thisBtn.prop("disabled","")}})});$("body").on("click",".gfgpay-close",function(event){$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},200)});$("#commentModal").on("hidden.bs.modal",function(){$(".modal-backdrop").remove()});$("body").on("click",".gfg-paynow",function(event){event.preventDefault();var formData=new FormData;formData.append("requestType","createOrder");formData.append("futoken",$("#futoken").val());formData.append("trantoken",$("#trantoken").val());if(typeof couponApplied!=="undefined"&&couponApplied!=false){formData.append("couponCode",appliedCC)}try{if($("#paypal-button-container").length){$(".gfg-paynow").hide();formData.append("gateway","paypal");paypal.Buttons({style:{color:"silver",layout:"horizontal"},createOrder:function(){return fetch("/ajax/gfgPayment.php",{method:"post",body:formData}).then(function(res){console.log(res);return res.json()}).then(function(data){if(data.status=="error"){console.log(data);$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},200);displayError("","",data.message)}else{if(data.message.hasOwnProperty("refresh")){$(".gfg-paynow").css("display","none");$("#paypal-button-container").remove();$("#gfg-payment-confirm").find(".modal-body").html('
Enrollment Confirmed.
Reloading Page in 3 seconds...');setTimeout(function(){location.reload()},5e3)}else{return data.message.orderID}}}).catch(error=>{console.log(error)})},onApprove:function(data){console.log("onapprove js log");$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},300);verifyPayment(data,$("#utoken").text(),"paypal")},onCancel:function(data){$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},300);$("#commentModal .modal-body .text-center").html('
Your payment could not be processed.
We\'ll re-verify your payment and update the status soon. Please try after some time. If your account was debited, the amount will be refunded within a week.
');$("#commentModal").modal("show");$("#commentModal div.modal-footer button").removeClass("btn-default");$("#commentModal div.modal-footer button").addClass("btn-success")},onError:function(err){$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},300);$("#commentModal .modal-body .text-center").html('
Your payment could not be processed.
Please try after some time. If your account was debited, the amount will be refunded within a week.
');$("#commentModal").modal("show");$("#commentModal div.modal-footer button").removeClass("btn-default");$("#commentModal div.modal-footer button").addClass("btn-success");console.log(err)}}).render("#paypal-button-container")}else{$(this).prop("disabled","true");$(".gfg-paynow").html("Processing ");$.ajax({type:"POST",url:"/ajax/gfgPayment.php",processData:false,contentType:false,data:formData,success:function(response){if(response["status"]=="SUCCESS"){if(response["message"].hasOwnProperty("refresh")){$(".gfg-paynow").css("display","none");$("#gfg-payment-confirm").find(".modal-body").html('
Enrollment Confirmed.
Reloading Page in 3 seconds...');setTimeout(function(){location.reload()},5e3)}else{$("#gfg-payment-confirm").find(".modal-footer").html(response["message"]);$("#rzp-pay-button").trigger("click");$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},200)}}else if(response["status"]=="error"){$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},200);displayError("","",response["message"])}},error:function(jqXHR,exception){$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},200);displayError(jqXHR,exception,"")},complete:function(response){}})}}catch(err){}})});function verifyPayment(rzpResponse,utoken,gateway="razorpay"){$('
Processing...
Please do not Refresh/Close this tab.
').insertBefore("footer");var formData=new FormData;formData.append("requestType","verifyPayment");formData.append("utoken",utoken);formData.append("gateway",gateway);formData.append("gateway_order_id",rzpResponse.orderID);if(gateway=="razorpay"){formData.append("razorpay_payment_id",rzpResponse.razorpay_payment_id);formData.append("gateway_order_id",rzpResponse.razorpay_order_id);formData.append("razorpay_signature",rzpResponse.razorpay_signature)}$.ajax({type:"POST",url:"/ajax/gfgPayment.php",processData:false,contentType:false,data:formData,success:function(response){$("#gfgpay-loading-wrap").remove();if(response["status"]=="SUCCESS"){gtag("event","conversion",{send_to:"AW-796001856/DLCZCKWT4qkBEMCMyPsC"});$(response["message"]).insertBefore("footer");$("#gfg-tran-completed").modal("show");if(response["type"]==102){var base_url=window.location.origin;setTimeout(function(){location.href=base_url+"/user/mocks"},3e3)}else{url=rtrim(window.location.origin+window.location.pathname,"/");url+="?payment=true";setTimeout(function(){window.location.href=url},3e3)}}else if(response["status"]=="error"){displayError("","",response["message"])}},error:function(jqXHR,exception){$("#gfgpay-loading-wrap").remove();displayError(jqXHR,exception,"")},complete:function(response){}})}function displayError(jqXHR,exception,msg){if(msg!=""){}else if(jqXHR.status===0){msg="Can't connect.\n Check your internet connection."}else if(jqXHR.status==404){msg="Requested page not found. [404]"}else if(jqXHR.status==500){msg="Internal Server Error [500]."}else if(exception==="parsererror"){msg="Requested JSON parse failed."}else if(exception==="timeout"){msg="Time out error."}else if(exception==="abort"){msg="Ajax request aborted."}else{msg="Uncaught Error.\n"+jqXHR.responseText}$("#gfg-snackbar").text(msg);$("#gfg-snackbar").addClass("show");setTimeout(function(){$("#gfg-snackbar").removeClass("show")},6e3)}$("body").on("click",".coupon-check",function(event){$(".coupon-check").hide();$(".apply-coupon-div").show()});var couponApplied=false;var appliedCC=false;$("body").on("click",".apply-coupon, .remove-coupon",function(event){event.preventDefault();var total_amount=$("#total-amount").text();var $this=$(this);if($(this).hasClass("apply-coupon")){$(this).prop("disabled","true");$(this).html("Applying ");appliedCC=$("#coupon-code").val();var formData=new FormData;formData.append("requestType","applyCoupon");formData.append("ptype",$("#ptype").val());formData.append("futoken",$("#futoken").val());formData.append("trantoken",$("#trantoken").val());formData.append("couponCode",$("#coupon-code").val());$.ajax({type:"POST",url:"/ajax/gfgPayment.php",processData:false,contentType:false,data:formData,success:function(response){if(response["status"]=="SUCCESS"){$(".coupon-disc").show();$(".coupon-div").hide();$("#total-amount").html(response["message"]["symbol"]+response["message"]["productPrice"]);$("#discount-amount").html(response["message"]["symbol"]+response["message"]["discount"]);var payableAmount=parseFloat(response["message"]["payableAmount"]).toFixed(2);if(payableAmount>0){$("#final-amount").html(response["message"]["symbol"]+payableAmount)}else{$("#final-amount").html(response["message"]["symbol"]+"0");$("#gfg-payment-confirm").find(".modal-body").append("Congratulations !! You have got this product for free
");$(".gfg-paynow").text("Proceed to Confirm")}couponApplied=true}else if(response["status"]=="error"){if($(".errorMessage").length){$(".errorMessage").remove()}$(".coupon-div").append(""+response["message"]+"
")}},error:function(jqXHR,exception){$("#gfg-payment-confirm").modal("hide");setTimeout(function(){$("#gfg-payment-confirm").remove()},200);displayError(jqXHR,exception,"")},complete:function(response){$this.prop("disabled","false");$this.html("Apply")}})}else if($(this).hasClass("remove-coupon")){couponApplied=false;$(".coupon-disc").hide();$(".errorMessage").remove();$(".coupon-div").show();$(".apply-coupon-div").hide();$(".coupon-check").show()}});