/**
 *
 * to check if current browser support ApplePay
 * @param {boolean}
 * if @returns {false} attach error message Your Device Dose Not Support ApplePay
 */
if (!window.ApplePaySession && dataObj.payment_brands.includes('APPLEPAY')) {
    jQuery('.woocommerce-notices-wrapper')
        .append(`<ul class="woocommerce-error" role="alert"><li> ${dataObj.is_arabic ? 'جهازك او متصفحك لا يدعم الدفع عن طريق ابل' : 'Your Device Or Browser Dose Not Support ApplePay'} </li></ul>`)
}

var wpwlOptions = {

    onReady: function () {
        jQuery('.wpwl-form-virtualAccount-STC_PAY .wpwl-wrapper-radio-qrcode').hide();
        jQuery('.wpwl-form-virtualAccount-STC_PAY .wpwl-wrapper-radio-mobile').hide();
        jQuery('.wpwl-form-virtualAccount-STC_PAY .wpwl-group-paymentMode').hide();
        jQuery('.wpwl-form-virtualAccount-STC_PAY .wpwl-group-mobilePhone').show();
        jQuery('.wpwl-group.wpwl-group-brand').hide() ;
    },
      onBlurCardNumber: function (isValid) {
        let paymentBrand = this.$form.find('.wpwl-control-brand').val();
        if (dataObj.id != 'hyperpay_mada' && paymentBrand == "MADA") {
            setTimeout(function () {
                jQuery('.wpwl-hint-cardNumberError').remove();
                jQuery('.wpwl-control-cardNumber').removeClass('wpwl-has-error');
                jQuery('.wpwl-control-cardNumber').addClass('wpwl-has-error').after('<div class="wpwl-hint wpwl-hint-cardNumberError">mada card is not allowed, please choose mada debit card from the payment options</div>');
                jQuery('.wpwl-button-pay').prop('disabled', true);
            }, 5);
        }
    },
    style: dataObj.style, // <== this style comes from settings page of gateways
    paymentTarget: "_top",
    locale: dataObj.is_arabic ? 'ar' : 'en',
    registrations: {
        hideInitialPaymentForms: true,
        requireCvv: "true"
    },
    browser: {
        threeDChallengeWindow: 5
    }


}

if (dataObj.supported_network) {
    wpwlOptions.applePay = {
        supportedNetworks: dataObj.supported_network
    }
}

