开发者

In App Purchase does not change its state to SKPaymentTransactionStatePurchased

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 J开发者_开发知识库an 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