当购买确认弹出窗口可见时,支付交易状态是什么?

时间:2013-05-27 19:16:51

标签: ios in-app-purchase

如果在购买确认弹出窗口可见时有什么支付交易状态?

假设是SKPaymentTransactionStatePurchasing,我似乎无法让它工作。

1 个答案:

答案 0 :(得分:0)

枚举SKPaymentTransactionStatePurchasing是指App Store正在处理的交易,而不是处于“购买”应用内购买状态的用户。

相关的方法

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

    for(SKPaymentTransaction *transaction in transactions) {
         NSString *productId = transaction.payment.productIdentifier;

    if(transaction.transactionState == SKPaymentTransactionStateFailed) {
        [self paymentTransactionFailed:transaction.error.code];
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

    }    
    and so on for the other enums
应该从

调用

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {   
    if([response.products count] > 0) {
       SKProduct *product = [response.products objectAtIndex:0];

       SKPayment *paymentRequest = [SKPayment paymentWithProduct:product];
       [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
       [[SKPaymentQueue defaultQueue] addPayment:paymentRequest];
    }    
    handling more than one product in the response if necessary

仅在用户取消或确认应用内购买后才会发生。

来源:http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKPaymentTransaction_Class/Reference/Reference.html