About

Payment API Demo

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.

Digital Goods:

ID Name License Type

Inventory:


Payment History:

No digital goods have been purchased from this application.

About

Home
Application icon

Description

Copyright

License

Icons (shopping_icons_set2) courtesy of Daily Overview via IconFinder.com.

Use Cases

Home

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:
  • Digital Content – eBooks, magazines, photos, artwork, or digital property (e.g. audio, video content) that you can use on a BlackBerry® device.
  • Additional Functionality – new features, levels, characters, or games (e.g. "epic sword", "levels 50-59". Must be distributed with the application and unlocked for a BlackBerry device user after a purchase.
  • Services – any kind of digital service that a BlackBerry device user must pay to use (e.g. subscriptions, video streaming).
Prohibited digital goods:
  • Virtual currencies or in-app credits – digital currencies or in-app credits that can be used to purchase digital goods are prohibited.
  • Physical goods or services – In-app purchases must be digital content that is usable on the BlackBerry device, not physical goods or services.
  • Digital goods used across multiple applications – You can’t sell digital goods to a user in one application that can be used with other applications.

Example:

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);

How it Works

Home

Getting Started: Sample app

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.

  1. Enable or disable payment service development mode.
  2. Click on a "Buy" button to purchase one of the available digital goods.
  3. Observe any success or error messages as well as the purchase history listing.

Buying Digital Goods

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.

Creating Digital Goods

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

Home

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.


Development Mode local dialog prompt    Development Mode local dialog prompt

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.


Preferred payment method prompt