In-App Subscription - android

when ever i test the subscription in application with testing account it return success callback and according to callback i store some information on my remote server......but when i publish it and test with other account the amount for the subscription deducted and it is performed successfully but i cannot receive success callback due to which im unable to access the content. how could we get transaction information from purchase model or inventory model other then that how could we get information about specific order ID like its remaining time etc, which is managed by google it self. how could we identify the user and (his/her) subscription on every device to access the content
mHelper = new IabHelper(this, "Key");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
} else {
Log.d(TAG, "In-app Billing is set up OK");
}
// Hooray, IAB is fully set up!
}
});
levelSubscriptionPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result,
Purchase purchase) {
if (result.isFailure()) {
Log.d(TAG, "failed billing");
} else {
Log.d(TAG, "purchase success Callback billing");
Log.d(TAG, purchase.getToken());
setSubscription(session.getUserDetail().getEmail());
}
}
};
mReceivedInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (!result.isFailure()) {
Log.d(TAG, "Query Inventory failed Callback billing");
/*Toast.makeText(Dashboard.this, "InventoryListener", Toast.LENGTH_SHORT).show();
// Handle failure
mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
mConsumeFinishedListener);*/
} else {
Log.d(TAG, "Query Inventory success Callback billing");
}
}
};
mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase,
IabResult result) {
if (result.isSuccess()) {
Log.d(TAG, "Consume finish success Callback billing");
} else {
Log.d(TAG, "Consume finish failed Callback billing");
}
}
};

You can get Purchase details in QueryInventoryFinishedListener like
Purchase monthlySubscription = inv.getPurchase(SKU_SUBSCRIPTION_MONTHLY);
if (monthlySubscription != null) {
Log.d(TAG, "User has already subscribed for monthly benefits.");
Utils.Log(monthlySubscription.toString());
} else {
launchSubscriptions();
}
private void launchSubscriptions() {
try {
iabHelper.launchSubscriptionPurchaseFlow((Activity) context,
SKU_SUBSCRIPTION_MONTHLY, REQUEST_CODE, new
IabHelper.OnIabPurchaseFinishedListener() {
#Override
public void onIabPurchaseFinished(IabResult result,
Purchase monthlySubscription) throws
IabHelper.IabAsyncInProgressException {
if (result.isFailure()) {
Log.e(TAG, "Error purchasing: " + result);
} else if (result.isSuccess()) {
Log.d(TAG, "---Success---");
} else {
Log.d(TAG, "---Error---");
}
}
}, String.valueOf(preferences.getUserId()));
} catch (IabHelper.IabAsyncInProgressException e) {
e.printStackTrace();
}
}
You also add one extra parameter in "launchSubscriptionPurchaseFlow" method. whenever you get Purchase details, you also get that extra parameter. so using this parameter you can identify user wise purchase
(in my case i add userId in launchSubscriptions() method)

Related

Inapp billing: Error response: 7:Item Already Owned Issue With Test Transactions

First time implementing in-app billing. i was able to complete first transaction, but second time while purchasing same item i am getting "Error response: 7:Item Already Owned" on onIabPurchaseFinished Method, how to make it re-purchase-able? any help would be appreciated.
screenshot of code structure is also attached.
Onclick purchase i am calling following method:
initilizeInAppPurchasePakages();
public void initilizeInAppPurchasePakages()
{
String base64EncodedPublicKey=getString(R.string.inAppBillingKey);
mHelper = new IabHelper(getActivity(), base64EncodedPublicKey);
mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
// Toast.makeText(getActivity(),"fail to purchase"+result, Toast.LENGTH_SHORT).show();
return;
}
else if (purchase.getSku().equals(purchaseItemId)) {
transactionId=purchase.getOrderId();
PackageFragment.isNeedToUpdate = true;
// consume the gas and update the UI
// Toast.makeText(getActivity(), "purchase successfully", Toast.LENGTH_SHORT).show();
mHelper.consumeAsync(purchase,
mConsumeFinishedListener);
}
else if (purchase.getSku().equals(purchaseItemId)) {
// give user access to premium content and update the UI
// Toast.makeText(getActivity(), "purchase successfully", Toast.LENGTH_SHORT).show();
}
}
};
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh no, there was a problem.
// Toast.makeText(getActivity(), "connection Error", Toast.LENGTH_SHORT).show();
}
else
{
// Toast.makeText(getActivity(), "connected successfully", Toast.LENGTH_SHORT).show();
Log.d(TAG, "Problem setting up In-app Billing: " + result);
mHelper.launchPurchaseFlow(getActivity(), purchaseItemId, 10001,
mPurchaseFinishedListener, "testing");
}
// Hooray, IAB is fully set up!
}
});
mConsumeFinishedListener =
new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase, IabResult result) {
if (result.isSuccess()) {
serverUtilities.savePayment(pakageId,pakagePrice,transactionId);
// Toast.makeText(getActivity(), "consumed", Toast.LENGTH_SHORT).show();
// provision the in-app purchase to the user
// (for example, credit 50 gold coins to player's character)
}
else {
// handle error
}
}
};
}
Alright,
After spending time on reading documentation of google in app billing i found that i need to test in app billing through testing so what i did
test billing:
mHelper.launchPurchaseFlow(getActivity(), purchaseItemIdSKU, 10001,
mPurchaseFinishedListener, "testing");
Calling only first time to remove that already purchased entry record above the test billing line that i used above:
ArrayList skusToBeListed = null;
skusToBeListed = new ArrayList<String> ();
skusToBeListed.add (SKU_PREMIUM);
skusToBeListed.add (SKU_PREMIUM_ELITE);
skusToBeListed.add (SKU_PREMIUM_PLUS);
mHelper.queryInventoryAsync(true, skusToBeListed, mGotInventoryListener);
and once its done you can do many test bookings without any headache.
mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
#Override
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
//complain("Failed to query inventory: " + result);
return;
}
Purchase currentPurchase = inventory.getPurchase(purchaseItemIdSKU);
if(currentPurchase != null)
{
//Boolean mIsPremium = (currentPurchase != null && verifyDeveloperPayload(currentPurchase));
mHelper.consumeAsync(currentPurchase,mConsumeFinishedListener);
}
}
} ;
Note:
In case of test billing transaction id will not be returned so make sure how to handle that, i did tested my in app billing by hard coding it to following format: "GPA.1234-5678-9012-34567"
In short above code of mine was fine if i would i have used it on production mode, but in case of testing mode it was giving me errors that i explained and given solution how i solved it.

android in app purchase - Articel already owned issue

