Oddities with iOS IAP
panagiotis m
merakosp at gmail.com
Tue Aug 15 13:22:34 EDT 2023
Hello Dan,
Just a rough guess, in the purchaseStateUpdate msg, you have:
mobileStoreConfirmPurchase pProductID //Inform the store that the purchase
identifier productID was successfully delivered
mobileStoreDisablePurchaseUpdates
in both cases for paymentReceived and restored.
Could you try commenting out the mobileStoreDisablePurchaseUpdates in these
2 cases? Once you call mobileStoreConfirmPurchase, it informs the store
that the purchase was successful, and then the store sends another
"purchaseStateUpdate" with state=complete.
But if you call mobileStoreDisablePurchaseUpdates just after
mobileStoreConfirmPurchase then this stops the communication with the
store. I suggest having mobileStoreDisablePurchaseUpdates just in the
"complete" case and remove it from "paymentReceived" and "restored".
Note that on Android (if I remember correctly)
mobileStoreEnablePurchaseUpdates/mobileStoreDisablePurchaseUpdates do not
actually do something - but they are added for consistency.
If you do this change, and still see the delay, then it is likely a
TestFlight/Sandbox issue. Note that Apple's sandbox servers are slower than
the actual ones used by StoreKit.
(e.g.
https://community.revenuecat.com/sdks-51/testflight-clicking-subscriptions-or-iaps-has-long-delay-2687
)
kind regards,
Panos
--
On Tue, 15 Aug 2023 at 17:49, Dan Friedman via use-livecode <
use-livecode at lists.runrev.com> wrote:
> 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 <use-livecode-bounces at lists.runrev.com> on behalf of
> panagiotis m via use-livecode <use-livecode at lists.runrev.com>
> Date: Tuesday, August 15, 2023 at 1:33 AM
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Cc: panagiotis m <merakosp at gmail.com>
> 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
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list