Panos,
Thank you for the reply. Here is my codeā¦. You click a button, and it calls
startInAppPurchase with the number of credits to purchase. After all is done,
pLog is completely empty. This is working perfectly on Android.
on startInAppPurchase numCredits
//setup purchase id
if numCredits = 1 then
put 1001 into productID
put "$0.99" into productAmount
else if numCredits = 2 then
put 1002 into productID
put "$1.99" into productAmount
else if numCredits = 3 then
put 1003 into productID
put "$2.99" into productAmount
else if numCredits = 11 then
put 1011 into productID
put "$9.99" into productAmount
end if
//confirm with user
if numCredits = 1 then
put "Are you sure you want to purchase 1 credit for" && productAmount & "?"
into pString
else
put "Are you sure you want to purchase" && numCredits && "credits for" &&
productAmount & "?" into pString
end if
if myAnswer(pString,"Cancel|Buy Now","Purchase Confirmation","|appBlue") =
"Cancel" then // <-- custom answer dialog
exit startInAppPurchase
end if
//initiate the purchase
mobileStoreEnablePurchaseUpdates
mobileStoreSetProductType productID,"inapp"
mobileStoreMakePurchase productID,"1","testPayload - Android Only"
end startInAppPurchase
on purchaseStateUpdate pPurchaseID,pProductID,pState
global user
global pLog
put pState & cr after pLog
switch pState
case "paymentReceived" //2,1001,paymentReceived
//tell our server is was successful and log users credits to database
if isIPhone() then
put mobileStoreProductProperty(pProductID,"transactionIdentifier") into
tIdentifier
get db_verifyPurchase(pProductID,tIdentifier)
else
//android handled in case "complete"
end if
mobileStoreConfirmPurchase pProductID //Inform the store that the
purchase identifier productID was successfully delivered
mobileStoreDisablePurchaseUpdates
loadMeUp //refresh our display
break
case "error"
answer "Error occured during purchase handling:" & return & return &
mobileStorePurchaseError(pPurchaseID)
mobileStoreDisablePurchaseUpdates
break
case "invalidSKU"
answer "Invalid SKU."
mobileStoreDisablePurchaseUpdates
break
case "alreadyEntitled"
answer "Already Owned."
mobileStoreDisablePurchaseUpdates
break
case "restored"
answer "restored"
offerPurchasedProduct pProductID
mobileStoreConfirmPurchase pProductID
mobileStoreDisablePurchaseUpdates
loadMeUp
break
case "canceled"
case "cancelled"
answer "Purchase Cancelled:" && pProductID
mobileStoreDisablePurchaseUpdates
break
case "complete"
if isAndroid() then
put mobileStoreProductProperty(pProductID,"orderId") into orderId
mobileStoreConsumePurchase pProductID
get db_verifyPurchase(pProductID,orderId)
end if
mobileStoreDisablePurchaseUpdates
break
end switch
end purchaseStateUpdate
Thank you!
-Dan
From: use-livecode <[email protected]> on behalf of
panagiotis m via use-livecode <[email protected]>
Date: Tuesday, August 15, 2023 at 1:33 AM
To: How to use LiveCode <[email protected]>
Cc: panagiotis m <[email protected]>
Subject: Re: Oddities with iOS IAP
Hello Dan,
Could you share the code that makes the purchase, as well as the
purchaseStateUpdate message?
Although, my guess is that this is rather a TestFlight issue, since if it
was an issue in LC's API for in-app purchase on iOS, it would have been
reported
ready.
Kind regards,
Panos
--
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode