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
New Contributor
nbody
Posts: 5
Registered: ‎02-20-2014
My Device: Z10
My Carrier: Rogers
Accepted Solution

Android Billing

Hi, 

 

I am trying to get billing working. Since the V2 libs are no longer available from Google I have resorted to a wrapper on the V2 library from github: https://github.com/robotmedia/AndroidBillingLibrary

 

All is ok when I use with Google Play. 

 

When I use with BBWorld the dialog for the purchase does not appear. The code that checks billing is supported does seem to work. I am in sandbox mode and starting the app from Setting/Developer in BBWorld. The goods are added etc. 

 

If there is reference code that does work, I am happy to switch to that. I am using this GitHub code as it was the only way I could find V2 market billing stuff. 

 

The logs are:

<BB10 logs>

I/BillingRequest(37949697): Sending bundle Bundle[{API_VERSION=1, PACKAGE_NAME=com.nbodyphysics.nball, BILLING_REQUEST=CHECK_BILLING_SUPPORTED}]

I/BillingRequest(37949697): response was Bundle[mParcelledData.dataSize=48]

I/NBallActivity(37949697): *** Billing is supported

D/Billing (37949697): Request -1 of type CHECK_BILLING_SUPPORTED sent

 

 

I/NBallActivity(37949697): checking billingSupported=true

I/BillingRequest(37949697): Sending bundle Bundle[{API_VERSION=1, PACKAGE_NAME=com.nbodyphysics.nball, BILLING_REQUEST=REQUEST_PURCHASE}]

I/BillingRequest(37949697): response was Bundle[mParcelledData.dataSize=208]

D/Billing (37949697): Request 2 of type REQUEST_PURCHASE sent

D/navigatorshell(37949673): payment request

</BB10Logs>

 

I am a bit puzzled by the API_VERSION=1, but when I changed that to 2 the app did not detect billing supported. 

 

For reference the same app talking to Google Play:

<Google Logs>

I/BillingRequest( 2044): Sending bundle Bundle[{BILLING_REQUEST=REQUEST_PURCHASE, PACKAGE_NAME=com.nbodyphysics.nball, API_VERSION=2}]

D/Finsky  ( 1850): [7009] InAppBillingUtils.getPreferredAccount: com.nbodyphysics.nball: Account from first account - [L3TNJ0-jYYopp50Lsxxycmwq9Og]

D/Finsky  ( 1850): [7009] InAppBillingUtils.getPreferredAccount: com.nbodyphysics.nball: Account from first account - [L3TNJ0-jYYopp50Lsxxycmwq9Og]

I/BillingRequest( 2044): response was Bundle[mParcelledData.dataSize=208]

D/Billing ( 2044): Request 5715815745718647738 of type REQUEST_PURCHASE sent

D/Finsky  ( 1850): [1] CarrierParamsAction.createCarrierBillingParameters: Carrier billing config is null. Device is not targeted for DCB 2.

D/Billing ( 2044): Received com.android.vending.billing.IN_APP_NOTIFY

D/Billing ( 2044): Notification -903949946837880483 available

I/BillingRequest( 2044): Sending bundle Bundle[{BILLING_REQUEST=GET_PURCHASE_INFORMATION, NONCE=5790625523383869766, PACKAGE_NAME=com.nbodyphysics.nball, API_VERSION=2}]

D/Finsky  ( 1850): [7008] InAppBillingUtils.getPreferredAccount: com.nbodyphysics.nball: Account from first account - [L3TNJ0-jYYopp50Lsxxycmwq9Og]

D/Finsky  ( 1850): [7008] InAppBillingUtils.getPreferredAccount: com.nbodyphysics.nball: Account from first account - [L3TNJ0-jYYopp50Lsxxycmwq9Og]

I/BillingRequest( 2044): response was Bundle[mParcelledData.dataSize=92]

D/Billing ( 2044): Request 6016901650873485619 of type GET_PURCHASE_INFORMATION sent

D/Finsky  ( 1850): [1] MarketBillingService.sendResponseCode: Sending response RESULT_OK for request 6016901650873485619 to com.nbodyphysics.nball.

D/Billing ( 2044): Received com.android.vending.billing.PURCHASE_STATE_CHANGED

