validate_purchase fix for SANDBOX requests (#2253)

* Fixed routing for validate_purchase method

* Fixed validate_purchase endpoint
This commit is contained in:
Valery Vaskabovich
2016-07-12 02:38:42 +03:00
committed by Florent Vilmart
parent 9658d216f3
commit 7a2e906202

View File

@@ -37,9 +37,6 @@ function validateWithAppStore(url, receipt) {
return fulfill();
}
// receipt is from test and should go to test
if (status == 21007) {
return validateWithAppStore(IAP_SANDBOX_URL);
}
return reject(body);
});
});
@@ -82,11 +79,30 @@ export class IAPValidationRouter extends PromiseRouter {
if (process.env.NODE_ENV == "test" && req.body.bypassAppStoreValidation) {
return getFileForProductIdentifier(productIdentifier, req);
}
function successCallback() {
return getFileForProductIdentifier(productIdentifier, req);
};
function errorCallback(error) {
return Promise.resolve({response: appStoreError(error.status) });
}
return validateWithAppStore(IAP_PRODUCTION_URL, receipt).then( () => {
return getFileForProductIdentifier(productIdentifier, req);
return successCallback();
}, (error) => {
return Promise.resolve({response: appStoreError(error.status) });
if (error.status == 21007) {
return validateWithAppStore(IAP_SANDBOX_URL, receipt).then( () => {
return successCallback();
}, (error) => {
return errorCallback(error);
}
);
}
return errorCallback(error);
});
}