Skip to content

Commit 7a2e906

Browse files
ValeryVaflovilmart
authored andcommitted
validate_purchase fix for SANDBOX requests (#2253)
* Fixed routing for validate_purchase method * Fixed validate_purchase endpoint
1 parent 9658d21 commit 7a2e906

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/Routers/IAPValidationRouter.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ function validateWithAppStore(url, receipt) {
3737
return fulfill();
3838
}
3939
// receipt is from test and should go to test
40-
if (status == 21007) {
41-
return validateWithAppStore(IAP_SANDBOX_URL);
42-
}
4340
return reject(body);
4441
});
4542
});
@@ -82,11 +79,30 @@ export class IAPValidationRouter extends PromiseRouter {
8279
if (process.env.NODE_ENV == "test" && req.body.bypassAppStoreValidation) {
8380
return getFileForProductIdentifier(productIdentifier, req);
8481
}
82+
83+
function successCallback() {
84+
return getFileForProductIdentifier(productIdentifier, req);
85+
};
86+
87+
function errorCallback(error) {
88+
return Promise.resolve({response: appStoreError(error.status) });
89+
}
8590

8691
return validateWithAppStore(IAP_PRODUCTION_URL, receipt).then( () => {
87-
return getFileForProductIdentifier(productIdentifier, req);
92+
93+
return successCallback();
94+
8895
}, (error) => {
89-
return Promise.resolve({response: appStoreError(error.status) });
96+
if (error.status == 21007) {
97+
return validateWithAppStore(IAP_SANDBOX_URL, receipt).then( () => {
98+
return successCallback();
99+
}, (error) => {
100+
return errorCallback(error);
101+
}
102+
);
103+
}
104+
105+
return errorCallback(error);
90106
});
91107
}
92108

0 commit comments

Comments
 (0)