1

我正在沙盒环境中测试我的应用内购买。当我开始“restoreCompletedTransactions”过程时,我得到一个对话框,要求我输入测试用户的密码。如果在那个阶段我只是按取消,我不会收到任何反馈表明该过程已被取消。

有什么建议么

礼萨

4

3 回答 3

7

如果您取消恢复购买paymentQueue:restoreCompletedTransactionsFailedWithError:方法,应该在您的支付交易观察器中调用。

于 2012-09-10T12:17:21.713 回答
0

如果用户单击取消按钮,则请求将失败 - 使用这样的商店观察者......

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

并且这样处理......

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}
于 2012-09-10T12:20:23.117 回答
0

当用户按下取消按钮时,会调用此方法,以便放置适当的消息。

- (void)failedTransaction:(SKPaymentTransaction *)transaction {
     [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
      }
    if (transaction.error.code != SKErrorPaymentCancelled)
     {
    NSLog(@"Transaction error: %@", transaction.error.localizedDescription);
      }


- (void)paymentQueue:(SKPaymentQueue   *)queuerestoreCompletedTransactionsFailedWithError:(NSError *)error {
       NSLog(@"%s","User Cancel.");
      }
于 2014-08-28T10:16:08.730 回答