0

I'm very confused by the current in-app billing documentation.

Here it says to initiate a purchase this call has to be made:

mHelper.launchPurchaseFlow(this, SKU_GAS, 10001,   
mPurchaseFinishedListener, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");

here it says that a pendingIntent initiates a purchase like this

Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");

PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

startIntentSenderForResult(pendingIntent.getIntentSender(),
1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
Integer.valueOf(0));

So which one is it? They both are API version 3 and both of these ways work independently of each other. Very confusing...

Marius Hilarious
  • 855
  • 9
  • 18

1 Answers1

0

The first uses the IabHelper class, which in turn uses the methods used in the second example internally. If you plan on using the IabHelper (which is maintained by Google and makes the API much more friendly for calling applications), then you'd use the first example. If instead you wanted to build your own In-App Billing interface, you'd use the second approach.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thanks a lot for the insight Iain. So, the second example is part of the first example. How do I consume a purchase then, is this done via mService.consumePurchase(3, getPackageName(), purchaseToken)? I'm asking, because when exporting my .apk and then making a purchase, consuming the purchase like this doesn't work, so the in-app purchase window only shows up once, but after that never again. – Marius Hilarious Feb 11 '14 at 20:18
  • What do you mean by 'doesn't work'? The response from the consume call should tell you what went wrong. – ianhanniballake Feb 11 '14 at 21:26
  • I tried again today for hours and hours and it always works for the SKU "android.test.purchased", however once I use an actual sku from a product that I created and export the .apk, I always get RESULT_DEVELOPER_ERROR == 5 as a reponse from mService.consumePurchase(3, getPackageName(), purchaseToken). Do you have any idea why? – Marius Hilarious Feb 12 '14 at 21:32
  • Assuming you've been able to do real purchases with the same app (ensuring that your signing/BILLING permission is set up correctly), the only reason I can imagine you getting a developer error would be if you aren't passing the right purchase token back. I'd consider asking another question as this is slightly tangential to the original question here. – ianhanniballake Feb 13 '14 at 17:44
  • I did actually, do you know what could be my mistake? http://stackoverflow.com/questions/21758242/mservice-consumepurchase3-packagename-purchasetoken-always-returns-result-de – Marius Hilarious Feb 13 '14 at 21:20