title: In App Purchase : Auto Renewable Subscription Flow
body: <p>I have integrated Monthly Subscription to my app, for this I am using auto renewable in app purchase. 
  Everything is working fine with SandBox build, but I am facing two issues when testing the build via TestFlight.</p>
  
  <ol>
  <li>After a successful purchase, app is still asking me to confirm my Apple ID password with message "<strong><em>Enter password for Apple ID xxxxxx.xxxx.xx to verify iTunes account and allow this device to confirm purchases.</em></strong>"</li>
  <li>After deleting and re installing the app I am trying to buy the previous item, and app shows a popup saying <strong><em>"You are currently Subscribed .......... Manage. OK."</em></strong> When I tap on Ok, nothing happens. I think at this moment <em>"updatedTransactions"</em> delegate should be called with <em>TransactionStatePurchased</em> but nothing is happening. or May be something is happening but I don't know how to debug this in TestFlight build.</li>
  </ol>
  
  <p>I have added the transaction observer to AppDelegate</p>
  
  <pre><code>/*
   * ----------------- FOLLOWING ARE OBSERVERS FOR PAYMENT TRANSACTION ----------------------------
   */
  
  
  -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray&lt;SKPaymentTransaction *&gt; *)transactions
  {
  
      NSLog(@"Count =  %lu",(unsigned long)transactions.count);
      for (SKPaymentTransaction *transaction in transactions)
      {
          switch (transaction.transactionState)
          {
              case SKPaymentTransactionStatePurchasing:
              {
                  NSLog(@"1. Transaction is in Purchasing state");
                  [self handlePurchasingStateFor:transaction withQueue:queue];
                  break;
              }
  
              case SKPaymentTransactionStatePurchased:
              {
                  NSLog(@"2. Transaction is in Purchased state");
                  [self handlePurchasedStateFor:transaction withQueue:queue];
                  break;
              }
  
              case SKPaymentTransactionStateFailed:
              {
  
                  NSString *failMsg = [[NSString alloc]initWithFormat:@"Purchase failed with error: %@",transaction.error.localizedDescription];
                  NSLog(@"3. Error Mesg - %@",failMsg);
  
                  [self handleFailStateFor:transaction withQueue:queue];
                  break;
              }
  
              case SKPaymentTransactionStateRestored:
              {
                  NSLog(@"4. Transaction is Restored");
                  [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                  [self handleRestoreStateFor:transaction withQueue:queue];
                  break;
              }
  
              case SKPaymentTransactionStateDeferred:
              {
                  NSLog(@"5. Transaction is deffered, waiting for parent approval");
                  [self handleDefferedStateFor:transaction withQueue:queue];
                  break;
              }
          }
      }
  }
  
  -(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
  
      if (queue.transactions.count &gt; 0)
      {
          NSDictionary* userInfo = @{@"error": @"Subscription restored successfully."};
          [[NSNotificationCenter defaultCenter] postNotificationName:InAppServicerestoreSuccessful object:self userInfo:userInfo];
      }
      else
      {
          NSDictionary* userInfo = @{@"error": @"There is no product to restore."};
          [[NSNotificationCenter defaultCenter] postNotificationName:InAppServicerestoreFail object:self userInfo:userInfo];
      }
  
  }
  
  -(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
  {
      NSDictionary* userInfo = @{@"error": @"Restore failed, please try again later"};
      [[NSNotificationCenter defaultCenter] postNotificationName:InAppServicerestoreFail object:self userInfo:userInfo];
  }
  
  
  
  /*
   * ------------------------------ CUSTOM METHODS TO HANDLE IN APP STATUS -----------------------
   */
  
  
  -(void)handlePurchasingStateFor:(SKPaymentTransaction*)transaction withQueue:(SKPaymentQueue*)queue {
      NSLog(@"User is attempting to purchase product id: %@",transaction.payment.productIdentifier);
  }
  
  -(void)handlePurchasedStateFor:(SKPaymentTransaction*)transaction withQueue:(SKPaymentQueue*)queue {
      NSLog(@"User purchased product id: %@",transaction.payment.productIdentifier);
      [queue finishTransaction:transaction];
  
      NSDictionary* userInfo = @{@"error": @"Purchase is successful, you are all set."};
      [[NSNotificationCenter defaultCenter] postNotificationName:InAppServicepurchaseSuccessful object:self userInfo:userInfo];
  }
  
  -(void)handleRestoreStateFor:(SKPaymentTransaction*)transaction withQueue:(SKPaymentQueue*)queue {
      NSLog(@"User restored product id: %@",transaction.payment.productIdentifier);
      [queue finishTransaction:transaction];
  }
  
  -(void)handleFailStateFor:(SKPaymentTransaction*)transaction withQueue:(SKPaymentQueue*)queue {
      NSLog(@"User failed to purchase product id: %@",transaction.payment.productIdentifier);
  }
  
  -(void)handleDefferedStateFor:(SKPaymentTransaction*)transaction withQueue:(SKPaymentQueue*)queue {
      NSLog(@"App is waiting for parental permission for product id : %@",transaction.payment.productIdentifier);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NTVni.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NTVni.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/Ff2Hp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ff2Hp.png" alt="enter image description here"></a></p>