Apple在App中购买StoreKit错误 [英] Apple In app purchase StoreKit error

查看:151
本文介绍了Apple在App中购买StoreKit错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施书架的应用购买功能,但在购买图书时会出现错误消息。

I am implementing in app purchase feature for a bookshelf but an error message RANDOMLY appear during purchasing books.

错误消息是
付款请求是仅限于通过Store Kit的didReceiveResponse方法返回的产品。

The error message is "Payment requests are restricted to products returned as valid via Store Kit's didReceiveResponse method."

我在apple中找到该文件
http://developer.apple.com/library/ios/#qa/qa2010/qa1691.html
但它没有帮助解决问题...

I find the document in apple http://developer.apple.com/library/ios/#qa/qa2010/qa1691.html but it does not help to solve the problem...

同时观察者打印出另一个错误:无法连接到iTunes Store。

in the same time observer print out another error : "Can't connect to the iTunes Store".

我的应用内购买逻辑流程:

my in app purchase logic flow:

APP START:

APP START:

- (void) requestProductDataWithSet:(NSSet*)_set
{
 SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: _set];
 request.delegate = self;
 [request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    //setup UI here
}

购买:

- (void) purchase:(SKProduct *)product
{
 if (!product || !verified) {
  return;
 }

 SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:product.productIdentifier]];
 request.delegate = self;
 [request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
if ([SKPaymentQueue canMakePayments] && [response.products count] > 0)
{
    NSLogInfo(@"xxxxxxxxx Make payment xxxxxxxxx");
    SKPayment *payment = [SKPayment paymentWithProduct:[response.products objectAtIndex:0]];
    [[SKPaymentQueue defaultQueue] addPayment:payment];   
  }
  else
  {
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Purchase" message:@"You are not authorized to purchase from AppStore"
                 delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
   [alert show];
   [alert release];
  }
    }

观察员:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
 for (SKPaymentTransaction *transaction in transactions)
 {
  NSLogInfo(@"updatedTransactions transactionState:%d, productIdentifier:%@",transaction.transactionState,transaction.payment.productIdentifier);
  switch (transaction.transactionState)
  {
   case SKPaymentTransactionStatePurchased:

                [self completeTransaction:transaction];

                break;

            case SKPaymentTransactionStateFailed:

                [self failedTransaction:transaction];

                break;

            case SKPaymentTransactionStateRestored:

                [self restoreTransaction:transaction];

            default:

                break;
  }   
 }
}


推荐答案

看起来问题不在你身边。根据技术Q& A QA1691 ,您的代码很好。

It looks like the problem isn't on your side. According to Technical Q&A QA1691, your code is fine.

这篇关于Apple在App中购买StoreKit错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