title: Facebook Realtime Updates Handling Payments
body: <p>I'm working on a Facebook Canvas app, with in-app purchase capabilities. This is where I'm at so far:</p>
  
  <ol>
  <li><p>I've set up my Realtime Updates callback page, and it gets called as desired when transactions have something changed.</p></li>
  <li><p>When the RTU callback gets called, I successfully get the PaymentID, Time, and Changed_Fields.</p></li>
  <li><p>I can successfully process test transactions within my Canvas app, and also get the expected javascript callback within the Canvas app, with payment details.</p></li>
  </ol>
  
  <p>Everything works great so far, but... the problem I'm having is dealing with delayed payment completion, disputes, etc. Using the example scenario of a user making a purchase but closing the browser before closing the final payment dialog: The charge is made, but the in-app javascript callback doesn't get called. So in this situation, all that exists is a charge to the user, and a RTU callback entry that I save to my server db, containing the PaymentID, time, and Changed_Fields (which says nothing but "actions").</p>
  
  <p>First Confusion:</p>
  
  <p>From reading the docs and watching the implementation videos, I'm supposed to be able to call the graph payments API - from my server backend - for payment details when I receive this RTU call. Because this page (which is C# asp.net) is not my APP, I can't for the life of me figure out how I'm to get an app token to make any calls. In all of my searches, every example of getting a token involve a user logging in/authorizing the page to get an access token. As this page is a backend server processing entity, that is impractical. If anybody could shed some light on how I'm supposed to accomplish that, it would be great. I do have the facebook sdk for .net installed, but haven't figured this step out yet.</p>
  
  <p>Second Confusion:</p>
  
  <p>I tried a different route, thinking ok create a unique request_id, create a record with basic information about the purchase that is about to happen, then update that record as necessary when the RTU gets called. That way my app could simply watch for the purchase to have been updated as completed, etc. The problem here though is that a paymentID doesn't exist yet when a purchase is started, and conversely the RTU call doesn't bring any data to work with other than a PaymentID, time and "actions". There is nothing that I can find that links the two events to be able to handle the fulfillment.</p>
  
  <p>Third Confusion:</p>
  
  <p>In the Json data that is sent with the RTU call, Changed_Fields shows as "actions" whether a payment completed or failed. So either I'm missing something completely in this server callback, or it's a matter of my first confusion, how am I supposed to get an app token to call the graph API for details?</p>
  
  <p>This whole thing has me feeling pretty stupid, as there has to be something I'm missing somewhere in the flow. I'm almost out of migraine pills though, so I'm hoping someone can tell me at least what step I'm not getting correct, and maybe some direction on where to find information on making it happen.</p>
  
  <p>Note: I realize these questions are not "code specific", but Facebook says to post questions here. Please forgive me if there is a better place.</p>