Android Tutorial Android In-app Billing tutorial

flyingbag

Member
Licensed User
Longtime 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

 

flyingbag

Member
Licensed User
Longtime 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
Longtime 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
Longtime 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
Longtime 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.


Does that mean it is ok to call RestorePurchases each time the app starts?
 

Inman

Well-Known Member
Licensed User
Longtime User
Alright cool! I will cache the results myself with the current library.
 

ashrafidkaidek

Member
Licensed User
Longtime 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
Longtime User

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
Longtime 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
Longtime 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:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…