I have just implemented the in app billing functionality in my app.
I only have one product to unlock all premium features.
The purchase itself works, but after the purchase flow, my code obviously isn't able to recognise the success of the purchase, because there appears a complain window right after purchase saying "Articel already owned". So somehow the purchase flow is not recogniced to be successful. After i restart the app, the pro features are unlocked, because the querying of the inventory says, the pro features have been bought.
I am out of ideas, so here is my code:
// SKUs for our products: the premium upgrade (non-consumable)
String SKU_PREMIUM;
// (arbitrary) request code for the purchase flow
final int RC_REQUEST = 10001;
// The helper object
IabHelper mHelper;
// Provides purchase notification while this app is running
public IabBroadcastReceiver mBroadcastReceiver;
IabHelper.QueryInventoryFinishedListener mGotInventoryListener;
AppCompatActivity activity;
private String payload;
public InAppBillingHelper(AppCompatActivity context, final IabBroadcastReceiver.IabBroadcastListener contextBroadcastListener, String base64EncodedPublicKey,String skuPremium, boolean debug){
//String base64EncodedPublicKey = "VALENTIN_HERR_SCHAFKOPF_RECHENHELFER";
this.activity = context;
SKU_PREMIUM = skuPremium;
// Create the helper, passing it our context and the public key to verify signatures with
Log.d(TAG, "Creating IAB helper.");
mHelper = new IabHelper(context, base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(debug);
// Start setup. This is asynchronous and the specified listener
// will be called once setup completes.
Log.d(TAG, "Starting setup.");
// Listener that's called when we finish querying the items and subscriptions we own
mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// Is it a failure?
if (result.isFailure()) {
complain("Fehler bei der Bestimmung der App-Lizenz: " + result);
// TODO analyse results and output it to the user
return;
}
Log.d(TAG, "Query inventory was successful.");
// Do we have the premium upgrade?
Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
}
updateUi();
setWaitScreen(false);
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
complain("Problem setting up in-app billing: " + result);
return;
}
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
mBroadcastReceiver = new IabBroadcastReceiver(contextBroadcastListener);
IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
try {
activity.registerReceiver(mBroadcastReceiver, broadcastFilter);
}catch (Exception e)
{}
// IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
try {
mHelper.queryInventoryAsync(mGotInventoryListener);
} catch (IabHelper.IabAsyncInProgressException e) {
complain("Error querying inventory. Another async operation in progress.");
}
}
});
}
public void receivedBroadcast() {
// Received a broadcast notification that the inventory of items has changed
Log.d(TAG, "Received broadcast notification. Querying inventory.");
try {
mHelper.queryInventoryAsync(mGotInventoryListener);
} catch (IabHelper.IabAsyncInProgressException e) {
complain("Error querying inventory. Another async operation in progress.");
}
}
// User clicked the "Upgrade to Premium".
public void handlePremiumPurchase() {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
setWaitScreen(true);
payload = "";
try {
mHelper.launchPurchaseFlow(activity, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
} catch (IabHelper.IabAsyncInProgressException e) {
complain("Error launching purchase flow. Another async operation in progress.");
setWaitScreen(false);
}catch (NullPointerException e)
{
complain("Fehler beim Kaufversuch. Stelle sicher, dass mit einem Google Konto im PlayStore angemeldet bist und eine stabile Internetverbindung besteht." +
"Versuche es nach noch einmal." +
"");
setWaitScreen(false);
}
}
public boolean isPremium() {
return mIsPremium;
}
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
if (mHelper == null) return false;
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
// Todo handle
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
return true;
}
/** Verifies the developer payload of a purchase. */
boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();
// Todo payload string verification
return true;//payload.equals(this.payload);
}
// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
// if we were disposed of in the meantime, quit.
if (mHelper == null) return;
if (result.isFailure()) {
if(result.getResponse() == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED)
{
mIsPremium = true;
updateUi();
//complain("Du besitzt bereits das Premium Paket auf einem deiner angemeldeten Google Konten.");
}
else {
complain("Fehler beim Kauf: " + result);
}
setWaitScreen(false);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
setWaitScreen(false);
return;
}
Log.d(TAG, "Purchase successful.");
if (purchase.getSku().equals(SKU_PREMIUM)) {
// bought the premium upgrade!
Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
alert("Danke für das Premium Upgrade! Ich wünsche dir weiterhin viel Spaß bei der Nutzung!");
mIsPremium = true;
updateUi();
setWaitScreen(false);
}
}
};
Btw: The code is a modified version of the **trivial drive* example.
Thanks in advance!
Although it's not the cleanest solution, just query the inventory again if you have a "already owned error". Then update the UI only according to the inventory query result
Thanks #DerAdler . I implemented it just the way you said and it worked.

How to check user status on my app? In App Billing

