在使用Apple服务器验证Apple IOS应用内购买收据时,我们的一些交易返回:
{"status":21002,"exception":"java.lang.NumberFormatException"}
我可以知道问题的原因是什么吗? 我们已按照Apple In-App购买指南进行操作,即我们将使用来自iOS Client的Base 64对应用程序商店退货收据进行编码,然后发送收据以进行验证
注意:我们的大多数交易确实经历过,大约有10%的交易存在上述错误
答案 0 :(得分:8)
有几个可能的原因:
有人试图破解您的IAP收据验证。有些技术会插入虚假收据,希望开发人员不能正确验证它们。 urus hack有这种行为。
测试期间的错误导致测试收据进入生产验证程序。
我经常看到这些错误,但我不记得这两个中的哪一个导致了这个确切的消息。我认为他们都这样做。看到它们后,我还没有客户投诉。
如果您的音量足够低(不幸的是,我的音量),请进入iTunes Connect并查看是否有任何与错误匹配的销售。您还可以查看收据数据,看看它是否可疑。
答案 1 :(得分:0)
还有另一个可能性,你只发送pucharse_info而不是整个解密的JSON(带有单一等)。
var receipt = Ti.Utils.base64encode(evt.receipt).text;
答案 2 :(得分:0)
验证收据时,您可以尝试以下代码:
NSData *receipt; // Sent to the server by the device
// Create the JSON object that describes the request
NSError *error;
NSDictionary *requestContents = @{
@"receipt-data": [receipt base64EncodedStringWithOptions:0]
};
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 ... */
} else {
NSError *error;
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (!jsonResponse) { /* ... Handle error ...*/ }
/* ... Send a response back to the device ... */
}
}];