[TUT] Simple InApp Billing / Payment

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

Re: [TUT] Simple InApp Billing / Payment

Postby DKDiveDude » Sat Aug 27, 2011 6:18 pm

Unfreaking believable! I now even published my app update and I still get "item requested not available for purchase". I am beginning to despise Google!
DKDiveDude
Junior Developer
Junior Developer
 
Posts: 18
Joined: Mon Dec 13, 2010 2:40 pm

Top

Re: [TUT] Simple InApp Billing / Payment

Postby ajwest » Sat Aug 27, 2011 7:14 pm

Hammy wrote:I found out exactly where it is crashing, so I did some work-around so if It does do this in the real world, it cancels the transaction.
In BillingHelper.verifyPurchase() the first line: BillingSecurity.verifyPurchase returns null. So it crashes on latestPurchase = purchases.get(0);

It is returning null because the signature does not match the data.. Now I did copy my public key into the code exactly how it should be. My current setup is I'm debugging the project (com.blundell.test) straight to my device and using android.test.purchased as the product

Any suggestions for what I am doing wrong?



I had the same problem. I just threw in an if statement into BillingHelper and it seems to work fine.


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. protected static void verifyPurchase(String signedData, String signature) {
  2.                 ArrayList<VerifiedPurchase> purchases = BillingSecurity.verifyPurchase(signedData, signature);
  3.                 if (purchases.isEmpty()){ //added this
  4.                         //do nothing
  5.                 }else{
  6.                         latestPurchase = purchases.get(0);
  7.                         confirmTransaction(new String[]{latestPurchase.notificationId});
  8.                         if(mCompletedHandler != null){
  9.                                 mCompletedHandler.sendEmptyMessage(0);
  10.                         } else {
  11.                                 Log.e(TAG, "verifyPurchase error. Handler not instantiated. Have you called setCompletedHandler()?");
  12.                         }
  13.                 }
  14.         }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
ajwest
Freshman
Freshman
 
Posts: 2
Joined: Mon Apr 25, 2011 2:58 am

Re: [TUT] Simple InApp Billing / Payment

Postby Hammy » Sun Aug 28, 2011 8:16 pm

Thanks for the input and that does fix the issue of a potential FC if there are no purchases, however, that doesnt fix my specific problem. My problem is that BillingSecurity.verifyPurchase() returns null. It says the signature does not match the data, I did put my public key into the code. So it must just be a stupid small error on my side if everyone else's code is working and not mine.

Any suggestions would be appreciated.
Hammy
Freshman
Freshman
 
Posts: 3
Joined: Sat Feb 12, 2011 5:56 pm

Re: [TUT] Simple InApp Billing / Payment

Postby DKDiveDude » Mon Aug 29, 2011 1:14 am

Ok figured it out. It was the item format in your code. Why I previously had asked here what EXACTLY the format needed to be!

This is what works:

BillingHelper.requestPurchase(mContext, "my_item");
DKDiveDude
Junior Developer
Junior Developer
 
Posts: 18
Joined: Mon Dec 13, 2010 2:40 pm

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Mon Aug 29, 2011 5:33 pm

Glad you find it useful!

Yeah it's on my todo list thanks for the reminder!
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 murali.a » Mon Sep 12, 2011 6:49 am

how to run your app in my device? what are the steps to follow? i download the code and do not know how to run and make purchase?. please help me
murali.a
Freshman
Freshman
 
Posts: 2
Joined: Mon Sep 12, 2011 6:43 am

Top

Re: [TUT] Simple InApp Billing / Payment

Postby murali.a » Mon Sep 12, 2011 8:27 am

i am new to android.i download the InAppPurchaseTut.apk file and install my device. it is successfully installed .when i run the app i did the following 1) click the yes button. 2) click the buy $0.99 button 3) i get progress bar. but at last step i did not get the passport image (that is again i get the yes button without image). . thanks.
murali.a
Freshman
Freshman
 
Posts: 2
Joined: Mon Sep 12, 2011 6:43 am

Re: [TUT] Simple InApp Billing / Payment

Postby Umesh » Tue Sep 20, 2011 7:46 am

while i am running on my device getting invalidkeyException.....plz help.
Umesh
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Sep 20, 2011 7:19 am

Re: [TUT] Simple InApp Billing / Payment

Postby ixikos » Fri Oct 07, 2011 1:51 am

Thank you for the excellent tutorial! Got all of the in app stuff working in a fraction of the time it would have taken. I am curious if you would consider putting together a tutorial on how to properly use restoreTransactionInformation.

Another question, what do you do in situations with poor network response time? Thanks!

Cheers,
Zach
ixikos
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Oct 07, 2011 1:49 am

Re: [TUT] Simple InApp Billing / Payment

Postby jovan_novko » Wed Oct 12, 2011 2:07 pm

Thanks for this tutorial...i want to implement it in my app. I have a few questions...let's go :D
1.In BillingHelper in method startBuyPageActivity what do i need to put for 2.0 android device???
2.If i have a server, do i move whole class Security on server??? That's for now...Thank's in advance ;)
jovan_novko
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Oct 12, 2011 2:00 pm

Re: [TUT] Simple InApp Billing / Payment

Postby rjadhav » Fri Oct 21, 2011 10:43 am

Thank you for good tutorial!

This sample is working on device with android os 2.2.
But its not working on device with android os 2.1.
After clicking purchase confermation YES button it show in app billing screen with price.
But when i select buy button, purchase screen disappers and nothing happan.

I checked with many devices with android os 2.1. All having same problem.
But it works on devices with android os 2.2.


Same issue i observed in google in-app-billing sample code.
rjadhav
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Oct 21, 2011 10:17 am

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Fri Oct 21, 2011 12:08 pm

rjadhav, it won't be Android 2.1 it will be the version of the Market App your running
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 Preetha » Thu Oct 27, 2011 9:40 am

Can you please let me know if its possible to list the in app products by fetching it dynamically from the market place?
Preetha
Freshman
Freshman
 
Posts: 3
Joined: Thu Oct 27, 2011 9:36 am

Re: [TUT] Simple InApp Billing / Payment

Postby blundell » Thu Oct 27, 2011 11:15 am

Hi Preetha,

No you can't retrieve any information about in-app products, this for security reasons.
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 Preetha » Thu Oct 27, 2011 12:12 pm

Thanks for the quick response. I am new to android development and trying to figure things here... How will we then list the products available within the app? Should we release new versions of the app if we add any new entry in the in-app product catalog?
Preetha
Freshman
Freshman
 
Posts: 3
Joined: Thu Oct 27, 2011 9:36 am

Top
PreviousNext

Return to Advanced Tutorials

Who is online

Users browsing this forum: Google [Bot] and 4 guests