I have added IAP to my Mac Appstore application. I am unable to properly validate the receipt server-side. I am reading the receipt using this code:
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
// This is my own method to convert to base64
NSString *receiptString = [NSData base64forData:receipt];
I am then sending the data to my server which in turn queries https://buy.itunes.apple.com/verifyReceipt to see if the receipt is valid. I always end up with an invalid receipt whatever I'm trying. I have also tried using the gem Venice which has the same issue when I provide it my receipt file as plain text or encoded with base64
command line tool. But at the same time it fails with whichever receipt file I try from all of my apps in /Applications
.
Has anyone successfully implemented receipt validation on the Mac Appstore?
After investigating this a lot more I finally found a gem that works with the Mac Appstore receipts: itunes-receipt
require 'itunes/receipt'
# pass Base64 encoded raw receipt data which you received from your app
receipt = Itunes::Receipt.verify! 'ewoJInNpZ25hdHVyZSIgPSAi...'
receipt.product_id # => 'com.example.products.100gems'
receipt.transaction_id # => '1234567890'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With