</Google>

Please use plain text.
New Contributor
nbody
Posts: 5
Registered: ‎02-20-2014
My Device: Z10
My Carrier: Rogers

Re: Android Billing

The difference in the two cases is that in the Google play case there is a notification from the billing service:

D/Billing ( 2044): Received com.android.vending.billing.IN_APP_NOTIFY

D/Billing ( 2044): Notification -903949946837880483 available

 

This is not happening on BB. I have confirmed that the sending of the request gets an OK response - but this is probably handled in the AIDL code and does not indicate life in the Market Billing proxy.

 

This makes me suspicous of some kind of dev setup.

- I am starting from BBWorld/Settings/Developer

- App is in draft statys

- I am logged in with the BBID I have put in the sandbox

 

On Google this cannot be the same as the developer account, I needed to create a second ID.

Anyone know if the same restriction applies on BB?

 

Cheers.

 

Please use plain text.
New Developer
JuanIrache
Posts: 9
Registered: ‎08-13-2013
My Device: Playbook
My Carrier: Pepephone

Re: Android Billing

Exact same issue here.
Please use plain text.
New Developer
JuanIrache
Posts: 9
Registered: ‎08-13-2013
My Device: Playbook
My Carrier: Pepephone

Re: Android Billing

Rockgecko's suggestion her: http://supportforums.blackberry.com/t5/Android-Runtime-Development/Is-in-app-billing-API-v3-supporte... helped me get sucessfully to the next problem :smileyhappy:

Please use plain text.
New Contributor
nbody
Posts: 5
Registered: ‎02-20-2014
My Device: Z10
My Carrier: Rogers

Re: Android Billing

Interesting. 

 

I have tried changing the API_VERSION to 1 in only the billing request and in all requests. I still do not get a notification response. 

 

You are now seeing a notification after the Billing Request?

 

 

Please use plain text.
New Developer
JuanIrache
Posts: 9
Registered: ‎08-13-2013
My Device: Playbook
My Carrier: Pepephone

Re: Android Billing

So what I got now is I can pay for the products: the payment window shows up and points at the right goods... but I'm not getting the right response, although I think I'm skipping the signature verification process correctly. onPurchaseStateChange is never called.

 

Documentation on this topic is really scarce, and testing is cumbersome... My code works seamlessly on Android devices, but it's taking me ages to get it ready for BB.

Please use plain text.
New Contributor
nbody
Posts: 5
Registered: ‎02-20-2014
My Device: Z10
My Carrier: Rogers

Re: Android Billing

Concur. 

 

I was excited for a minute when I found "enable Billing Logging" under accounts in BBWorld, until no new info appeared. 

 

I have raised an issue in the developer bug tracker. A working example along the lines of the Cascades Fremium sample is sorely needed. 

Please use plain text.
New Developer
JuanIrache
Posts: 9
Registered: ‎08-13-2013
My Device: Playbook
My Carrier: Pepephone

Re: Android Billing

Ok. I think I solved my case. I suspect I was skipping too much of the verification process. In the end, from the Security class of the Dungeons example, this is what I had to modify:

 

(the variable BB indicates that the app is running on a BlackBerry device, I check that when my code starts running)

 

if (!TextUtils.isEmpty(signature)) {

 

Becomes

 

if (!TextUtils.isEmpty(signature) || BB) {

 

-------------------------------------------------------

 

and

 

verified = Security.verify(key, signedData, signature);

 

Becomes

 

if (BB){

verified = true;
} else {
verified = Security.verify(key, signedData, signature);
}

 

-----------

 

And that's it really. Other tweaks apply only to my app in particular.

 

I hope this helps!

Please use plain text.
New Contributor
nbody
Posts: 5
Registered: ‎02-20-2014
My Device: Z10
My Carrier: Rogers

Re: Android Billing

Awesome. 

 

I still had problems with the original GitHub repo code. 

 

I switched to: 

http://code.google.com/p/marketbilling/source/browse/v2/r=e4f8a8789c678fcb4960a3d2adc5be185e11b519#v...

 

Applied the two changes you suggested and Dungeons works vs Blackberry World. 

 

Fabulous!

Please use plain text.