In-App Purchase Error - Google Play Store

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gstone
Posts: 17
Joined: Wed Aug 19, 2015 4:19 pm
Location: United Kingdom
Contact:

In-App Purchase Error - Google Play Store

Post by gstone » Wed Sep 07, 2016 1:05 pm

Hi everyone,

I have a problem at the moment where i can not successfully test my in-app purchases via the Google Play Store.

After implementing the following lesson - http://lessons.livecode.com/m/19606/l/1 ... play-store into my application. I did the following:

1). Upload the signed .APK into the Beta environment saved as draft.
2). Signed in on my test device using the test account. (Set-up in the Google console).
3). Downloaded the App onto my device.

I have the following error: Error Authentication is required. You need to sign in to your Google Account.
I don't understand the message as on the test device is only one account. The test account specifically for this.

Just so I am 100% sure on where the App code should be loaded, is anybody able to confirm where i should place some items of code?

For example I currently have this in my non consumable button.

Code: Select all

on mouseUp

  mobileStoreEnablePurchaseUpdates

  mobileStoreSetProductType "com.mycompany.myapp.nonconsumable", "inapp"

  mobileStoreMakePurchase "com.mycompany.myapp.nonconsumable", "1", "This belongs to me"

end mouseUp
The stack code from the guide lives in the stack (Must have that right) with the company identifiers changed.

This is where I became slightly unstuck.. I embedded this code into the non-consumable button as I couldn't see any specific placement on the guide.

Code: Select all

setProp cNonConsumablePurchased pValue

    set the cNonConsumablePurchased of this stack to pValue

  if pValue then

     set the backColor of this stack to 0,255,0

     put "PURCHASED" into fld "purchased"

  else

     set the backColor of this stack to 255,255,255

  end if

end cNonConsumablePurchased
If you could help in anyway I would really appreciate it.

Many thanks,

Gary

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: In-App Purchase Error - Google Play Store

Post by KimD » Wed Sep 07, 2016 9:47 pm

Hi Gary

I'm NOT a LC or Android expert, but I got IAP working through shear bloody minded persistence. I have LC8.0.2 CONSUMABLE in-app purchases working with Android / Google Play Store using the following:

On my "PurchaseIt" button -
... blah blah blah ...
mobileStoreEnablePurchaseUpdates
mobileStoreSetProductType "abc.def.ghi.consumable1", "inapp"
mobileStoreMakePurchase "abc.def.ghi.consumable1", "1", "MyInAppPurchase"
... blah blah blah ...

Within my stack script -
on purchaseStateUpdate pPurchaseID, pProductID, pState
... blah blah blah ...
switch pState
case "paymentReceived"
If pProductID = "abc.def.ghi.consumable1" then
mobileStoreConfirmPurchase pProductID
mobileStoreDisablePurchaseUpdates
mobileStoreConsumePurchase "abc.def.ghi.consumable1"
// then some code that increments a field within the app to give the user more of whatever it is that they have just purchased
End if
... blah blah blah ...

On the Google Play Developer Console > All Applications > MyApp > In App Products
- the product ID of the in-app purchase - that is the text that appears in brackets after the bold text - is set to "abc.def.ghi.consumable1"

On MyApp > Standalone Application Settings > Android:
- I've ticked "In-App Purchasing"
- the Store is set to Google
- I've correctly cut-n-paste the Public Key that google gave me for MyApp

Other than that, make sure that:
- you have verified the GMAIL address for your test account if this is required (I remember that Apple requires this, but I can't remember for Google)
- you download the test app apk from the Google Play Store using the link provided on the beta testing page (if you just search for your app on the play store you can end up with the wrong version)
- the version name & version code numbers that you use in Standalone Settings are greater than the last version name & version code numbers that you submitted to the Google Play Store.

Good luck

Kim

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 818
Joined: Fri Feb 06, 2015 4:03 pm

Re: In-App Purchase Error - Google Play Store

Post by LiveCode_Panos » Wed Sep 07, 2016 9:53 pm

Hi Gary,

The "setProp cNonConsumablePurchased .." code should be put in the stack script. Now, regarding the error you get:

"Error Authentication is required. You need to sign in to your Google Account.",

If I remember correctly, I was getting the same error when I was trying to purchase a product with an invalid identifier (i.e. different from the one registered in Google Play Dev Console):

For example the product ID in the Google Play Dev Console was com.panos.inapp.nonconsumable, but my handler was:

Code: Select all

on mouseUp

  mobileStoreEnablePurchaseUpdates

  mobileStoreSetProductType "com.mycompany.myapp.nonconsumable", "inapp"

  mobileStoreMakePurchase "com.mycompany.myapp.nonconsumable", "1", "This belongs to me"

end mouseUp
So first make sure that you use the same product IDs in both your code and the Google Play Dev Console.

Moreover, make sure that product you want to purchase is marked as "Active" in the Google Play Dev Console.

Last but not least, you might want to test in-app purchases using static responses, i.e. make a purchase request using an item that has a reserved product ID. Each reserved product ID returns a specific static response from Google Play. You can see the lesson for more details.

Regards,
Panos
--

gstone
Posts: 17
Joined: Wed Aug 19, 2015 4:19 pm
Location: United Kingdom
Contact:

Re: In-App Purchase Error - Google Play Store

Post by gstone » Thu Sep 08, 2016 7:44 am

Hello,

Thank you both for your support on this!
I will try and implement changes to my App this evening so hopefully I can get this working.

I will let you know how I get on, appreciate your advice as this has been quite a headache.

Gary

Post Reply

Return to “Android Deployment”