Testing the application

You can test in-app purchases in several ways:

  1. Nokia SDK for Java Emulator: If you do not yet have real devices, you can test using the Nokia SDK for Java Emulator.

  2. Test server mode: If you are testing with real devices, you can use the In-App Purchase API to test real user authentication, but simulate payments through a test server: This method accesses an external Nokia sign-in server to authenticate users and an external test server to simulate purchases.

  3. Live mode: If you are testing with real devices, you can test both real user authentication and payments through Nokia Store. This method uses the Nokia sign-in server to authenticate users and the Nokia payment server to process real payments.

Nokia SDK for Java Emulator

The Nokia SDK for Java allows you to simulate in-app purchasing in the emulator. The SDK supports both local simulation (meaning no Internet connection is used) and Nokia test server simulation. You can use the emulator to:
  • Create and save application-specific simulation settings for in-app purchasing by predefining what values the API methods return

  • Retrieve product metadata

  • Purchase a product

  • Retrieve restorable product details

  • Restore content that is protected using Nokia's DRM

  • Retrieve current user and device details to restore content that is not protected using Nokia's DRM

  • Simulate DRM access to resource files

The emulator does not interact with the actual Nokia Store servers, so no money transactions are made. For more information about using the emulator, see the Nokia SDK for Java documentation.

Note: Only Nokia DRM encrypted items can be restored using IAPClient API. Restoration of DRM content can only be tested with the In-App Purchase Simulation in Local Mode of Nokia SDK for Java.

Activate testing

The Test server mode uses a test mode configuration file, which enables you to:

  • test the purchase of an item without having to pay real money for it

  • test how purchase successes and failures are handled by your app

To use test mode:

  1. Create a TEST_MODE.TXT file. If this file does not exist, is empty, or does not contain syntactically correct content, it has no effect; the API initiates real authentication and payments with live servers.

  2. Save this file in your project's resource folder:

    project_root>\<resource_folder>\

  3. Open the TEST_MODE.TXT file and add a [testserver] section as described in the Test Server Mode section below.

In addition to the file TEST_MODE.TXT, the file IAP_VARIANTID.TXT must also be present and contain 000000, as described in Creating the in-app purchase resource files.

Test server mode

In this mode, the API client on a real device uses external servers. You can use this mode to test sign-in and purchases without incurring real payments. For:

  • User authentication: The API uses the Nokia sign-in server to authenticate users.

  • Payment processing: The API simulates successful and unsuccessful in-app purchases, without incurring real payments.

  • Nokia DRM license activation: The API bypasses license activation for Nokia DRM-protected items. Real file encryption and license activation does not happen until your app is published in Nokia Store. You must ensure that your app includes the required code to decrypt the DRM-protected in-app purchases, as described in Protecting content with built-in DRM.

To activate this Test server mode, add a [testserver] section to TEST_MODE.TXT. You can select the following options:

  • Purchase: The test server treats all purchases as first-time purchases, and never converts purchases to restorations. You can purchase the same item repeatedly.

  • Normal: The test server simulates live mode for Nokia DRM-protected in-app purchases. The server converts in-app purchases to restorations after the first purchase.

    What this mode does not do:
    • Activate licenses for Nokia DRM-protected items. These licenses are activated only in the live production mode, after your app is published to Nokia Store. This mode just simulates licensing.

    • Convert purchases to restorations for apps not using Nokia DRM-protected in-app purchases. It is up to you to test restoration for these apps in your own way. If your app provides in-app purchases from a back-end server, you must test the purchase records on your back-end server and delivery of restored content.

  • Fail: The test server always returns a failure after a payment.

As described in Restoration of purchased items, there can be different restoration policies, depending on whether or not you are using Nokia DRM-protected in-app purchases. In Test server mode however, the restoration policy follows whatever option you select.

To activate Test server mode with the Purchase option:

[testserver]
testMode=purchase

Live mode

After you publish your app to Nokia Store, you can test that your app handles real payments in the production environment. For:

  • User authentication: The API uses the Nokia sign-in server to authenticate users.

  • Payment processing: The API uses Nokia Store to charge real money for in-app purchases.

  • Nokia DRM license activation: The API uses a License Key Manager to activate licenses for Nokia DRM-protected in-app purchases.

To use this mode, you must remove the file TEST_MODE.TXT from your app project's root folder.