I am trying to setup the in app payment on a Blackberry 10 app. When I put the following line in my code, my app does not show any error but is not working anymore (buttons do not respond, etc.):
blackberry.payment.developmentMode = true;
What is the proper way to enable the payment development mode? I am doing all my tests on the Blackberry Simulator version 10.0.10.261. I do not have a real device.
I'm actually working on a Payment SDK sample right now. Here's how I'm doing it... Note that my initApp function is being called when the webworksready event is fired.
In your index.html you'll want to create an event listener for this. You cannot access any native APIs until this event has triggered.
<!-- Set the webworksready event handler -->
<head>
<script type="text/javascript">
document.addEventListener("webworksready", initApp);
</script>
</head>
Then, the JavaScript portion...
/**
* called by the webworksready event when the environment is ready
*/
function initApp() {
// init payment service development mode
try {
blackberry.payment.developmentMode = true;
} catch(e) {}
}
function purchase() {
console.log('purchasing');
try {
blackberry.payment.purchase({
"digitalGoodID": "123",
"digitalGoodSKU": "someSKU",
"digitalGoodName": "SomeName",
"metaData": "metadata",
"purchaseAppName": "WebWorks APP",
"purchaseAppIcon": null,
"extraParameters": {
"key1": "value1",
"key2": "value2"
}
},
onSuccess, onFailure);
} catch (e) {
alert("Error" + e);
}
}
function onSuccess(purchasedItem) {
console.log(purchasedItem)
}
function onFailure(error) {
console.log(error);
}