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(); return fulfill();
} }
// receipt is from test and should go to test // receipt is from test and should go to test
if (status == 21007) {
return validateWithAppStore(IAP_SANDBOX_URL);
}
return reject(body); return reject(body);
}); });
}); });
@@ -83,10 +80,29 @@ export class IAPValidationRouter extends PromiseRouter {
return getFileForProductIdentifier(productIdentifier, req); return getFileForProductIdentifier(productIdentifier, req);
} }
return validateWithAppStore(IAP_PRODUCTION_URL, receipt).then( () => { function successCallback() {
return getFileForProductIdentifier(productIdentifier, req); return getFileForProductIdentifier(productIdentifier, req);
}, (error) => { };
function errorCallback(error) {
return Promise.resolve({response: appStoreError(error.status) }); return Promise.resolve({response: appStoreError(error.status) });
}
return validateWithAppStore(IAP_PRODUCTION_URL, receipt).then( () => {
return successCallback();
}, (error) => {
if (error.status == 21007) {
return validateWithAppStore(IAP_SANDBOX_URL, receipt).then( () => {
return successCallback();
}, (error) => {
return errorCallback(error);
}
);
}
return errorCallback(error);
}); });
} }