Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate_purchase fix for SANDBOX requests #2253

Merged
merged 2 commits into from
Jul 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/Routers/IAPValidationRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down Expand Up @@ -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);
});
}

Expand Down