应用内购买被拒绝

时间:2014-04-29 02:25:23

标签: ios in-app-purchase

我的应用因以下问题而被拒绝: 错误地实现了收据验证,因此它无法正确区分审核(沙箱)环境和生产环境

我的沙盒环境一切正常但不太确定为什么会这样。我在这里附上我的代码,希望有人可以帮助我看看我可能错过的内容。当事务观察者收到支付队列呼叫时,将触发此代码。

#ifdef DEBUG
#define STORE_URL @"https://sandbox.itunes.apple.com/verifyReceipt"
#endif

#ifdef RELEASE
#define STORE_URL @"https://buy.itunes.apple.com/verifyReceipt"
#endif

-(void)retrieveJSONReceipt:(NSData *)receipt andTransaction:(SKPaymentTransaction *)transaction{
    //Get the JSON receipt
    NSError *error;
    NSDictionary *requestContents = @{@"receipt-data": [receipt base64EncodedStringWithOptions:0]};
    NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents
                                                      options:0
                                                        error:&error];
    if (!requestData) {
        NSLog(@"No requestData with error: %@", [error localizedDescription]);
    }

    //Create a POST request with the receipt NSData
    NSURL *storeURL = [NSURL URLWithString:STORE_URL];
    NSMutableURLRequest *storeRequest = [NSMutableURLRequest requestWithURL:storeURL];
    [storeRequest setHTTPMethod:@"POST"];
    [storeRequest setHTTPBody:requestData];

    void (^completionHandler)(NSData *, NSURLResponse *, NSError *);
    completionHandler = ^(NSData *data, NSURLResponse *response, NSError *error) {
        if(!error){
            NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
            if (!jsonResponse) {
            NSLog(@"Error: %@", [error localizedDescription]);
            }else{
                if ([self validateJSONReceipt:jsonResponse]) {
                    [self verifyPurchaseInReceipt:jsonResponse[@"receipt"] andTransaction:transaction];
                }else{
                    [self removeHUD];
                }
            }
        }
    };
    [[[NSURLSession sharedSession]dataTaskWithRequest:storeRequest
                               completionHandler:completionHandler]resume];
}

这是我从Apple收到的截图。不确定他们在这里要指出的是什么。我应该看到像"这个帐户不是测试用户帐户"如果我登录普通帐户?

enter image description here

0 个答案:

没有答案