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?