Validating App store receipt gives DrmInvalidArgumentException

in-app purchase receipt validation tutorial
ios receipt validation
the data in the receipt-data property was malformed or missing
exclude-old-transactions
latest_receipt_info
appstorereceipturl
the shared secret you provided does not match the shared secret on file for your account.
swift receipt sample

I'm following the documentation here.

https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

I have a receipt-data from my team that I'm trying to validate, they're getting error code 21002 which was malformed JSON. It looks like they had extra parameters appended to the base64 data, so I tried removing those and sending:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSData *receipt; // Sent to the server by the device



    // Create the JSON object that describes the request

    NSError *error;

    NSDictionary *requestContents = @{
                                      @"receipt-data": @"<<$mybase64data>>", @"password" : @"<<$thepassword>>"};

    NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents options:0 error:&error];



    if (!requestData) { /* ... Handle error ... */ }



    // Create a POST request with the receipt data.

    NSURL *storeURL = [NSURL URLWithString:@"https://buy.itunes.apple.com/verifyReceipt"];

    NSMutableURLRequest *storeRequest = [NSMutableURLRequest requestWithURL:storeURL];

    [storeRequest setHTTPMethod:@"POST"];

    [storeRequest setHTTPBody:requestData];



    // Make a connection to the iTunes Store on a background queue.

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];

    [NSURLConnection sendAsynchronousRequest:storeRequest queue:queue

                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

                               if (connectionError) {

                                   /* ... Handle error ... */

                                   NSLog(@"conerror %@", connectionError);
                               } else {

                                   NSError *error;

                                   NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];

                                   NSLog(@"hello %@", jsonResponse);
                                   NSLog(@"error %@", error);

                                   if (!jsonResponse) {

                                   }

                               }

                           }];



}

result:

2017-03-03 22:45:47.454 receipttest[89851:352604] hello {
    exception = "com.apple.jingle.mzfairplay.validators.DrmInvalidArgumentException";
    status = 21002;
}
2017-03-03 22:45:47.455 receipttest[89851:352604] error (null)

Something to keep in mind: In this example the data is sent to Apple straight from the App, but you might do this from a server too. When you testing your server App don't use NSLog() to print your base64 data, NSLog truncates data.

Validating App store receipt gives DrmInvalidArgumentException, Validating App store receipt gives DrmInvalidArgumentException - ios. DrmInvalidArgumentException"; status = 21002; } 2017-03-03 22:45:47.455  2 Validating App store receipt gives DrmInvalidArgumentException Mar 14 '17 1 Unable to translate Open Graph Stories in Facebook Apr 7 '14 1 Launch custom Android application from browser and URL shortener Nov 6 '13


I had this issue when using a receipt from a test user that was a couple days old with a yearly auto-renewable subscription.

I checked the above helpful responses about extra characters etc (I also checked I had supplied my app secret for auto-renewable) with no joy.

In the end I tried creating A NEW SANDBOX user and it worked first time 
with no other changes other than the new Receipt!

Hope this helps someone.

Validating Receipts with the App Store, Send this Base64-encoded data to your server. // Get the receipt if it's available if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL  An App Store receipt provides a record of the sale of an app or any purchase made from within the app, and you can authenticate purchased content by adding receipt validation code to your app or server. Receipt validation requires an understanding of secure coding techniques in order to employ a solution that is secure and unique to your


I also received the same error response for serveral receipts. The solution for me was to remove all occurrences of \r\n.

Maybe you have the same issue. I still haven't figured out when and why these chars are inserted.

Decoding an Apple App Store Receipt, Validating App store receipt gives DrmInvalidArgumentException. I'm following Apple Receipt Validation - Auto-Renewable Subscription Error 21004. So I am  In order to validate a purchase, you need to get an App Store receipt. This is the app’s trusted record and in-app purchases that are stored on-device as a single file. The receipt contains an Apple digital signature, an app certificate, and information on purchases. The image below shows the iOS receipt validation. Receipt validation guide


Pay attention to URLENCODE:

- (NSString *)URLEncodedString
{
    // CharactersToBeEscaped = @":/?&=;+!@#$()~',*";
    // CharactersToLeaveUnescaped = @"[].";

    NSString *unencodedString = self;
    NSString *encodedString = (NSString *)
    CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                              (CFStringRef)unencodedString,
                                                              NULL,
                                                              (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                              kCFStringEncodingUTF8));

    return encodedString;
}

ios - Réception de la validation App Store donne , Validating App store receipt gives DrmInvalidArgumentException. I'm following the documentation. Home · iOS & Swift Tutorials In-App Purchases: Receipt Validation Tutorial. In this tutorial, you’ll learn how receipts for In-App Purchases work and how to validate them to ensure your users have paid for the goodies you give them.


App Store receipt validation. How to implement? – Apphud Blog, App Store receipt's contents are a full snapshot a user's in-app-purchase (IAP) It is far from simple but it provides a fascinating look into how the App Store and StoreKit operate. We are using Python to decode and validate the receipt. First​  Genuine purchase receipts—from purchases in the App Store, iTunes Store, iBooks Store, or Apple Music—include your current billing address, which scammers are unlikely to have. You can also review your App Store, iTunes Store, iBooks Store, or Apple Music purchase history.


Receipt Validation · objc.io, J'ai aussi reçu la même réponse d'erreur pour les reçus serveral. La solution pour moi était de supprimer toutes les occurrences de \r\n . Peut-être que vous  PHP receipt validator for Apple iTunes, Google Play and Amazon App Store - aporat/store-receipt-validator. php itunes amazon receipt receipt-validation validation


If user has reinstalled the app or launched it from a new device, you must provide a mechanism to restore his purchases and give access to  Important. This article shows how to use members of the Windows.ApplicationModel.Store namespace to get and validate a receipt for an in-app purchase. If you are using the Windows.Services.Store namespace for in-app purchases (introduced in Windows 10, version 1607, and available to projects that target Windows 10 Anniversary Edition (10.0; Build 14393) or a later release in Visual Studio