IAP in App Store
J. Landman Gay
jacque at hyperactivesw.com
Fri Sep 17 14:52:54 EDT 2021
Here's what I'm doing. The initial request is set up for testing, the capitalized parts will be
removed later.
on purchaseIAPProduct pProductID,pQuantity
-- pProductID = the reverse-domain store ID
-- pQuantity = The number of pProductIDs to purchase. Defaults to 1
if mobileStoreCanMakePurchase() = false then -- purchasing disabled
LOG "mobileStoreCanMakePurchase = FALSE"
doAnswer "Purchasing is not enabled on this device."
exit purchaseIAPProduct
end if
-- init:
put empty into sCurrentStatus
put empty into sIAPErrorText
if pQuantity is not a number then put 1 into pQuantity
if sTimeout is not a number then put 120 into sTimeout
send "IAPtimeout" to me in sTimeout seconds
put the result into sTimerID
IF THE CRELEASE OF THIS STACK <> TRUE THEN PUT "com.wordathand.fpmobile.testsub" INTO pProductID
LOG "BEGIN IAP PURCHASE:" && pProductID
mobileStoreEnablePurchaseUpdates
mobileStoreSetProductType pProductID, "inapp" -- required for Play Store; compatible with
App Store
mobileStoreMakePurchase pProductID, pQuantity
end purchaseIAPProduct
on purchaseStateUpdate pPurchaseID, pProductID, pState
LOG "Purchase state:" && pProductID && pState &&"|" && "PurchaseID:" && pPurchaseID
put pState into sCurrentStatus
... etc.
end purchaseStateUpdate
on IAPtimeout
-- If the process does not complete in sTimeout seconds we wind up here
mobileDisablePurchaseUpdates
put "timeout" into sCurrentStatus
put "Purchase has timed out" into sIAPErrorText
IAPPurchaseComplete false, sCurrentStatus, sIAPErrorText
end IAPtimeout
IAPPurchaseComplete is the equivalent of the lesson's offerPurchase if it receives "true", only
in this case I send data to the backend server. Of course, this handler never gets a chance to run.
One other thing: the fake product ID doesn't have the same reverse-domain as the real products.
I wanted to make sure it didn't get confused with the real ones. I can't imagine that matters
but thought I'd mention it.
On 9/17/21 1:34 PM, panagiotis m via use-livecode wrote:
> Hello Jacque,
>
> How do you initiate a purchase? Have you called
> mobileStoreEnablePurchaseUpdates? This command creates a "channel" for
> communicating with the app store. Since you get no response at all, it
> seems for some reason this channel is not created. Can you share your
> purchase code?
>
> Kind regards,
> Panos
>
> On Fri, 17 Sep 2021, 19:39 J. Landman Gay via use-livecode, <
> use-livecode at lists.runrev.com> wrote:
>
>> After initiating a purchase I get nothing. No dialog, no errors. It acts
>> like I never pushed the button, the app just sits there. I'm logging
>> everything. The log shows my comment that I'm initiating a purchase. There
>> are no other log entries until the timeout message.
>>
>>
>> The product ID matches the one in iTunes Connect exactly, because I copied
>> it from there and pasted it into my script. (I've hard-coded a single
>> product just for testing because I needed one that was a non-renewable
>> subscription so that I could repurchase several times.)
>>
>>
>> There's one thing I didn't mention. Our Ruby programmer set up a server
>> API
>> in Connect so she could get notice of any refunds. Does that mean that all
>> responses would be going to the server? Even so, you'd think I'd get a
>> dialog about my Apple ID. She's turned it off for now and I'll try again
>> shortly, but she doesn't think that would be an issue. Do you know?
>>
>> --
>> Jacqueline Landman Gay | jacque at hyperactivesw.com
>> HyperActive Software | http://www.hyperactivesw.com
>> On September 17, 2021 2:48:49 AM panagiotis m via use-livecode
>> <use-livecode at lists.runrev.com> wrote:
>>
>>> Hello Jacque,
>>>
>>>>>>>> instead the next call to make a purchase should pop up a dialog
>> asking
>>> for an Apple ID
>>> Yes, this is what should happen. What do you get when trying to make a
>>> purchase?
>>>
>>> I take it that the in-app purchase product IDs in your script do match
>> the
>>> ones you set up in iTunes Connect, is that correct?
>>>
>>>>>>>> Is the lesson accurate? I get no response at all from
>>> purchaseStateUpdate.
>>> Yes, the lesson is still accurate, I did test it 2 weeks ago. The
>> response
>>> from purchaseStateUpdate will arrive *after* you get the purchase dialog
>>> and click Buy or Cancel.
>>>
>>> Kind regards,
>>> Panos
>>> --
>>>
>>>
>>> On Fri, 17 Sept 2021 at 01:27, J. Landman Gay via use-livecode <
>>> use-livecode at lists.runrev.com> wrote:
>>>
>>>> I'm trying to test IAP in the App Store. I have a tester account and
>> I'm a
>>>> verified test user
>>>> with a new Apple ID that is not used anywhere else.
>>>>
>>>> Following the LC lesson, it says to sign out of the app store in
>> Settings.
>>>> I had to look up how
>>>> to do that in iOS 14, and did so. It also said not to sign in again
>> while
>>>> in Settings, instead
>>>> the next call to make a purchase should pop up a dialog asking for an
>>>> Apple ID. It does not.
>>>>
>>>> Is the lesson accurate? I get no response at all from
>> purchaseStateUpdate.
>>>> There's a handler in
>>>> the script that triggers a timeout after 2 minutes, and that's all I
>> get.
>>>>
>>>> How do I trigger the sign-in dialog so I can log in as my test account?
>>>>
>>>> --
>>>> Jacqueline Landman Gay | jacque at hyperactivesw.com
>>>> HyperActive Software | http://www.hyperactivesw.com
>>>>
>>>> _______________________________________________
>>>> 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
>>
>>
>>
>>
>> _______________________________________________
>> 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
>
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list