voltrue2 / in-app-purchase

A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
http://iap.gracenode.org
Other
1.04k stars 287 forks source link

Weird iOS validation result #296

Open howg0924 opened 4 years ago

howg0924 commented 4 years ago

One of our customer complained he paid but didn't get the product. After check the log, I found the initial validation failed with the following error:

{"error":{},"status":-1,"message":"Unkown"}

But when I validate the receipt again now, it can be validated correctly.

What does this error mean? Does this mean some sort of network communication error?

Besides, I also found another validation error in the log:

{"error":{},"message":"Unkown"}

Seems both errors were generated through:

https://github.com/voltrue2/in-app-purchase/blob/develop/lib/apple.js#L395

What does these two errors mean? Thank you so much.

stephenDyksen commented 4 years ago

@howg0924 I see the exact same error, and I confirm the same thing... that when I retry the receipt validation a second time later, it works perfectly. Is it possible it is some issue with apple's validation endpoint?

chr4ss1 commented 4 years ago

Change this line:

data.message = errorMap[data.status] || 'Unkown';

to

data.message = errorMap[data.status] || `Unkown code ${data.status}`;

There are also few error codes that are not in the errorMap, namely:


21010 | This receipt could not be authorized. Treat this the same as if a purchase was never made.

21100-21199 | Internal data access error.

I believe it could very well be problem with Apple endpoint. Ideally your infrastructure has built a queue system that works followingly:

If we can't process the receipt for whatever reason (eg network connection failed or Apple gave us some random bullshit), queue the receipt to PurchaseReceiptsToProcess table with retryMaxCount=3 count, and have a CRON job that runs every minute will re-attempt to process it. These purchase receipts can also be manually processed from admin panel if retriesAttempted=3.