Responding to a purchase
When the purchase process completes, your app calls either onSuccess if the purchase is successful, or onFailure if the purchase is not successful.
<script type="text/javascript"> function purchase() { 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) { var transId = purchasedItem.transactionID; var sku = purchasedItem.digitalGoodSKU; var dgId = purchasedItem.digitalGoodID; alert("Purchased Item: " + transId + "," + sku + "," + dgId); } function onFailure(error) { alert("Error occurred: " + error.errorText + ", " + error.errorID); } </script>
Error responses for blackberry.payment.purchase
The paymentError object is returned as a parameter for callbackOnFailure if the purchase process is unsuccessful. The paymentError object has two properties: Number errorID and an errorText string.
Number errorID
The error number returned as part of the paymentError object corresponds with a preset list of specific error conditions, as follows:
- -1 = an unexpected application error
- 1 = the user canceled the transaction
- 2 = the payment system is busy
- 3 = a general payment system error
- 4 = the digital good was not found
- 5 = an illegal application error (applies only to BlackBerry OS 5.0 and later)
String errorText
The paymentError object returns a text string that can display as a readable message for the user.
Last modified: 2014-10-09
Got questions about leaving a comment? Get answers from our Disqus FAQ.
comments powered by Disqus