1

在确认您的应用内购买后,我将取消购买。在 iOS 6.1 中取消后,控制转移到- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions方法。

在 iOS 5.1 中,不会调用任何委托方法。所以我无法控制取消交易的应用程序。

我购买产品的代码:

- (void)buyProduct:(SKProduct *)product
{
    NSLog(@"Buying %@...", product.productIdentifier);

    SKPayment * payment = [SKPayment paymentWithProduct:product];
    [[SKPaymentQueue defaultQueue] addPayment:payment];

}

委托方式:

#pragma mark SKPaymentTransactionOBserver

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    NSLog(@"updated 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];
            case SKPaymentTransactionStatePurchasing:
                NSLog(@"SKPaymentTransactionStatePurchasing");
                break;
            default:
                break;
        }
    };
}

请让我知道是什么问题。

4

1 回答 1

2
I found the solution. It was working in both iOS in device. The Problem is of validate receipt. If you are testing inApp purchase using test user then you need to use sandbox verify receipt that is
 #define  TMS_SANDBOX_VERIFY_RECEIPT_URL @"https://sandbox.itunes.apple.com/verifyReceipt". but when you are uploading app to the appstore then you need to change it to 
#define ITMS_PROD_VERIFY_RECEIPT_URL  @"https://buy.itunes.apple.com/verifyReceipt". 

So when user download the app from the app store then for the valid receipt verification 'ITMS_PROD_VERIFY_RECEIPT_URL' is must. otherwise it will give failed receipt verification. 

So please use  #define ITMS_PROD_VERIFY_RECEIPT_URL  @"https://buy.itunes.apple.com/verifyReceipt" when you are uploading app to the app store.
于 2013-06-25T04:38:59.107 回答