363 lines
12 KiB
Java
363 lines
12 KiB
Java
package it.acxent.bank.poste2019;
|
||
|
||
import it.acxent.bank._BankAdapter;
|
||
import it.acxent.common.Parm;
|
||
import it.acxent.common.StatusMsg;
|
||
import it.acxent.db.ApplParmFull;
|
||
import it.acxent.db.DBAdapter;
|
||
import it.acxent.reg.EcDc;
|
||
|
||
public class PosteReq extends _BankAdapter {
|
||
private String VALUTA;
|
||
|
||
private String NUMORD;
|
||
|
||
private String IMPORTO;
|
||
|
||
private String LINGUA;
|
||
|
||
private String EMAILESERC;
|
||
|
||
private String EMAIL;
|
||
|
||
private String USERID;
|
||
|
||
public static final String TCONTAB_DIFFERITA = "D";
|
||
|
||
public static final String TCONTAB_IMMEDIATA = "I";
|
||
|
||
public static final String LANG_CODE_IT = "ITA";
|
||
|
||
public static final String LANG_CODE_EN = "EN";
|
||
|
||
public static final String P_POSTE19_MAC_KEY_START = "POSTE19_MAC_KEY_START";
|
||
|
||
public static final String P_POSTE19_URL_BACK = "POSTE19_URL_BACK";
|
||
|
||
public static final String P_POSTE19_URL_DONE = "POSTE19_URL_DONE";
|
||
|
||
public static final String P_POSTE19_URL_MS = "POSTE19_URL_MS";
|
||
|
||
public static final String P_POSTE19_EMAILESERC = "POSTE19_EMAILESERC";
|
||
|
||
public static final String P_POSTE19_MAC_KEY_ESITO = "POSTE19_MAC_KEY_ESITO";
|
||
|
||
public static final String P_POSTE19_IDNEGOZIO = "POSTE19_IDNEGOZIO";
|
||
|
||
public static final String P_POSTE19_TCONTAB = "POSTE19_TCONTAB";
|
||
|
||
public static final String P_POSTE19_OPTIONS = "POSTE19_OPTIONS";
|
||
|
||
public static final String URL_POSTE19_TEST = "https://acquistionlinetest.poste.it/poste/pagamenti/main?PAGE=MASTER";
|
||
|
||
public static final String URL_POSTE19_PROD = "https://acquistionline.poste.it/poste/pagamenti/main?PAGE=MASTER";
|
||
|
||
public static final String DEFAULT_URL_BACK_AND_DONE = "http://localhost/tf15/RicevutaPoste.abl";
|
||
|
||
public static final String DEFAULT_URL_MS = "http://localhost/tf15/RicevutaPoste.abl";
|
||
|
||
public static final String TEST_MAC = "CHENESOADESSO";
|
||
|
||
public static final String OPTIONS_G_REDIRIZIONE_IMMEDIATA = "G";
|
||
|
||
public static final String OPTIONS_L_ORDINE_DUPLICATO_CODE_07_URLMS = "L";
|
||
|
||
public static final String OPTIONS_N_NEGATA_SU_RULDONE = "N";
|
||
|
||
public static final String OPTIONS_P_SEND_RESPONSE_CODE_AUT = "P";
|
||
|
||
public PosteReq() {}
|
||
|
||
public PosteReq(ApplParmFull apFull) {
|
||
setAp(apFull);
|
||
}
|
||
|
||
public String getNUMORD() {
|
||
return (this.NUMORD == null) ? "" : this.NUMORD.trim();
|
||
}
|
||
|
||
public void setNUMORD(String myamount) {
|
||
this.NUMORD = myamount;
|
||
}
|
||
|
||
public String getIMPORTO() {
|
||
return (this.IMPORTO == null) ? "" : this.IMPORTO;
|
||
}
|
||
|
||
public void setIMPORTO(String mybuyeremail) {
|
||
this.IMPORTO = mybuyeremail;
|
||
}
|
||
|
||
public String getEMAILESERC() {
|
||
return (this.EMAILESERC == null) ? "" : this.EMAILESERC;
|
||
}
|
||
|
||
public void setEMAILESERC(String mybuyername) {
|
||
this.EMAILESERC = mybuyername;
|
||
}
|
||
|
||
public String getVALUTA() {
|
||
return (this.VALUTA == null) ? "" : this.VALUTA;
|
||
}
|
||
|
||
public void setVALUTA(String mycurrency) {
|
||
this.VALUTA = mycurrency;
|
||
}
|
||
|
||
public String getAlias() {
|
||
return getParm("POSTE19_MAC_KEY_ESITO").getTesto();
|
||
}
|
||
|
||
public String getMac() {
|
||
return getMacPagamento();
|
||
}
|
||
|
||
public String getMacPagamento() {
|
||
StringBuffer theUrl = new StringBuffer();
|
||
theUrl.append("&URLMS=");
|
||
theUrl.append(getURLMS());
|
||
theUrl.append("&URLDONE=");
|
||
theUrl.append(getURLDONE());
|
||
theUrl.append("&NUMORD=");
|
||
theUrl.append(getNUMORD());
|
||
theUrl.append("&IDNEGOZIO=");
|
||
theUrl.append(getIDNEGOZIO());
|
||
theUrl.append("&IMPORTO=");
|
||
theUrl.append(getIMPORTO());
|
||
theUrl.append("&VALUTA=");
|
||
theUrl.append(getVALUTA());
|
||
theUrl.append("&TCONTAB=");
|
||
theUrl.append(getTCONTAB());
|
||
theUrl.append("&TAUTOR=I");
|
||
if (!getOPTIONS().isEmpty()) {
|
||
theUrl.append("&OPTIONS=");
|
||
theUrl.append(getOPTIONS());
|
||
}
|
||
theUrl.append("&USERID=");
|
||
theUrl.append(getUSERID());
|
||
String res = "";
|
||
res = EcDc.encodeHMAC_256(getMAC_KEY_START(), theUrl.toString());
|
||
System.out.println("stringa mac: " + res);
|
||
return res;
|
||
}
|
||
|
||
public String getLINGUA() {
|
||
return (this.LINGUA == null) ? "" : this.LINGUA;
|
||
}
|
||
|
||
public void setLINGUA(String lang) {
|
||
this.LINGUA = lang;
|
||
}
|
||
|
||
public String getRequestUrl() {
|
||
return getRequestUrl(false);
|
||
}
|
||
|
||
public String getImportoUrl() {
|
||
if (this.IMPORTO == null)
|
||
return "0000";
|
||
String temp = this.IMPORTO;
|
||
if (temp.indexOf('.') < 0) {
|
||
temp = temp + "00";
|
||
} else if (temp.length() - temp.indexOf('.') < 3) {
|
||
temp = temp + "0";
|
||
}
|
||
return temp.replace(".", "");
|
||
}
|
||
|
||
public String getTestRequestUrl() {
|
||
return getRequestUrl(true);
|
||
}
|
||
|
||
public static void initApplicationParms(ApplParmFull ap) {
|
||
if (ap != null) {
|
||
DBAdapter.logDebug(true, "postepay 2019 chechout initParms: start");
|
||
String l_tipoParm = "POSTEPAY 2019";
|
||
StatusMsg.updateMsgByTag(ap, "INIT", l_tipoParm);
|
||
Parm bean = new Parm(ap);
|
||
bean.findByCodice("POSTE19_URL_BACK");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_URL_BACK");
|
||
bean.setDescrizione("POSTE19_URL_BACK");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""))
|
||
bean.setTesto("http://localhost/tf15/RicevutaPoste.abl");
|
||
bean.setNota("La URL verso la quale mandare l’utente in caso di annullamento del processo di pagamento e ritorno alla modifica del carrello");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_URL_DONE");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_URL_DONE");
|
||
bean.setDescrizione("POSTE19_URL_DONE");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""))
|
||
bean.setTesto("http://localhost/tf15/RicevutaPoste.abl");
|
||
bean.setNota("POSTE19_URL_MS");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_URL_MS");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_URL_MS");
|
||
bean.setDescrizione("POSTE19_URL_MS");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""))
|
||
bean.setTesto("http://localhost/tf15/RicevutaPoste.abl");
|
||
bean.setNota("La URL che il sistema deve utilizzare per notificare direttamente al negozio l’esito della transazione compiuta ");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_MAC_KEY_START");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_MAC_KEY_START");
|
||
bean.setDescrizione("POSTE19_MAC_KEY_START");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""))
|
||
bean.setTesto("CHENESOADESSO");
|
||
bean.setNota("E' la chiave per il calcolo del MAC nei messaggi di avvio pagamento");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_MAC_KEY_ESITO");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_MAC_KEY_ESITO");
|
||
bean.setDescrizione("POSTE19_MAC_KEY_ESITO");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""));
|
||
if (bean.getNota().isEmpty())
|
||
bean.setNota("E' la chiave per la verifica del MAC nei messaggi di esito emessi da Poste e per l’usodelle API.");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_EMAILESERC");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_EMAILESERC");
|
||
bean.setDescrizione("POSTE19_EMAILESERC");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""));
|
||
if (bean.getNota().isEmpty())
|
||
bean.setNota("MAIL ESERCENTE AL QUALE INVIARE L'ESITO DELLA TRANSAZIONE. SE VUOTA VIENE UTILIZZATA QUELLA DELL'ANAGRAFICA DEL NEGOZIO");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_IDNEGOZIO");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_IDNEGOZIO");
|
||
bean.setDescrizione("POSTE19_IDNEGOZIO");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""));
|
||
if (bean.getNota().isEmpty())
|
||
bean.setNota("Identificativo del negozio del merchant assegnato da Poste, Merchant ID (MID).");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_TCONTAB");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_TCONTAB");
|
||
bean.setDescrizione("POSTE19_TCONTAB");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""))
|
||
bean.setTesto("I");
|
||
if (bean.getNota().isEmpty())
|
||
bean.setNota("Tipo di contabilizzazione da utilizzare in questo ordine. Obbligatorio.<br>D --> Differita<br>I --> Immediata");
|
||
bean.save();
|
||
bean.findByCodice("POSTE19_OPTIONS");
|
||
bean.setFlgAdmin(0L);
|
||
bean.setTipoParm(l_tipoParm);
|
||
bean.setCodice("POSTE19_OPTIONS");
|
||
bean.setDescrizione("POSTE19_OPTIONS");
|
||
bean.setFlgTipo(0L);
|
||
if (bean.getTesto().equals(""));
|
||
if (bean.getNota().isEmpty())
|
||
bean.setNota("Opzioni aggiuntive per il pagamento in corso.<br>G – In caso di autorizzazione concessa il sistema invece di mostrare l’esito della transazione al consumatore effettua la redirezione immediata presso URLDONE in modo che il negozio virtuale possa mostrare un proprio “scontrino” personalizzato. In caso di autorizzazione negata all’utente viene riproposta la schermata di inserimento carta.<br>L – Nel caso di ordine duplicato il sistema invia una URLMS con codice di esito 07.<br>N – In caso di autorizzazione negata il sistema, invece di mostrare l’esito della transazione alconsumatore, effettua la redirezione immediata verso URLDONE.<br>P – Viene restituito, in URLMS E URDONE, il campo RESPONSE_CODE_AUT che rappresenta il codice di risposta ritornato dal backend autorizzativo.<br>");
|
||
bean.save();
|
||
DBAdapter.logDebug(true, "postepay 2019 chechout initParms: stop");
|
||
}
|
||
}
|
||
|
||
private String getIDNEGOZIO() {
|
||
return getParm("POSTE19_IDNEGOZIO").getTesto();
|
||
}
|
||
|
||
public String getURLBACK() {
|
||
return getParm("POSTE19_URL_BACK").getTesto();
|
||
}
|
||
|
||
public String getURLDONE() {
|
||
return getParm("POSTE19_URL_DONE").getTesto();
|
||
}
|
||
|
||
public String getURLMS() {
|
||
return getParm("POSTE19_URL_MS").getTesto();
|
||
}
|
||
|
||
public String getTCONTAB() {
|
||
return getParm("POSTE19_TCONTAB").getTesto();
|
||
}
|
||
|
||
public String getTAUTOR() {
|
||
return "I";
|
||
}
|
||
|
||
public String getOPTIONS() {
|
||
return getParm("POSTE19_OPTIONS").getTesto();
|
||
}
|
||
|
||
public String getEMAIL() {
|
||
return this.EMAIL;
|
||
}
|
||
|
||
public void setEMAIL(String eMAIL) {
|
||
this.EMAIL = eMAIL;
|
||
}
|
||
|
||
public String getUSERID() {
|
||
return this.USERID;
|
||
}
|
||
|
||
public void setUSERID(String uSERID) {
|
||
this.USERID = uSERID;
|
||
}
|
||
|
||
private String getMAC_KEY_START() {
|
||
return getParm("POSTE19_MAC_KEY_START").getTesto();
|
||
}
|
||
|
||
private String getRequestUrl(boolean test) {
|
||
StringBuilder theUrl = new StringBuilder();
|
||
if (test) {
|
||
theUrl.append("https://acquistionlinetest.poste.it/poste/pagamenti/main?PAGE=MASTER");
|
||
} else {
|
||
theUrl.append("https://acquistionline.poste.it/poste/pagamenti/main?PAGE=MASTER");
|
||
}
|
||
theUrl.append("&IMPORTO=");
|
||
theUrl.append(getIMPORTO());
|
||
theUrl.append("&VALUTA=");
|
||
theUrl.append(getVALUTA());
|
||
theUrl.append("&NUMORD=");
|
||
theUrl.append(getNUMORD());
|
||
theUrl.append("&IDNEGOZIO=");
|
||
theUrl.append(getIDNEGOZIO());
|
||
theUrl.append("&URLBACK=");
|
||
theUrl.append(getURLBACK());
|
||
theUrl.append("&URLDONE=");
|
||
theUrl.append(getURLDONE());
|
||
theUrl.append("&URLMS=");
|
||
theUrl.append(getURLMS());
|
||
theUrl.append("&TCONTAB=");
|
||
theUrl.append(getTCONTAB());
|
||
theUrl.append("&TAUTOR=I");
|
||
theUrl.append("&MAC=");
|
||
theUrl.append(getMacPagamento());
|
||
theUrl.append("&LINGUA=");
|
||
theUrl.append(getLINGUA());
|
||
if (!getEMAILESERC().isEmpty()) {
|
||
theUrl.append("&EMAILESERC=");
|
||
theUrl.append(getEMAILESERC());
|
||
}
|
||
if (!getOPTIONS().isEmpty()) {
|
||
theUrl.append("&OPTIONS=");
|
||
theUrl.append(getOPTIONS());
|
||
}
|
||
theUrl.append("&EMAIL=");
|
||
theUrl.append(getEMAIL());
|
||
theUrl.append("&USERID=");
|
||
theUrl.append(getUSERID());
|
||
return theUrl.toString();
|
||
}
|
||
}
|