I´m implementing In app Billing on my app, which let the user go to a "premium version of the app". In the premium version of the app the user will be able to click 3 buttons and use their functions. But that is not the problem.
The problem is how to check if the user has purchased the "premium version" yet and use all the app functions?
This is my code:
private void promptForUpgrade() {
AlertDialog.Builder upgradeAlert = new AlertDialog.Builder(this);
upgradeAlert.setTitle("Upgrade?");
upgradeAlert.setMessage("Do you want to upgrade to unlimited version?");
upgradeAlert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
//set progress dialog and start the in app purchase process
upgradeDialog = ProgressDialog.show(selector.this, "Please wait", "Upgrade transaction in process", true);
/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "developerinnovaciones#gmail.com";
try {
mHelper.launchPurchaseFlow(selector.this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
} catch (IabHelper.IabAsyncInProgressException e) {
e.printStackTrace();
}
}
}).setNegativeButton("Nop", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
upgradeAlert.show();
}
and this is the OnIabPurchaseFinishedListener
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
// if we were disposed of in the meantime, quit.
if (mHelper == null) return;
if (result.isFailure()) {
alert("Error purchasing: " + result);
upgradeDialog.dismiss();
}
else if (purchase.getSku().equals(SKU_PREMIUM)) {
alert("Thank you for upgrade");
mIsPremium = true;
setUserStatus(true);
upgradeDialog.dismiss();
}
}
};
So basically I want to create a method which verify if the user is premium or not.
Hope you can help me :D
Within your onCreate method you should check the purchase status in your mHelper setup with an mHelper.queryInventoryAsync call.
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
complain("Problem setting up in-app billing: " + result);
isBillingSupported = false;
return;
}
// Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(false, mGotInventoryListener);
isBillingSupported = true;
}
});
mGotInventory I defined like this
// Listener that's called when we finish querying the items we own
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
if (result.isFailure()) {
complain("Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
// Do we have the premium upgrade?
isPremium = inventory.hasPurchase(SKU_PREMIUM);
Log.d(TAG, "User is " + (isPremium ? "PREMIUM" : "NOT PREMIUM"));
updateUi();
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};
isPremium is a boolean flag defaulting to false.
The updateUi method enables/disables buttons depending on the isPremium state.
You will probably want to set isPremium and call updateUi on purchase completion as well to ensure the premium features are enabled immediately.

Android Studio In-App purchases configuration

I am setting up in-app purchases for my application and am stuck at a particular point. The code I have used so far is as follows:
IabHelper mHelper;
protected void onCreate(Bundle savedInstanceState) {
mHelper = new IabHelper(this, base64EncodedPublicKey); //base64EncodedPublicKey is a string declared earlier and not reposted here.
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "Failed: " + result);
Toast.makeText(MainActivity.this, "IAB setup Failed", Toast.LENGTH_SHORT).show();
} else {
Log.d(TAG, "Worked");
Toast.makeText(MainActivity.this, "IAB setup Successful", Toast.LENGTH_SHORT).show();
final List additionalSkuList = new ArrayList();
additionalSkuList.add("remove_ad");
mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
}
}
});
At this point, everything seems to be going well. The "Worked" section of code triggers and is processed successfully. The code sends a request at this point to mHelper.queryInventoryAsync, which is configured as follows, outside of onCreate():
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory)
{
if (result.isFailure()) {
Toast.makeText(MainActivity.this, "Query Listener Error", Toast.LENGTH_SHORT).show();
return;
}
String removalPrice =
inventory.getSkuDetails("remove_ad").getPrice();
Toast.makeText(MainActivity.this, removalPrice, Toast.LENGTH_SHORT).show();
// update the UI
}
};
At this point, Toast triggers to say "Query Listener Error", indicating that if (result.isFailure()) has triggered. This is where I am stuck. It is not giving me any clues as to why this might be happening.
From the Developer Console, these are the details of my In-App product:
Name/ID: Remove Ad (remove_ad)
Type: Managed product
Last Update: Jul 15, 2015
Status: Active
What have I done incorrectly? The only thing I am not too sure about is how I have declared and used my arrayList, and where I have submitted a string value to .getPrice();
mHelper.launchPurchaseFlow(Activity.this, SKU, 11,
mPurchaseFinishedListener, "mypurchasetoken");
Call this method and implement listner like below in that you will get result
public IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result,
Purchase purchase)
{
if (result.isFailure()) {
}
return;
}
};
Refer the below link:
http://www.techotopia.com/index.php/An_Android_Studio_Google_Play_In-app_Billing_Tutorial

