Fórum JSR 229: Mobile Payment API - Exemplo #18745
12/09/2007
0
Um novo canal de comércio, o de pagamentos móveis (m-payment)
Empresas como a MTV, a Fox Entertainment, a NBC, a LOreal e a Nike já aceitam pagamentos via mobile PenPal. As operações são feitas via portal WAP da PenPal desenvolvido para mobile payment. O Banco do Brasil e o Google já está entrando na onda.
Mais info em: Analysis of J2ME for developing Mobile Payment Systems -> www.microjava.com/articles/techtalk/mpayment
Site oficial -> http://jcp.org/en/jsr/detail?id=229
O processo de compra e venda evoluiu da simples troca de papel moeda e de cheques escritos para a transferência de dados de cartões de pagamento de forma pessoal... através de redes abertas, e o contato físico entre o comprador e o vendedor não é mais necessário. Esta evolução dos pagamentos físicos para os virtuais trouxe grandes benefícios a compradores e comerciantes
Empresas como a MTV, a Fox Entertainment, a NBC, a LOreal e a Nike já aceitam pagamentos via mobile PenPal. As operações são feitas via portal WAP da PenPal desenvolvido para mobile payment. O Banco do Brasil e o Google já está entrando na onda.
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) { }
}
Mais info em: Analysis of J2ME for developing Mobile Payment Systems -> www.microjava.com/articles/techtalk/mpayment
Site oficial -> http://jcp.org/en/jsr/detail?id=229
Liclopes
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)