×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    3

    Nokia java application In-App Purchase wrong code in purchase completed callback

    I have a J2ME based application and i am new to IAP purchase. My scenario is after user purchase the application first time he can then use the application for 1 month after which he needs to repurchase it and similarly if he wants to further use it he has to purchase it after every month. So i have created a boolean variable and after every 30 days i make it false and then if user purchase the application through in-app purchase i can then make this variable true. so if after one month if user wants to further use it he can then repurchase it by pressing a button.in this button i am calling

    int status = manager.purchaseProduct(PURCHASE_ID,
    IAPClientPaymentManager.FORCED_AUTOMATIC_RESTORATION);

    if (status != IAPClientPaymentManager.SUCCESS) {
    System.out.println(Messages.getPaymentError(status));
    return false;
    }
    return true;


    and in callback....

    public void purchaseCompleted(int status, String purchaseTicket) {
    System.out.println("Purchase Completed : "+status+" "+purchaseTicket);

    // battleTankCanvas.hideBuyMenuWaitIndicator();
    if (status == OK) {
    System.out.println("ok");
    // setTrial(false);
    // battleTankCanvas.hideBuyOption();
    // battleTankCanvas.hideCurrentMenu();
    }
    else {
    System.out.println("Not ok");
    // showAlertMessage("Purchase failure", "Purchase process failed. "
    // + Messages.getPaymentError(status), AlertType.ERROR);
    }
    }



    but in call back i am getting a code : -35 ....i dont know why.....please note i am using nokia asha 303 simulator and when i use In-APP simulation for local sdk i get the response code ok. but when i use the nokia server i am getting an error code -35 in purchase completed.

  2. #2
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Hi,

    Error you get is GENERAL_HTTP_ERROR -35. Before testing please verify you have network connectivity on device. To do so use web browser application. You should be able to browse Internet.

    The second point about your idea of implementation subscription model in your application. There is problem -- application persistent data storage is deleted when the application is uninstalled. So when your application gets locked due to the subscription expiration, user can re-install your application and use it for free until it will be locked again.

    To implement subscription model you need to save data related to user subscription outside of device -- on third party server. Please check IAP guide , non-DRM protected model document chapter for details.

    Subscription model implementation is not hard but requires some investments for your third - party server internet hosting.

    If you have more questions , please ask


    by the way your code fragment will force to restore user purchase automatically because of IAPClientPaymentManager.FORCED_AUTOMATIC_RESTORATION flag and that will break your subscription model :

    Code:
     
    int status = manager.purchaseProduct(PURCHASE_ID,
    IAPClientPaymentManager.FORCED_AUTOMATIC_RESTORATION);
    Check the documentation how to use the API and the API reference


    Regards,
    Igor
    Last edited by izinin; 2012-07-19 at 08:44.

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    3

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Thanks Igor for the reply and ure suggested points are really helpfull in iimplementing the subscription model. But i am still getting response code -35 in the callback. I have checked the browser and internet is up and running. Please note that when i user getproductdata() then in call back i am getting response code -16. i have tried my purchaseid (903303) as well as battle tank's purchase id (681803) but the error code are same in both cases . Please also note that before 1-2 days the purchaseid 681803(battle tank example) was working fine on my simulator and returing correct product data.
    Also plz note that in my IAP simulator when i use local sdk option then it is working fine but when i use test with nokia publish server then it is returning wrong response codes

  4. #4
    Registered User
    Join Date
    Jul 2012
    Posts
    3

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Thanks Igor for the reply and ure suggested points are really helpfull in iimplementing the subscription model. But i am still getting response code -35 in the callback. I have checked the browser and internet is up and running. Please note that when i user getproductdata() then in call back i am getting response code -16. i have tried my purchaseid (903303) as well as battle tank's purchase id (681803) but the error code are same in both cases . Please also note that before 1-2 days the purchaseid 681803(battle tank example) was working fine on my simulator and returing correct product data.
    Also plz note that in my IAP simulator when i use local sdk option then it is working fine but when i use test with nokia publish server then it is returning wrong response codes.

  5. #5
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Hi yousuflaksol

    But i am still getting response code -35 in the callback.
    Please note that code -35 can also be returned if you have forgotten to include the IAP_VARIANTID.txt with 6 zeros as content i.e. "000000" as specified here.
    Last edited by skalogir; 2012-07-22 at 23:55.

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    1

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Thanks for the reply, But both IAP_VARIANTID.txt and TEST_MODE.txt are present in my res folder. Please also note that if i user getproductdata() then in the call back i am getting error code -16. which means invalid product data. but i have tried both purchase ids i.e. Battle Tanks games purchase id as well as my own purchase id. Please also note that the battle tank's purchase id was returning correct data around2-3 days ago without any changes in the code. Any ideas/suggestions what is going wrong????

  7. #7
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Hi again,

    I have been trying to reproduce your error code -16 without success on Nokia SDK 1.1.

    I can reproduce the error code -35 when either retrieving the product data or when attempting a purchase and provided that

    a) I have not set up the emulator's date to the current date
    b) I am using wrong HTTP Proxy server settings (Tools > Preferences > Network)
    c) I am not using the proper resource files

    I have also managed to receive error code -15, if I add an empty space after the 6 zeros inside IAP_VARIANTID.txt (i.e. this "000000" works but this "000000 " throws -15).

    Otherwise your In-App purchase ID works fine with my code.

    Can you try to:
    a) Use this code:
    Code:
    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 IAPnoDRM 
    	extends MIDlet 
    	implements IAPClientPaymentListener, CommandListener {
    	
    	Form mainForm;
    	Display display;
    	Command retrieveCommand = new Command("Info", Command.OK, 0);
    	Command purchaseCommand = new Command("Purchase", Command.OK, 1);	
    	Command exitCommand = new Command("Exit", Command.EXIT, 0);
    	Command retrieveUser = new Command("User", Command.OK, 2);
    	
    	IAPClientPaymentManager manager; 
    	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");
    		mainForm.addCommand(exitCommand);
    		mainForm.addCommand(retrieveCommand);
    		mainForm.addCommand(purchaseCommand);
    		mainForm.addCommand(retrieveUser);
    		mainForm.setCommandListener(this);
    		mainForm.append(info);
    		display.setCurrent(mainForm);
    		try {
    			manager = IAPClientPaymentManager.getIAPClientPaymentManager();
    			IAPClientPaymentManager.setIAPClientPaymentListener(this);
    		}
    		catch (IAPClientPaymentException e) {
    				info.setText("IAPClientPaymentException:" + e.getMessage() + "\n");
    		}
    		
    	}
    	
    	//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";
    	        
    	        info.setText(output);
    	        
    	    }	
    	    else {
    	    	mainForm.append("Product data retrieval failed with code:" + status);
    	    }
    	}
    
    	public void commandAction(Command c, Displayable d) {
    		if(c == retrieveCommand) {
    			int status = manager.getProductData("903303"); 
    			if (status != IAPClientPaymentManager.SUCCESS) {
    				info.setText("Do not expect a description callback \n");
    			}
    		}
    		
    		if( c == purchaseCommand) {
    				int status = manager.purchaseProduct("903303", IAPClientPaymentManager.FORCED_AUTOMATIC_RESTORATION);
    			    if (status != IAPClientPaymentManager.SUCCESS) {
    			    	info.setText("Do not expect a purchase callback \n");
    			    }
    		}
    		
    		if( c == retrieveUser) {
    				int status = manager.getUserAndDeviceId(IAPClientPaymentManager.DEFAULT_AUTHENTICATION);
    			    if (status != IAPClientPaymentManager.SUCCESS) {
    			    	info.setText("Do not expect a purchase callback \n");
    			    }
    		}
    		
    		if(c == exitCommand) {
    			notifyDestroyed();
    		}		
    	}
    	
    	public void purchaseCompleted(int status, String ticket) {
    		if( (status == IAPClientPaymentManager.SUCCESS)) {
    				mainForm.append("Purchase completed successfully");
    				mainForm.append("\n");
    				mainForm.append("ticket: " + ticket);
    				mainForm.append("\n");
    		}
    		else {
    			mainForm.append("Purchase didn't complete. Status: " + status + "\n");
    			mainForm.append("ticket is :" + ticket);
    			mainForm.append("\n");
    		}	
    	}
    	
    	public void userAndDeviceDataReceived(int status, IAPClientUserAndDeviceData ud) {
    		if(status == IAPClientPaymentManager.SUCCESS) {
    			mainForm.append("account: " + ud.getAccount() + "\n");
    			mainForm.append("country: " + ud.getCountry() + "\n");
    			mainForm.append("device model: " + ud.getDeviceModel() + "\n");
    			mainForm.append("language: " + ud.getLanguage() + "\n");
    			mainForm.append("imei: " + ud.getImei() + "\n");
    			mainForm.append("imsi: " + ud.getImsi() + "\n");
    			
    		}
    		else {
    			mainForm.append("Retrieval of user data failed with code: " + status);
    			mainForm.append("\n");
    		}
    			
    	}
    	
    	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
    	}	
    }
    b) Ensure that you are using the latest version of SDK 1.1, i.e. in case you are testing with the old beta, please download the final version.

    c) Ensure that there are no white spaces in your resource files and that you Refresh your project after you make changes to your resource files (e.g. in Eclipse you can right click your working project and select Refresh or hit F5).
    My TEST_MODE.txt looks like this:

    Code:
    [testserver]
    testMode=purchase
    d) Ensure that you have updated your Emulator's date and time to the current date in case you have modified the date accidentally

    e) Ensure that there is active data packet connection as zinin suggested.

    Do you see the Nokia Account login page when you attempt a purchase? Have you set automatic sign in from the Emulator's Settings > Nokia Account? Try removing your Nokia Account from the emulator and add it again. Is there any delay until you get the error code -16 or do you get it almost instantly? Could this be something related to the Nokia Account you are testing with? Can you for example download a free app using the same account on your Nokia 303 from Nokia Store?
    Last edited by skalogir; 2012-07-23 at 09:43.

  8. #8
    Registered User
    Join Date
    Jul 2013
    Posts
    6

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    I have developed an In-app purchase app. I am using purchaseCompleted(.....) method. It is accepts two parameters : status and purchaseTicket. While testing on SDK local simulation, parameter purchaseTicket is present but while testing on Nokia Publish Server i don’t have purchaseTicket.
    How can I get confirmation for selected item when transaction is completed?

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,699

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    You are using an other, newer version of the API, that is why the question was removed from here.
    If you are really using the old API, note that it is not accepted for distribution any more, see last paragraph on https://developer.nokia.com/Distribute/In-app_payment/
    The introduction of Nokia In-App Payment means that the current in-app purchasing solution will be deprecated. In the near term, the intake of new apps using the deprecated in-app purchasing solution will be closed on June 10th 2013.

  10. #10
    Registered User
    Join Date
    Jul 2013
    Posts
    6

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Nokia asha 501 support In-App Purchases or not?

  11. #11
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Nokia java application In-App Purchase wrong code in purchase completed callback

    Hi dheerendra100,

    In-App Purchase has been replaced by Nokia In App Payment for Nokia Asha software platform 1.0 and 1.1 (beta). Nokia In App Payment API is currently provided on an invite-only basis. Please sign up here:

    http://developer.nokia.com/Distribute/In-app_payment/

    Br,
    Stratos

Similar Threads

  1. In app application purchase feature
    By AdnanShoukat in forum [Archived] Qt Quick
    Replies: 3
    Last Post: 2012-05-28, 13:56
  2. In-App purchase java SDK
    By paskuniak in forum [Archived] Monetizing your application
    Replies: 8
    Last Post: 2012-04-24, 13:58
  3. QT in-app purchase hangs application
    By onedeveloper in forum Monetization APIs
    Replies: 8
    Last Post: 2012-04-12, 17:48
  4. In-Application Purchase – maximize your reach
    By ltomuta in forum [Archived] Monetizing your application
    Replies: 0
    Last Post: 2012-04-03, 17:02

Posting Permissions

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