在App Purchase中不允许我购买消费品

时间:2015-09-15 23:38:29

标签: ios in-app-purchase skproduct

我正在以沙盒模式测试我的In App Purchase,并且当我尝试购买时,我不断收到消息“此应用内购买已被购买”,其中该产品应该是可消耗的,可以是买了无限次。我尝试过我的应用程序并重新启动它,但它继续给我这个消息。这是一个Xcode Objective C错误,还是这个iOS错误?我非常感谢任何解决这个问题的答案或指导,提前谢谢。

更新:SKPayment代码

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for(SKPaymentTransaction *transaction in transactions){
    switch(transaction.transactionState){
        case SKPaymentTransactionStatePurchasing: NSLog(@"Transaction state -> Purchasing");
            //called when the user is in the process of purchasing, do not add any of your own code here.
            break;
        case SKPaymentTransactionStatePurchased:
            //this is called when the user has successfully purchased the package (Cha-Ching!)
            [self doRemoveAds:validProduct];
            //you can add your code for what you want to happen when the user buys the purchase here, for this tutorial we use removing ads
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            NSLog(@"Transaction state -> Purchased");
            break;
        case SKPaymentTransactionStateRestored:
            NSLog(@"Transaction state -> Restored");
            [self doRemoveAds:validProduct];

            //add the same code as you did from SKPaymentTransactionStatePurchased here
            break;
        case SKPaymentTransactionStateFailed:
            //called when the transaction does not finish
            if(transaction.error.code == SKErrorPaymentCancelled){
                NSLog(@"Transaction state -> Cancelled");
                //the user cancelled the payment ;
            }
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

            break;
    }

0 个答案:

没有答案