Applepay Merchant Validation Optimization

Hi, I am looking to optimize the Merchant Validation process as it is talking some time due to validations from the Apple Server. I am using this code snippet for the merchant validation call:


    session.onvalidatemerchant = function(event) {
        var promise = performValidation(event.validationURL);
        promise.then(function(merchantSession) {
            session.completeMerchantValidation(merchantSession);
        });
    };



And my Ajax Call being :


function performValidation(validateURL) {
    return new Promise(function(resolve) {
        var domain = window.location.hostname;
        $.ajax({
            url: urlPrefix + "/cart/applepay/validateMerchant",
            type: "POST",
            data: { url: validateURL, domainName: domain },
            success: function(data) {
                data = JSON.parse(data);
                resolve(data);
            },
            error: function() {
                resolve("failed");
            }
        })
    })
}



Please let me know if using promises is the right way to go as given in the sample Emporium Code in Apple Website.
Let me know if there are other performance optimizing methods to resolve this.

Applepay Merchant Validation Optimization
 
 
Q