diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 288c3b892f..a2a07df839 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -512,7 +512,7 @@ public final class MPayment extends X_C_Payment // setErrorMessage(Msg.getMsg(getCtx(), msg)); // } else { // Process if validation succeeds - approved = pp.processCC (); + approved = pp.processCC(); if (approved) setErrorMessage(null); @@ -534,6 +534,9 @@ public final class MPayment extends X_C_Payment if (approved) { + setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber())); + setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); + setDateTrx(new Timestamp(System.currentTimeMillis())); setDateAcct(new Timestamp(System.currentTimeMillis())); setProcessed(true); // prevent editing of payment details once approved @@ -730,6 +733,23 @@ public final class MPayment extends X_C_Payment } } } + + if (isProcessed()) + { + if (getCreditCardNumber() != null) + { + String encrpytedCCNo = PaymentUtil.encrpytCreditCard(getCreditCardNumber()); + if (!encrpytedCCNo.equals(getCreditCardNumber())) + setCreditCardNumber(encrpytedCCNo); + } + + if (getCreditCardVV() != null) + { + String encrpytedCvv = PaymentUtil.encrpytCvv(getCreditCardVV()); + if (!encrpytedCvv.equals(getCreditCardVV())) + setCreditCardVV(encrpytedCvv); + } + } return true; } // beforeSave @@ -2852,13 +2872,6 @@ public final class MPayment extends X_C_Payment } } - // clear out the cc data when a Void happens since at that point we won't need the card information any longer - if (getTenderType().equals(TENDERTYPE_CreditCard)) - { - setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber())); - setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); - } - if (getC_Invoice_ID() != 0) { MInvoice inv = new MInvoice(getCtx(), getC_Invoice_ID(), get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java b/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java index bda8d64762..27ba32811c 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java @@ -75,7 +75,12 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce protected boolean beforeSave(boolean newRecord) { if (getCreditCardVV() != null) - setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); + { + String encrpytedCvv = PaymentUtil.encrpytCvv(getCreditCardVV()); + if (!encrpytedCvv.equals(getCreditCardVV())) + setCreditCardVV(encrpytedCvv); + } + return true; } @@ -226,7 +231,9 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce // setErrorMessage(Msg.getMsg(getCtx(), msg)); // } else { // Process if validation succeeds - approved = pp.processCC (); + approved = pp.processCC(); + setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber())); + setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); setIsApproved(approved); if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment)) @@ -319,8 +326,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce m_mPaymentTransaction.setIsDelayedCapture(false); boolean ok = m_mPaymentTransaction.processOnline(get_TrxName()); m_mPaymentTransaction.setRef_PaymentTransaction_ID(getC_PaymentTransaction_ID()); -// m_mPaymentTransaction.setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber())); -// m_mPaymentTransaction.setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); m_mPaymentTransaction.saveEx(); if (trx != null) @@ -334,9 +339,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce setIsVoided(true); setR_VoidMsg(m_mPaymentTransaction.getR_VoidMsg()); setRef_PaymentTransaction_ID(m_mPaymentTransaction.getC_PaymentTransaction_ID()); - -// setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber())); -// setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); } else setErrorMessage(m_mPaymentTransaction.getErrorMessage());