Macos 验证Mac应用商店接收服务器端

Macos 验证Mac应用商店接收服务器端,macos,mac-app-store,receipt-validation,Macos,Mac App Store,Receipt Validation,我已将IAP添加到我的Mac Appstore应用程序中。我无法在服务器端正确验证收据。我正在使用以下代码阅读收据: NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL]; NSData *receipt = [NSData dataWithContentsOfURL:receiptURL]; // This is my own method to convert to base64 NSString *receiptSt

我已将IAP添加到我的Mac Appstore应用程序中。我无法在服务器端正确验证收据。我正在使用以下代码阅读收据:

NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];

// This is my own method to convert to base64
NSString *receiptString = [NSData base64forData:receipt];
然后,我将数据发送到我的服务器,服务器反过来查询收据是否有效。不管我想做什么,我总是得到一张无效的收据。我还尝试使用,当我以纯文本形式或使用
base64
命令行工具进行编码时,它也有相同的问题。但同时,无论我从
/Applications
中的所有应用程序中尝试哪个接收文件,它都会失败


是否有人成功地在Mac Appstore上实施了收据验证?

在深入调查之后,我终于找到了一个适用于Mac Appstore收据的gem:

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'