77 lines
3.2 KiB
Java
77 lines
3.2 KiB
Java
package it.acxent.cc.servlet;
|
|
|
|
import it.acxent.anag.TipoPagamento;
|
|
import it.acxent.anag.Users;
|
|
import it.acxent.bank.servlet.stripe._StripeResponseSvlt;
|
|
import it.acxent.bank.stripe.StripeResp;
|
|
import it.acxent.cc.Attivita;
|
|
import it.acxent.contab.Documento;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.gtm.GoogleDataLayer;
|
|
import it.acxent.gtm.GoogleDataLayerBuilder;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
public class StripeResponseSvlt extends _StripeResponseSvlt {
|
|
private static final long serialVersionUID = -4056911711739700875L;
|
|
|
|
protected void recordOrder(HttpServletRequest req, HttpServletResponse res, StripeResp stripeRes) {
|
|
boolean debug = false;
|
|
ApplParmFull apFull = getApFull(req);
|
|
String status = stripeRes.getRedirect_status();
|
|
String clientSecret = stripeRes.getPayment_intent_client_secret();
|
|
if (debug)
|
|
System.out.println("StripeSvlt recordOrder prog www: status" + status + " clientSecret:" + clientSecret);
|
|
if (status.equals("succeeded")) {
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByDescTransactionStripe(stripeRes.getPayment_intent_client_secret());
|
|
if (debug)
|
|
System.out.println("StripeSvlt recordOrder prog www: " + bean.getProgOrdineWww() + " TROVATO E APPROVATO");
|
|
bean.setDataPagamento(DBAdapter.getToday());
|
|
bean.setDataTransaction(DBAdapter.getToday());
|
|
bean.setDescTransaction(clientSecret);
|
|
bean.setFlgPagata(1L);
|
|
ResParm rp = bean.save();
|
|
if (rp.getStatus()) {
|
|
if (bean.getFlgWwwRichiedeFattura() == 1L) {
|
|
long l = 22L;
|
|
} else {
|
|
long l = 23L;
|
|
}
|
|
Attivita attivita1 = Attivita.getDefaultInstance(apFull);
|
|
Users utente = (Users)getLoginUser(req);
|
|
rp = attivita1.sendOrderMailMessageCC(bean, utente, utente.getLang(), true, true, false, false, req);
|
|
}
|
|
Attivita attivita = Attivita.getDefaultInstance(apFull);
|
|
if (attivita.isTagManagerAttivo()) {
|
|
GoogleDataLayer gdl = new GoogleDataLayer(GoogleDataLayerBuilder.purchaseOrder("eec.purchase", bean));
|
|
req.setAttribute("_gdl", gdl);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void preparePaymenResPage(HttpServletRequest req, HttpServletResponse res, StripeResp stripeRes) {
|
|
boolean debug = false;
|
|
ApplParmFull apFull = getApFull(req);
|
|
String clientSecret = null;
|
|
if (stripeRes != null) {
|
|
String status = stripeRes.getRedirect_status();
|
|
clientSecret = stripeRes.getPayment_intent_client_secret();
|
|
}
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByDescTransactionStripe(clientSecret);
|
|
if (debug) {
|
|
clientSecret = "xxx";
|
|
stripeRes.setRedirect_status("succeeded");
|
|
recordOrder(req, res, stripeRes);
|
|
}
|
|
req.setAttribute("bean", bean);
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(
|
|
getApFull(req)).findPagamentiWww(!bean.getClifor().getId_nazione().equals("I"),
|
|
(bean.getFlgDeliveryType() == 2L)));
|
|
int ordineInverso = (bean.getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0;
|
|
req.setAttribute("righeDocumento", bean.findRigheDocumento(0, 0, ordineInverso));
|
|
}
|
|
}
|