Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
Contributor
varunagp1988
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book

Blackberry in app purchase not working after integrating google IAP v2

Hello guys,

 

I have integrated google in-app billing v2 for my app,i have a button called "buy full version" but when i click on that nothing happens.

 

I have verified the package name, SKU from the store its excatly same and permissions in the manifest file.

 

What might be the problem?what i am missing here.

 

Here is my code:

 

This is from the Dungeons example give by android.

 

// this is onclick of buy full version button

 

public void onClick(View v) {
    if (v == mBuyButton) {
        if (Consts.DEBUG) {
        Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
        }
        if (!mBillingService.requestPurchase(mSku, mPayloadContents)) {
        showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
        }
    }

 

 /**
     * A {@link PurchaseObserver} is used to get callbacks when Android Market sends
     * messages to this application so that we can update the UI.
     */
    private class DungeonsPurchaseObserver extends PurchaseObserver {
    public DungeonsPurchaseObserver(Handler handler) {
        super(Dungeons.this, handler);
    }

    @Override
    public void onBillingSupported(boolean supported) {
        if (Consts.DEBUG) {
        Log.i(TAG, "supported: " + supported);
        }
        if (supported) {
        restoreDatabase();
        mBuyButton.setEnabled(true);
        } else {
        showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
        }
    }

    @Override
    public void onPurchaseStateChange(PurchaseState purchaseState, String itemId, int quantity, long purchaseTime, String developerPayload) {
        if (Consts.DEBUG) {
        Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
        }

        if (developerPayload == null) {
        logProductActivity(itemId, purchaseState.toString());
        } else {
        logProductActivity(itemId, purchaseState + "\n\t" + developerPayload);
        }

        if (purchaseState == PurchaseState.PURCHASED) {
        mOwnedItems.add(itemId);
        }
        mCatalogAdapter.setOwnedItems(mOwnedItems);
        mOwnedItemsCursor.requery();
    }

    @Override
    public void onRequestPurchaseResponse(RequestPurchase request, ResponseCode responseCode) {
        if (Consts.DEBUG) {
        Log.d(TAG, request.mProductId + ": " + responseCode);
        }
        if (responseCode == ResponseCode.RESULT_OK) {
        if (Consts.DEBUG) {
            Log.i(TAG, "purchase was successfully sent to server");
        }
        logProductActivity(request.mProductId, "sending purchase request");
        } else if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
        if (Consts.DEBUG) {
            Log.i(TAG, "user canceled purchase");
        }
        logProductActivity(request.mProductId, "dismissed purchase dialog");
        } else {
        if (Consts.DEBUG) {
            Log.i(TAG, "purchase failed");
        }
        logProductActivity(request.mProductId, "request purchase returned " + responseCode);
        }
    }

    @Override
    public void onRestoreTransactionsResponse(RestoreTransactions request, ResponseCode responseCode) {
        if (responseCode == ResponseCode.RESULT_OK) {
        if (Consts.DEBUG) {
            Log.d(TAG, "completed RestoreTransactions request");
        }
        // Update the shared preferences so that we don't perform
        // a RestoreTransactions again.
        SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = prefs.edit();
        edit.putBoolean(DB_INITIALIZED, true);
        edit.commit();
        } else {
        if (Consts.DEBUG) {
            Log.d(TAG, "RestoreTransactions error: " + responseCode);
        }
        }
    }
    }

 

Please use plain text.
Contributor
varunagp1988
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book

Re: Blackberry in app purchase not working after integrating google IAP v2

Is there anyone here who can help me with that? Or should I ask somewhere else?

 

Thanks

Varuna G.P.

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: Blackberry in app purchase not working after integrating google IAP v2

Hi Varuna,

 

Which device and OS are you using? Have you debugged your app to see whre the failure may be occurring?

 

How was the app installed?

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
varunagp1988
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book

Re: Blackberry in app purchase not working after integrating google IAP v2

Hi gbeukeboom,

 

 Thanks for looking into my query.

 

Device : Blackberry Play Book

OS Version : 2.1.0.1526

 

Yes i have debugged it by adding toast messages, when we RequestPurchase it enters here,

 

 PendingIntent pendingIntent = response.getParcelable(Consts.BILLING_RESPONSE_PURCHASE_INTENT);
        if (pendingIntent == null) {
        Log.e(TAG, "Error with requestPurchase");
        Toast.makeText(getApplicationContext(), "Errors: Error with requestPurchase " + Consts.BILLING_RESPONSE_INVALID_REQUEST_ID, 2000)
            .show();
        return Consts.BILLING_RESPONSE_INVALID_REQUEST_ID;
        }

 

I am not able to proceed further this,please help me to solve this.

 

posted the same problem here by @dhatchina

 

http://supportforums.blackberry.com/t5/Android-Runtime-Development/Android-Inapp-purchase-response/t...

 

Thanks

Varuna G.P.

 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: Blackberry in app purchase not working after integrating google IAP v2

How was the app installed? In order to test in app payments in Android Runtime apps you need to install the app through the BlackBerry World client. Side-loading will not allow testing of in app payments and is the likely cause of this issue.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
varunagp1988
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book

Re: Blackberry in app purchase not working after integrating google IAP v2

Yes you are right, i have uploaded the bar and made it as draft, and now i have followed the steps given here to test the app

 

http://supportforums.blackberry.com/t5/BlackBerry-World-Development/How-To-Live-Testing-the-Payment-...

 

But i am facing this issue and not able to install the app on BB device.

 

http://supportforums.blackberry.com/t5/Android-Runtime-Development/Not-able-to-download-BB-app-Inter...

 

please have a look at it once.

 

 

Thanks

Varuna G.P.

Please use plain text.
Contributor
varunagp1988
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book

Re: Blackberry in app purchase not working after integrating google IAP v2

Today i was able to dowload the app from BlackBerry World client, but still i am facing the same issue, can you guide where i am going wrong or is there any issue from Blackberry end.

 

Thanks

Varuna G.P

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: Blackberry in app purchase not working after integrating google IAP v2

Hi Varuna,

 

We have several Android Runtime apps running on the platform, using in-app purchases, without error. Do you create log files from the app? We would need details of what is happening when the app is installed through BlackBerry World to determine what the root cause may be.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
varunagp1988
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book

Re: Blackberry in app purchase not working after integrating google IAP v2

Hello,

 

 As i had said before, this was already pointed by @dhatchina

 

here : http://supportforums.blackberry.com/t5/Android-Runtime-Development/Android-Inapp-purchase-response/t...

 


And your reply to that:

 

Can you PM me the ID of your app? I can perform some testing on my side to see if I notice anything strange.

 

I am having exactly same problem, so kindly help me to solve this issue.

 

If required i can post the entire code, i mean the dungeons example give by Google.

 

Thanks

Varuna G.P.

Please use plain text.