The process of making a purchase will typically go like this.
The key commands involved in this process are -
Code to handle a purchase could look like this.
InAppPurchaseActivate ( 0 )
do if GetInAppPurchaseState ( ) = 1 exit endif
sync ( ) loop
if GetInAppPurchaseAvailable ( 0 ) = 1 // provide the content endif
The call to InAppPurchaseActivate starts the process of purchasing the product with ID 0. In our case this is "productID1". After calling this command it is necessary to wait and check the state of the in app purchase.
The do loop checks the state of the purchase by calling GetInAppPurchaseState. Inside the do loop is a call to sync. This is important - you cannot simply wait in a loop without passing control back to AppGameKit, so ensure you call sync while waiting. Bear in mind that there may be a small delay after calling InAppPurchaseActivate prior to any dialogs appear on screen, therefore at this point it would be a good idea to display something on screen indicating to the user that an attempt is being made to purchase the product.
The final stage is a call to GetInAppPurchaseAvailable. If this returns 1 then the purchase was a success and our product can be presented to the user. If this returns 0 then something went wrong e.g. the user decided to cancel at some point in the process or the payment failed to go through, in which case we must not let the user have the product.