Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Another Prototype Java ME payment API using HTTP

From Wiki
Jump to: navigation, search
Article Metadata
Created: vivartpandey (16 Jul 2008)
Last edited: hamishwillee (26 Jul 2013)

Needs-update.pngThis article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.

Reasons: hamishwillee (26 Aug 2011)
JSR-229 is not supported on Nokia phones. It is not clear whether this payment API would work and whether there are alternatives on Nokia platforms now. I'm not an expert on Java ME though, so if a java me expert could comment on an appropriate title for the article and whether the code is "good", that would be helpful we can update this article appropriately

I feel that JSR-229 (Payment API) is very much useful API for many applications. I am here trying to make a simple example on payment API. This example is about, you offer a demo version of your game to the user and want to attach a functionality that offer that if user wants, he can upgrade his game to the full version after paying appropriate money.

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.payment.TransactionListener;
import javax.microedition.payment.TransactionModule;
import javax.microedition.payment.TransactionRecord;
import javax.microedition.payment.TransactionModuleException;
public class MyGame extends MIDlet implements TransactionListener, CommandListener {
private TransactionModule transModul;
private int upgrade = 0;
private boolean full_version = false;
private Display display;
private Command CMD_EXIT;
public MyGame(){
display = Display.getDisplay(this);
Form formMain = new Form("GamePay");
CMD_EXIT = new Command("Exit", Command.EXIT, 1);
display.setCurrent(formMain);//display the game screen
try {
transModul = new TransactionModule(this);
catch(TransactionModuleException e) {
catch(Exception e) { }
try {
} catch(Exception e) { }
public void startApp(){
while (!full_version) {
try {
//process the transaction of the money for the full version.
transModulo.process(upgrade, "full version", "if you like the demo version and you want to play the full version download the full version of the game");
synchronized(this) {
try {
wait(); //wait for some time
catch (InterruptedException ie) { }
catch (Exception e) { }
Alert alert; ;
alert = new Alert("congrats!","welcome u have the full version of the game" ,null, AlertType.CONFIRMATION);
alert = new Alert("sorry","you are running a demo version of the game",null, AlertType.WARNING);
try {
catch (InterruptedException el) {
public void processed(TransactionRecord record){
switch(record.getState()) {
case TransactionRecord.TRANSACTION_SUCCESSFUL:
case TransactionRecord.TRANSACTION_REJECTED:
case TransactionRecord.TRANSACTION_FAILED:
synchronized(this) {
protected void pauseApp() { }
protected void destroyApp(boolean arg0) { }
public void commandAction(Command command, Displayable displayable){
if (command == CMD_EXIT) {

I have not tested this app for transferring money. I want to learn more about this api. So please try it in your system and tell me if you want to correct something.

For this program some jad entries are also required that is also I am giving below.

MIDlet-Version: 1.0.0
MIDlet-Vendor: Midlet Suite Vendor
MIDlet-Jar-URL: MyGame.jar
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
MIDlet-Name: MyGame Midlet Suite
Pay-AMEX-Info: X-CCARD, EUR, AMEX, https://localhost
Pay-AMEX-Tag-0: 1.55, full_version
Pay-Adapters: PPSMS,X-CCARD
Pay-DNSDNA-Info: PPSMS, EUR, 380, 77
Pay-DNSDNA-Tag-0: 1.45, 5550000, full_version
Pay-Feature-0: 0
Pay-MASTERCARD-Info: X-CCARD, EUR, MASTERCARD, https://localhost
Pay-MASTERCARD-Tag-0: 1.45, full_version
Pay-RADIOG-Info: PPSMS, EUR, 747, 88
Pay-RADIOG-Tag-0: 1.35, 5550000,full_version
Pay-SONERA-Info: PPSMS, EUR, 928, 99
Pay-SONERA-Tag-0: 1.40, 5550000, full_version
Pay-Update-Stamp: 2004-08-12T13:30:00Z
Pay-Update-URL: http://localhost/MyGame/bin/MyGame.jpp
Pay-VISA-Info: X-CCARD, EUR, VISA, https://localhost
Pay-VISA-Tag-0: 1.50, full_version
Pay-Version: 1.0


Prototype Java ME payment API using HTTP

This page was last modified on 26 July 2013, at 05:24.
76 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.