Product ID from SKPaymentTransaction?

Hi,


I'm surprised that the SKPaymentTransaction object doesn't include the productIdentifier of the product that was being purchased.


I need this information in my transaction observer so I can record which product was purchased and configure my app accordingly.


I guess I could keep track of this by recording the last product a user tried to purchase, but that seems error-prone; it doesn't account for restoring transactions on a new device, or the possibility that the transaction observer might be called at a time later than expected, or that two purchases might overlap.


Is there a way to obtain the productIdentifier from the transaction?


Thanks,

Frank

Answered by PBK in 244584022

It does.


transaction.payment.productIdentifier


-(void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
   for(SKPaymentTransaction *transaction in transactions){
        switch (transaction.transactionState){
            case SKPaymentTransactionStatePurchased:
                if([myArrayOfProductIdentifiers containsObject:transaction.payment.productIdentifier]){
                 ////
                }
Accepted Answer

It does.


transaction.payment.productIdentifier


-(void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
   for(SKPaymentTransaction *transaction in transactions){
        switch (transaction.transactionState){
            case SKPaymentTransactionStatePurchased:
                if([myArrayOfProductIdentifiers containsObject:transaction.payment.productIdentifier]){
                 ////
                }

Thanks. The documentation is kind of broken here. I notice now that payment is a property of type SKPayment, but it's not linked in the documentation. You have to manually type it in to the search bar to find it.

Product ID from SKPaymentTransaction?
 
 
Q