×
Namespaces

Variants
Actions

Title of purchasable item cannot be retrieved with In-App Purchase API in Series 40

From Nokia Developer Wiki
Jump to: navigation, search

Contents

Overview

The title of a purchasable item cannot be retrieved with In-App Purchase API and null is returned instead.

Description

Each purchasable item contains 4 General In-App Purchase Metadata, that the developer can define on Nokia Store's Publish Web Page:

  • Display Name
  • Short Description
  • Long Description
  • Global Price Point

All Metadata with the exception of Long Description, can be retrieved with the In-App Purchase API. This enables the publisher to display information to the potential customers, before a purchase is initiated. Metadata is represented as Product Data in the API and the following methods can be applied on a Product Data Object:

Metadata Method
Display Name getTitle
Short Description getShortDescription
Global Price Point getPrice

While Short Description and Global Price Point are successfully retrieved, the Display Name of the Purchasable Item cannot be retrieved and null is displayed instead.

How to reproduce

Prior to attempting to retrieve Product Data with In-App Purchase API, a new Content Item needs to be created on Nokia Store's Publish Web page, and a new In-App purchase item, for the created content item needs to be added. The General In-App Purchase Metadata for the In-App purchase item, should be filled out and the item needs to be submitted to QA. As soon as QA approves the In-App purchase item, the Publication State for the item changes to Published and an In-App ID is assigned to the item. This is needed in order for the developer to be able to retrieve the item's Metadata with the API by using the code below:

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
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 InAppProductDataRetrievalMIDlet
extends MIDlet
implements IAPClientPaymentListener {
 
Form mainForm;
Display display;
 
protected void startApp() throws MIDletStateChangeException {
display=Display.getDisplay(this);
mainForm=new Form("IAP");
display.setCurrent(mainForm);
try {
IAPClientPaymentManager manager = IAPClientPaymentManager.getIAPClientPaymentManager();
IAPClientPaymentManager.setIAPClientPaymentListener(this);
int status = manager.getProductData("681803"); //BattleTank's Product ID
if (status != IAPClientPaymentManager.SUCCESS) {
mainForm.append("Not Product Data will be Received\n");
}
} catch (IAPClientPaymentException e) {
mainForm.append("IAPClientPaymentException\n");
}
}
public void productDataReceived(int status, IAPClientProductData pd) {
if (status == IAPClientPaymentListener.OK) {
 
String title = pd.getTitle(); //This should return "BattleTank", instead of null
String price = pd.getPrice();
String sdesc = pd.getShortDescription();
 
mainForm.append("Title:"+title+"\n");
mainForm.append("Price:"+price+"\n");
mainForm.append("Short Description:"+sdesc+"\n");
}
else
{
mainForm.append("Product data retrieval failed with code:" +status);
}
}
 
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
 
}
protected void pauseApp() {
 
}
public void purchaseCompleted(int arg0, String arg1) {
 
}
public void userAndDeviceDataReceived(int arg0,IAPClientUserAndDeviceData arg1) {
 
}
public void productDataListReceived(int arg0, IAPClientProductData[] arg1) {
 
}
public void restorableProductsReceived(int arg0, IAPClientProductData[] arg1) {
 
}
public void restorationCompleted(int arg0, String arg1) {
 
}
}

The source code above can be downloaded from here: Media:InAppProductDataRetrievalMIDletSource.zip

The installation files for the source code above can be downloaded from here: Media:InAppProductDataRetrievalMIDlet.zip

Ensure that there is an active data package connection prior to running the application. This application contacts Nokia Store's back end server.

Actual Result

The following message is displayed on the screen:

Title:null

Price:€1.00

Short Description:Full version of Battle Tank


Expected Result

The following message should be displayed on the screen:

Title:Battle Tank

Price:€1.00

Short Description:Full version of Battle Tank


Affected Devices

This error affects all devices that support the In-App purchase API for Java ME. A list of these devices can be found on the Device Specification page here.

Solution

No solution is available.

Article Metadata
Code ExampleTested with
Devices(s): Nokia 303
CompatibilityArticle
Created: skalogir (29 Feb 2012)
Last edited: hamishwillee (31 Jul 2013)
This page was last modified on 31 July 2013, at 09:34.
75 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×