SKU bought with IAP doesn't show up on as purchased on a second device owned by the same user

I get this complaint every so often that a user buys my premium features with IAP and that it works fine on the device they bought but their other device won't get the features, I ask them to reboot the other device and that usually fixes it. So the other day I tried to see if I could do something about this so I purchased on one of my devices (test account) and then I went to the other, killed my app to make sure it was starting from zero, and then stepped the code. The query of purchases was actually returning no purchases. It did not tell me about purchases until I tried to buy premium from that device. Trying to buy premium from that device didn't create a dialog or anything, it just returned as if nothing had happened but after that the device had that purchase on its inventory.
Here are the methods I have, I am using the IABHelper from Google's example and I think I updated it just a month ago.
public void createIABHelper(final Context ac) {
mHelper = new IabHelper(ac, myid);
try {
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
} else {
iabSetup = true;
//queryIAB(ac);
queryIABPurchases(ac);
}
}
});
} catch (Throwable e) {
final String desc = "Error starting IABHelper";
Log.w(TAG, desc, e);
}
}
public void queryIAB(final Context ctx) {
List<String> additionalSkuList = new ArrayList<String>();
additionalSkuList.add(Constants.PREMIUM_UPGRADE);
IabHelper.QueryInventoryFinishedListener
mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
// handle error
return;
} else {
Purchase p = inventory.getPurchase(Constants.PREMIUM_UPGRADE);
if (p != null) {
setHasPremiumPref(p.getPurchaseState() == 0);
} else {
setHasPremiumPref(false);
}
}
// inventory.hasDetails(PREMIUM_UPGRADE);
// update the UI
}
};
mHelper.queryInventoryAsync(true, additionalSkuList,
mQueryFinishedListener);
}
#Override
public void purchaseIAB(final Activity ac) {
if (iabSetup) {
try {
final String finalPayload = ....;
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
return;
} else if (purchase.getSku().equals(Constants.PREMIUM_UPGRADE)) {
Log.w(TAG, "Purchased " + purchase.getPurchaseState());
if (purchase.getDeveloperPayload().equals(finalPayload) && purchase.getPurchaseState() == 0) {
setHasPremiumPref(true);
} else {
Log.w(TAG, "Something went wrong verifying purchase.");
setHasPremiumPref(false);
}
}
}
};
mHelper.launchPurchaseFlow(ac, Constants.PREMIUM_UPGRADE, 10001,
mPurchaseFinishedListener, finalPayload);
} catch (Throwable ex) {
final String msg = "Error starting in-app purchase";
Log.w(TAG, msg, ex);
}
} else {
Log.w(TAG, "IAB not setup.");
}
}
public void queryIABPurchases(Context ctx) {
if (iabSetup) {
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
} else {
// does the user have the premium upgrade?
Purchase p = inventory.getPurchase(Constants.PREMIUM_UPGRADE);
if (p != null) {
setHasPremiumPref(p.getPurchaseState() == 0);
} else {
setHasPremiumPref(false);
}
// update UI accordingly
}
}
};
List<String> additionalSkuList = new ArrayList<String>();
additionalSkuList.add(Constants.PREMIUM_UPGRADE);
mHelper.queryInventoryAsync(false, additionalSkuList, mGotInventoryListener);
} else {
Log.w(TAG, "IAB not setup.");
}
}
Anyways, basically I use queryIABPurchases but p is always null on that second device. Is this an issue with test accounts or maybe something to do with time, do I maybe need to wait a few hours before testing on the second device?
Thanks.

Categories

Resources