title: How does IN_APP_NOTIFY works when a refund is performed with Android's In-App Billing?
body: <p>We developed our app using Titanium Studio and Appcelerator offers a free module for <a href="https://marketplace.appcelerator.com/apps/776" rel="nofollow">In-App Billing which only support API v2</a> (I know we should use v3 but we're an indie group so $100 for the module that supports API v3 is a no for the time being).</p>
  
  <p>I've read the documentation on the <a href="http://developer.android.com/google/play/billing/v2/billing_integrate.html" rel="nofollow">In-App Billing workflow for API v2</a>, and so far the purchase logic works like a charm.</p>
  
  <p>That is until we got to the part of the refunds. We have managed products and subscriptions in our app.</p>
  
  <p>According to the documentation, when a refund is made, the <strong><em>IN_APP_NOTIFY</em></strong> event is triggered, which requires us to make a <em>getPurchaseInformation</em> call. What we have doubt is what happens after we make the <em>getPurchaseInformation</em> call. Does a <strong><em>PURCHASE_STATE_CHANGED</em></strong> event is triggered? If it is, then the signed data with the orders is returned updated?</p>
  
  <p>For example, let's say a user Uriel buys Managed Product A, then Uriel asks for a refund. This would trigger an IN_APP_NOTIFY event and a <em>getPurchaseInformation</em> call is made.</p>
  
  <p>What event will be triggered so I can update the app to lock the content previously available to the user? Will <strong><em>PURCHASE_STATE_CHANGED</em></strong> be triggered? If it is, then the signed data with the orders information will be returned empty? In my <strong><em>PURCHASE_STATE_CHANGED</em></strong> I validate if there are orders, if no orders are found, then all of the content is blocked.</p>
  
  <p>So in short, is my guessing right or the work flow for refunds is different?</p>
  
  <p>For reference, here are my <strong><em>PURCHASE_STATE_CHANGED</em></strong> function:</p>
  
  <pre><code>function PURCHASE_STATE_CHANGED_EVENT(e)
  {
      Ti.API.info('PURCHASE STATE CHANGED CALLED');
      Ti.API.info('Signature Verification Result:\n' + VerificationString(e.result));
      Ti.API.info('Signed Data:\n' + e.signedData);
      /*
       * We receive an object that might look like this
       * {
       *  "nonce":-2458019374247073515,
       *  "orders":[
       *   {
       *    "notificationId":"notificationId",
       *    "orderId":"transactionId",
       *    "packageName":"my.package",
       *    "productId":"in_app_identifier",
       *    "purchaseTime":1394062412214,
       *    "purchaseState":0
       *   }
       *  ]
       * }
       */
  
      if (e.signedData != null) {
          var response = JSON.parse(e.signedData);
          /*
           * We are not guaranteed to have any orders returned so 
           * we need to make sure that this one exists before using it.
           * 
           * If there is no notificationId then there is no need to confirmNotifications().
           * This happens when restoreTransactions() triggers a PURCHASE_STATE_CHANGED_EVENT.
           */
          if(response.orders.length === 0)
          {
              Ti.API.info('nothing to restore');
              setNoTransactionsToRestore();
              return;
          }
          for(var i = 0; i &lt; response.orders.length; i++)
          {
              if(typeof response.orders[i] !== 'undefined')
              {
                  Ti.API.info('set purchase flag');
                  setPurchaseFlag(response.orders[i].productId);
              }
              if (response.orders[i] &amp;&amp; response.orders[i].notificationId) 
              {
  
                  Ti.API.info('confirming notification for order ' + JSON.stringify(response.orders[i]));
                  var synchronousResponse = InAppBilling.confirmNotifications({
                      notificationIds: [response.orders[i].notificationId]
                  });
                  displaySynchronousResponseCodes(synchronousResponse);
              }
          }
      }
      else
      {
          Ti.API.info('signed data was null');
      }
  }
  
  InAppBilling.addEventListener(InAppBilling.PURCHASE_STATE_CHANGED_EVENT, PURCHASE_STATE_CHANGED_EVENT);
  </code></pre>
  
  <p>and my <strong><em>IN_APP_NOTIFY</em></strong> function:</p>
  
  <pre><code>function NOTIFY_EVENT(e)
  {
      Ti.API.info('NOTIFY CALLED \n' + 'Notify Id:\n' + e.notifyId);
  
      var synchronousResponse = InAppBilling.getPurchaseInformation({
          notificationIds: [e.notifyId]
      });
      displaySynchronousResponseCodes(synchronousResponse);
  }
  InAppBilling.addEventListener(InAppBilling.NOTIFY_EVENT, NOTIFY_EVENT);
  </code></pre>