Jack.Right
Jack.Right

Reputation: 994

how to get transaction id in inAppPurchase

in my app i am implementing inAppPurchase. Problem : while testing App in test account i am showing the popup of transaction complete. but i dont know how to get transaction id.

here is my code

-(void)paymentQueue:(SKPaymentQueue *)queue

updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) {

    switch (transaction.transactionState) {
        case SKPaymentTransactionStatePurchasing:
            NSLog(@"Purchasing");
            break;
        case SKPaymentTransactionStatePurchased:
            if ([transaction.payment.productIdentifier
                 isEqualToString:kTutorialPointProductID]) {
                NSLog(@"Purchased ");
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:
                                          @"Purchase is completed succesfully" message:nil delegate:
                                          self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
                [alertView show];
                _shipbutton.hidden=FALSE;
            }

            if ([transaction.payment.productIdentifier
                 isEqualToString:kTutorialPointProductID45]) {
                NSLog(@"Purchased ");
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:
                                          @"Purchase is completed succesfully" message:nil delegate:
                                          self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
                [alertView show];
                _shipbuttonPremium.hidden=FALSE;
            }


            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            break;
        case SKPaymentTransactionStateRestored:
            NSLog(@"Restored ");
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            break;
        case SKPaymentTransactionStateFailed:
            NSLog(@"Purchase failed ");
            break;
        default:
            break;
    }
}

}

i am requesting product and getting that product identifier or even transaction is also giving success message. so how can i get transaction id?

Upvotes: 1

Views: 3087

Answers (1)

Satyanarayana
Satyanarayana

Reputation: 1067

// i think it will help for you

        for (SKPaymentTransaction * transaction in transactions) {
    switch (transaction.transactionState)
    {

        case SKPaymentTransactionStatePurchased:
           NSLog(@"id ===> %@",transaction.transactionIdentifier);
            break;
        case SKPaymentTransactionStateFailed:
            break;
        case SKPaymentTransactionStateRestored:
            NSLog(@"id ===> %@",transaction.transactionIdentifier);
        default:
           NSLog(@"Deafault");
            break;
    }
};

Upvotes: 1

Related Questions