291 lines
8.1 KiB
Java
291 lines
8.1 KiB
Java
|
|
package it.acxent.bank.paypalcheckout;
|
||
|
|
|
||
|
|
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 java.net.URLEncoder;
|
||
|
|
|
||
|
|
public class PayPalReq extends _BankAdapter {
|
||
|
|
private String paypalClientId;
|
||
|
|
|
||
|
|
private String paypalClientSecret;
|
||
|
|
|
||
|
|
private boolean useSandbox = false;
|
||
|
|
|
||
|
|
private double amt;
|
||
|
|
|
||
|
|
private long id_ordine;
|
||
|
|
|
||
|
|
private String cancelURL;
|
||
|
|
|
||
|
|
private String returnUrl;
|
||
|
|
|
||
|
|
private String paypalOrderId;
|
||
|
|
|
||
|
|
private String TOKEN;
|
||
|
|
|
||
|
|
private String PAYERID;
|
||
|
|
|
||
|
|
private String SHIPTOCITY;
|
||
|
|
|
||
|
|
private String SHIPTOCOUNTRYCODE;
|
||
|
|
|
||
|
|
private String SHIPTONAME;
|
||
|
|
|
||
|
|
private String SHIPTOSTATE;
|
||
|
|
|
||
|
|
private String SHIPTOSTREET;
|
||
|
|
|
||
|
|
private String SHIPTOZIP;
|
||
|
|
|
||
|
|
private String DESC;
|
||
|
|
|
||
|
|
private String currency;
|
||
|
|
|
||
|
|
public static final String P_CHECKOUT_APPLICATION_CLIENT_ID = "PAYPAL_CHECKOUT_APPLICATION_CLIENT_ID";
|
||
|
|
|
||
|
|
public static final String P_CHECKOUT_APPLICATION_CLIENT_SECRET = "PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET";
|
||
|
|
|
||
|
|
public static final String P_CHECKOUT_USE_SANDBOX = "P_PAYPAL_CHECKOUT_USE_SANDBOX";
|
||
|
|
|
||
|
|
public static final String P_CANCEL_URL = "PAYPAL_CANCELURL";
|
||
|
|
|
||
|
|
public static final String P_CURRENCY = "PAYPAL_CURRENCY";
|
||
|
|
|
||
|
|
public static final String P_PAYMENT_OK_PAGE = "PAYPAL_OK";
|
||
|
|
|
||
|
|
public static final String P_RETURN_URL = "PAYPAL_RETURNURL";
|
||
|
|
|
||
|
|
public double getAmt() {
|
||
|
|
return this.amt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setAmt(double amt) {
|
||
|
|
this.amt = amt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCancelURL() {
|
||
|
|
return (this.cancelURL == null) ? "" : this.cancelURL;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setCancelURL(String cancelURL) {
|
||
|
|
this.cancelURL = cancelURL;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getReturnUrl() {
|
||
|
|
return (this.returnUrl == null) ? "" : this.returnUrl;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setReturnUrl(String returnUrl) {
|
||
|
|
this.returnUrl = returnUrl;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getTOKEN() {
|
||
|
|
return (this.TOKEN == null) ? "" : this.TOKEN;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setTOKEN(String token) {
|
||
|
|
this.TOKEN = token;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getPAYERID() {
|
||
|
|
return this.PAYERID;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setPAYERID(String payerid) {
|
||
|
|
this.PAYERID = payerid;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getSHIPTOCITY() {
|
||
|
|
return (this.SHIPTOCITY == null) ? "" : this.SHIPTOCITY;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getSHIPTOCOUNTRYCODE() {
|
||
|
|
return (this.SHIPTOCOUNTRYCODE == null) ? "" : this.SHIPTOCOUNTRYCODE;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getSHIPTONAME() {
|
||
|
|
return (this.SHIPTONAME == null) ? "" : this.SHIPTONAME;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getSHIPTOSTATE() {
|
||
|
|
return (this.SHIPTOSTATE == null) ? "" : this.SHIPTOSTATE;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getSHIPTOSTREET() {
|
||
|
|
return (this.SHIPTOSTREET == null) ? "" : this.SHIPTOSTREET;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getSHIPTOZIP() {
|
||
|
|
return (this.SHIPTOZIP == null) ? "" : this.SHIPTOZIP;
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getId_ordine() {
|
||
|
|
return this.id_ordine;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setId_ordine(long id_ordine) {
|
||
|
|
this.id_ordine = id_ordine;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getShippingAddressString() {
|
||
|
|
return "SHIPTONAME=" + URLEncoder.encode(getSHIPTONAME()) + "&DESC=" + URLEncoder.encode(getDESC()) + "&SHIPTOSTREET=" +
|
||
|
|
URLEncoder.encode(getSHIPTOSTREET()) + "&SHIPTOCITY=" + URLEncoder.encode(getSHIPTOCITY()) + "&SHIPTOSTATE=" +
|
||
|
|
URLEncoder.encode(getSHIPTOSTATE()) + "&SHIPTOCOUNTRYCODE=" + URLEncoder.encode(getSHIPTOCOUNTRYCODE()) + "&SHIPTOZIP=" +
|
||
|
|
URLEncoder.encode(getSHIPTOZIP()) + "&ADDROVERRIDE=1";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSHIPTOCITY(String shiptocity) {
|
||
|
|
this.SHIPTOCITY = shiptocity;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSHIPTOCOUNTRYCODE(String shiptocountrycode) {
|
||
|
|
this.SHIPTOCOUNTRYCODE = shiptocountrycode;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSHIPTONAME(String shiptoname) {
|
||
|
|
this.SHIPTONAME = shiptoname;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSHIPTOSTATE(String shiptostate) {
|
||
|
|
this.SHIPTOSTATE = shiptostate;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSHIPTOSTREET(String shiptostreet) {
|
||
|
|
this.SHIPTOSTREET = shiptostreet;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSHIPTOZIP(String shiptozip) {
|
||
|
|
this.SHIPTOZIP = shiptozip;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void initApplicationParms(ApplParmFull ap) {
|
||
|
|
boolean debug = false;
|
||
|
|
if (ap != null) {
|
||
|
|
DBAdapter.logDebug(debug, "payPal chechout initParms: start");
|
||
|
|
String l_tipoParm = "PAYPAL";
|
||
|
|
Parm bean = new Parm(ap);
|
||
|
|
l_tipoParm = "PAYPAL_CHECKOUT";
|
||
|
|
StatusMsg.updateMsgByTag(ap, "INIT", l_tipoParm);
|
||
|
|
bean.findByCodice("PAYPAL_CANCELURL");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_CANCELURL");
|
||
|
|
bean.setDescrizione("PAYPAL_CANCELURL");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
bean.setNota("PAYPAL_CANCELURL");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("PAYPAL_CURRENCY");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_CURRENCY");
|
||
|
|
bean.setDescrizione("PAYPAL_CURRENCY");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
if (bean.getTesto().equals(""))
|
||
|
|
bean.setTesto("EUR");
|
||
|
|
bean.setNota("PAYPAL_CURRENCY");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("PAYPAL_OK");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_OK");
|
||
|
|
bean.setDescrizione("PAYPAL_OK");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
if (bean.getTesto().equals(""))
|
||
|
|
bean.setTesto("payPalRes.jsp");
|
||
|
|
bean.setNota("PAYPAL_OK");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("PAYPAL_RETURNURL");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_RETURNURL");
|
||
|
|
bean.setDescrizione("PAYPAL_RETURNURL");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
bean.setNota("PAYPAL_RETURNURL");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("PAYPAL_CHECKOUT_APPLICATION_CLIENT_ID");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_CHECKOUT_APPLICATION_CLIENT_ID");
|
||
|
|
bean.setDescrizione("PAYPAL_CHECKOUT_APPLICATION_CLIENT_ID");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
bean.setNota("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.setDescrizione("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
bean.setNota("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.setFlgAdmin(0L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.setDescrizione("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.setFlgTipo(0L);
|
||
|
|
bean.setNota("PAYPAL_CHECKOUT_APPLICATION_CLIENT_SECRET");
|
||
|
|
bean.save();
|
||
|
|
bean.findByCodice("P_PAYPAL_CHECKOUT_USE_SANDBOX");
|
||
|
|
bean.setFlgAdmin(1L);
|
||
|
|
bean.setTipoParm(l_tipoParm);
|
||
|
|
bean.setCodice("P_PAYPAL_CHECKOUT_USE_SANDBOX");
|
||
|
|
bean.setDescrizione("P_PAYPAL_CHECKOUT_USE_SANDBOX");
|
||
|
|
bean.setFlgTipo(5L);
|
||
|
|
bean.setNota("P_PAYPAL_CHECKOUT_USE_SANDBOX");
|
||
|
|
bean.save();
|
||
|
|
DBAdapter.logDebug(debug, "payPal chechout initParms: stop");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getDESC() {
|
||
|
|
return (this.DESC == null) ? "" : this.DESC.trim();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setDESC(String dESC) {
|
||
|
|
this.DESC = dESC;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCurrency() {
|
||
|
|
return (this.currency == null) ? "EUR" : this.currency.trim();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setCurrency(String currency) {
|
||
|
|
this.currency = currency;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getPaypalClientId() {
|
||
|
|
return this.paypalClientId;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setPaypalClientId(String paypalClientId) {
|
||
|
|
this.paypalClientId = paypalClientId;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getPaypalClientSecret() {
|
||
|
|
return this.paypalClientSecret;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setPaypalClientSecret(String paypalClientSecret) {
|
||
|
|
this.paypalClientSecret = paypalClientSecret;
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean isUseSandbox() {
|
||
|
|
return this.useSandbox;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setUseSandbox(boolean useSandbox) {
|
||
|
|
this.useSandbox = useSandbox;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getPaypalOrderId() {
|
||
|
|
return (this.paypalOrderId == null) ? "" : this.paypalOrderId.trim();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setPaypalOrderId(String paypalOrderId) {
|
||
|
|
this.paypalOrderId = paypalOrderId;
|
||
|
|
}
|
||
|
|
}
|