Closed triplef closed 4 years ago
I was able to achieve the above by passing my own callback function to validate() like this:
const validatedData = await new Promise((resolve, reject) => {
iap.validate(
receipt,
(error, response) => {
if (error) {
error.validatedData = response; // attach validation data to error
reject(error);
} else {
resolve(response);
}
}
);
});
We have a use case where we want to process Apple receipts without IAPs and access metadata like "original_application_version".
Unfortunately the following code in apple.js currently causes the library to throw an exception for this case: https://github.com/voltrue2/in-app-purchase/blob/65b058f0c764fcbe7f5c86082bea3dddb2474f90/lib/apple.js#L377-L390
Is there a way to call
iap.validate()
with such a receipt and still access thedata.receipt
field? It is passed as the second parameter to the callback in line 389 above, but I haven’t found a way to access it, as the "catch" block will only allow you to reference the first (error) parameter.Thanks!