in-app-purchase icon indicating copy to clipboard operation
in-app-purchase copied to clipboard

Adding more details in validation fail error

Open F0RIS opened this issue 7 years ago • 5 comments

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 image

What you think about adding this in the library and may be for other responses too?

F0RIS avatar Oct 08 '17 09:10 F0RIS

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

voltrue2 avatar Oct 10 '17 02:10 voltrue2

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.

jshanman avatar Jun 04 '19 18:06 jshanman

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 avatar Jun 06 '19 01:06 voltrue2

@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? 🤔

svzi avatar May 26 '20 12:05 svzi

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...

svzi avatar Jul 01 '20 19:07 svzi