-1

Currently, I am working on a project where I have 2 buttons "Add 500 Points" or "Add 1000 Points" and when they press on it, they will pay 5$ or 10$ using in-app payment.

The user can pay multiple time by pressing the buttons.

As I am doing first time this type of work, kindly let me know how can do this in Android.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Faisal Shaikh
  • 3,900
  • 5
  • 40
  • 77

2 Answers2

0

First of all you need to implement in-app purchase, follow this for more : Implementing In-app Billing

after purchasing any product, you need to consume product : Consuming In-app Products

mService.consumePurchase(3, getPackageName(), token);

for more code you can check here : Consuming a Purchase

you can even follow this tutorial for easy use of in-app purchase.

Ravi
  • 34,851
  • 21
  • 122
  • 183
  • While adding new product IN-APP PRODUCTS 'What type of product' I should choose? – Faisal Shaikh May 24 '16 at 11:59
  • That depends on your requirement, but according to your question it should be managed product. – Ravi May 24 '16 at 12:00
  • I want that user should will pay on click of button and 1 user can click multiple times. I have 2 buttons for $5 and $10. Should I choose 'managed product' – Faisal Shaikh May 24 '16 at 12:05
  • yes choose managed product and once purchase is complete, consume that product so user can buy it again – Ravi May 24 '16 at 12:09
  • I checked the documentation, can you tell me what is the 2nd parameter of `launchPurchaseFlow` and what is the use of it? Is there any use while adding product into IN-APP PRODUCTS list? – Faisal Shaikh May 30 '16 at 07:18
-1

This question is tagged with "android-pay" so I thought I would add some clarification. Android Pay cannot be used to sell digital goods. If you are selling digital goods or virtual goods you should use the Google Play in-app billing service.

See Android Pay questions

Q: Can I use the Android Pay API for selling digital goods?

A: No. The Android Pay API cannot be used for selling digital goods, whether they are consumed on the device or outside the device. The Android Pay API may be used only for the sale of merchandise, goods or services provided to a Buyer outside a digital environment in the physical world. The Android Pay API may not be used for the sale of any digital content or services provided through any means.

Developers who want to sell digital goods should use the Google Play in-app billing service.

For more info, see Google Play in-app billing service

Michael Levy
  • 13,097
  • 15
  • 66
  • 100