in-app-purchase
in-app-purchase copied to clipboard
Adding more details in validation fail error
If google didn't approved purchase and responsed with status 400+ I can get in my app only error message "Status: 400" And thats all. Such answer is not very self describing. Meanwhile method which generates answer for such responses have all nedded data for detailed error message. I mean validateMethod (google.js:227) method
I added here commented line, which put in answer more info about error, for example "Invalid value"
// try live first
validateMethod(function (error, data) {
if (error) {
if (!publicKeyMap.sandbox) {
verbose.log(NAME, 'Failed to validate against:', pubkey, error);
return cb(error, {
status: constants.VALIDATION.FAILURE,
message: error.message,
description: data.message.error.message //added line
});
}
And now this is what I have in my code
What you think about adding this in the library and may be for other responses too?
Hello Thank you for the suggestion. I think it does make sense to pass more detailed error message to the application. I will look into implementing the changes!
Cheers
I'd like to +1 this. It is critical to know exactly what the request error was so we can determine whether a retry is possible or know if 3rd party servers are having issues. For example, Apple occasionally responds to iap and subscription responses with a 500 error and there is no exposure for us to capture that, we just get "Unknown".
In apple.js I'd suggest adding both "res" and "data" to the "// request error" block:
send(prodPath, content, function (error, res, data) {
verbose.log('<Apple>', prodPath, 'validation response:', data);
// request error
if (error) {
// add these 2 lines?
error.res = res;
error.data = data;
// 1 is unknown
status = data ? data.status : 1;
validatedData = {
sandbox: false,
status: status,
message: errorMap[status] || 'Unknown'
};
applyResponseData(validatedData, data);
verbose.log('<Apple>', prodPath, 'failed:', error, validatedData);
error.validatedData = validatedData;
return next(error);
}
Also, it would be great if you could expose the "request" object or provide a way to attach a function to request.on("error", myCustomFunction)
so apps can attach their own logging.
Hello, Apologies for getting back on this issue so late... I will be looking at this issue early next week, also I will consider exposing the request object as @jshanman has suggested.
Cheers!
@voltrue2 Any update on this?
I'm currently getting this error message back from my validation, but it's not that helpful to me:
{"error":{},\"status":1,"message":"Status:400"}
I wonder what it means? 🤔
Any update on this @voltrue2 ? I'm still seeing this error in my logs, and It's really annoying to me, because I don't know why this is happening sometimes...