Testing your application

The Payment Service supports simulated local testing as well as live testing with the Payment Service server. To test an application, you must have the BlackBerry App World™ storefront 2.1 or later installed on the BlackBerry device or the BlackBerry Smartphone Simulator.

Local testing

During local testing, the Payment Service library enables your application to simulate the entire purchase process. Testing your application locally is useful for verifying that your application deals with the results of a purchase the way you intend it to. To enable local testing, you must invoke PaymentEngine.setConnectionMode(PaymentEngine.CONNECTION_MODE_LOCAL) in your application.

Local testing doesn't make any network calls to the Payment Service server. Purchase attempts are always successful unless you manually change the result in your application. You can simulate the following purchase results in local testing mode:

Result

Return value / exception

Description

Success

Returns a Purchase object

Indicates that purchase is successful

Digital good not found

Throws a DigitalGoodNotFoundException

Indicates that the purchase fails because the digital goods are not registered with the Payment Service

Illegal application

Throws an IllegalApplicationException

Indicates that the purchase fails because the application that invokes the purchases is not downloaded from the BlackBerry App World™ storefront

Payment server error

Throws a PaymentServerException

Indicates that the purchase fails because of an error with the Payment Service server.

Unknown error

Throws a PaymentException

Indicates that the purchase fails because of an unknown error

Cancelled

Throws a UserCancelException

Indicates that the purchase fails because the user cancels the purchase

In addition to the purchase results, you can change the following pieces of information about the transaction:

Item

Description

Status message

The message that is displayed in the application that describes the result of the purchase.

License key

The license key that is required for authenticating the purchase.

Transaction ID

The unique identifier for the purchase.

Run an application in the simulator from Eclipse

Before you begin: Add the Payment Service library to a project.
  1. In Eclipse®, on the Run menu, click Run Configurations.
  2. On the Projects tab, select the option for the project that you want to run.
  3. If you're testing the application against the live Payment Service server, on the Simulator tab, select the Launch Mobile Data System Connection Service (MDS-CS) with simulator check box.
  4. In the Device drop-down list, click the BlackBerry Smartphone Simulator that you want to run the application on.
  5. Click Run.
  6. On the Home screen of the simulator, click the application icon.

Run an application in the simulator from the BlackBerry Java Development Environment

Before you begin: Add the Payment Service library to a project.
  1. In the BlackBerry® Java® Development Environment, on the Project menu, click Set active projects.
  2. Select the project that you want to run and click OK.
  3. On the Edit menu, click Preferences.
  4. On the Simulator tab, in the Profile drop-down list, click the simulator profile that you want to use.
  5. If you want to test the application against the live Payment Service server, select the Launch Mobile Data System Connection Service (MDS-CS) with simulator check box.
  6. In the Device drop-down list, click the BlackBerry Smartphone Simulator that you want to run the application on.
  7. Click OK.
  8. On the Build menu, click Build and run.
  9. On the Home screen of the simulator, click the application icon.

Change the test purchase result

Before you begin: Enable local testing in your application.
  1. On the BlackBerry® Smartphone Simulator or on a BlackBerry device, start your application.
  2. In your application, initiate a purchase request.
  3. On the login screen for BlackBerry® ID, click Log In.
  4. Press the Menu key > Edit Result.
  5. Change the appropriate information.
  6. Click Save.

Live testing

Live testing permits you to test the purchase of digital goods against the live Payment Service server without being charged real money. To test your applications live, you must perform the following actions:

  • Add your application to the vendor portal for the BlackBerry App World™ storefront (the application can remain in the Draft state).
  • Add digital goods and a release bundle to your application in the vendor portal.

  • Register for a BlackBerry® ID account at na.blackberry.com/id/.
  • Create a sandbox account by registering your BlackBerry ID in the vendor portal.

After you add your application and digital goods, you can download your application from BlackBerry App World and start testing the purchase process against the live Payment Service server.

By registering the BlackBerry ID with the vendor portal, you can use the BlackBerry ID to perform test purchases of applications, as well as digital goods within your applications. When you initiate a purchase, and log in using the BlackBerry ID that you registered with the vendor portal, you can simulate a real purchase without any charges to your account. The BlackBerry ID that you register with the vendor portal can be used only to purchase digital goods from the applications associated with your BlackBerry App World vendor account.

For more information about submitting applications and creating sandbox accounts, see the BlackBerry App World vendor documentation at www.blackberry.com/go/appworld/vendordocs/.

Create a sandbox account

  1. On the vendor portal for the BlackBerry App World™ storefront, click Sandbox.
  2. Click Add New User.
  3. In the Email field, type the email address associated with a BlackBerry® ID.
  4. In the Description field, type a description for the sandbox account.
  5. Click Create.

Download an application before you make it available for distribution

If your application has any distribution restrictions (such as the BlackBerry® device models or BlackBerry® Device Software versions that it supports), make sure that the BlackBerry device that you download the application to is compatible with your application, otherwise you won't be able to locate your application in the BlackBerry App World™ storefront.

If you purchase another vendor's application or digital goods using your BlackBerry® ID account that is configured for testing, the transaction is real, not simulated, and your account is charged. You can only simulate the purchases of your own applications and digital goods.

Before you begin:
  • Add your application, a release bundle, and digital goods in the vendor portal for the BlackBerry App World (application status can remain as Draft).
  • Create a sandbox account in the vendor portal using a BlackBerry ID.
  1. On the Home screen of the device, click the BlackBerry App World icon.
  2. Press and hold the alt key while pressing t, s, and t.
  3. Provide the Content ID or SKU for your application.
  4. Click OK.
  5. Provide your BlackBerry ID login information.
  6. On the Details screen for your application, click Purchase.
  7. Follow the instructions on the screen to download the application.
After you finish: You can use the same BlackBerry ID login information to purchase the digital goods that your application offers.
Next topic: Related resources

Was this information helpful? Send us your comments.