Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: SKPaymentTransactionStateRestored originalTransaction == nil

I have an app which has auto renewable subscriptions, the purchasing of these are fine, however if a user deletes the app and attempts to restore the subscriptions at a later date I'm not getting back the data that'd expect.

According to apple docs, I should recieve an originalTranscation with the details of the initial transaction, in most cases and on the sandbox this is exactly what is happening however on some of our customers live apps we are receiving a nil value for the originalTransaction.

Can anyone think why I would not receive the originalTransaction back? The date sent back in [transaction transactionDate] is the same as I'd expect from [[transaction originalTransaction] transactionDate] however I don't know whether it's safe to assume that if the originalTransaction is nil that the [transaction transactionDate] will always be the date of the originalTransaction.

like image 407
opdude Avatar asked Dec 14 '11 08:12

opdude


1 Answers

I was having exact same issue. I resolved it by checking if original transaction is nil return the current transaction.

here is the code i replaced in - (void)restoreTransaction:(SKPaymentTransaction *)transaction

if (transaction.originalTransaction.payment.productIdentifier) {
    [self provideContentForProductIdentifier:transaction.originalTransaction.payment.productIdentifier];
} else {
    [self provideContentForProductIdentifier:transaction.payment.productIdentifier];
}
like image 124
Sam Avatar answered Sep 19 '22 13:09

Sam