Restoring In-App Purchases
Posted: Sat Mar 15, 2014 4:14 am
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:
To make a purchase, I use this code in a button script:
all works just fine. Very cool...
I thought that restoring purchases would be simple - by just using the command
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
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
Code: Select all
mobilePurchaseCreate "com.projectiveart.1ThingDone.Shake"
put the result into tID
mobileEnablePurchaseUpdates
mobilePurchaseSendRequest tID
I thought that restoring purchases would be simple - by just using the command
Code: Select all
mobileRestorePurchases
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