This sample demonstrates how to leverage the BlackBerry Payment Service in an application created using the WebWorks SDK. The Payment Service JavaScript API provides an end-to-end payment solution for monetizing application content.
ID | Name | License Type |
---|
Description
License
Icons (shopping_icons_set2) courtesy of Daily Overview via IconFinder.com.
Using the Payment Service API, you can provide an end-to-end payment solution to allow users to purchase in-application digital goods.
As explained in the Developer's Blog posting, Introducing the BlackBerry Payment Service and BlackBerry Payment Service SDK, there are certain types of digital goods that can be distributed through BlackBerry App World, and others that cannot.
Allowed digital goods:Display a "Subscriptions" menu item if the user has purchased an given digital good "123":
HTML:
<ul>
<li>Home</li>
<li>News</li>
<li>Channels</li>
<li id="sub" style="display:none;">Subscriptions</li>
</ul>
JavaScript:
function checkForSubscription(data)
{
for (var i = 0, len = data.length; i < len; i++)
{
if (data[i].digitalGoodID === "123") {
document.getElementById("sub").style.display = "";
break;
}
}
}
blackberry.payment.getExistingPurchases(true, checkForSubscription, onFailure);
The "Payment API Test App" demonstrates how to make use of the BlackBerry Payment Service to include features such as a "Buy" button in your application, as well as processing a history of purchases.
A purchase request is completed by creating a JSON object containing the details of a digital good, and calling the blackberry.payment.purchase() method. The payment service (live server, or local cache depending on whether development mode is On) will return another JSON object containing the successful details of the transaction.
As a developer, you create the digital goods for your application through the App World vendor portal.
For detailed information on how to create digital goods for your application, see the "Submitting digital goods" chapter of the Payment Service SDK Development Guide.
Development mode is a true/false value that defines how an application behaves when a purchase request is submitted using the BlackBerry payment API. Development mode is Off by default.
On - If development mode is On, the application does not contact the (live) Payment Service server for any transactions. This mode is useful for testing how your application handles the possible results without requiring network connections or currency. For purchases, a simulated purchase screen is displayed, allowing the user to choose the result of the purchase. For retrieving existing purchases, only simulated successful purchases are returned.
Off - If development mode is Off, purchases and retrievals of existing purchases proceed normally, contacting the (live) Payment Service server for any transactions. Users are prompted to select one of their preferred payment methods. Off is the default development mode, and applications in production should not modify it.