1(function(){jQuery(function(e){return window.SV_WC_Apple_Pay_Handler_v5_15_11=class{constructor(e){this.init_product_page=this.init_product_page.bind(this),this.init_cart_page=this.init_cart_page.bind(this),this.init_checkout_page=this.init_checkout_page.bind(this),this.on_validate_merchant=this.on_validate_merchant.bind(this),this.validate_merchant=this.validate_merchant.bind(this),this.on_payment_method_selected=this.on_payment_method_selected.bind(this),this.on_shipping_contact_selected=this.on_shipping_contact_selected.bind(this),this.on_shipping_method_selected=this.on_shipping_method_selected.bind(this),this.on_payment_authorized=this.on_payment_authorized.bind(this),this.process_authorization=this.process_authorization.bind(this),this.on_cancel_payment=this.on_cancel_payment.bind(this),this.reset_payment_request=this.reset_payment_request.bind(this),this.get_payment_request=this.get_payment_request.bind(this),this.gateway_id=e.gateway_id,this.gateway_slug=e.gateway_slug,this.merchant_id=e.merchant_id,this.ajax_url=e.ajax_url,this.validate_nonce=e.validate_nonce,this.recalculate_totals_nonce=e.recalculate_totals_nonce,this.process_nonce=e.process_nonce,this.payment_request=e.payment_request,this.generic_error=e.generic_error,this.wrapper=".sv-wc-external-checkout",this.container=".buttons-container",this.button=".sv-wc-apple-pay-button"}is_available(){return!!window.ApplePaySession&&ApplePaySession.canMakePaymentsWithActiveCard(this.merchant_id).then(e=>e)}init(){if(1===e(this.container).children().length&&e(this.wrapper).hide(),this.is_available()&&(e("form.cart").length?this.init_product_page():e("form.woocommerce-cart-form").length?this.init_cart_page():e("form.woocommerce-checkout").length&&this.init_checkout_page(),this.ui_element))return this.payment_request&&(e(this.button).show(),e(this.wrapper).show()),e(document.body).on("click",".sv-wc-apple-pay-button",e=>{e.preventDefault(),this.block_ui();try{return this.session=this.get_new_session(this.payment_request),this.session.onvalidatemerchant=e=>this.on_validate_merchant(e),this.session.onpaymentmethodselected=e=>this.on_payment_method_selected(e),this.session.onshippingcontactselected=e=>this.on_shipping_contact_selected(e),this.session.onshippingmethodselected=e=>this.on_shipping_method_selected(e),this.session.onpaymentauthorized=e=>this.on_payment_authorized(e),this.session.oncancel=e=>this.on_cancel_payment(e),this.session.begin()}catch(e){return this.fail_payment(e)}})}init_product_page(){return this.ui_element=e("form.cart")}init_cart_page(){return this.ui_element=e("form.woocommerce-cart-form").parents("div.woocommerce"),e(document.body).on("updated_cart_totals",()=>this.reset_payment_request())}init_checkout_page(){return this.ui_element=e("form.woocommerce-checkout"),e(document.body).on("updated_checkout",()=>this.reset_payment_request())}get_new_session(e){return new ApplePaySession(this.get_sdk_version(),e)}get_sdk_version(){return 2}on_validate_merchant(e){return this.validate_merchant(e.validationURL).then(e=>(e=JSON.parse(e),this.session.completeMerchantValidation(e)),e=>(this.session.abort(),this.fail_payment("Merchant could no be validated. "+e.message)))}validate_merchant(t){return new Promise((s,i)=>{var n;return n={action:`wc_${this.gateway_id}_apple_pay_validate_merchant`,nonce:this.validate_nonce,merchant_id:this.merchant_id,url:t},e.post(this.ajax_url,n,e=>e.success?s(e.data):i(e.data))})}on_payment_method_selected(t){return new Promise((t,s)=>{var i;return i={action:`wc_${this.gateway_id}_apple_pay_recalculate_totals`,nonce:this.recalculate_totals_nonce},e.post(this.ajax_url,i,e=>e.success?(i=e.data,t(this.session.completePaymentMethodSelection(i.total,i.line_items))):(console.error("[Apple Pay] Error selecting a shipping contact. "+e.data.message),s(this.session.completePaymentMethodSelection(this.payment_request.total,this.payment_request.lineItems))))})}on_shipping_contact_selected(t){return new Promise((s,i)=>{var n;return n={action:`wc_${this.gateway_id}_apple_pay_recalculate_totals`,nonce:this.recalculate_totals_nonce,contact:t.shippingContact},e.post(this.ajax_url,n,e=>e.success?(n=e.data,s(this.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,n.shipping_methods,n.total,n.line_items))):(console.error("[Apple Pay] Error selecting a shipping contact. "+e.data.message),i(this.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE,[],this.payment_request.total,this.payment_request.lineItems))))})}on_shipping_method_selected(t){return new Promise((s,i)=>{var n;return n={action:`wc_${this.gateway_id}_apple_pay_recalculate_totals`,nonce:this.recalculate_totals_nonce,method:t.shippingMethod.identifier},e.post(this.ajax_url,n,e=>e.success?(n=e.data,s(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,n.total,n.line_items))):(console.error("[Apple Pay] Error selecting a shipping method. "+e.data.message),i(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE,this.payment_request.total,this.payment_request.lineItems))))})}on_payment_authorized(e){return this.process_authorization(e.payment).then(e=>(this.set_payment_status(!0),this.complete_purchase(e)),e=>
1(this.set_payment_status(!1),this.fail_payment("Payment could no be processed. "+e.message)))}process_authorization(t){return new Promise((s,i)=>{var n;return n={action:`wc_${this.gateway_id}_apple_pay_process_payment`,nonce:this.process_nonce,payment:JSON.stringify(t)},e.post(this.ajax_url,n,e=>e.success?s(e.data):i(e.data))})}on_cancel_payment(e){return this.unblock_ui()}complete_purchase(e){return window.location=e.redirect}fail_payment(e){return console.error("[Apple Pay] "+e),this.unblock_ui(),this.render_errors([this.generic_error])}set_payment_status(e){var t;return t=e?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE,this.session.completePayment(t)}reset_payment_request(t={}){return this.block_ui(),this.get_payment_request(t).then(t=>(e(this.button).show(),e(this.wrapper).show(),this.payment_request=JSON.parse(t),this.unblock_ui()),t=>(console.error("[Apple Pay] Could not build payment request. "+t.message),e(this.button).hide(),1===e(this.container).children().length&&e(this.wrapper).hide(),this.unblock_ui()))}get_payment_request(t){return new Promise((s,i)=>{var n;return n={action:`wc_${this.gateway_id}_apple_pay_get_payment_request`},e.extend(t,n),e.post(this.ajax_url,t,e=>e.success?s(e.data):i(e.data))})}render_errors(t){return e(".woocommerce-error, .woocommerce-message").remove(),this.ui_element.prepend('<ul class="woocommerce-error"><li>'+t.join("</li><li>")+"</li></ul>"),this.ui_element.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.ui_element.offset().top-100},1e3)}block_ui(){return this.ui_element.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}unblock_ui(){return this.ui_element.unblock()}},e(document.body).trigger("sv_wc_apple_pay_handler_v5_15_11_loaded")})}).call({}); 2//# sourceMappingURL=sv-wc-payment-gateway-apple-pay.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.