在购买产品时的应用购买问题

时间:2013-12-06 13:45:49

标签: ios objective-c in-app-purchase

点击按钮后,我正在进行In app购买 (多次显示我的测试用户的登录提醒)

- (IBAction)BuyProduct:(id)sender {
    SKPayment *payment = [SKPayment paymentWithProduct:_product];
    [[SKPaymentQueue defaultQueue] addPayment:payment];

}

然后代码移至

case SKPaymentTransactionStateFailed:NSLog(@"Transaction Failed");
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

最后我的控制台显示:

2013-12-06 18:56:13.694 sample_purchase[505:60b] Transaction Failed
2013-12-06 18:56:20.553 sample_purchase[505:60b] <SKPaymentQueue: 0x166809c0>: Ignoring restoreCompletedTransactionsWithApplicationUsername: because already restoring transactions
2013-12-06 18:56:21.844 sample_purchase[505:60b] <SKPaymentQueue: 0x166809c0>: Ignoring restoreCompletedTransactionsWithApplicationUsername: because already restoring transactions

请帮忙!

1 个答案:

答案 0 :(得分:1)

这对您有用:

- (void)restoreCompletedTransactions {

    if ([[[SKPaymentQueue defaultQueue] transactions] count]) {

        NSLog(@"We get very non-patient user");

        for (SKPaymentTransaction *transaction in [[SKPaymentQueue defaultQueue] transactions])
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
    }else{

         [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
    }
}