Testing in-app purchases

You can test purchase and payment transactions in your app by using: local testing, which simulates purchases, and sandbox user account, which sends transactions to the BlackBerry World server but doesn’t charge you.

You can also test your app in production mode in BlackBerry World, and your purchases will be charged to your account.

Check out each of these methods in the following diagrams:

Testing locally

Setting your connection mode to paymentservice_set_connection_mode() allows you to use a simulated interface to test in-app purchases.

When the value true is returned, your connection mode is set to local, and your app doesn't contact the BlackBerry World server for any transactions that you make. When you test in-app purchases, the purchase options are displayed in a dialog box.

You can choose the response that is returned to the application (either Success or Failure) and you can specify the reason for failures by using standard error codes.

You can view a list of successful purchases and test other requests such as requesting prices, subscription terms, and payment information.

Screen showing a simulated purchase while in Native Payment Service test mode.

When you tap OK, responses are populated with simulated data that is generated by the Payment Service.

In Test mode you can use the purchase data from the transactions you make in the current test session, to test the logic for retrieving past purchases. This is a great initial testing step for any application that sells digital goods.

Testing in the BlackBerry World sandbox

You can also use the BlackBerry World sandbox to test in-app purchases. When you use a sandbox user account to purchase digital goods from BlackBerry World, your app sends transactions to the BlackBerry World server but doesn’t charge you when you make a purchase. This method closely resembles the BlackBerry World storefront, so it’s a great way to test purchases in your app. To learn more about using the BlackBerry World storefront and the vendor portal for BlackBerry World, see the BlackBerry World documentation.

To create a sandbox user account, you need to have a BlackBerry World vendor portal membership and you must log in with a user account with an Admin role. To learn how to create a vendor portal membership, see Managing vendor portal accounts.

You can test a new app in the sandbox before it is offered for sale in the BlackBerry World storefront. Or you can add new digital goods to an existing app that is for sale in the storefront, and test the purchase of these new digital goods. There is no requirement that the app that you are testing be in a draft or approved state.

Test the purchase of your digital goods with a sandbox user account

  1. Sign in to the BlackBerry World vendor portal using your vendor account.

  2. Add the BlackBerry ID associated with your device to the list of sandbox user accounts in the vendor portal. In the left pane, click Sandbox to display the Manage Sandbox User Accounts page. Click Add New User.
    Screen showing the BlackBerry World vendor portal.

  3. Add the app you want to test, a version for the app, and any digital goods offered in your app. To learn how to add apps to the vendor portal, see Adding apps to BlackBerry World.

    BlackBerry World has a cache, so when you add your app and your digital goods to the vendor portal there might be a delay before they are visible in BlackBerry World on your device.

  4. To turn on development mode on your device, swipe down from the top of the screen and tap Settings > Security and Privacy > Development Mode. Tap the Use Development Mode switch.

  5. Open BlackBerry World on your device and swipe down from the top of your screen to display the application menu. Tap Settings > Development Mode, then enter the ID or SKU of your app and tap Load to download your app from your vendor account.

    The Development Mode screen, where you can enter the ID of your application and download it right from your vendor account, is visible only if your device is in development mode.

    Screens showing how to download an app from the BlackBerry World vendor portal using the mode ID/SKU entry.

After you install your app, you can make purchases in your app without being charged, even if your app is listed as a paid app.

All the purchases you make appear as actual purchases, just like the image on the right.

Screen showing an actual purchase made in BlackBerry World.

If your app and the digital goods offered in your app are loaded into the BlackBerry World sandbox, you won’t be charged for any of the purchases made in your app. If you make purchases from other paid applications, you will be charged as usual.

Here are some best practices to consider when you use the BlackBerry World sandbox:

  • Set the connection mode to Production to use the sandbox so that the BlackBerry World server is used to complete transactions.
  • Download and test apps in BlackBerry World only if your device's BlackBerry ID email is added to the sandbox accounts list in the vendor portal.
  • Download apps that are in draft status only when you use a sandbox user account (any other kind of user account won't work).
  • Don't remove an existing app from the BlackBerry World storefront to add new digital goods in draft status and test it with a sandbox user account.
  • Add a release (application data), to test the download and purchase of the digital goods when you add a new app (meta data) and digital goods to the BlackBerry World vendor portal.
  • A delay might occur when you add your app and your digital goods to the vendor portal before they are visible in BlackBerry World on your device.
  • Retrieve the past purchases only for the current test session. Digital goods that are purchased in a draft status are not written to the transaction database, so when you end the test session the cache is cleared.
  • Use the sandbox to test apps running only on a physical device. The sandbox does not support the BlackBerry 10 Device Simulator.

Last modified: 2014-09-29



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus