Page 1 of 1

Restoring In-App Purchases

Posted: Sat Mar 15, 2014 4:14 am
by joel.epsteinBUS31vi
Hi all -

With your help, I was finally able to get mobile in-app purchasing working. Thanks so much.

But now, I'm struggling with restoring purchases and I'd be ever so grateful for a little more assistance.

As a recap, my purchasing script looks like this:

Code: Select all

on purchaseStateUpdate pPurchaseID
      
      switch mobilePurchaseState(pPurchaseID)
      
      case "initialized"
         break
                  
      case "sendingRequest"
          break
                  
      case "paymentReceived"
         answer "Purchase successful"
         put mobilePurchaseGet(pPurchaseID, "productID") into tProduct
         if mobilePurchaseGet(pPurchaseID, "productID") is "com.projectiveart.1ThingDone.Shake" then
            put "true" into line 6 of gPrefs
         else
            put "true" into line 5 of gPrefs
            set the visible of image "holdon"        of card "display" to false
            set the visible of image "addAnother" of card "display" to true
         end if
         writeScores
         mobilePurchaseConfirmDelivery pPurchaseID
         put true into tComplete
         break
          
      case "restored" 
         answer "Purchase Restored"
         
         if mobilePurchaseGet(pPurchaseID, "productID") is "com.projectiveart.1ThingDone.Shake" then
            put "true" into line 6 of gPrefs
         else
            put "true" into line 5 of gPrefs
            if the visible of image "holdon" is true then
               set the visible of image "holdon"        of card "display" to false
               set the visible of image "addAnother" of card "display" to true
            end if 
         end if
         writeScores
         mobilePurchaseConfirmDelivery pPurchaseID
         put true into tComplete
         
         mobilePurchaseConfirmDelivery purchaseID 
         break 
                 
      case "error"
         answer "Purchase failed" & LF & mobilePurchaseError(pPurchaseID)
         put true into tComplete
         break
                  
      case "cancelled"
         answer "Purchase cancelled"
         put true into tComplete
         break
                  
      end switch
      
      if tComplete then
            mobileDisablePurchaseUpdates
      end if
      
end purchaseStateUpdate
To make a purchase, I use this code in a button script:

Code: Select all

mobilePurchaseCreate "com.projectiveart.1ThingDone.Shake"
put the result into tID
mobileEnablePurchaseUpdates
mobilePurchaseSendRequest tID
all works just fine. Very cool...

I thought that restoring purchases would be simple - by just using the command

Code: Select all

mobileRestorePurchases
in a button script. When I do this, however, the following happens:

I am asked to supply my sandbox ID and password. However, when I enter these values, absolutely nothing happens next. I would have thought that the purchaseStateUpdate handler in my stack script would have been called. But it is not.

Unfortunately, I seem to be missing something rather basic and would be ever so grateful for some additional advice.

Thanks so much.

Joel

Re: Restoring In-App Purchases

Posted: Fri Mar 21, 2014 10:48 pm
by vedus
well i am no sure if this help
try to catch the error or info ?

Code: Select all

try
//your script
catch rlst
answer error rlst