/** * */ package com.gpc.manager; import java.math.BigDecimal; import java.util.Date; import com.gpc.message.RefundAuthorizationMessage; import com.gpc.message.SaleAuthorizationMessage; import com.gpc.message.isd.CCMessage; import com.gpc.message.isd.SVMessage; import com.gpc.message.isd.fields.CurrencyCode; import com.gpc.message.isd.fields.TenderType; import com.gpc.tams.json.SaleResp; import com.gpc.tams.repository.ipc.IpcTransactionLog; /** * @author * */ public class TransactionLogHandler { public static void updateTxLogEntry ( IpcTransactionLog txLog, CCMessage authMsg ) throws Exception { if ( authMsg instanceof SaleAuthorizationMessage ) { authMsg = ( SaleAuthorizationMessage ) authMsg; } else if ( authMsg instanceof RefundAuthorizationMessage ) { authMsg = ( RefundAuthorizationMessage ) authMsg; } txLog.setAuthorizedAmount( authMsg.getAuthorizationAmount() ); txLog.setTenderType( authMsg.getTenderType() ); txLog.setAuthorizationTime( authMsg.getAuthorizationDateTime() ); txLog.setAuthorizationSource( authMsg.getAuthorizationSource() ); txLog.setCurrencyCode( authMsg.getCurrencyCode() ); txLog.setPosEntryMode( authMsg.getPosEntryMode() ); txLog.setPosConditionCode( authMsg.getPosConditionCode() ); txLog.setPosTerminalType( authMsg.getPosTerminalType() ); txLog.setPosTerminalEntryCapability( authMsg.getPosTerminalEntryCapability() ); txLog.setMerchantCategoryCode( authMsg.getMerchantCategoryCode() ); txLog.setRequestedCashBackAmount( authMsg.getCashBack() ); txLog.setApprovedCashBackAmount( authMsg.getApprovedCashBack() ); txLog.setLocalTransactionTime( authMsg.getLocalTransactionTime() ); txLog.setNetworkId( authMsg.getDebitNetworkId() ); txLog.setAccountNumberLength( authMsg.getAccountNumberLength() ); txLog.setCardLevelResults( authMsg.getCardLevelResults() ); txLog.setAuthorizationTrackNumber( authMsg.getTrackNumber() ); txLog.setAuthorizerBankNumber( authMsg.getAuthorizerBankNumber() ); txLog.setMarketSpecificIndicator( authMsg.getMarketSpecificIndicator() ); txLog.setPartialApprovalIndicator( authMsg.getPartialApprovalIndicator() ); txLog.setCustomerName( authMsg.getCustomerName() ); txLog.setCreditPlan( authMsg.getCreditPlan() ); txLog.setAuthorizationCode( authMsg.getAuthorizationCode() ); txLog.setPaymentServiceIndicator( authMsg.getPaymentServiceIndicator()); txLog.setTransactionId( authMsg.getTransactionId()); txLog.setResponseCode( authMsg.getResponseCode()); txLog.setValidationCode( authMsg.getValidationCode()); txLog.setHostTransactionReferenceNumber( authMsg.getHostTransactionReferenceNumber()); txLog.setTraceNumber( authMsg.getSystemTraceAuditNumber().toString()); txLog.setRetrievalReference( authMsg.getRetrievalReference()); txLog.setAmount( authMsg.getAmount()); } public static void updateTxLogEntry ( IpcTransactionLog txLog, SVMessage svMsg ) throws Exception { txLog.setAuthorizedAmount( svMsg.getAuthorizedAmount() ); txLog.setTenderType( svMsg.getTenderType() ); txLog.setAuthorizationTime( svMsg.getAuthorizationDateTime() ); txLog.setCurrencyCode( svMsg.getCurrencyCode() ); txLog.setRequestedCashBackAmount( svMsg.getCashBack() ); txLog.setAccountNumberLength( svMsg.getAccountNumberLength() ); txLog.setAuthorizationCode( svMsg.getAuthorizationCode() ); txLog.setResponseCode( svMsg.getResponseCode()); txLog.setAmount( svMsg.getAmount()); } public static void updateTxLogEntry ( IpcTransactionLog txLog, SaleResp saleResp ) throws Exception { txLog.setAuthorizedAmount( saleResp.getAuthorizedAmount() ); String tenderType = saleResp.getCard().getType(); if (TenderType.CREDIT_CARDS.name().startsWith(tenderType)) { txLog.setTenderType(TenderType.CREDIT_CARDS); } else if (TenderType.DEBIT_CARDS.name().startsWith(tenderType)) { txLog.setTenderType(TenderType.DEBIT_CARDS); } else { txLog.setTenderType(TenderType.valueOf(saleResp.getCard().getType())); } txLog.setAuthorizationTime( saleResp.getTimestamp() ); // PAS return "USD" only. If that changes, the currencyCode needs to be set differently txLog.setCurrencyCode( CurrencyCode.UNITED_STATES.getType()); txLog.setAuthorizationCode( saleResp.getProcessor().getAuthorizationCode() ); txLog.setResponseCode( String.valueOf(saleResp.getProcessor().getResponseCode())); txLog.setAmount( saleResp.getAuthorizedAmount()); } public static void updateTxLogEntry ( IpcTransactionLog txLog, BigDecimal authorizationAmount, TenderType tenderType, Date authorizationDateTime, String authorizationSource, Integer currencyCode, String posEntryMode, Integer posConditionCode, Integer posTerminalType, Integer posTerminalEntryCapability, Integer merchantCategoryCode, BigDecimal cashBack, BigDecimal approvedCashBack, Date localTransactionTime, String debitNetworkId, Integer cccountNumberLength, String cardLevelResults, String trackNumber, Integer authorizerBankNumber, String marketSpecificIndicator, String partialApprovalIndicator, String custName, String creditPlan) throws Exception { txLog.setAuthorizedAmount( authorizationAmount ); txLog.setTenderType( tenderType ); txLog.setAuthorizationTime( authorizationDateTime ); txLog.setAuthorizationSource( authorizationSource ); txLog.setCurrencyCode( currencyCode ); txLog.setPosEntryMode( posEntryMode ); txLog.setPosConditionCode( posConditionCode ); txLog.setPosTerminalType( posTerminalType ); txLog.setPosTerminalEntryCapability( posTerminalEntryCapability ); txLog.setMerchantCategoryCode( merchantCategoryCode ); txLog.setRequestedCashBackAmount( cashBack ); txLog.setApprovedCashBackAmount( approvedCashBack ); txLog.setLocalTransactionTime( localTransactionTime ); txLog.setNetworkId( debitNetworkId ); txLog.setAccountNumberLength( cccountNumberLength ); txLog.setCardLevelResults( cardLevelResults ); txLog.setAuthorizationTrackNumber( trackNumber ); txLog.setAuthorizerBankNumber( authorizerBankNumber ); txLog.setMarketSpecificIndicator( marketSpecificIndicator ); txLog.setPartialApprovalIndicator( partialApprovalIndicator ); txLog.setCustomerName( custName ); txLog.setCreditPlan( creditPlan ); } }