Hello Friends!
Today I am going to share very useful blog for In App Purchase in Android. Google provide In App Billing faculty in Android. In App Purchase is a very easy and secure way for make payment online.
Please follow my blog step by step-
Screen Shot:
1)Create a new Project in Android.
2)Create MainActivity.java class.
3)Add activity_main.xml in your res/layout folder.
4)Add Billing services and permission in Manifest.xml.
2)Don't use unsigned apk for Billing services.
3)Don't share your key with any one.
My Code-
1)MainActivity.java
package com.manish.inapppurchase;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
Button btn1, btn2, btn3;
private Context mContext=this;
private static final String TAG = "Android BillingService";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button) findViewById(R.id.button1);
btn2 = (Button) findViewById(R.id.button2);
btn3 = (Button) findViewById(R.id.button3);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
startService(new Intent(mContext, BillingService.class));
BillingHelper.setCompletedHandler(mTransactionHandler);
}
public Handler mTransactionHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
Log.i(TAG, "Transaction complete");
Log.i(TAG, "Transaction status: "+BillingHelper.latestPurchase.purchaseState);
Log.i(TAG, "Item purchased is: "+BillingHelper.latestPurchase.productId);
if(BillingHelper.latestPurchase.isPurchased()){
showItem();
}
};
};
@Override
public void onClick(View v) {
if (v == btn1) {
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
} else {
Log.i(TAG,"Can't purchase on this device");
btn1.setEnabled(false); // XXX press button before service started will disable when it shouldnt
}
Toast.makeText(this, "Shirt Button", Toast.LENGTH_SHORT).show();
}
if (v == btn2) {
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
} else {
Log.i(TAG,"Can't purchase on this device");
btn2.setEnabled(false); // XXX press button before service started will disable when it shouldnt
}
Toast.makeText(this, "TShirt Button", Toast.LENGTH_SHORT).show();
}
if (v == btn3) {
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
} else {
Log.i(TAG,"Can't purchase on this device");
btn3.setEnabled(false); // XXX press button before service started will disable when it shouldnt
}
Toast.makeText(this, "Denim Button", Toast.LENGTH_SHORT).show();
}
}
private void showItem() {
//purchaseableItem.setVisibility(View.VISIBLE);
}
@Override
protected void onPause() {
Log.i(TAG, "onPause())");
super.onPause();
}
@Override
protected void onDestroy() {
BillingHelper.stopService();
super.onDestroy();
}
}
2)activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099CC"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#FFFFFF"
android:text="Shirt for 5.4$" />
<Button
android:id="@+id/button2"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:text="Tshirt for 7.4$" />
<Button
android:id="@+id/button3"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_below="@+id/button2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:text="Denim for 10.7$" />
</RelativeLayout>
3)manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.manish.inapppurchase"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.manish.inapppurchase.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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>
</application>
</manifest>
4)Zip Code
For any help or suggestion please comment on my blog :)-
Thanks,
Today I am going to share very useful blog for In App Purchase in Android. Google provide In App Billing faculty in Android. In App Purchase is a very easy and secure way for make payment online.
Please follow my blog step by step-
Screen Shot:
1)Create a new Project in Android.
2)Create MainActivity.java class.
3)Add activity_main.xml in your res/layout folder.
4)Add Billing services and permission in Manifest.xml.
Do's
1)Create sign apk for your application.
2)Upload your apk on Google play store.
3)Create product for your application.
4)wait for 6-12 hour for update item's on store.
5)Copy Key of your Google account and paste it into BillingSecurity.java class Line number 135-
String base64EncodedPublicKey = "PUT YOUR PUBLIC KEY HERE";
6)Give Billing permissions in Manifest.xml
7)Add IMarketBillingService.java in com.android.vending.billing package.
Don't
1)Don't use emulator for testing its does not support Billing Services.2)Don't use unsigned apk for Billing services.
3)Don't share your key with any one.
My Code-
1)MainActivity.java
package com.manish.inapppurchase;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
Button btn1, btn2, btn3;
private Context mContext=this;
private static final String TAG = "Android BillingService";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button) findViewById(R.id.button1);
btn2 = (Button) findViewById(R.id.button2);
btn3 = (Button) findViewById(R.id.button3);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
startService(new Intent(mContext, BillingService.class));
BillingHelper.setCompletedHandler(mTransactionHandler);
}
public Handler mTransactionHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
Log.i(TAG, "Transaction complete");
Log.i(TAG, "Transaction status: "+BillingHelper.latestPurchase.purchaseState);
Log.i(TAG, "Item purchased is: "+BillingHelper.latestPurchase.productId);
if(BillingHelper.latestPurchase.isPurchased()){
showItem();
}
};
};
@Override
public void onClick(View v) {
if (v == btn1) {
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
} else {
Log.i(TAG,"Can't purchase on this device");
btn1.setEnabled(false); // XXX press button before service started will disable when it shouldnt
}
Toast.makeText(this, "Shirt Button", Toast.LENGTH_SHORT).show();
}
if (v == btn2) {
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
} else {
Log.i(TAG,"Can't purchase on this device");
btn2.setEnabled(false); // XXX press button before service started will disable when it shouldnt
}
Toast.makeText(this, "TShirt Button", Toast.LENGTH_SHORT).show();
}
if (v == btn3) {
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
} else {
Log.i(TAG,"Can't purchase on this device");
btn3.setEnabled(false); // XXX press button before service started will disable when it shouldnt
}
Toast.makeText(this, "Denim Button", Toast.LENGTH_SHORT).show();
}
}
private void showItem() {
//purchaseableItem.setVisibility(View.VISIBLE);
}
@Override
protected void onPause() {
Log.i(TAG, "onPause())");
super.onPause();
}
@Override
protected void onDestroy() {
BillingHelper.stopService();
super.onDestroy();
}
}
2)activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099CC"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#FFFFFF"
android:text="Shirt for 5.4$" />
<Button
android:id="@+id/button2"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:text="Tshirt for 7.4$" />
<Button
android:id="@+id/button3"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_below="@+id/button2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:text="Denim for 10.7$" />
</RelativeLayout>
3)manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.manish.inapppurchase"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.manish.inapppurchase.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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>
</application>
</manifest>
4)Zip Code
For any help or suggestion please comment on my blog :)-
Thanks,
Do you still have the zip file?
ReplyDeleteYes Mike I have put a Dropbox shared folder link on click of zip code but I think it have some problem so please give me some time I will upload a new one. you can put your email-id here I will send you the zip code if you needed..
DeleteThanks,
You can use mdcarroll6@gmail.com! Thanks!
DeleteHi Mike please check your email I have sent you the zip code.Hope it will help you..
DeleteI think it will! Thanks!
Delete
ReplyDeleteHi,
Recently I came across some great articles on your site.
The other day, I was discussing (http://www.androidhub4you.com/2013/03/how-to-inegrate-in-app-purchase-billing.html)with my colleagues and they suggested I submit an article of my own. Your site is just perfect for what I have written!
Would it be ok to submit the article? It is free of charge, of course!
Let me know what you think
Contact me at anelieivanova@gmail.com
Regards
Anele Ivanova
Hi Manish,
ReplyDeleteI am Mohit. Can you please send me the code on my email ?
my email : charadva.mohit@gmail.com
Thanks.
Hi Mohit, Download the zip code from my blog-
DeletePoint 4)Zip Code
https://www.dropbox.com/s/v068uwfzfhhwoez/InAppPurchaseDemo.zip
Thanx bro.. Your demo is really usefull to me.. jay Bharat
DeleteJay Bharat!
Deleteif you don't mind . .
Deletecan you send full code of this demo.. jay bharat
i can't understood code of this ..
DeleteBillingHelper.requestPurchase(mContext, "android.test.purchased");
In my apps use same package "android.test.purchased" or not . .????
thanx a lot..
show force close error on accept and buy button click
ReplyDeleteI think you have not done Google store part(Google Developer). I mean add item on store and publish them that's why you are getting this crash.
Deletebefore run this app please done needed things. you can do googling also and its working for me. Please check your side...
This is a good in app billing tutorial. Now I will be able to implement it into my application. Thanks
ReplyDeleteYes man enjoy happy coding!
Deletewhere to link my product inside your demo
ReplyDeleteYou can't add product inside my demo. you should take a android developer account it's cost approx 50$. And into your application you can add product it will update after 10 hour approx.
DeleteHi, I am developing hotel and restaurant booking app. I have problem in payment part. Could help me how can i do. Please send the code on megha.sutar05@gmail.com
ReplyDeletePlease its my humble request for you.
Hi Megha! Please check above code everything is there step by step and check option number 4 for zip code.
DeleteAnd you can use paypal also for you application.
Thanks,
Ok... Thanks alot...
ReplyDelete1 more thing i have did multidate picker dialog in same activity but i am not able to do multitime picker dialog in same activity... Do you have any sample example of multitime picker dialog and fields validation of registration form. If you have then please send me on megha.sutar05@gmail.com
Hi megha!
DeleteI did not get meaning of multidate piker..
Well you can try some of them-
http://www.androidhub4you.com/2013/05/date-piker-example-in-android-simple.html
http://www.androidhub4you.com/2013/03/custom-picker-in-android-number-picker.html
and I have mailed you validation code..
Thanks,
Please send me zip code
ReplyDeletemy gmail id rsbijendra@gmail.com
Please download it from above post option number-4(zip-code).
DeleteThanks Manish, Brilliant work. Just want to know why it is taking to payment again , even after i got payment successful for a particular product. Isn't this case is handled that if a payment made is managed for products which got product type as managed or is there any setting anywhere in the code that we need to handle
ReplyDeleteIt is a demo app and I did not manage like this. So please get successes response of payment and hide that particular product.
DeleteIn your case It is Okay but if any one want buy again same item then? so please maintain your product and requirement as per your application need.
Thanks,
HI,
ReplyDeleteCan u send this zip to vijaymadhu97@gmail.com please
Hey please see code again there a download link also..
DeleteThanks,
Hello Manish! You've put a "showItem();" in the
ReplyDeletepublic Handler mTransactionHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
Log.i(TAG, "Transaction complete");
Log.i(TAG, "Transaction status: "+BillingHelper.latestPurchase.purchaseState);
Log.i(TAG, "Item purchased is: "+BillingHelper.latestPurchase.productId);
if(BillingHelper.latestPurchase.isPurchased()){
showItem();
}
};
};
But that file doesn't exist, even including that drawable the code never works... transaction is ok and i get a RESULT_OK but the drawable never gets visible, you even COMMENT that line in
private void showItem() {
//purchaseableItem.setVisibility(View.VISIBLE);
}
Any idea how to know when i get RESULT_OK and show wherever i want?!
Code is PERFECT except for that little part, never get the showItem(); up and running... "BillingHelper.latestPurchase.isPurchased()" looks like never working.
Hope you can help me with this. Thanks in advance!
No no it is just a demo project provide by android just search on google for more help..
Deletehi manish i used your project working well but when i integrate this project in my apps its give me null signature i cont understands please help me .
ReplyDeleteHi Sujeet, I can't help without code here or without log-cat..
DeleteHave you check your App-Key?
and have you declare all thing in Manifest? and Internet permission?
please check your log-cat and googling for it..
Hi Manish,
Deletein your code there possible change price programmatically
thanks manish ,
ReplyDeleteits working very well with your demo but when i used your packages and classes in our project then its give me signature null and give me arrayindexoutofbound exception
have you copy com.android.vending.billing package?
Deleteand one more thing check your manifest-
In my case my pckage was default so i used ..BillingService only but in your case your parent pacakage is diffrent so call it with full name like-
android:name="com.manish.inapppurchase.BillingService "
Hope it will help you..
This comment has been removed by the author.
DeleteHi Manish,
DeleteI got the same issue. It was working fine for a while, but dont know what went wrong. The Helper class started throwing out of bound exceptions.
I have rechecked my manifest file and I have the vending package.
Log:
07-18 23:30:08.159 17040-17040/? I/BillingService: signedData: {"nonce":-9223021552019373094,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"com.myexample.android","productId":"android.test.purchased","purchaseTime":135169194838,"purchaseState":0}]}
07-18 23:30:08.189 11959-11959/? D/Finsky: [1] MarketBillingService.sendResponseCode: Sending response RESULT_OK for request 9013055853120068051 to com.myexample.android.
07-18 23:30:08.199 17040-17040/? D/AndroidRuntime: Shutting down VM
07-18 23:30:08.199 17040-17040/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
07-18 23:30:08.219 17040-17040/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver com.myexample.android.inapppurchase.BillingReceiver: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at android.app.ActivityThread.handleReceiver(ActivityThread.java:1826)
at android.app.ActivityThread.access$2400(ActivityThread.java:121)
hi manish
ReplyDeletei have an problem with service in this demo problem is that "BillingHelper not fully instantiated" when back to service and just start service again
Hope you can help me with this. Thanks in advance!
Hi Manish,
ReplyDeleteThis helped me a lot.
Can you please send a sample code of TCP and UDP connection on client side coding.
If you have plz send me to srivatsava.arjun@gmail.com
Thanks
No sorry please..
DeleteDo you have hotel and restaurant booking android app???
ReplyDeleteCan you send me that with full coding. Please...
No megha sorry no code.. my all projects for client,and i can't leak their code and idea...
DeleteHi Manish, Is it compulsory to register items in google play account from which we are going to publish our app or it can be from any account?? Does it really takes at least 6-8 hours to get items updated on account?? Waiting for reply. Thanks
ReplyDeleteNo no not compulsory in google doc they have mention it maxmium time.. may be it take only one hour..
DeleteThanks Manish
DeleteYour welcome mitesh! And yes same account needed for add item... you can test it using draft sign apk in your account..
DeleteDear Manish,
ReplyDeleteThanks for the post. Really appreciate your attitude to share your knowledge to others. It would be great if you could give a brief explanation of the flow using your example. Something like a flow diagram, how different classes communicate and what are their roles in performing an in-app purchase.
Thanks
rahul
All the best..keep rocking
Okay sure raauu I will mind it next time..
DeleteThanks for your nice suggestion..
hi Manish can you give me some working code for Restoring functionality too .i am working for that from last 20 days but couldn't get ride of it please help
ReplyDeleteSorry Ashish I don't have code for Restore purchase..
DeleteTry this-
mBillingService.restoreTransactions();
http://developer.android.com/google/play/billing/billing_integrate.html
install sample code from here it will help you..
Hello Manish
ReplyDeleteI used your sample code and your guide and i integrate it with my current project.
but i want to validate on my server not on device so in verify method i call httppost method and pass json which contains signature and publick key and purchase data string..i used recommended method in php to verify transaction.
but it is always 0 but if you check on device verification is true..
both having same algorithm technique (sh1withrsa) same parameter but on server it false but on device its true...
do you have any idea what is wrong in my steps.
one more thing is that I am using public key which is generated before your code integration and i am using same public key but same public key validates true on device..
waiting for reply
thank you
How this is possible?
DeleteHave you printed it in log before send it on server? I think problem in setting value HTTP param..
I think it is pick Boolean default value false, not getting from server. So please check it where you set it in your code..
Yes i log the all three string in log cat..and i am getting values also i convert it into json and send it by httppost... and he also getting same value on server public key , data , signature and he call verify_ssl (something like that because i am not php developer) so according to you php developer is making some mistake in http param?
DeleteAnd One more thing is that i skip your verification code and into that verify method i create json and call http post method to send 3 values to my server than my server response me 400 (which is false) and than my app display Log that "Signature does not match data" And After that i got Unable to start Receiver exception .. Null pointer Exception. can you help me please
Great work man,
ReplyDeleteI have got a question on this,how will I test If I integrate it within my app,,because for to register in the console,google I have to pay 25$ to register ..Do you know any other way to do it..
Please reply
No there is no any other way to test application.
DeleteYou have to pay 25$ to Google or ask to your client for provide their account for configure Google wallet..
Thanks,
Thanks man....
DeleteCan You help me with this,I need to call asynctask in BroadCastReceiver on on Receive.
But its not allowing me to ...
hello Manish.
ReplyDeleteI solved that problem..its bacause of php developer made mistake in json at server side..
I need your help i want to verify with my server and after verification i want to downlaod video file in httpresponse..so i created one asynctask with progress bar..but the issue is i called my async task in verify method of billing security and i pass the context from billing service for progress bar..but i got windows.token null exception..for progress bar...
Can you tell how can i call my asynctask with progres bar from your service?
waiting for reply
thank you
I can't say anything with out code front of me but i think we can't create progress bar in service class. So try other way search on stackoverflow or ask question on stack overflow it will help you..
DeleteThanks,
Awesome work dude
ReplyDeleteJust want to know How can i restore purchase by using your code.
Have you written any method in your code for restoration of product?
do reply
thanks
Sorry Swapnil I don't have code for Restore purchase..
DeleteTry this-
mBillingService.restoreTransactions();
http://developer.android.com/google/play/billing/billing_integrate.html
install sample code from here it will help you..
i saw sample docs I just want to know that do i need to add its AIDL file (service) to implement restore into my project?. Do i need to copy all the files into my project?
DeleteIs there any other way to use their restore part into my code?
thank you
Yes if you make payment using your application and want restore purchase then you should add all files because that provided by google including services, receiver, base64 classes for secure payment so we should use all of their code..
DeleteThanks,
Manish thanks for reply i am using your code for purchase and if i add googles all files than there will be some conflict of file. i think so and one more thing is that if i used google code to purchase than i got Null signature and with your code it works fine for purchase...so wondering i will do some research and i will add part of code (restore) into my project..with AIDL and service and helper.
Deletemanish Issue in your code is that your purchase code is only work on 3g ..on restricted wifi it wont work..but google sample code works for same restricted wifi but ur code won't.. i think problem is in port number you are using for communicating with google play..can you please tell me where should i find this port number code ?
DeleteNo I don't think this is a case..
Deletewifi and 3g no matter here I have tested on both..
Okay may be there is restriction on my wifi..on more thing is you are using "API_VERSION" 1 in makeRequestBundle method?..api version 3 available but still you have used version 1..if i try to change it from 1 to 3 it wont work but it work on version 2 why?
DeletePlease read Google doc for further detail, May be only changing version does not work you should change code also according version-3.
DeleteVersion 2 supports both unmanaged and managed products, as well as supports subscriptions, where Version 3 does not yet offer support for subscriptions. If you want to sell subscriptions in your app, you should implement In-app Billing Version 2, rather than Version 3.
If you do not need to sell subscriptions, you should implement In-app Billing Version 3 instead.
Thanks Manish for this great tut.
ReplyDeleteMy question is will the item purchased will be removed upon uninstalling the app and then install it agin?
Should i implement a database to keep track of users item?
Or the app itself keep track of the item purchased by the user account and his item?
Thanks in advance
Prefer way to keep a database on server for future use,,
Deletewell Google have all record of purchase of your application on their server you can get any time for there but if you want maintain your own database you can...
Thanks,
Hello, Manish , how can i find out my public key for String base64EncodedPublicKey = "PUT YOUR PUBLIC KEY HERE"; please help me.
ReplyDeletePlease see top of my blog I have wrote all steps there..
DeleteWell when you register for Google developer account with paying $25, you will get your public key..
thank you, for your reply. May I use general SDK for payment for all system like paypal, google wallet and any other which available in world? if yes please give me the references.
Deletehi Manish how can i get the response for unmanaged products , is this condition( if(BillingHelper.latestPurchase.isPurchased()){
ReplyDeleteshowItem();
}) works for unmanaged products
No its not work for bulk purchase means cart system..
DeleteAll product should be register with Google store...
thanks manish for the project that is really helpful me...
ReplyDeleteactually i m working with a project that have online billing concept so i don't know how to integrate ur project with that...give me some solution.
Hi Just copy pate whole package in your project.
Deleteand add all permission in your manifest..
thanks buddy...
DeleteThis comment has been removed by the author.
ReplyDeletevery helpful blog.... thanks a lot manish....
ReplyDeleteI want to know that your project should be attached with my app or it should be separately done.
ReplyDeletePlease reply......thanks in advance..........
Just copy paste all package in your project and play with mainactivity.java...
DeleteHi manish, I want to show the XLSpreadsheet and edit the Sheet in ralativelayout, can you please help me for that
DeleteHey Manish,
ReplyDeleteHere I am back with one more query..!! Is it possible to set a password to check the installation of .apk on mobile, i.e when i install my app on to mobile it should ask for a password or key and only if the key is correct it should install the application. Tried googling but couldnot find much info.
Hope you will help me, thanks in advance....
Best regards,
yamini.
In my knowdladge there is no way like this but you can do one thing-
DeleteMake an activity Applaunch.java and chek prefrence for first time use before your home or splash page. And add an editbox for match password, if password is ok login into app and save preference true so app did not ask again and again password.
That was a great idea can you please help me out how i can do it, check preferenceonly once?!
DeleteHi Yamini, I want to show the XLSpreadsheet and edit the Sheet in ralativelayout, can you please help me for that
DeleteHi manish can you send zip file to me. actually i am working on a project.....
ReplyDeleteEmail id: vipin.vishwakarma@countrysideworks.com
I hope u will send ASAP.
Hi Please Check my blog a download link there..
DeleteThanks!
Hai,
ReplyDeleteI am using your same code and i have implement my in app package and hash key but it will give me error like "USER IS NOT ELIGIBLE FOR THIS PURCHASE".
Can you just help to solve this problem?
Are you using developer account? I mean have you added item on Google play store?
DeleteHello Manish,
ReplyDeleteIs it Latest version of in-app purchase V3 or old version of V2.
and can you please how to implement in-purchase with subscriptions of one month or one year.
Can you please reply for this. I would like to implement your code in my app.
Thanks,
Hi please see android developer website for more detail..
DeleteYes subscriptions is possible in android in app purchase, read this-
http://developer.android.com/google/play/billing/billing_overview.html
Hi Manish,
ReplyDeleteIn MainActivity.java line number 50 the 2nd parameter "android.test.purchased" what dose it do.?
should I change it when the code goes to live.?
If it needed a change what should I pass parameter.?
Can you please tell me.
Thanks,
There is no need to change any thing.. Just see BillingHelper class.
DeleteIt is tag only "com.test.purchase" , if you want change it you can no issue but make changes in both places..
Thanks!
Ok thanks Manish,
ReplyDeleteOne more thing, Is there any testing mode to make sure that the payment transactions are in proper.? If yes how.?
Yes sure you can test your payment getway.
Delete1)create signed apk for your application
2)add your apk on google store in draft folder. Don't publish it.
3)now test your application.
4)for more detail please read google doc. and when you login into google developer console you will got more info there, on merchant account.
Hi Manish,
ReplyDeleteI have created one android app. Please tell me procedure to create paid app(one time payment).
Thanks,
Shrikant.Salunkhe
That mean your app is paid, right? means there is no 2 version paid and free?
DeleteThis is very easy condition. At the time of uploading your apk on google market use paid merchant account. Here you can set your price for your application. Just setup merchant account on play store.
Ok Manish. Thanks. Is any document required to open merchant account?
ReplyDeleteNo Document. And no worry, when you going to upload your apk on google store it will provide step by step help.
DeleteHi Manish,
ReplyDeletethis works perfectly for me however I am having a small issue.
How can i check whether the item has been purchased and the run a little code snippet?
Thanks,
please check log-cat here you will got successes or failure message...
DeleteHi, how can i test the purchase when i am doing it on a test device, as I am required to sign the apk file?
DeleteAlso is the following line of code what is used to detect whether the purchase has been completed and if so run some code:
BillingHelper.latestPurchase.isPurchased()
Thanks
i have one application develop and integration your code and change base64 code key but run the code and get error for 'mservice' get null
ReplyDelete10-17 10:50:51.578: E/AndroidRuntime(13089): FATAL EXCEPTION: main
10-17 10:50:51.578: E/AndroidRuntime(13089): java.lang.NullPointerException
10-17 10:50:51.578: E/AndroidRuntime(13089): at com.fortunot.inapppurchase.BillingHelper.isBillingSupported(BillingHelper.java:51)
10-17 10:50:51.578: E/AndroidRuntime(13089): at com.fortunot.fortunecookie.MainActivity.onClick(MainActivity.java:263)
10-17 10:50:51.578: E/AndroidRuntime(13089): at android.view.View.performClick(View.java:2485)
10-17 10:50:51.578: E/AndroidRuntime(13089): at android.view.View$PerformClick.run(View.java:9080)
10-17 10:50:51.578: E/AndroidRuntime(13089): at android.os.Handler.handleCallback(Handler.java:587)
10-17 10:50:51.578: E/AndroidRuntime(13089): at android.os.Handler.dispatchMessage(Handler.java:92)
10-17 10:50:51.578: E/AndroidRuntime(13089): at android.os.Looper.loop(Looper.java:130)
10-17 10:50:51.578: E/AndroidRuntime(13089): at android.app.ActivityThread.main(ActivityThread.java:3687)
10-17 10:50:51.578: E/AndroidRuntime(13089): at java.lang.reflect.Method.invokeNative(Native Method)
10-17 10:50:51.578: E/AndroidRuntime(13089): at java.lang.reflect.Method.invoke(Method.java:507)
10-17 10:50:51.578: E/AndroidRuntime(13089): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
10-17 10:50:51.578: E/AndroidRuntime(13089): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
10-17 10:50:51.578: E/AndroidRuntime(13089): at dalvik.system.NativeStart.main(Native Method)
plz I hope u will send ASAP.
thanks
hi manish,
ReplyDeletei will use your code but i have a problem, how to know transaction is complete or not...?
i will try to sell virtual coins for my games.please help me,to know transaction process or
detail tutorial please. thanks
Hi please check your log, I have printed there successes message.
DeleteYou can check for more android developer web-site and yes there zip code too you can try that. I think that will help you..
Thanks!
See this URL-
Deletehttp://developer.android.com/google/play/billing/billing_overview.html
This comment has been removed by the author.
Deletehi manish,
ReplyDeletei will try and can't understand all things, its give massage "RESULT_OK" , its mean transaction
is success..? and i will upload my apk also in google play "https://play.google.com/store/apps/details?id=com.mobibit.gpay" for testing. please help me if i will pay the amount its give RESULT_OK else other massage.. i m right or not...?
You are right dear and it will give you successes message. And upload your project in google market and you can test it and clear your doubt.
DeleteThanks!
This comment has been removed by the author.
ReplyDeleteHi manish there are some confustion pls help me
ReplyDelete1) i had succefyly draf apk file and publish in app purchse product but the question is that i had upload product with name pro verion but when i test from my device it's display me sample title and 0.99$ as price. it there anything wrong or it's display it due to testing mode
2) when i am going to live that app what thing i have to change in my app that my application can get proper in app purchase?
1)Please read android doc first properly. At the time of testing they allow fix price .99$ if any change in earlier I have no idea.Please read doc.
Delete2)Sure it will work perfectly and no change you have to make. And if you got any issue you can re-wart to draft any time. so please test your self only then promote your app.
Thanks!
This comment has been removed by the author.
DeleteOk and i cannot found any item id in my google play ac then which is item and where i have to replace it?
ReplyDeletePlease don't remove comments and read this url hope it will help you-
Deletehttp://developer.android.com/google/play/billing/billing_testing.html
Hi! I need some help, maybe you can answer for my question. My problem is the following:
ReplyDeleteI have an uploaded app with a package name e.g. com.android.example1. I created another project e.g. com.android.example2. So my question is: Is there any way from example2 to get the purchases which i made in example1? (the google account the same, the base64key is the same, the only one difference is the packagename.)
In my knowledge there is no way for this task and google does not allow us for security reason.
DeleteHi manish...........This is the best 'greatest' website to learn Android..you are the best author to reply all the questions in time....this is really superb.....Please keep this up....Thank you.....Thanks from my heart
ReplyDeleteThanks Dear!
DeleteHi Manish,
ReplyDeleteI am using your above code and everything is working fine, I have added my own items into the developer account and the purchase happens correctly.
The issue I am having is how do i detect that the user has made the purchase? I am trying to use this line of code 'showItem(BillingHelper.latestPurchase.productId)', however this is never going into my function showItem().
Basically, I have an upgrade managed product, then when the user purchases this I want to make one of my buttons invisible, so I need the app to trigger a function when the purchase is complete, please help.
Thanks.
Please see log it will give you successes message after that you can do what you want with your button..
DeleteI have seen the log and know it is a success, however the problem is I DO NOT know how to call a function upon success.
DeleteThere must be a snippet of code, could you please provide this and where in my code I would need to place this in order for the function to be calle.
Is this Version 3 of the inapp Billing library?
ReplyDeleteHi, May I know where do I get payment response.? whether the payment is successful of unsuccessful.?
ReplyDeleteIf successful I need to do a service call there.
please check log-cat here you will get successes message. and for more detail please use debugger. please check BillingService.java i think here that log.
DeleteHi Manish,
ReplyDeleteIm beginner in Android apps.Will u post the code for our expense manager? I hope u will provide ASAP.It will be helpful for me.
Thanks in advance
Sudhakar
whole app code? i think this is not good to post whole app code. if you have query related to any particular task please tell, i will try to provide you.
DeleteThanks
Hi Manishji,
ReplyDeleteMay I know how to store and fetch data through datewise transaction using datepicker?
Thanks in Advance
Sudhakar
(sudhakarmsc91@gmail.com)
do some thing like that-
Deleteselect *
from TableName
where mydate >= Datetime('2010-01-01 00:00:00')
and mydate <= Datetime('2030-01-01 23:00:59');
AND for one date-
select *
from TableName
where mydate == Datetime('2010-01-01 00:00:00');
Thanks!
Hellol thanks for your share, hot to implement this code in code source of another apps? we have to follow and creat a MainActivity.java or we can create another one with other name? thanks
ReplyDeleteJust copy paste same package in your app just change code of mainActivity.. You can read android developer website too for more help.
DeleteHello Manish am trying to implement in app purchase using ur article how can i update my app public key in my app,.And also how to test my app with testers acc pls help me to achieve this,.
ReplyDeletethank you,.
Hi am getting these exceptions,.. please check out
ReplyDelete12-26 16:25:00.345: E/AndroidRuntime(294): FATAL EXCEPTION: main
12-26 16:25:00.345: E/AndroidRuntime(294): java.lang.RuntimeException: Unable to resume activity {com.vm.vminapppurchase/com.vm.vminapppurchase.MainActivity}: android.app.SuperNotCalledException: Activity {com.vm.vminapppurchase/com.vm.vminapppurchase.MainActivity} did not call through to super.onResume()
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.os.Looper.loop(Looper.java:123)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-26 16:25:00.345: E/AndroidRuntime(294): at java.lang.reflect.Method.invokeNative(Native Method)
12-26 16:25:00.345: E/AndroidRuntime(294): at java.lang.reflect.Method.invoke(Method.java:521)
12-26 16:25:00.345: E/AndroidRuntime(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-26 16:25:00.345: E/AndroidRuntime(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-26 16:25:00.345: E/AndroidRuntime(294): at dalvik.system.NativeStart.main(Native Method)
12-26 16:25:00.345: E/AndroidRuntime(294): Caused by: android.app.SuperNotCalledException: Activity {com.vm.vminapppurchase/com.vm.vminapppurchase.MainActivity} did not call through to super.onResume()
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.Activity.performResume(Activity.java:3825)
12-26 16:25:00.345: E/AndroidRuntime(294): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
12-26 16:25:00.345: E/AndroidRuntime(294): ... 12 more
12-26 16:25:08.922: I/BillingService(312): Service starting with onCreate
12-26 16:25:08.932: E/BillingService(312): Market Billing Service could not be bound.
12-26 16:25:08.943: D/AndroidRuntime(312): Shutting down VM
amgetting this too
ReplyDelete12-26 16:25:08.952: E/AndroidRuntime(312): FATAL EXCEPTION: main
12-26 16:25:08.952: E/AndroidRuntime(312): java.lang.RuntimeException: Unable to create service com.vm.vminapppurchase.BillingService: java.lang.NullPointerException
12-26 16:25:08.952: E/AndroidRuntime(312): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2969)
12-26 16:25:08.952: E/AndroidRuntime(312): at android.app.ActivityThread.access$3300(ActivityThread.java:125)
12-26 16:25:08.952: E/AndroidRuntime(312): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
12-26 16:25:08.952: E/AndroidRuntime(312): at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 16:25:08.952: E/AndroidRuntime(312): at android.os.Looper.loop(Looper.java:123)
12-26 16:25:08.952: E/AndroidRuntime(312): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-26 16:25:08.952: E/AndroidRuntime(312): at java.lang.reflect.Method.invokeNative(Native Method)
12-26 16:25:08.952: E/AndroidRuntime(312): at java.lang.reflect.Method.invoke(Method.java:521)
12-26 16:25:08.952: E/AndroidRuntime(312): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-26 16:25:08.952: E/AndroidRuntime(312): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-26 16:25:08.952: E/AndroidRuntime(312): at dalvik.system.NativeStart.main(Native Method)
12-26 16:25:08.952: E/AndroidRuntime(312): Caused by: java.lang.NullPointerException
12-26 16:25:08.952: E/AndroidRuntime(312): at com.vm.vminapppurchase.MainActivity.setStatus(MainActivity.java:132)
12-26 16:25:08.952: E/AndroidRuntime(312): at com.vm.vminapppurchase.BillingService.onCreate(BillingService.java:32)
12-26 16:25:08.952: E/AndroidRuntime(312): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2959)
12-26 16:25:08.952: E/AndroidRuntime(312): ... 10 more
Please register on google developer console for in app billing. well you can ask to your client to for access of developer console from where you can create new KEY.
Deleteplease check below link and follow step by step-
https://play.google.com/apps/publish/
Thank you, But i already created dev console and i did upload the apk also ,.i.e,. I did all steps in this article,.but am getting this error while clicking button "SecurityException : Binder invocation to incorrect interface "
DeleteNo idea dear. Please check your log-cat in which you are getting this error then try again. you can search on google for your problem too.
DeleteIf still you have trouble please go through android developer and download latest zip demo code.
Hey my name is aniruidh
ReplyDeleteAfter following this steps how to integrate it to my application
1)Create a new Project in Android.
2)Create MainActivity.java class.
3)Add activity_main.xml in your res/layout folder.
4)Add Billing services and permission in Manifest.xml.
Read more: http://www.androidhub4you.com/2013/03/how-to-inegrate-in-app-purchase-billing.html#ixzz2pjKbwhCB
Dear all code are there just copy and paste into your project and there some suggestion as well try to follow them..
DeleteHi Manish,
DeleteThanks for ur reply,i have done and i tested in test mode it is working fine but, how to pass the product name and price.please can help me regarding this
Regards
Anirudh
You have to add item and price on Google developer console. And you have to just pass that specific id for every product.
DeleteERROR While retrieving information from server.[RPC:S-7:AEC-0] is coming when saving the credit card details .... sorry for asking u like this what is the version of in app purchase code .
ReplyDeleteI am not sure about that error but I think it version-3.
ReplyDeletehello manish first of all Thanks for giving such a superb tutes, i wanna make demo for InApp purchase i am using your code ,Is'nt there a way to do it for demos. means Can we do it without paying, like sandbox type in paypal.??
ReplyDeleteYes please check In app Purchase document. And if you go through real development at that time also you can test your product.
DeleteManish thanks for u response ,One thing more as per you demo it is showing prices in $ ,in India it is in Rs etc etc according to country, so it is handling by us(means need to code for that) or google play will handel? Waiting for your responce Thanks
ReplyDeletehi,I want to implement inapp purchase for some feature of my application .so, can you pls give me idea about it
ReplyDeleteHi Manish ! I want to know the benefit and different between In App Purchase and Normal payment. Which one is best?
ReplyDeletei am getting this error
ReplyDeleteReceived action: com.android.vending.billing.IN_APP_NOTIFY
notify got id: android.test.purchased
getPurchaseInformation()
Nonce generateD: -2625802164677832116
current request is:7910620689484784487
GET_PURCHASE_INFORMATION Sync Response code: RESULT_OK
Received action: com.android.vending.billing.PURCHASE_STATE_CHANGED
purchaseStateChanged got signedData: {"nonce":-2625802164677832116,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"com.futerox.fbvideos","productId":"android.test.purchased","purchaseTime":1395404323710,"purchaseState":0}]}
purchaseStateChanged got signature:
signedData: {"nonce":-2625802164677832116,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"com.futerox.fbvideos","productId":"android.test.purchased","purchaseTime":1395404323710,"purchaseState":0}]}
Shutting down VM
03-21 17:47:04.356: W/dalvikvm(26432): threadid=1: thread exiting with uncaught exception (group=0x40e3f2a0)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver com.futerox.inappbillinservice.BillingReceiver: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2274)
at android.app.ActivityThread.access$1500(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:99)
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at com.futerox.inappbillinservice.BillingHelper.verifyPurchase(BillingHelper.java:300)
at com.futerox.inappbillinservice.BillingReceiver.purchaseStateChanged(BillingReceiver.java:45)
at com.futerox.inappbillinservice.BillingReceiver.onReceive(BillingReceiver.java:27)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2267)
give some idea ya demo zip
on my email
santoshkumar@futerox.biz
08130824333
Thanks
can you plz give me some suggestion
I think you have not generated base64EncodedPublicKey = "PUT YOUR PUBLIC KEY HERE"; for you application on google play store.
Deletei think you don't read my error thats why you told
DeleteI think you have not generated base64EncodedPublicKey = "PUT YOUR PUBLIC KEY HERE"; for you application on google play store.
K
Thanks...
Santosh Kumar
Hi Manish.
ReplyDeleteI just wanted to know how should I integrate inApp purchase with my project. As I am new to this and never used the Inapp before
very good tutorial. pretty good..thanks manish
ReplyDeleteManish sir, Good tutorial.. It works.. And one thing I ask, have you any sample code for In-app subscription. This is in-app purchase but as per requirements, I have to use in-app subscription that means monthly or yearly renewable payment type. So is there in sample or tutorial, please upload here. Or you can contact me on my id: sagar.ucet091@gmail.com
ReplyDeleteThank you sir in advance.
I get "BillingService﹕ BillingHelper not fully instantiated" in LogCat and purchase doesn't start.
ReplyDeleteGetting Error
ReplyDeletejava.lang.SecurityException: Binder invocation to an incorrect interface
at android.os.Parcel.readException(Parcel.java:1322)
at android.os.Parcel.readException(Parcel.java:1276)
at rk.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:108)
at rk.contact.inapppurchase.BillingHelper.isBillingSupported(BillingHelper.java:43)
at rk.contact.SubscribeActivity.onClick(SubscribeActivity.java:120)
at android.view.View.performClick(View.java:2533)
at android.view.View$PerformClick.run(View.java:9320)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4389)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
This comment has been removed by the author.
DeleteHello sir can we get information about whether item already purchased or not by user in starting in application
ReplyDeleteso find one link for that but in those link's code is not related to our code so in our code how can it possible
link is..http://stackoverflow.com/questions/14549786/handling-in-app-billing-refunds-in-v3
I think better option set a flag into database and get with the item list and onpurchase any update that item flag and if flag is 0 dont give purchase option to user.
DeleteThank u for replying sir
DeleteSir my Question is when user buy some item and then uninstall app from those device and then re - install app so all database is clear then how to get info of those Google account that item is purchased or not....
is there any response (json) get that particular google account
thank you..
My application is Subscription type of like one month, three month , yearly (Whatsapp) so how can it possible
Deleteis there any possibility of getting info about purchased history of related to google account
DeletePlease read the in app billing doc there are two type of payment mode one time and subscription base. So there is nothing to handle just set there weekly monthly payment method..
Deleteis it possible in this code..?
ReplyDeletehow..?
hi Manish,
ReplyDeleteplease send me the zip file of that code. My mail id is ajayaswal.bwm@gmail.com. Thanks in advance.
Hi Amit Jayaswal,
Deleteclick option four "zip code"
Sorry I didn't see before.
DeleteOk Thank you.....:)
Hi manish,
ReplyDeletePlease help me if there possible to change price programmatically
Hi Manish,
ReplyDeleteI have a Base64 key its created by me in google app store.But its not working . My error is "The item you were attempting to purchase could not be found"
My E-mail id : imans.vijay@gmail.com
ReplyDeleteHell Sir,
ReplyDeleteI have used an In-App Billing example which have you posted on your blog.But the problem arrives while fetching the JSonobject named "Order" as a Response from Google Play, as Json is missing two fields "DeveloperPayload" and "purchaseToken".
Please can you tell me, from where to get this two fields, as "purchaseToken" is needed for checking the Subscription Expiry Date.
I have stucked into my project.
I hope you will reply soon.
Thanks Manish.
ReplyDeleteThanks a lot for nice tutorial and zip.
It helps me lot.
Your welcome vish!
DeleteHello sir Thanks for tutorial.
ReplyDeleteI have complete sign apk and upload to playstore after i get hashkey from playstore and set at BillingSecurity.java line 135 now when i run your demo then i get crash.
my uploaded sign apk package name is com.hk.quiz
i think i need to change packge name in any class of your demo code?
Please help me sir
yes, if package is issue then you need a unique package name for your project because google does not accept same package name for 2 application.
DeleteHello Manish...can U rply my question...??
Delete@Shanu still your problem is remain. I am not sure but you should get in response all the data. If you are not getting follow google doc might be their api have been changed because my code is very old.
DeleteOk...but what is a solution to get the Purchase Receipt..?As I require it to check the Subscription Validity of my Product,it wud be ur great help if u can provide me any solution...
ReplyDeleteHi
ReplyDeletecan you please tell me, is it mandatory to publish the app while testing.
If my item is image and some string, than what i do ? please help me for in app item image library.
ReplyDeleteKeep the image in key-value pair in side your application and on play store just put your id of item.
Delete01-19 13:13:36.858 31349-31349/com.abcd.inapppurchase E/AndroidRuntime﹕ FATAL EXCEPTION: main
ReplyDeleteProcess: com.abcd.inapppurchase, PID: 31349
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.PendingIntent.send(android.content.Context, int, android.content.Intent)' on a null object reference
at com.manish.inapppurchase.BillingHelper.startBuyPageActivity(BillingHelper.java:292)
at com.manish.inapppurchase.BillingHelper.requestPurchase(BillingHelper.java:106)
at com.manish.inapppurchase.MainActivity.onClick(MainActivity.java:57)
at android.view.View.performClick(View.java:4803)
at android.view.View$PerformClick.run(View.java:20102)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5532)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
can you please help me for this type of error
it's seem somewhere package name issue. as per your log you have 2 package name-
Deletecom.abcd.inapppurchase
and com.manish.inapppurchase
I'm creating an Android application to sell digital content on my backend server. What I wish to do is fetch the order details after successful payment from the InApp Purchase and send details to server side as php response to retrieve the required data and send it back to the customer.
ReplyDeleteOn the server side the PHP functions are ready and set however how to connect the InApp with the PHP code.
After successfully payment done InAppPurchase will give you success response and after that you can call web-service and update your php server.
DeleteHi Manish thanks for the reply. Excuse me I'm a newbie for JSON can you further help me with the call web-service. The PHP server side is ready.
DeletePHP code:
// Fetch all the order details from Woocommerce
$products = array();
$_name = $order->billing_first_name.' '.$order->billing_last_name;
$_email = $order->billing_email;
$lastOrderId = $order->id;
include ('/home/username/public_html/keys/success.php');
I need the help how to connect this PHP with the app and return the result as a file to be downloaded.
Hi Manish Srivastava, I am using google in-app purchase for my app. For the older version, I were not save the purchase token.
ReplyDeleteI tried to get the purchase token from asking google account from it. It was not possible to get from it, because user may have more than
one playstore account while the purchased playstore account not set as primary or main account.
Please help me to fix this.
sir please send me zip file i needed ths code at
ReplyDeletemansingh.20@gmail.com