HEX
Server: LiteSpeed
System: Linux premium221.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: madepabj (2566)
PHP: 8.3.26
Disabled: NONE
Upload Files
File: //home/madepabj/gharana.pk/price/wp-content/plugins/woocommerce/assets/js/gateways/paypal.min.js
jQuery(function(e){const t="paypal-standard-container";let r="",a="",o="",n={};function c(){const c=document.getElementById(t);if(!c)return;!function(){const e=document.getElementById(t),r=e.offsetWidth,a=Math.max(0,(r-750)/2);e.style.marginLeft=a+"px"}();const d=paypal.Buttons({appSwitchWhenAvailable:!0,async createOrder(e){if(paypal_standard.is_product_page){if(!await(async()=>{const e=document.querySelector('[name="add-to-cart"]');let t=e?e.value:null;const r=document.querySelector('[name="variation_id"]'),o=r?r.value:null;if(o&&(t=o),!t)return!1;const c=document.querySelector('[name="quantity"]'),d=c?c.value:"1";if(""===d)return!1;if(a&&n.id===t&&n.quantity===d)return!0;try{const e=await window.wp.apiFetch({method:"DELETE",path:"/wc/store/v1/cart/items"});if(!e||0!=e.length)throw new Error("Failed to empty cart");const r=await window.wp.apiFetch({method:"POST",path:"/wc/store/v1/cart/items",data:{id:t,quantity:d}});if(!r||!r.key)throw new Error("Failed to add product to cart")}catch(i){return!1}return n={id:t,quantity:d},!0})())return null}let t;try{if(!(t=await window.wp.apiFetch({method:"GET",path:"/wc/store/v1/checkout",headers:{Nonce:paypal_standard.wc_store_api_nonce}})).order_id||!t.order_key)return console.error("Failed to create WooCommerce order",t),null;const n=await window.wp.apiFetch({method:"POST",path:"/wc/v3/paypal-buttons/create-order",headers:{Nonce:paypal_standard.create_order_nonce},data:{order_id:t.order_id,order_key:t.order_key,payment_source:e.paymentSource||"",app_switch_request_origin:paypal_standard.app_switch_request_origin}});return a=n.order_id,o=t.order_key,r=n.return_url,n.paypal_order_id}catch(c){return console.error("Failed to create order",c),null}},onApprove(){r&&(window.location.href=r)},async onCancel(e){if(a||(a=new URLSearchParams(window.location.search).get("order_id")),a)try{await window.wp.apiFetch({method:"POST",path:"/wc/v3/paypal-buttons/cancel-payment",headers:{Nonce:paypal_standard.cancel_payment_nonce},data:{order_id:a,paypal_order_id:e.orderID}}),r=""}catch(t){console.error("Failed to cancel PayPal payment",t)}},onError:function(t){const r='<ul class="woocommerce-error" role="alert"><li>'+e("<div>").text(t.message||paypal_standard.generic_error_message).html()+"</li></ul>",a=e(".woocommerce-notices-wrapper").first();a.length&&(e(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message").remove(),a.prepend(r))}});d.hasReturned()&&d.resume(),d.render(c)["catch"](function(e){console.error("Failed to render PayPal buttons",e)})}e(document.body).on("updated_cart_totals",function(){const e=document.getElementById(t);e&&!e.querySelector("iframe")&&c()}),c()});