Verifying that in-app purchases are supported on the device

Before you present BlackBerry device users with purchase options, you can verify that in-app purchases are available. You can use the PaymentEngine.isAppWorldInstalledAndAtCorrectVersion() method to check for the presence of the minimum required version of the BlackBerry App World storefront. If the required version isn't available, your application can't invoke any of the Payment Service APIs.

You may want to design your application to restrict users from seeing purchase options for digital goods if they don't have BlackBerry App World 3.1 installed on their devices. You can also catch the AppWorldUpdateRequired exception that can be thrown, and then prompt the user to upgrade their BlackBerry App World client to the latest version by calling the PaymentEngine.upDateAppWorld() method.

The following code sample demonstrates how to create a PaymentEngine object, and verify that in-app purchases are supported on the device.

try{

				if (PaymentEngine.isAppWorldInstalledAndAtCorrectVersion()) {

    PaymentEngine engine = PaymentEngine.getInstance();

    //code that is executed if in-app payments are available
    }
} catch(AppWorldUpdateRequired awur) {

			//launches browser for user to upgrade their BlackBerry App World client
			PaymentEngine.upDateAppWorld();
}

Was this information helpful? Send us your comments.