[TUT] Simple InApp Billing / Payment

Tutorials with advanced 'difficulty' and more Lines of Code.

[TUT] Simple InApp Billing / Payment

Postby blundell » Mon Mar 28, 2011 7:32 pm

Simple tutorial to get your application to do In App purchases!

http://blog.blundell-apps.com/simple-inapp-billing-payment/

inAppPaymentAppS1.png
inAppPaymentAppS1.png (20.46 KiB) Viewed 28934 times


inAppPaymentAppS2.png
inAppPaymentAppS2.png (28.79 KiB) Viewed 28934 times


inAppPaymentAppS3.png
inAppPaymentAppS3.png (77.25 KiB) Viewed 28934 times


inAppPaymentAppS4.png
inAppPaymentAppS4.png (41.96 KiB) Viewed 28934 times


inAppPaymentAppS5.png
inAppPaymentAppS5.png (156.44 KiB) Viewed 28934 times


http://blog.blundell-apps.com/simple-inapp-billing-payment/

APK:
InAppPurchaseTut.apk
(66.86 KiB) Downloaded 1383 times

Source Project:
InAppPurchaseTUT.rar
(426.38 KiB) Downloaded 5755 times


Enjoy and PLS ask any questions.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Re: [TUT] Simple InApp Billing / Payment

Postby savadasin » Mon Apr 04, 2011 12:31 pm

The first thing i have to configure is set public key right? After I set public key and signed application then am i be able to test it?
savadasin
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Apr 04, 2011 11:39 am

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Wed Apr 06, 2011 8:44 pm

Yeah exactly :-) this is in BillingSecurity.java
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: [TUT] Simple InApp Billing / Payment

Postby ratso » Thu Apr 07, 2011 4:51 am

Awesome
5 stars
A+++

...problem though, i can't seem to get past a
Code: Select all
04-06 22:44:17.007: ERROR/BillingService(17146): Market Billing Service could not be bound.

for some reason

any likely causes?

i have the aidl file in the same place as your sample app, and i'm using essentially the same code as the sample app you posted, the only thing i changed was my public key.
ratso
Freshman
Freshman
 
Posts: 9
Joined: Fri Jul 23, 2010 8:18 pm

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Thu Apr 07, 2011 10:31 am

Hmm have you updated your Manifest file?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: [TUT] Simple InApp Billing / Payment

Postby ratso » Fri Apr 08, 2011 12:40 am

yeah
i have
Code: Select all
<uses-sdk android:minSdkVersion="4" />

bafore the <application> tag

then
Code: Select all
      <service android:name=".BillingService" />
      <receiver android:name=".BillingReceiver">
         <intent-filter>
            <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
            <action android:name="com.android.vending.billing.RESPONSE_CODE" />
            <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />         
         </intent-filter>
      </receiver>   

before the </application> tag
and
Code: Select all
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="com.android.vending.BILLING" />

after the </application> tag


I have de-buggable set equal to false, if that means anything
ratso
Freshman
Freshman
 
Posts: 9
Joined: Fri Jul 23, 2010 8:18 pm

Top

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Fri Apr 08, 2011 9:38 am

Have you changed the package name? I'm just guessing in the dark here, hard to debug someone else's code you can't see :-)

The original code works perfectly, why don't you see if you have changed anything else by accident, maybe you have an XML error so the AIDL file isn't loading. Are you running Android 1.6 or higher? Have you got version 2.3.4 (or higher) of the Android Market.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: [TUT] Simple InApp Billing / Payment

Postby ratso » Sat Apr 09, 2011 2:23 am

i think android market version may be it
i assumed it was up to date, but little did i know that cyanogenmod's android market was still 1.x

ill try it on a different phone and report back soon

EDIT::
That was the exact problem!
everything works as you've described it now

lesson:if you're using a rooted phone with non standard roms, MAKE SURE YOUR VERSION ARE CORRECT regardless of what is supposed to auto update
ratso
Freshman
Freshman
 
Posts: 9
Joined: Fri Jul 23, 2010 8:18 pm

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Fri Apr 15, 2011 2:00 pm

Ah good!

Yeah Android Market version is one to look out for!
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: [TUT] Simple InApp Billing / Payment

Postby ratso » Thu Apr 21, 2011 5:44 am

next issue i'm working on is keeping and retrieving a list of purchases, i noticed a restoreTransactionInformation method, but i am unsure as to how to actually use it, i don't know which variables to use or how to access the information it supposedly retrieves

on a related note, what should i be passing for notifyIds if i want to use the methods that require that as a parameter (getPurchaseInformation)?
ratso
Freshman
Freshman
 
Posts: 9
Joined: Fri Jul 23, 2010 8:18 pm

Re: [TUT] Simple InApp Billing / Payment

Postby MonRoyals » Fri Apr 22, 2011 11:03 pm

Hi,
I tried to use your inapp-billing version and I tried to adapt the Dungeons example. However, both don't work for me on an Android 1.6 device. I'm able to do the purchase, but the final message is delivered to me only if I close my application. I think it's the same behaviour like described here http://code.google.com/p/marketbilling/ ... etail?id=7 . Does anyone has a workaround for this issue? I even tried to stop the billing service if I got back the focus, but it doesn't worked. Any ideas?
MonRoyals
Freshman
Freshman
 
Posts: 2
Joined: Fri Apr 22, 2011 10:55 pm

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Mon Apr 25, 2011 9:42 pm

Hi MonRoyals,

That sounds like an issue with Googles servers / Android Market versions, your best waiting for an answer / resolution from a Google employee.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Mon Apr 25, 2011 9:46 pm

ratso wrote:next issue i'm working on is keeping and retrieving a list of purchases, i noticed a restoreTransactionInformation method, but i am unsure as to how to actually use it, i don't know which variables to use or how to access the information it supposedly retrieves

on a related note, what should i be passing for notifyIds if i want to use the methods that require that as a parameter (getPurchaseInformation)?



You should only use restoreTransactionInformation() for when people have reinstalled, to check normally if someone has already purchased the item, after the initial purchase you should store this on a server of your own and then query from there. You could store the purchase locally but this has security implications.

See here: http://developer.android.com/guide/mark ... tices.html

Protect your unlocked content

To prevent malicious users from redistributing your unlocked content, do not bundle it in your .apk file. Instead, do one of the following:

Use a real-time service to deliver your content, such as a content feed. Delivering content through a real-time service allows you to keep your content fresh.
Use a remote server to deliver your content.
When you deliver content from a remote server or a real-time service, you can store the unlocked content in device memory or store it on the device's SD card. If you store content on an SD card, be sure to encrypt the content and use a device-specific encryption key.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: [TUT] Simple InApp Billing / Payment

Postby ratso » Sat Apr 30, 2011 8:59 pm

while that type of delivery seems effective, is there a more "low-budget" approach?
ratso
Freshman
Freshman
 
Posts: 9
Joined: Fri Jul 23, 2010 8:18 pm

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Mon May 02, 2011 1:32 pm

Yeah just save a SharedPreference when the transaction is complete :-) bear in mine this'll be lost on an uninstall and re-install.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top
Next

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests