IDEMPIERE-860 Review Payment Processors
- improve the error message when a payment processor model is not found - clear the result columns when copy from a payment transaction record - fix the use of database transaction in payment transaction
This commit is contained in:
parent
c906b847b2
commit
305a23403a
|
@ -1978,21 +1978,35 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
|||
int[] ids = MPaymentTransaction.getAuthorizationPaymentTransactionIDs(orderIDList, getC_Invoice_ID(), get_TrxName());
|
||||
if (ids.length > 0)
|
||||
{
|
||||
boolean pureCIM = true;
|
||||
ArrayList<MPaymentTransaction> ptList = new ArrayList<MPaymentTransaction>();
|
||||
BigDecimal totalPayAmt = BigDecimal.ZERO;
|
||||
for (int id : ids)
|
||||
{
|
||||
MPaymentTransaction pt = new MPaymentTransaction(Env.getCtx(), id, get_TrxName());
|
||||
MPaymentTransaction pt = new MPaymentTransaction(getCtx(), id, get_TrxName());
|
||||
|
||||
if (!pt.setPaymentProcessor())
|
||||
{
|
||||
if (pt.getC_PaymentProcessor_ID() > 0)
|
||||
{
|
||||
MPaymentProcessor pp = new MPaymentProcessor(getCtx(), pt.getC_PaymentProcessor_ID(), get_TrxName());
|
||||
m_processMsg = Msg.getMsg(getCtx(), "PaymentNoProcessorModel") + ": " + pp.toString();
|
||||
}
|
||||
else
|
||||
m_processMsg = Msg.getMsg(getCtx(), "PaymentNoProcessorModel");
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
boolean isCIM = pt.getC_PaymentProcessor_ID() > 0 && pt.getCustomerPaymentProfileID() != null && pt.getCustomerPaymentProfileID().length() > 0;
|
||||
if (pureCIM && !isCIM)
|
||||
pureCIM = false;
|
||||
|
||||
totalPayAmt = totalPayAmt.add(pt.getPayAmt());
|
||||
ptList.add(pt);
|
||||
}
|
||||
|
||||
// automatically void authorization payment and create a new sales payment when invoiced amount is NOT equals to the authorized amount (applied to CIM payment processor)
|
||||
if(getGrandTotal().compareTo(totalPayAmt) != 0 &&
|
||||
ptList.size() > 0 &&
|
||||
ptList.get(0).getC_PaymentProcessor_ID() > 0 &&
|
||||
ptList.get(0).getCustomerPaymentProfileID() != null &&
|
||||
ptList.get(0).getCustomerPaymentProfileID().length() > 0)
|
||||
if (getGrandTotal().compareTo(totalPayAmt) != 0 && ptList.size() > 0 && pureCIM)
|
||||
{
|
||||
// create a new sales payment
|
||||
MPaymentTransaction newSalesPT = MPaymentTransaction.copyFrom(ptList.get(0), new Timestamp(System.currentTimeMillis()), MPayment.TRXTYPE_Sales, "", get_TrxName());
|
||||
|
|
|
@ -492,9 +492,18 @@ public final class MPayment extends X_C_Payment
|
|||
if (m_mBankAccountProcessor == null)
|
||||
setPaymentProcessor();
|
||||
if (m_mBankAccountProcessor == null)
|
||||
{
|
||||
if (getC_PaymentProcessor_ID() > 0)
|
||||
{
|
||||
MPaymentProcessor pp = new MPaymentProcessor(getCtx(), getC_PaymentProcessor_ID(), get_TrxName());
|
||||
log.log(Level.WARNING, "No Payment Processor Model " + pp.toString());
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNoProcessorModel") + ": " + pp.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
log.log(Level.WARNING, "No Payment Processor Model");
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNoProcessorModel"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -549,6 +558,8 @@ public final class MPayment extends X_C_Payment
|
|||
|
||||
try
|
||||
{
|
||||
trx.start();
|
||||
|
||||
MPaymentTransaction m_mPaymentTransaction = createPaymentTransaction(trx.getTrxName());
|
||||
m_mPaymentTransaction.setIsApproved(approved);
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
|
|
|
@ -170,11 +170,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
* @return true if approved
|
||||
*/
|
||||
public boolean processOnline()
|
||||
{
|
||||
return processOnline(get_TrxName());
|
||||
}
|
||||
|
||||
public boolean processOnline(String trxName)
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info ("Amt=" + getPayAmt());
|
||||
//
|
||||
|
@ -212,9 +207,18 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
if (m_mBankAccountProcessor == null)
|
||||
setPaymentProcessor();
|
||||
if (m_mBankAccountProcessor == null)
|
||||
{
|
||||
if (getC_PaymentProcessor_ID() > 0)
|
||||
{
|
||||
MPaymentProcessor pp = new MPaymentProcessor(getCtx(), getC_PaymentProcessor_ID(), get_TrxName());
|
||||
log.log(Level.WARNING, "No Payment Processor Model " + pp.toString());
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNoProcessorModel") + ": " + pp.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
log.log(Level.WARNING, "No Payment Processor Model");
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNoProcessorModel"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -252,7 +256,7 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
&& !getTrxType().equals(MPaymentTransaction.TRXTYPE_VoiceAuthorization)
|
||||
&& !getTrxType().equals(MPaymentTransaction.TRXTYPE_Void))
|
||||
{
|
||||
MPayment m_mPayment = createPayment(trxName);
|
||||
MPayment m_mPayment = createPayment(get_TrxName());
|
||||
m_mPayment.saveEx();
|
||||
setC_Payment_ID(m_mPayment.getC_Payment_ID());
|
||||
processed = m_mPayment.processIt(DocAction.ACTION_Complete);
|
||||
|
@ -321,16 +325,14 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
{
|
||||
if (getTenderType().equals(TENDERTYPE_CreditCard) && isOnline() && getTrxType().equals(TRXTYPE_Authorization) && !isVoided() && !isDelayedCapture())
|
||||
{
|
||||
Trx trx = Trx.get(Trx.createTrxName("ppt-"), true);
|
||||
|
||||
boolean ok = false;
|
||||
try
|
||||
{
|
||||
MPaymentTransaction m_mPaymentTransaction = copyFrom(this, new Timestamp(System.currentTimeMillis()), TRXTYPE_Void, getR_PnRef(), trx.getTrxName());
|
||||
MPaymentTransaction m_mPaymentTransaction = copyFrom(this, new Timestamp(System.currentTimeMillis()), TRXTYPE_Void, getR_PnRef(), get_TrxName());
|
||||
m_mPaymentTransaction.setIsApproved(false);
|
||||
m_mPaymentTransaction.setIsVoided(false);
|
||||
m_mPaymentTransaction.setIsDelayedCapture(false);
|
||||
ok = m_mPaymentTransaction.processOnline(get_TrxName());
|
||||
ok = m_mPaymentTransaction.processOnline();
|
||||
m_mPaymentTransaction.setRef_PaymentTransaction_ID(getC_PaymentTransaction_ID());
|
||||
m_mPaymentTransaction.saveEx();
|
||||
|
||||
|
@ -348,14 +350,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
log.log(Level.SEVERE, "voidOnlineAuthorizationPaymentTransaction", e);
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNotProcessed") + ": " + e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (trx != null)
|
||||
{
|
||||
trx.commit();
|
||||
trx.close();
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -367,12 +361,10 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
{
|
||||
if (getTenderType().equals(TENDERTYPE_CreditCard) && isOnline() && getTrxType().equals(TRXTYPE_Authorization) && !isVoided() && !isDelayedCapture())
|
||||
{
|
||||
Trx trx = Trx.get(Trx.createTrxName("ppt-"), true);
|
||||
|
||||
boolean ok = false;
|
||||
try
|
||||
{
|
||||
MPaymentTransaction m_mPaymentTransaction = copyFrom(this, new Timestamp(System.currentTimeMillis()), TRXTYPE_DelayedCapture, getR_PnRef(), trx.getTrxName());
|
||||
MPaymentTransaction m_mPaymentTransaction = copyFrom(this, new Timestamp(System.currentTimeMillis()), TRXTYPE_DelayedCapture, getR_PnRef(), get_TrxName());
|
||||
m_mPaymentTransaction.setIsApproved(false);
|
||||
m_mPaymentTransaction.setIsVoided(false);
|
||||
m_mPaymentTransaction.setIsDelayedCapture(false);
|
||||
|
@ -380,7 +372,7 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
if (C_Invoice_ID != 0)
|
||||
m_mPaymentTransaction.setC_Invoice_ID(C_Invoice_ID);
|
||||
|
||||
ok = m_mPaymentTransaction.processOnline(get_TrxName());
|
||||
ok = m_mPaymentTransaction.processOnline();
|
||||
m_mPaymentTransaction.setRef_PaymentTransaction_ID(getC_PaymentTransaction_ID());
|
||||
m_mPaymentTransaction.saveEx();
|
||||
|
||||
|
@ -399,14 +391,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
log.log(Level.SEVERE, "delayCaptureOnlineAuthorizationPaymentTransaction", e);
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNotProcessed") + ": " + e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (trx != null)
|
||||
{
|
||||
trx.commit();
|
||||
trx.close();
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -596,26 +580,26 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce
|
|||
to.setDateTrx(dateTrx);
|
||||
to.setDescription(from.getDescription());
|
||||
to.setIsActive(from.isActive());
|
||||
// to.setIsApproved(from.isApproved());
|
||||
// to.setIsDelayedCapture(from.isDelayedCapture());
|
||||
to.setIsApproved(false);
|
||||
to.setIsDelayedCapture(false);
|
||||
to.setIsOnline(from.isOnline());
|
||||
to.setIsReceipt(from.isReceipt());
|
||||
to.setIsSelfService(from.isSelfService());
|
||||
// to.setIsVoided(from.isVoided());
|
||||
to.setIsVoided(false);
|
||||
to.setMicr(from.getMicr());
|
||||
to.setOrig_TrxID(orig_TrxID);
|
||||
to.setPayAmt(from.getPayAmt());
|
||||
to.setPONum(from.getPONum());
|
||||
// to.setProcessed(from.isProcessed());
|
||||
// to.setR_AuthCode(from.getR_AuthCode());
|
||||
// to.setR_AvsAddr(from.getR_AvsAddr());
|
||||
// to.setR_AvsZip(from.getR_AvsZip());
|
||||
// to.setR_CVV2Match(from.isR_CVV2Match());
|
||||
// to.setR_Info(from.getR_Info());
|
||||
// to.setR_PnRef(from.getR_PnRef());
|
||||
// to.setR_RespMsg(from.getR_RespMsg());
|
||||
// to.setR_Result(from.getR_Result());
|
||||
// to.setR_VoidMsg(from.getR_VoidMsg());
|
||||
to.setProcessed(false);
|
||||
to.setR_AuthCode(null);
|
||||
to.setR_AvsAddr(null);
|
||||
to.setR_AvsZip(null);
|
||||
to.setR_CVV2Match(false);
|
||||
to.setR_Info(null);
|
||||
to.setR_PnRef(null);
|
||||
to.setR_RespMsg(null);
|
||||
to.setR_Result(null);
|
||||
to.setR_VoidMsg(null);
|
||||
to.setRoutingNo(from.getRoutingNo());
|
||||
to.setTaxAmt(from.getTaxAmt());
|
||||
to.setTenderType(from.getTenderType());
|
||||
|
|
|
@ -393,6 +393,11 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
}
|
||||
|
||||
public boolean processOnline(String CCType, String CCNumber, String CCExp)
|
||||
{
|
||||
return processOnline(CCType, CCNumber, CCExp, 0);
|
||||
}
|
||||
|
||||
public boolean processOnline(String CCType, String CCNumber, String CCExp, int C_PaymentProcessor_ID)
|
||||
{
|
||||
processMsg = null;
|
||||
boolean error = false;
|
||||
|
@ -427,6 +432,7 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
mpt.setAD_Org_ID(m_AD_Org_ID);
|
||||
mpt.setCreditCard(MPayment.TRXTYPE_Sales, CCType, CCNumber, "", CCExp);
|
||||
mpt.setAmount(m_C_Currency_ID, payAmount);
|
||||
mpt.setC_PaymentProcessor_ID(C_PaymentProcessor_ID);
|
||||
mpt.setPaymentProcessor();
|
||||
|
||||
if (isPOSOrder || isInvoice)
|
||||
|
|
Loading…
Reference in New Issue