/* Minification failed. Returning unminified contents. (1357,9-13): run-time error JS1300: Strict-mode does not allow assignment to undefined variables: size (1352,9-13): run-time error JS1300: Strict-mode does not allow assignment to undefined variables: size (1319,9-13): run-time error JS1300: Strict-mode does not allow assignment to undefined variables: size (1314,9-13): run-time error JS1300: Strict-mode does not allow assignment to undefined variables: size */ "use strict"; var bet365在线平台pingCartV4 = (function () { var controls = {}; // event handlers var initEventHandlers = function () { $('body').on('input', ".promo-code-input", function() { checkPromoInput(); }); $('body').on("click", ".shopping-cart-item__remove-link-v4", function () { UpdateCartItem($(this).closest(".shopping-cart-parent-item").data("cartitemid"), 0); }); $('body').on("click", ".shopping-cart-item__addon-remove-link-v4", function () { UpdateCartItem($(this).closest(".shopping-cart-item__addon-v4").data("cartitemid"), 0); }); $('body').on("change", ".qtySelect", function () { UpdateCartItem($(this).attr("id"), $(this).val()); }); $('body').on("keypress", ".cart-v4__guest-checkout__textbox", function (e) { if (e.keyCode === 13) { $(".cart-v4__guest-checkout__submit").click() } }); $("body").on("click", ".cart-v4__user-ship-address__edit", function () { if (CurrentUser.IsAuthenticated) { LoadListUserShippingAddresses(); } else { LoadEditShippingAddress($(this).closest(".cart-v4__user-ship-address").data("id")) } }); //Unauthenticated users will be brought directly to the edit address page instead of the list $("body").on("click", ".cart-v4__user-address__edit-btn", function () { LoadEditShippingAddress($(this).closest(".cart-v4__user-address").data("id")); }); $("body").on("click", ".cart-v4__user-address__delete-btn", function () { DeleteShippingAddress(this); }); $("body").on("click", ".cart-v4__user-address__select-btn", function () { UseShippingAddress(this); }); $("body").on("click", ".cart-v4__new-address-btn", function () { LoadCreateShippingAddress(); }); $("body").on("click", ".cart-v4__user-address", function () { var id = $(this).data("id"); $("input[type='radio'][value='" + id + "']").click(); }); $("body").on("click", ".cart-v4__selected-delivery__edit", function () { LoadDeliveryOptions(); }); $("body").on("click", ".cart-btn-v4__unshippable-items-remove", function () { RemoveUnshippableItems(); }); $("body").on("click", ".cart-v4__delivery-option__submit", function () { var buttonText = $(this).text(); $(this).html("Loading"); SubmitDeliveryOption(true, buttonText); }); $('body').on('keyup', '.cart-v4__delivery-notes-text, .cart-v4__delivery-salesperson-text', function () { if ($(this).val().length >= $(this).attr('maxlength')) { $(this).siblings('.cart-v4__delivery-error').show(); } else { $(this).siblings('.cart-v4__delivery-error').hide(); } }); $('body').on('focusout', '.cart-v4__guest-checkout .cart-v4__guest-checkout__textbox', function () { validateRegEmailAddress(); }); $("body").on("click", ".cart-v4__new-bill-address-btn", function () { LoadCreateBillingAddress(); }); $("body").on("click", ".cart-v4__user-bill-address__edit", function () { if (CurrentUser.IsAuthenticated){ LoadListUserBillingAddresses(); } else{ LoadEditBillingAddress($('.cart-v4__user-bill-address').data('id')) }}); $("body").on("click", ".cart-v4__list-bill-address__edit-btn", function () { LoadEditBillingAddress($(this).closest(".cart-v4__list-bill-address").data("id")); }); $("body").on("click", ".cart-v4__list-bill-address__delete-btn", function () { DeleteBillingAddress(this); }); $("body").on("input", ".cart-v4__login-btn", function () { SignInSelection() }); /* Using JS to add __selected class for now because :placeholder-shown is not supported in Edge */ if (/Edge/.test(navigator.userAgent)) { $(".cart-v4 .form-group .form-control").addClass("__selected"); } }; function checkPromoInput(){ var promoInputVal = $('.promo-code-input').val(); //If they have something entered it should be enabled. If not, it should be disabled. $('.cart-v4__promo-code-apply').prop( "disabled", promoInputVal.length === 0 ); }; // functions function UpdateCartItem(cartItemId, qty) { if (qty == 0) { // add spinner for remove item const cartItemEl = $('.shopping-cart-item-v4[data-cartitemid="' + cartItemId + '"]'); if (cartItemEl) { var spinner = $('
Loading...
'); cartItemEl.addClass('position-relative'); cartItemEl.append(spinner); } } return Post('bet365在线平台pingCart/bet365在线平台pingCart/UpdateCartItem', { "cartItemId": cartItemId, "qty": qty }) .then(function(data){ if (data.Method == 'UpdateCartItem') { // spinner to indicate reloading items LoadViewCartItems().then(function () { if (data.IsCartEmpty) { $('.view-cart-summary-v4__checkout').hide(); $('.view-cart-v4__qty-update-msg').text('Cart is empty.'); } else if (qty == 0) { $('.view-cart-v4__qty-update-msg').text('Item removed'); } else { $('.view-cart-v4__qty-update-msg').text('Quantity changed to ' + qty); $('.qtySelect#' + cartItemId).focus(); } }); LoadViewCartTotals(); } else { $(".view-cart-v4__error-msg").html(data.Error); $(".spinner-border-mask").remove(); $(".spinner-border").remove(); } }); } function LoadViewCartItems(callback) { return Get('bet365在线平台pingCart/bet365在线平台pingCart/Getbet365在线平台pingCartItemsHtmlV4') .then(function(data){ $(".view-cart-v4__items").html(data); if (typeof(callback) === 'function'){ callback(data); } if ($('.shopping-cart-item__addon').length > 0) { $.each($('.shopping-cart-item__addon'), function () { $(this).closest('.shopping-cart-item__addons-v4').show(); }); } }); } function LoadViewCartTotals() { return Get('bet365在线平台pingCart/bet365在线平台pingCart/CurrentCartTotals') .then(function (data) { //console.log(data); $('.view-cart-summary-v4__itemtotal').html(data.SubtotalString); $('.view-cart-summary-v4__subtotal').html(data.EstimatedTotalString); $('.view-cart-summary-v4__subtotal-update-msg').text('Subtotal updated to ' + data.EstimatedTotalString); const numberFormat = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }); $('.view-cart-summary-v4__fees').html(""); for (let i = 0; i < data.Fees.length; i++) { $('.view-cart-summary-v4__fees').append('
' + data.Fees[i].Title + '
' + numberFormat.format(data.Fees[i].Amount) + '
') } if (data.RemovedPromoCode || data.RemovedPromoReason) { ReloadViewCartPromo(data.RemovedPromoCode, data.RemovedPromoReason); } else if (data.PromoCodeString != "") { $('.cart-v4__applied-promo-total').html(data.PromoCodeString); } // Update Stripe BNPL Block Amount if enabled var stripeMessageBlock = document.getElementById("payment-method-messaging-element"); if (stripeMessageBlock) { const stripeOptions = { amount: data.EstimatedTotal * 100, currency: 'USD', countryCode: 'US', }; stripePaymentMessageElement.update(stripeOptions); } }); } //Used to reload the promo code section after an item is removed/updated and the promo that was applied is no longer valid. //This will show the error message on why the promo was removed with the promo code in the input. function ReloadViewCartPromo(removedPromoCode, removedPromoReason) { //console.log('reloading view cart promo', removedPromoCode, removedPromoReason); var query = '?promo=' + removedPromoCode + '&errorMessage=' + removedPromoReason; Get('bet365在线平台pingCart/bet365在线平台pingCart/ViewCartPromoCode' + query) .then(function (data) { $('.view-cart-summary-v4__promo-container').html(data); }); } function LoadSignIn(id) { //Remove active and add d-none to hide the sections $('.cart-login-v4__content').each(function(){ $(this).addClass('d-none'); $(this).removeClass('__active'); }); //Now make sure d-none is removed and active is added to the section we want. var section = $(id).closest(".cart-login-v4__section"); $(id).removeClass('d-none'); $(section).addClass("__active"); } function SelectGuestCheckout(registerBtn, success) { //use spinner here var buttonText = $(registerBtn).text(); $(registerBtn).html("Loading"); //validate the page var pageValid = true; var email = $('.cart-v4__guest-checkout__textbox').val().trim(); if (email.length == 0) { setRegStatusMessage('Please enter your email address first.'); pageValid = false; } pageValid = validateRegEmailAddress(); if (!pageValid) { $(registerBtn).html(buttonText); return false; } //create viewmodel var vm = {}; vm.EmailAddress = email; vm.xexyz = $('.requirednotes').val(); vm.xexyz_cb = $('.terms-cb').prop('checked'); //call api to do guest checkout var reqData = JSON.stringify(vm); return Post('bet365在线平台pingCart/Login/GuestCheckout', reqData) .then(function (data) { var parsedData = JSON.parse(data); if (parsedData.status == 1) { if (data.redirectUrl){ window.location.replace(data.redirectUrl); } else { success(); } } else { $(registerBtn).html(buttonText); setRegStatusMessage(parsedData.message); } }); } function setRegStatusMessage(text) { $('.cart-v4__guest-checkout .cart-v4__guest-checkout__status').html(text); } function validateRegEmailAddress() { var email = $('.cart-v4__guest-checkout .cart-v4__guest-checkout__textbox').val().trim(); if (email.length > 0) { if (!Utils.validateEmail(email)) { setRegStatusMessage('Please enter a valid email address.'); return false; } else { return true; } } } function LoadCreateShippingAddress(callback) { return Get('bet365在线平台pingCart/Address/CreateShippingAddress') .then(function(data){ $("#shipping").html(data); ShowCartSection("#shipping"); if (callback) callback(); $('body,html').scrollTo(".shipping-address__create"); }); } function LoadListUserShippingAddresses() { return Get('bet365在线平台pingCart/Address/ListUserShippingAddresses') .then(function (data) { $("#shipping").html(data); ShowCartSection("#shipping"); }); } function LoadEditShippingAddress(addressId) { return Get('bet365在线平台pingCart/Address/EditShippingAddress?addressId=' + addressId) .then(function(data){ $("#shipping").html(data); ShowCartSection("#shipping"); }); } function DeleteShippingAddress(trigger) { if (!confirm('Are you sure you would like to permanently delete this address?')) return false; var addressId = $(trigger).closest(".cart-v4__user-address").data("id"); return $.ajax({ type: "DELETE", url: Utils.BaseURL + 'bet365在线平台pingCart/Address/RemoveShippingAddress', contentType: "application/json; charset=utf-8", data: JSON.stringify({ "addressId": addressId }) }).then(function (data) { console.log(data); if (data.success) { LoadListUserShippingAddresses(); } }); } function UseShippingAddress(trigger) { // error if no ship address selected var addressId = $(trigger).closest('.cart-v4__user-address').data('id'); var updateBillingAddress = $(trigger).closest('.cart-v4__user-address').data('updatebilling'); return Post('bet365在线平台pingCart/Address/ChooseShippingAddress', { "addressId": addressId, "updateBillingAddress": updateBillingAddress }) .then(function(data){ LoadDeliveryOptions(); }); } function LoadSelectedDelivery() { return Get('bet365在线平台pingCart/Delivery/GetSelectedDeliveryOptions') .then(function (data) { $("#shipping").html(data); }); // .then(function(){ //re-load the summary with updated delivery option. // LoadSummary(); //}); } function LoadDeliveryOptions() { return Get('bet365在线平台pingCart/Delivery/GetDeliveryOptions') .then(function(data){ $("#shipping").html(data); ShowCartSection("#shipping"); }); } function RemoveUnshippableItems() { var model = { CartItemIds: [] } $.each($(".cart-v4__shipping-item"), function (i, v) { model.CartItemIds.push($(this).data('id')); }); var reqData = JSON.stringify(model); return Post('bet365在线平台pingCart/Delivery/RemoveUnshippableItems', reqData) .then(function (data) { LoadDeliveryOptions(); LoadSummary(); }); } function SubmitDeliveryOption(continueToBilling, buttonText) { if ($('.cart-v4__unshippable-items-container').length > 0 && $("input.cart-v4__delivery-input:checked").data("type") != 1) { $('.cart-v4__delivery-option__submit').html(buttonText); $('.cart-v4__unshippable-error').html('Please select pickup option or remove the items that are not shippable to proceed.'); return; } var deliveryNotes = $("textarea#DeliveryDetails_DeliveryNotes").val(); // error if no delivery method selected? var model = { DeliveryNotes: deliveryNotes, SalespersonName: "", SelectedDeliveryOptions: [] }; var salespersonName = $("input#DeliveryDetails_SalespersonName"); if (salespersonName.length > 0) { model.SalespersonName = salespersonName.val(); } $.each($("input.cart-v4__delivery-input:checked"), function (i, v) { var SelectedDeliveryOption = {}; SelectedDeliveryOption["SelectedOptionId"] = $(this).val(); if ($(this).attr('name') == "dropShipDeliveryOption") { SelectedDeliveryOption["DropShipParentOptionId"] = $(this).closest(".cart-v4__delivery-drop-ship__options").data("dropshipid"); } else { SelectedDeliveryOption["DropShipParentOptionId"] = 0; } model.SelectedDeliveryOptions.push(SelectedDeliveryOption); }); var reqData = JSON.stringify(model); return Post('bet365在线平台pingCart/Delivery/SubmitDeliveryOption', reqData) .then(function(data){ LoadSummary(); if (continueToBilling){ LoadBilling(); var resp = JSON.parse(data); //Ga4 fdEvents.publish("add_shipping_info", resp.gaEvent); //GALogCartStep(5); window.fbPixel.done(function () { fbq('track', 'AddPaymentInfo', {}, { eventID: resp.metaEventId }); }); } }); } function GALogCartStep(step){ if(gaCartTrackingObj){ gaCartTrackingObj.checkout_step = step; gtag('event','checkout_progress',gaCartTrackingObj); } } function LoadCreateBillingAddress() { return Get('bet365在线平台pingCart/Address/CreateBillingAddress') .then(function(data){ $("#billing").html(data); // $('body,html').scrollTo(".billing-address__create"); }); } function LoadListUserBillingAddresses() { return Get('bet365在线平台pingCart/Address/ListUserBillingAddresses') .then(function(data){ $("#billing").html(data); ShowCartSection("#shipping, #billing"); }); } function LoadEditBillingAddress(addressId) { return Get('bet365在线平台pingCart/Address/EditBillingAddress?addressId=' + addressId) .then(function(data){ $("#billing").html(data); }); } function UseBillingAddress() { // error if no ship address selected var address = $("input[name='billAddress']:checked"); var addressId = address.val(); return Post('bet365在线平台pingCart/Address/ChooseBillingAddress', { "addressId": addressId }) .then(function (data) { LoadBilling(); }); } function DeleteBillingAddress(trigger) { if (!confirm('Are you sure you would like to permanently delete this address?')) return false; var addressId = $(trigger).closest(".cart-v4__list-bill-address ").data("id"); return $.ajax({ type: "DELETE", url: Utils.BaseURL + 'bet365在线平台pingCart/Address/RemoveBillingAddress', contentType: "application/json; charset=utf-8", data: JSON.stringify({ "addressId": addressId }) }).then(function(data){ console.log(data); if (data.success){ LoadListUserBillingAddresses(); } }); } function LoadBilling(){ var query = '?token=' + paymentToken + '&paymentMethod=' + paymentMethod; return Get('bet365在线平台pingCart/Checkout/Billing' + query) .then(function(data){ LoadSelectedDelivery(); $("#billing").html(data); ShowCartSection("#billing, #shipping"); }); } function LoadPaymentOptions() { var query = '?token=' + paymentToken + '&paymentMethod=' + paymentMethod; $("#Payment-Options").addClass('d-none'); $('.payment-options-spinner').removeClass('d-none'); return Get('bet365在线平台pingCart/Checkout/PaymentOptions' + query) .then(function(data){ LoadSelectedDelivery(); $("#Payment-Options").html(data); $("#Payment-Options").removeClass('d-none'); $('.payment-options-spinner').addClass('d-none'); ShowCartSection("#billing, #shipping"); }); } function LoadSummary() { return Get('bet365在线平台pingCart/bet365在线平台pingCart/GetCartSummary') .then(function(data){ $(".cart-summary-v4__container").html(data); }); } function ShowCartSection(section) { $(".cart-v4__section-content").removeClass("__active"); $(".cart-v4__section-content").not(section).empty(); $(section).addClass("__active"); } function RegistrationCallback() { // update for ab testing? window.location.replace(Utils.BaseURL + "shoppingcart/checkout"); } function SignInSelection() { return $.ajax({ "type": "POST", "url": Utils.BaseURL + "bet365在线平台pingCart/Login/LogCheckoutLoginSelection" }); } function Get(url){ return $.ajax({ "type": "GET", "url": Utils.BaseURL + url, cache: false }); } function Post(url, reqData){ var data = typeof reqData === 'string' ? reqData : JSON.stringify(reqData); return $.ajax({ type: "POST", url: Utils.BaseURL + url, contentType: "application/json; charset=utf-8", data: data }); } $(function () { initEventHandlers(); }); if(cartScriptLoaded) cartScriptLoaded.resolve(); return { LoadViewCartItems: LoadViewCartItems, LoadCreateShippingAddress: LoadCreateShippingAddress, LoadListUserShippingAddresses: LoadListUserShippingAddresses, LoadDeliveryOptions: LoadDeliveryOptions, LoadBilling: LoadBilling, LoadPaymentOptions: LoadPaymentOptions, RegistrationCallback: RegistrationCallback, LoadSignIn: LoadSignIn, UpdateCartItem: UpdateCartItem, LoadViewCartTotals: LoadViewCartTotals, LoadCreateBillingAddress: LoadCreateBillingAddress, LoadListUserBillingAddresses: LoadListUserBillingAddresses, LoadEditBillingAddress: LoadEditBillingAddress, DeleteBillingAddress: DeleteBillingAddress, UseBillingAddress: UseBillingAddress, GALogCartStep: GALogCartStep, LoadSummary: LoadSummary, SignInSelection: SignInSelection, SelectGuestCheckout: SelectGuestCheckout }; })();; /* Shared */ var showSpinner = function (element) { element.addClass('spinner'); }; var hideSpinner = function (element) { element.removeClass('spinner'); }; var disableButton = function (element) { element.disabled = true; element.classList.add('disabled'); }; var enableButton = function (element) { element.disabled = false; element.classList.remove('disabled'); }; var ShowPaymentError = function (message) { $('.payment-error').html(message); $('.payment-error').removeClass('d-none'); console.log('showing error'); }; /* Promo Codes */ var applyPromo = function (isViewCart) { if ($('.cart-summary-v4__container').length > 0) { $('.cart-v4__promo-code-apply').html(""); } else { $('.cart-v4__promo-code-apply').html(""); } var promo = $('.promo-code-input').val(); $('.cart-v4__promo-code-apply').prop('disabled', true); var url = Utils.BaseURL + 'bet365在线平台pingCart/bet365在线平台pingCart/ApplyPromoCode'; $.post(url, { 'promo': promo, 'isViewCart': isViewCart }) //the load summary needs to happen before re-load placing the response html into the page. the LoadSummary() triggers generating all the totals/discounts calculations. the response //html contains a js call to reload the delivery optoins. in order to get the correct option the cart totals/discounts need to have happened before the response/script are rendered thus this ordering. .then(function (response) { if ($('.cart-summary-v4__container').length > 0) { bet365在线平台pingCartV4.LoadSummary(); } else if ($('.view-cart-summary-v4').length > 0) { bet365在线平台pingCartV4.LoadViewCartTotals(); } //keep passing the response along return response; }) .then(function (response) { $('.cart-v4__promo-code').replaceWith(response); }); }//end applyPromo() var handleApplyEvent = function (e, isViewCart) { if (e.keyCode === 13) { applyPromo(isViewCart); } }; var clearPromoMessages = function () { $('.cart-v4__promo-success').hide(); $('.cart-v4__promo-error').hide(); }; var removePromo = function (promo, isViewCart) { $.ajax({ type: "DELETE", url: Utils.BaseURL + 'bet365在线平台pingCart/bet365在线平台pingcart/RemovePromoCode?promoId=' + promo + '&isViewCart=' + isViewCart, }) .then(function (response) { $('.cart-v4__promo-code').replaceWith(response); }) .then(function (response) { if ($('.cart-summary-v4__container').length > 0) { bet365在线平台pingCartV4.LoadSummary(); } else if ($('.view-cart-summary-v4').length > 0) { bet365在线平台pingCartV4.LoadViewCartTotals(); } }); }; /*End Promo Codes */ //var LoadPaymentOptions = function(){ // var url = Utils.BaseURL + 'bet365在线平台pingCart/Checkout/PaymentOptions; // $.get(url) // .then(function(response){ // console.log(data); // $("#Payment-Options").html(data); // }); //}// /* Payment Options */ var LoadCreditCardCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.card-container').removeClass('d-none'); }; var LoadPayPalCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.paypal-container').removeClass('d-none'); }; var LoadSynchronyCheckout = function () { //$.get(Utils.BaseURL + 'bet365在线平台pingCart/Checkout/Synchrony') // .then(function (data) { // $('#Synchrony').html(data); // $('#Synchrony').removeClass('d-none'); // }); $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.synchrony-container').removeClass('d-none'); }; var LoadSetPayCheckout = function () { //$.get(Utils.BaseURL + 'bet365在线平台pingCart/Checkout/SynchronySetPay') // .then(function (data) { // $('#Synchrony').html(data); // $('#Synchrony').removeClass('d-none'); // }); $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.setpay-container').removeClass('d-none'); }; var LoadWellsFargoCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.wellsfargo-container').removeClass('d-none'); }; var LoadSecondaryFinancing = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.versatile-container').removeClass('d-none'); }; var LoadWellsFargoV2Checkout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.wellsfargov2-container').removeClass('d-none'); } var LoadAffirmCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.affirm-container').removeClass('d-none'); }; var LoadPayLaterCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.pay-later-container').removeClass('d-none'); }; var LoadAcimaCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.acima-container').removeClass('d-none'); }; var LoadStripeCheckout = function () { $('.payment-method-container').each(function () { $(this).addClass('d-none'); }); $('.stripe-container').removeClass('d-none'); }; // Validates Terms and Conditions checkbox. Call method in each integration click handler to make sure checkbox has been checked if it is showing var ValidateTermsCheckbox = function (event) { if ($('input.cart-v4__terms-check').length > 0) { if (!$('input.cart-v4__terms-check').is(':checked')) { //If submit event is passed in, stop the submit. If it's just a click, we don't need to stop anything. if (typeof event !== 'undefined') { event.preventDefault(); } $('.cart-v4__terms-error').text('You need to agree to the terms before continuing.'); return false; } } return true; }; var ClearTermsCheckboxError = function (trigger) { if (trigger.checked) { $('.cart-v4__terms-error').empty(); } }; //Submit payments var SubmitAuthorizeNetPayment = function(opaqueData, onError){ $.ajax({ url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/AuthorizeNetPayment', data: JSON.stringify(opaqueData), contentType: 'application/json', type: 'POST', }) .then(function(data){ console.log('then', data); if (data.Success){ window.location.replace(data.RedirectUrl); } else{ ShowPaymentError(data.ErrorMessage); if (onError){ onError(); } } }).catch(function(e){ console.log('caught error', e.message); }); }; //Handle Client Side Validation Errors var logAuthNetPaymentError = function (response) { console.log(JSON.stringify(response.messages)); //Log the error $.ajax({ type: 'POST', url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/PaymentError', data: JSON.stringify(response.messages), contentType: 'application/json', }); if (!response.opaqueData || !response.opaqueData.datavalue) { //Handle error codes - https://developer.authorize.net/api/reference/features/acceptjs.html#Appendix_Error_Codes var i = 0; while (i < response.messages.message.length) { //Log Error Messages console.log( response.messages.message[i].code + ": " + response.messages.message[i].text ); switch (response.messages.message[i].code) { case 'E_WC_05': // $('#cardNumber').addClass('is-invalid'); ShowPaymentError('Invalid Card Number'); break; case 'E_WC_07': // $('#expirationYear').addClass('is-invalid'); ShowPaymentError('Invalid Expiration Year'); break; case 'E_WC_06': // $('#expirationMonth').addClass('is-invalid'); ShowPaymentError('Invalid Expiration Month'); break; case 'E_WC_08': ShowPaymentError('Invalid Expiration or card has expired.'); break; case 'E_WC_15': // $('#CVV').addClass('is-invalid'); ShowPaymentError('Invalid CVV'); break; default: ShowPaymentError('There was an error processing your payment. Please verify your payment information and try again.'); } i = i + 1; } } //Reset the status so it can be re-submitted with new information. window.authNetHandled = false; window.authNetSubmitted = false; }; /* End Authorize.NET */ /* Start PayPal */ //PayFlow Pro var payFlowValidateCard = function (event) { // Validate terms and conditions checkbox if (!ValidateTermsCheckbox(event)) { return false; } //Verify the cart is in a valid state and hasn't changed so the user can continue with payment. var url = Utils.BaseURL + 'bet365在线平台pingCart/Checkout/PayPalCardCheckoutConfirmation'; $.get(url) .then(function(response){ console.log(response); if (!response.canContinue) { location.replace(url + '?reloadReason=Something Changed in your Cart, please confirm your order details'); } }); var initialHtml = $('#SubmitPayment').html(); $('#SubmitPayment').html("Processing Payment"); var form = $('#PayPal-PayFlowPro-Container>form')[0]; //Disable the button to prevent duplicate submits. disableButton(form.SubmitPayment); form.classList.remove('was-validated'); var expMonth = $('#expirationMonth').val(); var expYear = $('#expirationYear').val(); var expiration = expMonth + expYear; $("#EXPDATE").val(expiration); //Use HTML5 Validation to check regex patterns + other attributes if (form.checkValidity()) { console.log('form was valid'); //Let the form submit go through //return true; form.submit(); return true; } else { event.preventDefault(); $('#SubmitPayment').html(initialHtml); console.log('validation error'); form.classList.add('was-validated'); enableButton(form.SubmitPayment); return false; } }; //PayPal Checkout var handlePayPalResponse = function (data, actions) { }; var paypalCheckoutAuthorizeTransaction = function (data, actions) { return actions.order.authorize().then(function (authorization) { console.log('order authorization success', authorization); console.log(data); $.ajax({ url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/LogPayPalCheckoutResponse', data: JSON.stringify(authorization), contentType: 'application/json', type: 'POST', }); var orderDetails = { 'OrderTimestamp': authorization.create_time, 'PayPalOrderId': authorization.id, 'Intent': authorization.intent, 'OrderAmount': authorization.purchase_units[0].amount.value, 'OrderStatus': authorization.status, 'PayerId': authorization.payer.payer_id, 'Email': authorization.payer.email_address, 'PaymentId': authorization.purchase_units[0].payments.authorizations[0].id, 'PaymentCurrency': authorization.purchase_units[0].payments.authorizations[0].amount.currency_code, 'PaymentAmount': authorization.purchase_units[0].payments.authorizations[0].amount.value, 'PaymentStatus': authorization.purchase_units[0].payments.authorizations[0].status }; console.log('order details', orderDetails); $.ajax({ url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/PayPalCheckoutOrder', data: JSON.stringify(orderDetails), contentType: 'application/json', type: 'POST', }) .then(function (data) { location.replace(data.RedirectUrl); }); }); }; var paypalCheckoutCaptureFunds = function (data, actions) { return actions.order.capture().then(function (details) { console.log('order capture success', details); console.log(data); $.ajax({ url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/LogPayPalCheckoutResponse', data: JSON.stringify(details), contentType: 'application/json', type: 'POST' }); var orderDetails = { 'OrderTimestamp': details.create_time, 'PayPalOrderId': details.id, 'Intent': details.intent, 'OrderAmount': details.purchase_units[0].amount.value, 'OrderStatus': details.purchase_units[0].status, 'PayerId': details.payer.payer_id, 'Email': details.payer.email_address, 'PaymentId': details.purchase_units[0].payments.captures[0].id, 'PaymentCurrency': details.purchase_units[0].payments.captures[0].amount.currency_code, 'PaymentAmount': details.purchase_units[0].payments.captures[0].amount.value, 'PaymentStatus': details.purchase_units[0].payments.captures[0].status }; console.log('order details', orderDetails); $.ajax({ url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/PayPalCheckoutOrder', data: JSON.stringify(orderDetails), contentType: 'application/json', type: 'POST' }) .then(function (data) { location.replace(data.RedirectUrl); }); }); }; var GetSynchronyToken = function (onSuccess, isDigBuy, modalNum) { $.ajax({ "type": "GET", "url": Utils.BaseURL + 'bet365在线平台pingCart/Checkout/SynchronyToken?isDigBuy=' + isDigBuy + '&modalNum=' + modalNum, cache: false, }) .then(function (data) { if (data.success) { console.log('success'); console.log(data); onSuccess(data.clientToken); } else { console.log('synchrony error'); if (data.redirectUrl) { window.location.replace(data.redirectUrl); } else { ShowPaymentError("There was an error"); } } }); }; var GetSynchronyUnifiToken = function () { $.ajax({ "type": "GET", "url": Utils.BaseURL + 'bet365在线平台pingCart/Synchrony/GetSynchronyUnifiPosToken', }) .then(function (data) { if (data.Success) { console.log('success'); console.log(data); onSuccess(data.mppToken); } else { console.log('synchrony error'); if (data.RedirectUrl) { window.location.replace(data.RedirectUrl); } else { ShowPaymentError("There was an error"); } } }); }; var GetSynchronyStatus = function (clientToken, isDigBuy) { console.log(clientToken); $.ajax({ "type": "GET", "url": Utils.BaseURL + 'bet365在线平台pingCart/Checkout/SynchronyStatus?token=' + clientToken + '&isDigBuy=' + isDigBuy, }) .then(function (data) { if (data.Success) { console.log('Synchrony Success'); } //If a redirect url is given, navigate there. If the payment failed, this could be due to an expired client token so they will need to do the combined modal. if (data.RedirectUrl) { console.log('redirecting..'); window.location.replace(data.RedirectUrl); } else { console.log('Synchrony Error'); console.log(data.ErrorMessage); ShowPaymentError(data.ErrorMessage); } }); }; var GetSynchronyUnifiStatus = function (clientToken) { console.log(clientToken); $.ajax({ "type": "GET", "url": Utils.BaseURL + 'bet365在线平台pingCart/Synchrony/UnifiTransactionStatus?posTokenId=' + clientToken, }) .then(function (data) { if (data.Success) { console.log('Synchrony Success'); } //If a redirect url is given, navigate there. If the payment failed, this could be due to an expired client token so they will need to do the combined modal. if (data.RedirectUrl) { console.log('redirecting..'); window.location.replace(data.RedirectUrl); } else { console.log('Synchrony Error'); console.log(data.ErrorMessage); ShowPaymentError(data.ErrorMessage); } }); }; // log synchrony modal data var LogSynchronyModalData = function (formContent) { $.ajax({ type: 'POST', url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/LogSynchronyModal', data: formContent, contentType: 'application/x-www-form-urlendcoded', }); }; var increaseSetPayIframeSize = function () { $('#SetPayIFrame').addClass('stretchFrame'); //.height(1200); }; var decreaseSetPayIframeSize = function () { // $('#SetPayIFrame').height(200); $('#SetPayIFrame').removeClass('stretchFrame'); //.height(1200); }; var PayLaterSubmit = function (event) { // Validate terms and conditions checkbox if (!ValidateTermsCheckbox(event)) { return false; } $('.pay-later-submit').html("Submitting Order"); //Disable the button to prevent duplicate submits. var payLaterButton = $('.pay-later-submit')[0]; disableButton(payLaterButton); $('#PayLaterForm').submit(); //$.post(Utils.BaseURL + 'bet365在线平台pingCart/Checkout/PayLaterSubmit') // .then(function (response) { // console.log(response); // window.location.replace(Utils.BaseURL + response.RedirectUrl); // }); }; var wellsFargoValidateAccount = function (event) { // Validate terms and conditions checkbox if (!ValidateTermsCheckbox(event)) { return false; } var initialHtml = $('#SubmitPayment').html(); $('#SubmitPayment').html("Processing Payment"); var form = $('#PayPal-PayFlowPro-Container>form')[0]; //Disable the button to prevent duplicate submits. disableButton(form.SubmitPayment); form.classList.remove('was-validated'); var expMonth = $('#expirationMonth').val(); var expYear = $('#expirationYear').val(); var expiration = expMonth + expYear; $("#EXPDATE").val(expiration); //Use HTML5 Validation to check regex patterns + other attributes if (form.checkValidity()) { console.log('form was valid'); //Let the form submit go through //return true; form.submit(); return true; } else { event.preventDefault(); $('#SubmitPayment').html(initialHtml); console.log('validation error'); form.classList.add('was-validated'); enableButton(form.SubmitPayment); return false; } }; var WellsFargoOrderReview = function (accountNumber, planNumber) { console.log('loading order review..'); // Validate terms and conditions checkbox //if (!ValidateTermsCheckbox(event)) { // return false; // } //var nextButton = $('.wellsfargo-next'); //nextButton.html("Loading"); //Disable the button to prevent duplicate submits. ///disableButton(nextButton[0]); var query = '?accountNumber=' + accountNumber + '&planNumber=' + planNumber; $.get(Utils.BaseURL + 'bet365在线平台pingCart/Checkout/WellsFargoReviewOrder' + query) .then(function (response) { $('#Payment-Options').html(response); }); }; //old version //var WellsFargoApplyNowClcked = function () { // $.ajax({ // type: 'POST', // url: Utils.BaseURL + 'bet365在线平台pingCart/Checkout/WellsFargoApplyNow', // data: JSON.stringify(CurrentUser) // }); //}; var WellsFargoSaveApplicationResult = function (data) { $.ajax({ type: 'POST', url: Utils.BaseURL + 'bet365在线平台pingCart/WellsFargo/ApplicationResult', data: data }); }; var WellsFargoSavePreQualifyResult = function (data) { $.ajax({ type: 'POST', url: Utils.BaseURL + 'bet365在线平台pingCart/WellsFargo/PreQualify', data: data }); }; var WellsFargoError = function (data) { $.ajax({ type: 'POST', url: Utils.BaseURL + 'bet365在线平台pingCart/WellsFargo/Error', data: data }); }; var WellsFargoLog = function (data) { $.ajax({ type: 'POST', url: Utils.BaseURL + 'bet365在线平台pingCart/WellsFargo/Log', data: data }); }; //Cleanup pasted acct number var cleanupWellsFargoAccountNumber = function (e) { e.preventDefault(); var pastedText = ''; if (window.clipboardData && window.clipboardData.getData) { // IE pastedText = window.clipboardData.getData('Text'); } else if (e.clipboardData && e.clipboardData.getData) { pastedText = e.clipboardData.getData('text/plain'); } this.value = pastedText.replace(/\D/g, ''); }; var resetVModal = function () { $('#V-Modal').modal('hide'); $('.vcredit-frame').hide(); var modalBody = document.getElementById('VModalBody'); if (modalBody) { while (modalBody.firstChild) { modalBody.removeChild(modalBody.firstChild); } } }; var closeVModal = function (event) { if (event.element) { event.element.destroy(); } $('.vcredit-frame').hide(); $('#V-Modal').modal('hide'); }; ; // Made for use with asp.net form button submit with validation function FormButtonSpinner(btn, vgroup) { if (Page_ClientValidate(vgroup)) { FormButtonSpinnerAdd(btn); } } function FormButtonSpinnerAdd(btn) { var css = "fdn-spinner fdn-spinner--xs fdn-spinner--absolute", style = "", top, left, w = $(btn).innerWidth(), h = $(btn).innerHeight(); size = h; if ($(btn).hasClass('cta-btn')) { $(btn).addClass('__loading'); size -= 16; // position spinner on page top = ($(btn).position().top + parseInt($(btn).css('marginTop'), 10)) + ((h / 2) - (size / 2)); left = ($(btn).position().left + parseInt($(btn).css('marginLeft'), 10)) + ((w / 2) - (size / 2)); } else { // position spinner on page top = ($(btn).position().top + parseInt($(btn).css('marginTop'), 10)) + ((h / 2) - (size / 2)); left = ($(btn).position().left + parseInt($(btn).css('marginLeft'), 10)) + (w + (h / 2)); } style += "top:" + top + "px;"; style += "left:" + left + "px;"; style += "width:" + size + "px;"; style += "height:" + size + "px;"; // add spinner once if ($('.fdn-spinner').length == 0) $(btn).after(""); return true; } function MVCButtonSpinnerAdd(btn) { var css = "fdn-spinner fdn-spinner--xs fdn-spinner--absolute", style = "", top, left, w = $(btn).innerWidth(), h = $(btn).innerHeight(); size = h; if ($(btn).hasClass('cta-btn')) { $(btn).addClass('__loading'); size -= 16; // position spinner on page top = ($(btn).position().top + parseInt($(btn).css('marginTop'), 10)) + ((h / 2) - (size / 2)); left = ($(btn).position().left + parseInt($(btn).css('marginLeft'), 10)) + ((w / 2) - (size / 2)); } else { // position spinner on page top = ($(btn).position().top + parseInt($(btn).css('marginTop'), 10)) + ((h / 2) - (size / 2)); left = ($(btn).position().left + parseInt($(btn).css('marginLeft'), 10)) + (w + (h / 2)); } //style += "top:" + top + "px;"; style += "left:" + left + "px;"; style += "width:" + size + "px;"; style += "height:" + size + "px;"; // add spinner once if ($('.fdn-spinner').length == 0) $(btn).after(""); return true; } // Made for use with asp.net form button submit with validation function FormButtonSpinnerRemove(btn) { //blowup spinner - should only be one on page. $('.fdn-spinner').remove(); //remove __loading class if a cta-btn $('.cta-btn').removeClass('__loading'); };