2013-03-15 50 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