在App Purchase中没有使用iPhone 3,4

时间:2014-02-14 10:47:48

标签: ios iphone in-app-purchase

iphone 5上的一切都很好但是在iPhone 3,4上我按下购买的按钮后得到了交易失败状态... 我几乎尝试了一切,但总是遇到同样的问题,如果你有同样的问题,你知道答案,请帮助它不到一分钟;)谢谢!

    -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions) {
        switch (transaction.transactionState) {
            case SKPaymentTransactionStatePurchasing:{
                // show wait view here
                NSLog(@"Processing...");
                break;
            }
            case SKPaymentTransactionStatePurchased:{
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                // remove wait view and unlock feature 2
                NSLog(@"DONE!");

                [prefs setObject:@"yes" forKey:@"payed"];
                self.buyButton.hidden = TRUE;
                [self getData:@"yes"];
                break;
            }
            case SKPaymentTransactionStateRestored:{
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                NSLog(@"Error payment cancelled2");
                break;
            }
            case SKPaymentTransactionStateFailed:{
                if (transaction.error.code != SKErrorPaymentCancelled) {
                    NSLog(@"Error payment cancelled1:%@",transaction.error.description);
                }
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                break;
            }
            default:{
                break;
            }
        }
    }
}






-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{

    // remove wait view here
    //statusLabel.text = @"";

    int count = [response.products count];

    if (count>0) {
        SKProduct *validProduct = [response.products objectAtIndex:0];

        //SKPayment *payment = [SKPayment paymentWithProduct:validProduct];
        [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
        SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:validProduct];

        [[SKPaymentQueue defaultQueue] addPayment:payment];

    } else {
      // no products found
    }


}

-(void)requestDidFinish:(SKRequest *)request
{

}

-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
    NSLog(@"Failed to connect with error: %@", [error localizedDescription]);
}



#pragma mark AlertView Delegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    NSLog(@"%d",buttonIndex);

    if (alertView==askToPurchase) {
        if (buttonIndex==1) {
            // user tapped YES, but we need to check if IAP is enabled or not.
            if ([SKPaymentQueue canMakePayments]) {

                SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.adam.CrowdControl.adamProduct1"]];

                request.delegate = self;
                [request start];


            } else {
                UIAlertView *tmp = [[UIAlertView alloc]
                                    initWithTitle:@"Prohibited"
                                    message:@"Parental Control is enabled, cannot make a purchase!"
                                    delegate:self
                                    cancelButtonTitle:nil
                                    otherButtonTitles:@"Ok", nil];
                [tmp show];
            }
        }
    }

}

2 个答案:

答案 0 :(得分:1)

我认为这与手机型号无关。

该应用是沙盒模式吗?如果是,则不得在手机上保存任何iTunes帐户。从每个手机上的帐户退出。您可以使用在iTunes Connect中创建的“测试用户”帐户“仅”成功测试。

我假设你在iTunes Connect中做了关于IAP的所有安排,添加了产品与因为你说它在一部手机上工作。

答案 1 :(得分:-1)

您是否向苹果提交了应用版本?您需要提交它,并选择您的应用内商店项目,然后拒绝它(因为还不是最终版本)。  此外,在此之后允许一段时间(大约12个小时左右,因为我看到有时会有很长的延迟)。  还有一件事,使用美国测试账户和为美国商店提交的物品(我记得在过去的项目中失败的任何其他事项)。