Consumable in-app purchases

Hi, I am trying to create in my game in the app store so that players can buy virtual currencies which are consumables. But I'm a little unsure if my approach is correct or not. So I think it would be nice to ask for help here.

After clicking the Buy button, the buyProductIdentifier is called

- (void)buyProductIdentifier:(NSString *)productIdentifier {

  NSLog(@"Buying %@...", productIdentifier);

  SKPayment *payment = [SKPayment paymentWithProductIdentifier: productIdentifier];
  [[SKPaymentQueue defaultQueue] addPayment:payment];



and then complete the payment

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions


  for (SKPaymentTransaction *transaction in transactions)
    switch (transaction.transactionState)
        case SKPaymentTransactionStatePurchased:
            [self completeTransaction:transaction];
        case SKPaymentTransactionStateFailed:
            [self failedTransaction:transaction];
//      case SKPaymentTransactionStateRestored:
//          [self restoreTransaction:transaction];


I tried commenting out the SKPaymentTransactionStateRestored case to force the player to make a purchase every time, rather than popping up a message saying "you already bought this but it hasn't been downloaded."

Is this approach correct? if not can you guys give me some advice?

Many thanks.


source to share

1 answer

I don't think this is a code issue.

Are you sure you have created an In-App Purchase in iTunes Connect as Consumable?

If you selected "Non-Consumable", you can only buy the item once.



All Articles