AsjadSiddiqui / in-app-purchase

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

Validating iOS receipts for paid apps with no in-app purchases #1

Open AsjadSiddiqui opened 3 years ago

AsjadSiddiqui commented 3 years ago

in-app-purchase/lib/apple.js

Lines 377 to 390 in feaf563

if (data.receipt[REC_KEYS.IN_APP] && !data.receipt[REC_KEYS.IN_APP].length) { 
     // receipt is valid, but the receipt bought nothing 
     // probably hacked: https://forums.developer.apple.com/thread/8954 
     // https://developer.apple.com/library/mac/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-RECEIPT-HOW_DO_I_USE_THE_CANCELLATION_DATE_FIELD_ 
     data.status = constants.VALIDATION.POSSIBLE_HACK; 
     data.message = errorMap[data.status]; 
     verbose.log( 
         '<Apple>', 
         'Empty purchased detected: in_app array is empty:', 
         'consider invalid and does not validate', 
         data 
     ); 
     return cb(new Error('failed to validate for empty purchased list'), data); 
 } 
AsjadSiddiqui commented 3 years ago

Found a workaround for this as outlined here: #299 (comment)

You can use this to catch the error and check for the following in the error hander: error.validatedData && error.validatedData.status == 2 / VALIDATION.POSSIBLE_HACK /

If this is the case the receipt was valid, but contained no in-app purchases.