97 lines
3.7 KiB
Java
97 lines
3.7 KiB
Java
package it.acxent.pg.servlet;
|
|
|
|
import it.acxent.anag.Clifor;
|
|
import it.acxent.bank.paypal.PayPalResp;
|
|
import it.acxent.bank.servlet.paypal.PayPalSvlt;
|
|
import it.acxent.cart.Cart;
|
|
import it.acxent.contab.Documento;
|
|
import it.acxent.contab.DocumentoInterface;
|
|
import it.acxent.contab.RigaDocumento;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.pg.Users;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
@Deprecated
|
|
public class PayPalDoPaymentSvlt extends PayPalSvlt {
|
|
protected static ApplParmFull ap2;
|
|
|
|
protected void recordOrder(HttpServletRequest req, HttpServletResponse res, PayPalResp ppResponse) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
ResParm rp = new ResParm(true);
|
|
if (ppResponse != null && ppResponse.isPaymentDone()) {
|
|
String s_amt = ppResponse.getAMT().trim();
|
|
long l_id_users = ppResponse.getId_ordine();
|
|
Users user = new Users(apFull);
|
|
user.findByPrimaryKey(l_id_users);
|
|
if (user.getId_clifor() == 0L) {
|
|
Clifor clifor = new Clifor(apFull);
|
|
clifor.setFlgTipo("C");
|
|
clifor.setNome(user.getNome());
|
|
clifor.setCognome(user.getCognome());
|
|
clifor.setIndirizzo(user.getIndirizzo());
|
|
clifor.setNumeroCivico(user.getNumeroCivico());
|
|
clifor.setFlgSesso(user.getFlgSesso());
|
|
clifor.setDescrizioneComune(user.getCitta());
|
|
clifor.setCapComune(user.getCap());
|
|
clifor.setId_nazione(user.getId_nazione());
|
|
clifor.setCodFisc(user.getCodFisc());
|
|
clifor.setTelefono(user.getTelefono());
|
|
clifor.setContatto(user.getContatto());
|
|
rp = clifor.save();
|
|
if (rp.getStatus()) {
|
|
user.setId_clifor(clifor.getId_clifor());
|
|
rp = user.save();
|
|
}
|
|
}
|
|
if (rp.getStatus()) {
|
|
Documento doc = new Documento(apFull);
|
|
long l_id_tipo_doc_ordine_www = getParm("ID_DOC_ORDINE_WWW").getNumeroLong();
|
|
doc.setId_tipoDocumento(l_id_tipo_doc_ordine_www);
|
|
doc.setDataDocumento(DBAdapter.getToday());
|
|
doc.setId_clifor(user.getId_clifor());
|
|
doc.setFlgPagata(1L);
|
|
doc.setDataPagamento(DBAdapter.getToday());
|
|
doc.setDescTransaction(ppResponse.getTRANSACTIONID());
|
|
rp = doc.save();
|
|
if (rp.getStatus()) {
|
|
RigaDocumento rd = new RigaDocumento(apFull);
|
|
rd.setDescrizioneRiga("Rinnovo abbonamento tramite PayPal trans.#" + ppResponse.getTRANSACTIONID());
|
|
rd.setNr(1.0D);
|
|
rd.setImponibile(Double.parseDouble(s_amt));
|
|
rd.setId_iva(3L);
|
|
rp = Documento.addRigaDocumento((DocumentoInterface)doc, rd);
|
|
if (rp.getStatus()) {
|
|
System.out.println("recrod order:amt: " + s_amt + " cliente: " + user.getCognomeNome());
|
|
if (s_amt.equals("40.00")) {
|
|
rp = user.rinnovaAnno(3000L, 3);
|
|
user.sendRinnovoMailMessage(3000L, 3);
|
|
} else if (s_amt.equals("20.00")) {
|
|
rp = user.rinnovaAnno(1000L, 1);
|
|
user.sendRinnovoMailMessage(1000L, 1);
|
|
} else {
|
|
rp = user.rinnovaAnno(25L, 1);
|
|
user.sendRinnovoMailMessage(25L, 1);
|
|
}
|
|
}
|
|
req.setAttribute("bean", doc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void preparePaymenResPage(HttpServletRequest req, HttpServletResponse res, PayPalResp ppResponse) {
|
|
long l_id_users = 0L;
|
|
if (ppResponse != null)
|
|
l_id_users = ppResponse.getId_ordine();
|
|
Users user = new Users(getApFull());
|
|
user.findByPrimaryKey(l_id_users);
|
|
req.setAttribute("user", user);
|
|
}
|
|
|
|
protected String getCheckOutMailMessage() {
|
|
return getParm(Cart.P_CHECKOUTMSG).getTesto();
|
|
}
|
|
}
|