2013-03-15 99 views
8

当与苹果服务器验证苹果IOS应用程序内购买收据,由于一些我们的交易回报:的iOS应用程序内购买状态21002,java.lang.NumberFormatException

{"status":21002,"exception":"java.lang.NumberFormatException"} 

我可以知道什么原因问题? 我们已经按照苹果应用内购买指南,即我们将从iOS客户端的Base 64编码应用商店返回收据,然后发送收据用于验证目的

注意:我们的大部分交易确实通过,约10%的上述错误

回答

8

几个可能的原因事务:

  • 有人试图破解您的IAP收汇核销。有一些技术会插入虚假收据,希望开发人员无法正确验证它们。 urus hack有这种行为。

  • 测试过程中的错误导致测试收据发送给生产验证者。

我已经经常看到这些错误,但我只是不记得这两个中的哪一个会导致这个确切的消息。我认为他们都这样做。看到他们后,我还没有收到客户的投诉。

如果您的音量足够低(不幸的是,我的是),请进入iTunes Connect并查看是否有任何与该错误相匹配的销售。您还可以查看收据数据,看看它是否看起来可疑。

0

有彼此posibility,你只发送pucharse_info而不是整个解密的JSON(有singature等)

var receipt = Ti.Utils.base64encode(evt.receipt).text; 
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 ... */ 
    } 
}]; 

参考:https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1