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:
Run an application in the simulator from Eclipse
- In Eclipse®, on the Run menu, click Run Configurations.
- On the Projects tab, select the option for the project that you want to run.
- 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.
- In the Device drop-down list, click the BlackBerry Smartphone Simulator that you want to run the application on.
- Click Run.
- On the Home screen of the simulator, click the application icon.
Run an application in the simulator from the BlackBerry Java Development Environment
- In the BlackBerry® Java® Development Environment, on the Project menu, click Set active projects.
- Select the project that you want to run and click OK.
- On the Edit menu, click Preferences.
- On the Simulator tab, in the Profile drop-down list, click the simulator profile that you want to use.
- 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.
- In the Device drop-down list, click the BlackBerry Smartphone Simulator that you want to run the application on.
- Click OK.
- On the Build menu, click Build and run.
- On the Home screen of the simulator, click the application icon.
Change the test purchase result
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
Download an application before you make it available for distribution
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.
- 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.
- On the Home screen of the device, click the BlackBerry App World icon.
- Press and hold the alt key while pressing t, s, and t.
- Provide the Content ID or SKU for your application.
- Click OK.
- Provide your BlackBerry ID login information.
- On the Details screen for your application, click Purchase.
- Follow the instructions on the screen to download the application.