Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2012

    In-App Purchase API not giving proper response


    I have been facing this issue for the past few days. I have made a sample application to test In-App Purchase API so that I can have an understanding of how the API works. I have created the In-App Id for the available item on the Nokia Store and got it approved. I have followed all the steps in the Java Developer Library. However, every time I try to retrieve the Product Data, I get status value -16 in the productDataReceived method. I have found that value -16 stands for Invalid Product Data which is a Server specific error value. I have not been able to test the In-App Purchase API on both the Nokia emulator and Nokia Asha 303 device.

    Please help me and provide some solution to this issue.

    Thanks in advance.

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011

    Re: In-App Purchase API not giving proper response

    Can you please update the time and date of your device to today's date and current time and try again? Can you also software update your Nokia Asha 303 to the latest software? We are aware that some older software versions were giving invalid response codes for the In-App Purchase API. If the problem persists, can you provide the Product ID (either here, or PM me) so that I can look into your issue?

  3. #3
    Registered User
    Join Date
    Mar 2012

    Re: In-App Purchase API not giving proper response

    Thanks skalogir

    I have updated the device time and date. I am going to update its software. Please tell me how I can PM you.

    Do you have any idea why this is not working on the emulator. If I do an in-app purchase simulation on the emulator, it works fine.

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2011

    Re: In-App Purchase API not giving proper response

    You said you got your item approved. What is the current publication state, on Nokia Publish web site for your Product ID? Can it be that for some reason your content has been rejected? In order to check the publication state you need to login to the publisher's web page and select:

    Content > Select the Content Item > Select the In-App Purchases Tab > QA Status > "Publication state" should be set to "Published".

    Keep in mind that your Product ID is the six digit number that appears under the In-App Purchase Tab that says:
    In-app ID

    This might be a code related issue. Can you please compile the following code with SDK 1.1 (replace XXXXXX with your Product ID)?

    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import com.nokia.mid.payment.IAPClientPaymentException;
    import com.nokia.mid.payment.IAPClientPaymentListener;
    import com.nokia.mid.payment.IAPClientPaymentManager;
    import com.nokia.mid.payment.IAPClientProductData;
    import com.nokia.mid.payment.IAPClientUserAndDeviceData;
    public class IAPtest 
    	extends MIDlet 
    	implements IAPClientPaymentListener, CommandListener {
    	Form mainForm;
    	Display display;
    	Command retrieveCommand = new Command("Info", Command.OK, 0);
    	Command exitCommand = new Command("Exit", Command.EXIT, 0);
    	StringItem info = new StringItem("Product Data", ""); //Displays either Product Data or Error messages
    	protected void startApp() throws MIDletStateChangeException {
    		//The main Screen's components
    		display = Display.getDisplay(this);
    		mainForm = new Form("In App Purchase");
    	//Call back method that is asynchronously called after invoking the getProductData method
    	public void productDataReceived(int status, IAPClientProductData pd) {
    	    if (status == IAPClientPaymentListener.OK) {
    	    	String title = pd.getTitle();
    	        String price = pd.getPrice();
    	        String sdesc = pd.getShortDescription();
    	        String output = "";
    	        output = "Title:"+title+"\n";
    	        output = output + "Price:"+price+"\n";
    	        output = output + "Short Description:" + sdesc + "\n";
    	    else {
    	    	mainForm.append("Product data retrieval failed with code:" + status);
    	public void commandAction(Command c, Displayable d) {
    		if(c == retrieveCommand) {
    			try {
    			    IAPClientPaymentManager manager = IAPClientPaymentManager.getIAPClientPaymentManager();
    			    int status = manager.getProductData("XXXXXX"); //replace this with your Product ID
    			    if (status != IAPClientPaymentManager.SUCCESS) {
    			    	info.setText("Do not expect a callback \n");
    			catch (IAPClientPaymentException e) {
    				info.setText("IAPClientPaymentException:" + e.getMessage() + "\n");
    			catch(Exception e) {
    				info.setText("Exception:" + e.getMessage() + "\n");
    		if(c == exitCommand) {
    	public void purchaseCompleted(int arg0, String arg1) {
    		//To do
    	public void userAndDeviceDataReceived(int arg0,IAPClientUserAndDeviceData arg1) {
    		//To do
    	public void productDataListReceived(int arg0, IAPClientProductData[] arg1) {
    		//To do
    	public void restorableProductsReceived(int arg0, IAPClientProductData[] arg1) {
    		//To do
    	public void restorationCompleted(int arg0, String arg1) {
    		//To do
    	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    		//To do
    	protected void pauseApp() {
    		//To do
    Also ensure that you can access the web from the emulator (visit a random page). If your publication state is set to Published, you can access the internet from the Emulator of the SDK 1.1 and the above code still gives you the code error -16, please PM me and provide your Product ID from Private Messages on this page > Send new message

    Don't forget to test on Nokia's server by selecting on Emulator: Tools > In App Purchase Simulation > Application Details > Test with Nokia Publish Server

Similar Threads

  1. BPP GetJobAttribute request not giving proper value
    By ravindra.n in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2009-08-14, 06:10
  2. proper referenses
    By sepideh06 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-06-21, 10:54
  3. Proper use of RScheduler?
    By mapeters in forum Symbian
    Replies: 11
    Last Post: 2006-07-03, 07:42
  4. Is the usage of HBufC proper here?
    By asheeshv in forum Symbian
    Replies: 0
    Last Post: 2005-03-29, 15:35
  5. Proper way to add to project?
    By smueller in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2005-01-13, 19:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts