Android Tutorial Android In-app Billing tutorial

flyingbag

Member
Licensed User
One workaround to add subscription is as follows:

-Store the user's app install date in a database on your own server
-Your server can check when a certain time frame is done (such as a week or a month or whatever.
-Then you prompt an "In App Billing" for a "Managed" or "Unmanaged Product" that allows usage for "X" number of days
- The in-app billing library can be used as is for the above step
-Update your Database accordingly with new end date
- Use the server and database to check and repeat at your desired subscription interval

I have an app that uses the above workaround and is working fine

I could do a donation aswell, since a project that's 90+% finished will get cancelled if I can't add the subscription stuff (they requested it when it was already at this stage tho, so lesson learned... next time they can put it all on paper and if stuff change I can still decide if I want to add it or not and for what price)
 

flyingbag

Member
Licensed User
Hi Erel,
With the in-APP billing version 3 API
In-app Billing Overview | Android Developers there is a mention as follows:

Migration Considerations
If you have an existing In-app Billing implementation that uses Version 2 or earlier, it is strongly recommended that you migrate to In-app Billing Version 3 at your earliest convenience.

If you have published apps selling in-app products, note that:

Managed items and subscriptions that you have previously defined in the Developer Console will work with Version 3 as before.
Unmanaged items that you have defined for existing applications will be treated as managed products if you make a purchase request for these items using the Version 3 API. You do not need to create a new product entry in Developer Console for these items, and you can use the same product IDs to purchase these items. They will still continue to be treated as unmanaged items if you make a purchase request for them using the Version 2 or earlier API.

Question: I am currently using your in-app library for managing in-app purchases. Is this change something we should be worried about ?
 

jdiperla

Member
Licensed User
Is there an example project of how to use this flying around somewhere?

I would love to see how it would work in action with some 1 cent items to mess with.
 

NJDude

Expert
Licensed User
If you want to test without "paying" then change this line on the Main Activity:

From:
B4X:
InAppBillingService.Manager.RequestPayment(Activity, "unmanaged_1", "extra data")
To:
B4X:
InAppBilling.Manager.RequestPayment(Activity, "android.test.purchased", "extra data")
I'm assuming you already followed the steps on the tutorial.
 

Inman

Well-Known Member
Licensed User
According to Google documentation you should not call RestoreTransactions each time your application starts.
According to In-app API version 3, Google has implemented caching.

Because the Google Play client now caches In-app Billing information locally on the device, you can use the Version 3 API to query for this information more frequently, for example through a getPurchases call. Unlike with previous versions of the API, many Version 3 API calls will be serviced through cache lookups instead of through a network connection to Google Play, which significantly speeds up the API's response time.
Does that mean it is ok to call RestorePurchases each time the app starts?
 

ashrafidkaidek

Member
Licensed User
Sorry for the stupid question, but Erel mentioned “PublicKey is your developer public key as appears in the developer console under Edit Profile.”

It seems that Google has changed developer account user interface! Because I can’t find my developer PublicKey, even there is no “Edit Profile” option! Any idea how should I find my developer PublicKey?

Thank you
 

Inman

Well-Known Member
Licensed User
Sorry for the stupid question, but Erel mentioned “PublicKey is your developer public key as appears in the developer console under Edit Profile.”

It seems that Google has changed developer account user interface! Because I can’t find my developer PublicKey, even there is no “Edit Profile” option! Any idea how should I find my developer PublicKey?

Thank you
The PublicKey has been moved to Services & APIs page of an app. Checkout this page:

https://support.google.com/googleplay/android-developer/answer/186113?hl=en
 

ashrafidkaidek

Member
Licensed User
I have followed Erel original recommendations to test in app billing, so I have 100% new device with totally different Gmail account than my developer account, I have bridge this device to basic4android and installed my app in it, then directly built the apk and uploaded it to my Google developer account, and created the only managed service that my app has, then added the required app description / art work ... etc

Also I have added the test account to my “License Testing” list, under Account Details, and picked “Licensed” from License Test Response drop-box.

Now when I try to run the app and request to purchase the “managed service” I’m getting the error below:
“Signature does not match expected signature”
The above error show when "Manager_PurchaseStateChange" event is raised.

Erel also mentioned “The application must be signed with the same signature and have the same version number as the uploaded one.”

So can somebody please direct me on how to check and correct this signature issue!

Thank you all
 
Last edited:

ashrafidkaidek

Member
Licensed User
Yes Erel, i have created a new Signing key before building the apk and before installing the app in the new device, so both has exactly the same signing key.

I have even published the app then installed it to the device directly from the store, and got the same error! This does not make science to me … any ideas …
 
Last edited:
Top