Restoring Promo Code transaction

Hi



We already set up the iTunes Connect for promo codes.

There are promocodes that will give you for example (100 gems when you enter this code)

But the user enters the promo code when purchasing the app. the app behaves just as it would if it had been purchased.


1) My question is how can i determined that he purchased the app using promocode?

2) Also how can i restor his transaction that he already used this promo code?



What framework should i used. StoreKit?,SKPaymentQueue?.



Btw i try this code but no luck..


-(void)checkTransactions{
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
#pragma mark - StoreKit Observer
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
   
    for (SKPaymentTransaction *transaction in transactions) {
       
        switch (transaction.transactionState) {
            case SKPaymentTransactionStatePurchased: {
                /
                /
               
                NSLog(@">>>>>>>>> %lu",(unsigned long)transactions.count);
               
                [[SKPaymentQueue defaultQueue]finishTransaction:transaction];
                break;
            }
               
            case SKPaymentTransactionStateFailed: {
                /
                 NSLog(@"There was a problem with your purchase. Please try again later.");
                break;
            }
               
            case SKPaymentTransactionStateRestored: {
                /
                NSLog(@"Successfully restored your purchase");
                [[SKPaymentQueue defaultQueue]finishTransaction:transaction];
                break;
            }
               
               
            case SKPaymentTransactionStatePurchasing: {
                /
               
                NSLog(@"SKPaymentTransactionStatePurchasing");
               
                break;
            }
               
            default:
                break;
        }
    }
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
    NSMutableArray * purchasedItemIDs = [[NSMutableArray alloc] init];
   
    NSLog(@"received restored transactions: %lu", (unsigned long)queue.transactions.count);
   
    for (SKPaymentTransaction *transaction in queue.transactions)
    {
        NSLog(@"???? %@",transaction.payment.productIdentifier);
       
        NSString *productID = transaction.payment.productIdentifier;
        [purchasedItemIDs addObject:productID];
    }
   
}

I am having a similar problem (on iOS 11). I have redeemed a promo code for a non-consumable IAP. That seems to work fine. However when I go to restore the purchase, my paymentQueue:updatedTransactions:methos is never called and thus the code doesn't know the purchase has been restored. My paymentQueueRestoreCompletedTransactionsFinished: method is called so I believe I have my observer set up correctly.


This used to work in a different version of the app so I'm mystified why this is no longer working. However, I'm now compiling with the latest Xcode and libraries so maybe something has changed there.


I've implemented all the failure notification methods, so I don't think it is "failing".


Some people seem to imply that you can't restore IPA purchases made with a promo code. That seems unlikely. Anyone know if it's really true?


Any thoughts would be appreciated

Restoring Promo Code transaction
 
 
Q