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];
    }
   
}

Replies

If you are using a promo code from the App Store then the user makes a regular purchase and when it comes time to pay they enter the code. Your app gets a regular 'purchased' transaction. The user can restoreCompletedTransactions. There is no way for you to recognize that a promo code was used - but in order for a user to get a promo code you have to give it to them.


If you are using your own promo code system then you are violating the guidelines.

Thanks for the info.

@PBK,


followup with the original question:



the promo code is redeem within the appstore and how does the app will know that there is an existing inapp that has been purchase given by the promo code when you open the app?


and yes the promo code will be given to the users. the promo codes is already coordinated with apple that is why it can be redeem in the appstore.


Thanks.

The app handles a purchase with a promo code exactly the same as without the promo code. The only difference is when the user interacts with the App Store (which the app never sees one way or the other) they give the promo code rather than accept a charge to their credit card.

Hi!


Does the restore of an In App purchased with a promo code work only on iOS 10? Because I tested it on an iOS 8 device, and it says that the account has no transaction to restore.


Thank you.

I've redeemed 2 promo-codes for IAP products via the App Store app on my iPhone. Both codes were redeemed without a problem.


When I try to purchase the actual products in my app I still get asked to use Touch ID to confirm the purchase of the product for the full cost, e.g. £19.99 in this case. There is nothing to suggest that a promo-code is being used for the the purchase and that I won't be charged.


I didn't go any further and cancelled at that point.

>I've redeemed 2 promo-codes for IAP products via the App Store app on my iPhone. Both codes were redeemed without a problem. When I try to purchase the actual products in my app....


Are these consumables or non-consumables?


If non-consumables - why do you think you were able to repurchase them - since your app should have indicated they were purchased already?


If consumables - why are you surprised that you are being charged for another purchase?

They're consumables. This is my first experience of promo codes (of any kind) and I didn't know how they work.


So IAP promo codes only work for non-consumables?

I believe they work for anything. But once used, the promo code can't be used a second time. If you use it to purchase a non-consumable then you have purchased that non-consumable and if you want to restore it or 'repurchase for free' you can do that for a non-consumable. Not so with a consumable. Once purchased using a promo code if you want to purchase it again you would need a new promo code.

I'm not grasping how to purchase the consumable with the promo-code though. The promo-code is entered in the App Store app on my device - what now? I then went to my app and tried to purchase the product but was asked to spend the real money.

You wrote above:

> I've redeemed 2 promo-codes for IAP products via the App Store app on my iPhone. Both codes were redeemed without a problem.


If that is the case, it worked. Once a promo code is used it cannot be used again. That is what you would be doing if you tried to make a second purchase of a consumable IAP - each purchase requires a new promo code.


Given your statement above, "I've redeemed ...without a problem", what is your question?

Ok, let's start again here.


The steps were slightly different this time but the end result is the same.


(1) I go to iTunes Connect and generate a new code for a consumable product in my game.

(2) I go to the App Store on my iPhone, scroll down and press the Redeem button.

(3) I enter my code manually and press Redeem in the top-right corner.

(4) I'm asked for my touch id which I give.

(5) I'm told that I've successfully redeemed my code for the in-app purchase (which is why I said before that I had redeemed my code).

(6) I press the OPEN button to launch my app.

(7) I'm asked for my Apple password in the app. I give it, and press the Continue button.


Now what do I do in order to get the consumable product?

Is my app supposed to do something that I've missed out during development?

Is it likely there is a StoreKit event that I'm not handling?


My app is developed with Unity with StoreKit done via a third-party plugin.

I literally signed-up to this forum to get answer to this and the thread stopped here! Did you ever work it out? Thanks.

No I didn't. Haven't tried since.


I'm guessing that there's some event I'm supposed to subscribe to which I don't. Although, I've been doing a bit of experimenting with Unity's IAP system and with that I should get all events so I'll have to go back and try again some time.

I have non-consumable products, promo codes successfully redeemed on appStore but tryed to restore them inside the app and the transactions array is not bringing the products, the state is like they were never purchased. iOS11...