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

Web and WebWorks Development

Reply
Contributor
rufustitus
Posts: 14
Registered: ‎09-27-2012
My Device: Curve 9220
Accepted Solution

In App Purchases not working in Blackberry 10 devices. Forces the App to close abruptly

Hi all. I hope you can help.

I am developing an app using HTML5 and Webworks for BB10 devices, I have all required programs installed with their latest versions.

The app sells a digital good, a monthly subscription, by making use of the Payment API. The digital good exists and is approved in the vendor portal.

The issue is that when trying to use the blackberry.payment.purchase to initiate the purchase of the digital good; the code catches the error : ReferenceError: Can't find variable:blackberry. And nothing happens in the app.

Searching in Google I found out that I needed to include the <script src="local:///chrome/webworks.js" type="text/javascript"></script> in order to avoid getting the error.

After doing that, the app no longer shows the error. Instead it closes itself right at the moment in which the blackberry.payment.purchase is called. It does not throw any error, it just closes abruptly.

I have added the features needed features to make my app to work, These are the ones I used in my config xml

<feature id="blackberry.payment" required="true"  version="1.0.0.0"/>
<feature id="blackberry.identity" required="true" />
<feature id="blackberry.app" required="true" version="1.0.0.0" />
<feature id="blackberry.identity.phone" required="true" />
<feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0"/>

Can any one help.

Additional note: this failed in a Z10 dev alpha, a purchased Z10 device, and a Q10 when sent for approval to blackberry.

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 832
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: In App Purchases not working in Blackberry 10 devices. Forces the App to close abruptly

Since you only added the webworks.js file at the end, I'm guessing that you might not have included the proper steps to use blackberry APIs. Are you setting up a listener for the webworksready event before you call any blackberry APIs? There is a good example here: https://github.com/blackberry/BB10-WebWorks-Samples/blob/master/BfB-Boilerplate-bbUI.js-0.9x/index.h...

 

Looking at the Payment docs, I also see we've got both BBOS/PlayBook APIs listed in there with the BB10 ones and you'd have to double check them before calling them to see which ones are the right to use.

 

Have you stepped through the code in WebInspector to see what payment call triggers the crash?

Tim Windsor
Open Source Technical Lead
Please use plain text.
Contributor
rufustitus
Posts: 14
Registered: ‎09-27-2012
My Device: Curve 9220

Re: In App Purchases not working in Blackberry 10 devices. Forces the App to close abruptly

 

I have review the code. And in order to solve this I did the following

 

- I include at the top of the <header> the BBUI.js

- Then I include webworks.js and then all other Js code I have.

- Put the webworks listener and inside it the code I needed to prepare my app

- And finally Make sure that all the parameters and values in the purchase function are in quotes.

 

Once I did all these steps I manage to solve the issue.

Thanks for your help.

PS

Can you let me know if you have a billing example for Blackberry 10?

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 832
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: In App Purchases not working in Blackberry 10 devices. Forces the App to close abruptly

I'm glad to hear that. It sounds like you made the necessary changes. I looked before and found no full examples of payment in our samples on GitHub. I thought we did have one, but it doesn't appear so.

Tim Windsor
Open Source Technical Lead
Please use plain text.
Contributor
rufustitus
Posts: 14
Registered: ‎09-27-2012
My Device: Curve 9220

Re: In App Purchases not working in Blackberry 10 devices. Forces the App to close abruptly

 

Hey we got our app approved. But we are now havin this other issue, that in this other post.

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Payment-Error-quot-The-Item-you-...

 

Please use plain text.