how to solve the error "could not load payment api" in payment api implementation
i had implemented a simple application using payment api. it is running fine on emulator .But if i launch it on device a message like "Could not load purchasing information". can any one help me in solving this. The manifest file is like this,
MIDlet-1: t1, t1.png, myMain
MIDlet-Certificate-1-1: MIICFTCCAX6gAwIBAgIEReVCMTANBgkqhkiG9w0BAQUFAD
BPMQ4wDAYDVQQIEwVzdGF0ZTENMAsGA1UEBxMEY2l0eTEMMAoGA1UEChMDb3JnMRAwDgY
DVQQLEwdvcmdVbml0MQ4wDAYDVQQDEwVjTmFtZTAeFw0wNzAyMjgwODQ5NTNaFw0xMjA4
MjAwODQ5NTNaME8xDjAMBgNVBAgTBXN0YXRlMQ0wCwYDVQQHEwRjaXR5MQwwCgYDVQQKE
wNvcmcxEDAOBgNVBAsTB29yZ1VuaXQxDjAMBgNVBAMTBWNOYW1lMIGfMA0GCSqGSIb3DQ
EBAQUAA4GNADCBiQKBgQDOa1faZAW8KdkAMgtVe/0+/hyxjQmhgLFzlI0b3MoccTiloOf
0awLoyV9mi8C/cL6qNDMLENCu9RHFRhGXbgOGt21KLyphOLblbariYa8x2P63tkHfry3l
GXvzXTOa8p6vT+Gs5/wX87PI2uaCRiel3B9LfNduLOqwvw2VyDusRQIDAQABMA0GCSqGS
Ib3DQEBBQUAA4GBAHUCKiCdFDtTdgFGizDrgiZPKVbh2Jzy6Ddy2FMvbqqpMQjSJfepR9
kHC8a7bs65fh+tXIzfRUQhtY7vcQe7TiUJufsyakAiN9Ag/1cCng9LOapWnx+UVMUaWxB
T1CxaUbwcmVmXylp1aUOxKGq7kXvwGOpwnneze2wpSTmtKO9m
MIDlet-Name: t1
MIDlet-Permissions: javax.microedition.payment.process,javax.wireless.
messaging.sms.send,javax.microedition.io.Connector.http,javax.microed
ition.io.Connector.https,javax.microedition.io.Connector.sms
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.1
Pay-AMEX-Info: X-CCARD, EUR, AMEX, [url]https://localhost[/url]
Pay-AMEX-Tag-0: 1.55, 1_life
Pay-AMEX-Tag-1: 3.05, 3_lives
Pay-AMEX-Tag-2: 2.25, 1_level
Pay-AMEX-Tag-3: 4.45, 3_levels
Pay-DNSDNA-Info: PPSMS, EUR, 380, 77
Pay-DNSDNA-Tag-0: 1.45, 5550000, 1_LIFE
Pay-DNSDNA-Tag-1: 2.85, 5550000, 3_LIVES, 2
Pay-DNSDNA-Tag-2: 2.15, 5550000, 1_LEVEL
Pay-DNSDNA-Tag-3: 4.25, 5550000, 3_LEVELS, 2
Pay-Feature-0: 0
Pay-Feature-1: 1
Pay-Feature-2: 2
Pay-Feature-3: 3
Pay-MASTERCARD-Info: X-CCARD, EUR, MASTERCARD, [url]https://localhost[/url]
Pay-MASTERCARD-Tag-0: 1.45, 1_life
Pay-MASTERCARD-Tag-1: 2.95, 3_lives
Pay-MASTERCARD-Tag-2: 2.15, 1_level
Pay-MASTERCARD-Tag-3: 4.35, 3_levels
Pay-Providers: SONERA, VISA, RADIOG, DNSDNA, MASTERCARD, AMEX
Pay-RADIOG-Info: PPSMS, EUR, 747, 88
Pay-RADIOG-Tag-0: 1.35, 5550000, 1_LIFE
Pay-RADIOG-Tag-1: 2.75, 5550000, 3_LIVES, 2
Pay-RADIOG-Tag-2: 2.05, 5550000, 1_LEVEL
Pay-RADIOG-Tag-3: 4.05, 5550000, 3_LEVELS, 2
Pay-SONERA-Info: PPSMS, EUR, 928, 99
Pay-SONERA-Tag-0: 1.40, 5550000, 1_LIFE
Pay-SONERA-Tag-1: 2.80, 5550000, 3_LIVES, 2
Pay-SONERA-Tag-2: 2.10, 5550000, 1_LEVEL
Pay-SONERA-Tag-3: 4.20, 5550000, 3_LEVELS, 2
Pay-Update-Stamp: 2004-08-12T13:30:00Z
Pay-Update-URL: [url]http://localhost
Pay-VISA-Info: X-CCARD, EUR, VISA, [url]https://localhost[/url]
Pay-VISA-Tag-0: 1.50, 1_life
Pay-VISA-Tag-1: 3.00, 3_lives
Pay-VISA-Tag-2: 2.20, 1_level
Pay-VISA-Tag-3: 4.40, 3_levels
Pay-Version: 1.0
source code is as follows,
import java.util.Date;
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.payment.TransactionListener;
import javax.microedition.payment.TransactionListenerException;
import javax.microedition.payment.TransactionModule;
import javax.microedition.payment.TransactionModuleException;
import javax.microedition.payment.TransactionRecord;
public class myMain extends MIDlet implements TransactionListener, CommandListener, Runnable
{
private static final String JAR_RESOURCE = "/META-INF/MANIFEST.MF";
// transaction status
protected static final int TRAN_SUCCESSFUL = 0x08;
protected static final int TRAN_REJECTED = 0x10;
protected static final int TRAN_FAILED = 0x20;
private Command exit = new Command("Exit", Command.EXIT, 0);
private Command continueAlert = new Command("Continue", Command.OK, 0);
private Command exitAlert = new Command("Exit", Command.EXIT, 0);
private TransactionModule txModule;
private int feature = 0;
private boolean enableTranListenerNull = false;
private String title = "";
private String description = "";
private int lastTransState;
private boolean tran = false;
Graphics g;
private boolean p = false;
private boolean suc = false;
public myMain() {
InputStream is = getClass().getResourceAsStream(JAR_RESOURCE);
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
init();
} else {
System.out.println("priting*************************");
String textAlert = "Please execute this application via OTA" ;
Alert alert = new Alert("JBricks", textAlert, null, AlertType.WARNING);
Alert alert2 = new Alert("Transaction Failed", textAlert, null, AlertType.WARNING);
Alert alert3 = new Alert("Transaction rejected", textAlert, null, AlertType.WARNING);
alert.addCommand(exitAlert);
alert.addCommand(continueAlert);
alert.setCommandListener(this);
Display.getDisplay(this).setCurrent(alert);
}
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command cmd, Displayable dis) {
if (cmd == continueAlert) {
init();
} else if (cmd == exitAlert) {
destroyApp(true);
}
}
public void processed(TransactionRecord record) {
switch (record.getState()) {
case TransactionRecord.TRANSACTION_SUCCESSFUL:
String t1="Transaction success";
Alert alert1 = new Alert("Transaction success", t1, null, AlertType.WARNING);
suc = true;
String t8 = "EA GAMES";
Alert a1 = new Alert("Welcome to EA",t8,null,AlertType.WARNING);
Display.getDisplay(this).setCurrent(alert1);
if(suc)
{
Display.getDisplay(this).setCurrent(a1);
}
break;
case TransactionRecord.TRANSACTION_REJECTED:
String t2="Transaction REJECTED";
Alert alert2 = new Alert("Transaction rejected", t2, null, AlertType.WARNING);
Display.getDisplay(this).setCurrent(alert2);
break;
case TransactionRecord.TRANSACTION_FAILED:
String t3="Transaction failed";
Alert alert3 = new Alert("Transaction failed", t3, null, AlertType.WARNING);
Display.getDisplay(this).setCurrent(alert3);
break;
}
}
public void run() {
System.out.println("value***********"+p);
}
protected void setTransactionListenerNull(boolean b) {
enableTranListenerNull = b;
}
protected int getLastTransactionState() {
return lastTransState;
}
private void restoreBoughtFeatures() {
TransactionRecord[] record = txModule.getPastTransactions(10);
if (record != null) {
for (int i = 0; i < record.length; i++) {
processed(record[i]);
}
}
}
private void init() {
try {
txModule = new TransactionModule(this);
txModule.setListener(this);
txModule.deliverMissedTransactions();
restoreBoughtFeatures();
} catch (TransactionListenerException tle) {
tle.printStackTrace();
} catch (TransactionModuleException tme) {
tme.printStackTrace();
}
p = true;
if(p)
{
try {
title = "Buy";
description = "You are able to view";
txModule.setListener(this);
txModule.process(feature, title, description);
if (enableTranListenerNull) {
txModule.setListener(null);
}
} catch (TransactionListenerException tle) {
System.err.println("Transaction Listener is not set");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Re: how to solve the error "could not load payment api" in payment api implementati
You are running it on a Device with that specific API ?
which device are you testing it on ?
Re: how to solve the error "could not load payment api" in payment api implementati
Iam testing it on sonyericsson W910. I have doubt in providing provisioning information in MANIFEST regarding AMEX , VISA , MASTERCARD.
In this MANIFEST i had mentioned "Pay-AMEX-Info: X-CCARD, EUR, AMEX, [url]https://localhost[/url] " . But i think i need to mention the correct URL. Can you please suggest me the correct approach to this. Is there any other reasons for this issue?
Re: how to solve the error "could not load payment api" in payment api implementati
Any reply or help would be beneficial for us also.
Please post here if any solution.
Cheers,
-Vikram.
Re: how to solve the error "could not load payment api" in payment api implementati
Would like to know what exactly you are trying to do , i could see that you are adding [url]https://localhost[/url] in the manifest file, https is a secure protocol which requires certificates. Can you explain step by step what you did , and you say that it works on the emulator, wch emulator, and how does it connect to your server???
But when i try to run the same i get the following using emulator, application loads and ask Please execute using OTA... when i click continue it gives me the following...
priting*************************
The required Pay-Version attribute is missing
javax.microedition.payment.TransactionModuleException: Missing provisioning information
at com.sun.j2me.payment.TransactionModuleImpl.<init>(+59)
at com.sun.kvem.payment.KvemTransactionModuleImpl.<init>(+5)
at com.sun.kvem.payment.KvemPaymentModule.createTransactionModule(+8)
at javax.microedition.payment.TransactionModule.<init>(+12)
at com.sun.j2me.payment.MyMain.init(+9)
at com.sun.j2me.payment.MyMain.commandAction(+12)
at javax.microedition.lcdui.Alert$1.commandAction(+35)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+186)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)
java.lang.NullPointerException
at com.sun.j2me.payment.MyMain.init(+76)
at com.sun.j2me.payment.MyMain.commandAction(+12)
at javax.microedition.lcdui.Alert$1.commandAction(+35)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+186)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)
Execution completed.
3447270 bytecodes executed
633 thread switches
1667 classes in the system (including system classes)
18070 dynamic objects allocated (549652 bytes)
4 garbage collections (460724 bytes collected)
Re: how to solve the error "could not load payment api" in payment api implementati
For this application to work we need to add the these pay-attributes in JAD also.
I had executed thia app on SonyEricsson JP7 emulator.
In the documentation of payment api it is been mentioned that we need to add SOAP url's in pay-provider-info title. In this application i just mentioned [url]https://localhost[/url] with this is working fine on emulator.
I want to know more about this.
Iam very thankful if you could provide any information on this.
Re: how to solve the error "could not load payment api" in payment api implementati
From where did you find the api documentation, i have been searching it .. can you provide link for the same, and also which server are you hitting with the emulator, https only listens on 443....
Re: how to solve the error "could not load payment api" in payment api implementati
Are u sure the device supports Payment api ? or web services api -- i guess u need that for the soap part
Re: how to solve the error "could not load payment api" in payment api implementati
[url]http://jcp.org/en/jsr/detail?id=229[/url]
From this link i had downloaded the document
Re: how to solve the error "could not load payment api" in payment api implementati
ya iam sure that the device supports these two apis. I have a test app for that and also i have a document that lists the supported JSrs for all mobiles
Re: how to solve the error "could not load payment api" in payment api implementati
When it works from the simulatoro tht means it connects to the payment adapter, which a dummy adaptor for testing purpose. And also when you put onto the device it will not connect because it says that the PSMS should be available from the operator. When you see the Jbricks example in the WTK(wireless toolkit) you will come to know exactly what is happening, you can also view the adaptor logs from here.
I think there is still lot of research should be done how to contact the operator and how it works etc. I hope this has answered your question.
Re: how to solve the error "could not load payment api" in payment api implementati
Yes exactly this is the point where i had stucked. I had started developing this app learning from JBricks only. The JBricks app is also making use of a dummy.
So i could n't get more information on this issue from JBrich=ks app.
I will be really thankful to you if you could provide more information on how to contact the operator and how to make my applicatio to work on device .
Thanks in advance.
Re: how to solve the error "could not load payment api" in payment api implementati
I dont think operator's support this , i am not sure you need to check, the other way around would be to connect to a payment gateway.
and have a secure communication between midlet and the server....
Re: how to solve the error "could not load payment api" in payment api implementati
can u please give any example or some useful links to proceed further