本文介绍了在App Purchase中,其状态不会更改为SKPaymentTransactionStatePurchased的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将应用购买功能添加到我的iphone-ipad应用程序中,它现在正在app store中运行。我正在更新此应用并使用以下方法获取交易状态通知

   - (无效)paymentQueue:(SKPaymentQueue *)队列updatedTransactions :(NSArray *)交易
{
for(SKPaymentTransaction *交易中的交易)
{
NSLog(@付款队列);
switch(transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
休息;
case SKPaymentTransactionStateFailed:
NSLog(@付款未完成);
[self failedTransaction:transaction];
休息;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
休息;
案例SKPaymentTransactionStatePurchasing:
NSLog(@试图购买);
休息;
默认值:
NSLog(@Buraya giriyor);
休息;
}
}

}



但问题是当我尝试连接到沙盒服务器时,我得到了事务失败状态。一切都与应用商店中的工作相同。我刚刚在应用中更新了一些视图。在商店中使用该应用程序时,它会询问AppleID并要求确认下载内容。当我在应用程序购买测试时,它也要求这个AppleID和确认。但现在,虽然它找到并获得了产品标识符,但它不会要求这些确认。







Fri Jan 9 04:14:19 iPod-touch CCDergi [1740]:indirilenappkey = 201107



两行之间的日志信息属于我试图购买的产品。

一个产品,我想买。周一9月4日04:14:21 iPod-touch CCDergi [1740] :----------------------------------------------



Fri Jan 9 04:14:21 iPod-touch CCDergi [1740]:产品名称:Call Center Life Issue 8



Fri Jan 9 04:14:21 iPod-touch CCDergi [1740]:产品描述:Call Center Life Magazine第8期



Fri Jan 9 04:14: 21 iPod-touch CCDergi [1740]:产品价格:2.99



Fri Jan 9 04:14:21 iPod-touch CCDergi [1740]:产品编号:com.selvitech .cclife.201107



周五1月9日04:14:21 iPod-touch CCDergi [1740]:--------------- -------------------------------



Fr. i Jan 9 04:14:21 iPod-touch CCDergi [1740]:购买Dergi



Fri Jan 9 04:14:21 iPod-touch CCDergi [1740]:付款方式队列



Fri Jan 9 04:14:21 iPod-touch CCDergi [1740]:试图购买



1月9日星期五04:14:25 iPod-touch CCDergi [1740]:付款队列



Fri Jan 9 04:14:25 iPod-touch CCDergi [1740]:付款方式未完成






可能是什么问题?我错过了什么?



提前谢谢..

解决方案

**(取消..这对我不起作用,虽然它可能对其他人有用)



我注意到transactionReceipt方法不可用在iOS9上。它返回nil值而不是收据数据。因此,使用此方法的某些应用程序无法购买。从iOS7开始不推荐使用此方法。最后它变得不起作用了。

  NSData receipt = [transaction transactionReceipt]; //总是在ios9上返回nil 

您应该使用[NSBundle appStoreReceiptURL]来获取收据数据。

  NSURL * url = [[NSBundle mainBundle] appStoreReceiptURL]; 
NSData * receipt = [NSData dataWithContentsOfURL:url]; //工作正常。

一旦我尝试将其集成到我的App中进行测试,我会更新。


I have added in app purchase feature to my iphone-ipad application and it is working in app store right now. I am updating this app and using method below to get transaction State notification

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        NSLog(@"Payment Queue");
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                NSLog(@"Payment not finished");
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
                break;
            case SKPaymentTransactionStatePurchasing:
                NSLog(@"Trying To Purchase");
                break;
            default:
                NSLog(@"Buraya giriyor");
                break;
    }
}

}

but the problem is when i try to connect to sandbox servers i get transaction failed state. Everything is the same with the working one in the app store. I just updated some views in the app. While using the app in the store it asks about AppleID and asks for a confirmation to download content. While i was testing in app purchase it was also asking for this AppleID and confirmation. But now, although it finds and gets the product identifiers it does not ask for these confirmations.



Fri Jan 9 04:14:19 iPod-touch CCDergi[1740] : indirilenappkey = 201107

The log info between two lines belong to the product that i am trying to buy.


Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : ----------------------------------------------

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Product title: Call Center Life Issue 8

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Product description: Issue 8 of the Call Center Life Magazine

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Product price: 2.99

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Product id: com.selvitech.cclife.201107

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : ----------------------------------------------

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Purchase Dergi

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Payment Queue

Fri Jan 9 04:14:21 iPod-touch CCDergi[1740] : Trying To Purchase

Fri Jan 9 04:14:25 iPod-touch CCDergi[1740] : Payment Queue

Fri Jan 9 04:14:25 iPod-touch CCDergi[1740] : Payment not finished



What may be the problem? What is it that I am missing?

Thank you in advance..

解决方案

**(Cancel that.. this didn't work for me, though it may still be helpful for others)

I noticed transactionReceipt method is not available on iOS9. It return nil value instead of a receipt data. So some apps using this method fail in purchase. This method is deprecated since iOS7. At last It became not working.

    NSData receipt = [transaction transactionReceipt]; //always return nil on ios9  

You should use [NSBundle appStoreReceiptURL] to get receipt data.

    NSURL* url = [[NSBundle mainBundle] appStoreReceiptURL];  
    NSData* receipt = [NSData dataWithContentsOfURL:url]; //works fine. 

I will update once I try to integrate this into my App for testing.

这篇关于在App Purchase中,其状态不会更改为SKPaymentTransactionStatePurchased的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:36