You Are Here:

Community: Wiki

This page was last modified on 29 September 2009, at 04:49.

API de pagamento: JSR 229

From Forum Nokia Wiki

Original em: Payment API: jsr 229

Eu sinto que a JSR-229 (Payment API(API de pagamento)) é uma API muito útil para muitas aplicações. Eu estou aqui tentando desenvolver um simples exemplo na payment API(API de pagamento). Este exemplo é sobre, você oferecer uma versão demo de um jogo para o usuário e deseja anexar uma funcionalidade que oferece a possibilidade de que se o usuário quiser, ele pode atualizar o seu jogo para uma versão completa depois de pagar o valor requerido.

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);
formMain.addCommand(CMD_EXIT);
formMain.setCommandListener(this);
display.setCurrent(formMain);//display the game screen
 
try {
transModul = new TransactionModule(this);
}
catch(TransactionModuleException e) {
 
e.toString();
}
catch(Exception e) { }
 
try {
transModul.setListener(this);
} 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; ;
if(full_version)
alert = new Alert("congrats!","welcome u have the full version of the game" ,null, AlertType.CONFIRMATION);
else
alert = new Alert("sorry","you are running a demo version of the game",null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
try {
Thread.sleep(5000);
}
catch (InterruptedException el) {
el.getMessage();
}
 
 
}
}
 
 
public void processed(TransactionRecord record){
switch(record.getState()) {
case TransactionRecord.TRANSACTION_SUCCESSFUL:
full_version=true;
break;
case TransactionRecord.TRANSACTION_REJECTED:
 
break;
case TransactionRecord.TRANSACTION_FAILED:
default:
 
break;
}
synchronized(this) {
notify();
}
}
 
protected void pauseApp() { }
 
protected void destroyApp(boolean arg0) { }
 
public void commandAction(Command command, Displayable displayable){
if (command == CMD_EXIT) {
destroyApp(true);
notifyDestroyed();
}
}
}

Eu não testei essa aplicação para trasferência de dinheiro. Eu quero aprender mais sobre esta API. Então, por favor teste no seu sistema e diga-me se você quer corrigir alguma coisa.

Para este programa algumas entradas do Jad são requeridas também, as quais eu estou dando abaixo.


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-Providers: SONERA, VISA, RADIOG, DNSDNA, MASTERCARD, AMEX
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

Links

Outro exemplo da payment API( API de pagamento)

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aMicrokernelE5fArchitectureE2eGIFX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