This page was last modified 16:58, 16 July 2008.
Payment API
From Forum Nokia Wiki
Payment API (JSR 229) allows Java ME applications to request the device to charge for some content, like a new game level, an information, or anything else. You can pay per application, per use (f.e. per day) or per functionality.
This API isn't fixed for the technology behind the payment. The payment can be made by SMS, Credit Card, or phone bill. The operator of the user can configure what payment options the user will have available to pay.
MIDlet prototype example
import java.io.*; import javax.microedition.midlet.*; import javax.microedition.io.*; import javax.microedition.lcdui.*; public class SslTest extends MIDlet implements CommandListener { private final String merchant="4181607"; private final String amount="19095"; private final String currency="208"; private final String orderid ="991002b"; private final String accepturl ="https://payment.architrade.com/cgissl/relay.cgi/http://www.java4mobile/dibs/godkendt.jsp"; private final String declineurl ="https://payment.architrade.com/cgissl/relay.cgi/http://www.java4mobile/dibs/afvist.jsp"; private final String test="foo"; private String cardno; private String expmon; private String expyear; private String cvc; private String url = "https://payment.architrade.com/cgi-ssl/auth.cgi"; private String post; private String urlTotal; private Command exitCommand = new Command("Exit", Command.EXIT, 2); private Command getCommand = new Command("Pay", Command.SCREEN, 1); private Form form; private TextField txtCardno = new TextField("Card no:", null , 16, TextField.NUMERIC); private TextField txtExpmon = new TextField("Expmon", null, 2, TextField.NUMERIC); private TextField txtExpyear = new TextField("Expyear", null , 2, TextField.NUMERIC); private TextField txtCvc = new TextField("Cvc", null, 3, TextField.NUMERIC); private Display display; public SslTest() { } public void startApp() { if (display == null) display = Display.getDisplay(this); form = new Form("Payment"); form.append(txtCardno); form.append(txtExpmon); form.append(txtExpyear); form.append(txtCvc); form.addCommand(exitCommand); form.addCommand(getCommand); form.setCommandListener(this); display.setCurrent(form); } public void commandAction(Command c, Displayable d) { if (c == exitCommand) { notifyDestroyed(); } else if (c == getCommand) { cardno=txtCardno.getString(); expmon=txtExpmon.getString(); expyear=txtExpyear.getString(); cvc=txtCvc.getString(); post = "?merchant="+merchant+"&amount="+amount+"¤cy="+currency+"&orderid="+orderid+ "&accepturl="+accepturl+"&declineurl="+declineurl+"&cardno="+cardno+"&expmon="+expmon+ "&expyear="+expyear+"&cvc="+cvc+"&test="+test; StringBuffer b = new StringBuffer(); HttpsConnection con = null; InputStream is = null; OutputStream os = null; urlTotal = url+post; try { int len = 0; int ch = 0; con = (HttpsConnection)Connector.open(urlTotal); con.setRequestMethod(HttpsConnection.POST); /* byte[] data = post.getBytes(); con.setRequestProperty("Content-Length", Integer.toString(data.length)); os = con.openOutputStream(); os.write( data ); os.close(); */ System.out.println(Integer.toString(con.getResponseCode())); is = con.openInputStream(); len = (int) con.getLength(); if (len != -1) { for(int i=0; i<len; i++) { if((ch = is.read()) != -1) { b.append((char) ch); } } } else { while((ch = is.read()) != -1) { len = is.available(); b.append((char) ch); } } System.out.println("Response: " +b.toString()); Alert a = new Alert("Trans results:", b.toString(), null, null); a.setTimeout(Alert.FOREVER); display.setCurrent(a); } catch (Exception e) { e.printStackTrace(); String s = e.toString(); If(s != null) { Alert aa = new Alert("Error in connection:", s, null, null); aa.setTimeout(Alert.FOREVER); display.setCurrent(aa); } } finally { if (is != null) { try { is.close(); } catch (Exception ce) { } } if (c != null) { try { con.close(); } catch (Exception ce) { } } } } } public void pauseApp() {} public void destroyApp(boolean unconditional) { } }
More info: Analysis of J2ME for developing Mobile Payment Systems -> www.microjava.com/articles/techtalk/mpayment
Oficial Site -> http://jcp.org/en/jsr/detail?id=229
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SMPP Api for C/c++ | verruckt | General Messaging | 1 | 2007-02-07 10:52 |
| Smart messaging | peggy_pn | Smart Messaging | 1 | 2003-12-29 09:24 |
| RProperty::Set() function not work in OS 9.0(KErrorNotPermission) | aamitgupta | General Symbian C++ | 15 | 2008-02-20 11:44 |
| New message notification API | lenclud | General Symbian C++ | 9 | 2008-06-04 14:40 |
| SpeechRecognition API in Symbian | guy2d | General Symbian C++ | 0 | 2005-03-23 12:32 |
