private List <V2.TransactionData> GetTransByDoc(ICCPayment payment, IEnumerable <V2.TransactionData> trans) { string searchDocNum = payment.DocType + payment.RefNbr; List <V2.TransactionData> targetTran = trans.Where(i => i.DocNum == searchDocNum).ToList(); return(targetTran); }
private void CheckPaymentTransaction(TPrimary doc) { if (!IsFeatureSupported(SelectedProcessingCenter, CCProcessingFeature.TransactionGetter)) { return; } ICCPayment pDoc = GetPaymentDoc(doc); IEnumerable <V2.TransactionData> trans = null; if (LockExists(doc)) { retryUnsettledTran.HandleError(i => GetTransByDoc(pDoc, i).Count > 0 ? true : false); try { trans = retryUnsettledTran.Execute(() => GetPaymentProcessing().GetUnsettledTransactions(SelectedProcessingCenter)); } catch (InvalidOperationException) { } } if (trans != null) { IEnumerable <string> result = PrepeareTransactionIds(GetTransByDoc(pDoc, trans)); SyncPaymentTransactionById(doc, result); } ClearTransactionСaches(); IExternalTransaction tran = ExternalTranHelper.GetActiveTransaction(GetExtTrans()); if (tran != null) { TranStatusChanged(pDoc, tran.TransactionID); } }
protected V2.TranProfile GetCustomerProfileFromDoc(ICCPayment pDoc) { V2.TranProfile ret = null; if (pDoc.PMInstanceID > 0) { var query = new PXSelectJoin <CustomerPaymentMethod, InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethodDetail.pMInstanceID, Equal <CustomerPaymentMethod.pMInstanceID> >, InnerJoin <PaymentMethodDetail, On <PaymentMethodDetail.detailID, Equal <CustomerPaymentMethodDetail.detailID> > > >, Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> >, And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > >(Base); PXResultset <CustomerPaymentMethod> result = query.Select(pDoc.PMInstanceID); foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> item in result) { CustomerPaymentMethod cpm = (CustomerPaymentMethod)item; CustomerPaymentMethodDetail cpmDet = (CustomerPaymentMethodDetail)item; ret = new V2.TranProfile() { CustomerProfileId = cpm.CustomerCCPID, PaymentProfileId = cpmDet.Value }; break; } } return(ret); }
public virtual bool Authorize(ICCPayment aPmtInfo, bool aCapture, ref int aTranNbr) { Customer customer; CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer); if (pmInstance == null) { throw new PXException(Messages.CreditCardWithID_0_IsNotDefined, aPmtInfo.PMInstanceID); } CCProcessingCenter procCenter = _repository.FindProcessingCenter(pmInstance.PMInstanceID, null); if (procCenter == null) { throw new PXException(Messages.ERR_CCProcessingCenterIsNotSpecified, pmInstance.Descr); } if (!(procCenter.IsActive ?? false)) { throw new PXException(Messages.ERR_CCProcessingIsInactive, procCenter.ProcessingCenterID); } if (!IsValidForProcessing(pmInstance, customer)) { return(false); } CCTranType tranType = aCapture ? CCTranType.AuthorizeAndCapture : CCTranType.AuthorizeOnly; CCProcTran tran = new CCProcTran(); tran.Copy(aPmtInfo); return(this.DoTransaction(ref aTranNbr, tranType, tran, null, customer.AcctCD, procCenter)); }
private void CheckPaymentTranForceSync(TPrimary doc) { CheckPaymentTransaction(doc); IExternalTransaction storedTran = GetExtTrans().FirstOrDefault(); bool needSyncUnsettled = false; if (storedTran != null && ExternalTranHelper.GetTransactionState(Base, storedTran).IsActive) { SyncPaymentTransactionById(doc, new List <string>() { storedTran.TranNumber }); ClearTransactionСaches(); storedTran = GetExtTrans().FirstOrDefault(); if (storedTran?.Active == false) { needSyncUnsettled = true; } } else { needSyncUnsettled = true; } if (needSyncUnsettled) { ICCPayment pDoc = GetPaymentDoc(doc); IEnumerable <V2.TransactionData> trans = GetPaymentProcessing().GetUnsettledTransactions(SelectedProcessingCenter); IEnumerable <string> result = PrepeareTransactionIds(GetTransByDoc(pDoc, trans)); SyncPaymentTransactionById(doc, result); } }
public virtual bool Credit(ICCPayment aPmtInfo, string aExtRefTranNbr, ref int aTranNbr) { if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID)) { return(false); } Customer customer; CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer); CCProcTran refTran = _repository.FindReferencedCCProcTran(aPmtInfo.PMInstanceID, aExtRefTranNbr); if (refTran != null) { return(Credit(aPmtInfo, refTran.TranNbr.Value, ref aTranNbr)); } else { CCProcTran tran = new CCProcTran(); tran.Copy(aPmtInfo); tran.RefTranNbr = null; tran.RefPCTranNumber = aExtRefTranNbr; refTran = new CCProcTran(); refTran.PCTranNumber = aExtRefTranNbr; return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, refTran, customer.AcctCD, null)); } }
public V2.ProcessingInput GetProcessingInput(V2.CCTranType aTranType, ICCPayment pDoc) { if (pDoc == null) { throw new ArgumentNullException(nameof(pDoc)); } V2.ProcessingInput result = new V2.ProcessingInput() { TranType = aTranType, Amount = pDoc.CuryDocBal.Value, CuryID = pDoc.CuryID, OrigTranID = aTranType == V2.CCTranType.CaptureOnly ? null : pDoc.OrigRefNbr, AuthCode = aTranType == V2.CCTranType.CaptureOnly ? pDoc.OrigRefNbr : null }; if (FillCardData) { result.CardData = GetCardData(_provider.GetCardDataReader()); result.CardData.AddressData = GetAddressData(_provider.GetCustomerDataReader()); } if (FillCustomerData) { result.CustomerData = GetCustomerData(_provider.GetCustomerDataReader()); } result.DocumentData = new V2.DocumentData(); result.DocumentData.DocType = pDoc.DocType; result.DocumentData.DocRefNbr = pDoc.RefNbr; FillDocumentData(result); return(result); }
public void CheckHeldForReviewTranStatus(ICCPayment doc) { ExternalTransactionState state = GetActiveTransactionState(); if (state.IsOpenForReview) { int? tranID = state.ExternalTransaction.TransactionID; bool changed = TranStatusChanged(doc, tranID); if (changed) { IExternalTransaction affectedTran = GetExtTrans().Where(i => i.TransactionID == tranID).FirstOrDefault(); if (affectedTran != null && affectedTran.ProcessingStatus == ExtTransactionProcStatusCode.VoidSuccess || affectedTran.Active == false) { PaymentDoc.Cache.Clear(); PaymentDoc.Cache.ClearQueryCache(); ClearTransactionСaches(); throw new PXException(AR.Messages.CCProcessingAuthTranDeclined); } } else { string procCenter = GetPaymentProcessing().Repository.GetCustomerPaymentMethod(doc.PMInstanceID)?.CCProcessingCenterID; if (IsFeatureSupported(procCenter, CCProcessingFeature.TransactionGetter)) { throw new PXException(TranHeldwarnMsg); } else { throw new PXException(AR.Messages.CCProcessingApprovalHoldingTranNotSupported, procCenter); } } } }
public virtual IEnumerable AuthorizeCCPayment(PXAdapter adapter) { var methodName = GetClassMethodName(); AccessInfo info = this.Base.Accessinfo; PXTrace.WriteInformation($"{methodName} started."); List <TPrimary> list = new List <TPrimary>(); foreach (TPrimary doc in adapter.Get <TPrimary>()) { CheckDocumentUpdatedInDb(doc); PXCache cache = this.Base.Caches[typeof(TPrimary)]; bool prevAllowUpdateState = cache.AllowUpdate; cache.AllowUpdate = true; ICCPayment pDoc = GetPaymentDoc(doc); PXTrace.WriteInformation($"{methodName}. RefNbr:{pDoc.RefNbr}; UserName:{info.UserName}"); list.Add(doc); BeforeAuthorizePayment(doc); var afterAuthorizeActions = GetAfterAuthorizeActions(); CCPaymentEntry paymentEntry = GetCCPaymentEntry(); foreach (var item in afterAuthorizeActions) { paymentEntry.AddAfterProcessCallback(item); } if (ReleaseAfterAuthorize) { paymentEntry.AddAfterProcessCallback(ReleaseARDocument); } paymentEntry.AuthorizeCCpayment(pDoc, new GenericExternalTransactionAdapter <ExternalTransactionDetail>(ExternalTransaction)); cache.AllowUpdate = prevAllowUpdateState; } return(list); }
protected virtual void RecordCapture(ICCPayment doc, V2.TransactionData tranData) { var procGraph = PXGraph.CreateInstance <CCPaymentProcessingGraph>(); TranRecordData tranRecordData = FormatTranRecord(tranData); CCTranType tranType = CCTranType.CaptureOnly; if (tranData.TranType == V2.CCTranType.AuthorizeAndCapture) { tranType = CCTranType.AuthorizeAndCapture; procGraph.RecordCapture(doc, tranRecordData); } else if (tranData.TranType == V2.CCTranType.PriorAuthorizedCapture) { tranType = CCTranType.PriorAuthorizedCapture; procGraph.RecordPriorAuthorizedCapture(doc, tranRecordData); } else { procGraph.RecordCaptureOnly(doc, tranRecordData); } foreach (AfterTranProcDelegate callback in GetAfterCaptureActions()) { callback((IBqlTable)doc, tranType, true); } if (ReleaseAfterCapture) { ReleaseARDocument((IBqlTable)doc, tranType, true); } }
private void CheckInput(ICCPayment doc, IExternalTransaction tran) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } }
public virtual bool CaptureOnly(ICCPayment aPmtInfo, string aAuthorizationNbr, ref int aTranNbr) { Customer customer; CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer); if (string.IsNullOrEmpty(aAuthorizationNbr)) { throw new PXException(Messages.ERR_CCExternalAuthorizationNumberIsRequiredForCaptureOnlyTrans, aAuthorizationNbr); } CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(pmInstance.CCProcessingCenterID); if (procCenter == null) { throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotValid, pmInstance.CCProcessingCenterID, aTranNbr); } if (!(procCenter.IsActive ?? false)) { throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotActive, procCenter, aTranNbr); } if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID)) { return(false); } CCProcTran tran = new CCProcTran(); tran.Copy(aPmtInfo); CCProcTran refTran = new CCProcTran { AuthNumber = aAuthorizationNbr }; return(this.DoTransaction(ref aTranNbr, CCTranType.CaptureOnly, tran, refTran, customer.AcctCD, procCenter)); }
public void CaptureCCpayment(ICCPayment doc, IExternalTransactionAdapter paymentTransaction) { if (doc == null || doc.CuryDocBal == null) { return; } ExternalTransactionState state = ExternalTranHelper.GetActiveTransactionState(graph, paymentTransaction.Select()); if (ExternalTranHelper.HasOpenCCProcTran(graph, state.ExternalTransaction)) { throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress); } if (state.IsCaptured) { throw new PXException(Messages.ERR_CCAuthorizedPaymentAlreadyCaptured); } if (doc.Released == false) { graph.Actions.PressSave(); } ICCPayment toProc = graph.Caches[doc.GetType()].CreateCopy(doc) as ICCPayment; IExternalTransaction tranCopy = null; if (state.IsPreAuthorized && !ExternalTranHelper.IsExpired(state.ExternalTransaction)) { tranCopy = graph.Caches[state.ExternalTransaction.GetType()].CreateCopy(state.ExternalTransaction) as IExternalTransaction; } CCTranType operation = tranCopy != null ? CCTranType.PriorAuthorizedCapture : CCTranType.AuthorizeAndCapture; PXLongOperation.StartOperation(graph, delegate() { bool success = true; try { if (operation == CCTranType.PriorAuthorizedCapture) { TransactionProcessor.ProcessPriorAuthorizedCapture(toProc, tranCopy); } else { TransactionProcessor.ProcessAuthorizeCapture(toProc, tranCopy); } } catch { success = false; throw; } finally { RunCallbacks((IBqlTable)doc, operation, success); } }); }
public virtual void Copy(ICCPayment aPmtInfo) { this.PMInstanceID = aPmtInfo.PMInstanceID; this.DocType = aPmtInfo.DocType; this.RefNbr = aPmtInfo.RefNbr; this.CuryID = aPmtInfo.CuryID; this.Amount = aPmtInfo.CuryDocBal; this.OrigDocType = aPmtInfo.OrigDocType; this.OrigRefNbr = aPmtInfo.OrigRefNbr; }
public void RecordCCCredit(ICCPayment doc, ICCManualInputPaymentInfo info, IExternalTransactionAdapter paymentTransaction) { if (doc == null || doc.CuryDocBal == null) { return; } ExternalTransactionState state = ExternalTranHelper.GetActiveTransactionState(graph, paymentTransaction.Select()); if (ExternalTranHelper.HasOpenCCProcTran(graph, state.ExternalTransaction)) { throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress); } if (string.IsNullOrEmpty(info.PCTranNumber)) { throw new PXException(Messages.ERR_PCTransactionNumberOfTheOriginalPaymentIsRequired); } if (state.IsRefunded) { throw new PXException(Messages.ERR_CCPaymentIsAlreadyRefunded); } if (doc.Released == false) { graph.Actions.PressSave(); } ICCPayment toProc = graph.Caches[doc.GetType()].CreateCopy(doc) as ICCPayment; CCTranType operation = CCTranType.Credit; PXLongOperation.StartOperation(graph, delegate() { bool success = true; try { var procGraph = PXGraph.CreateInstance <CCPaymentProcessingGraph>(); TranRecordData recordData = new TranRecordData(); recordData.RefExternalTranId = toProc.RefTranExtNbr; recordData.ExternalTranId = info.PCTranNumber; recordData.AuthCode = info.AuthNumber; procGraph.RecordCredit(doc, recordData); } catch { success = false; throw; } finally { RunCallbacks((IBqlTable)doc, operation, success); } }); }
protected ICCPayment GetPaymentDoc(TPrimary doc) { ICCPayment pDoc = doc as ICCPayment; if (pDoc == null) { pDoc = PaymentDoc.View.SelectSingleBound(new object[] { doc }) as ICCPayment; } if (pDoc == null) { throw new PXException(NotLocalizableMessages.ERR_CCProcessingNotImplementedICCPayment); } return(pDoc); }
public void VoidCCPayment(ICCPayment doc, IExternalTransactionAdapter paymentTransaction) { if (doc == null || doc.CuryDocBal == null) { return; } ExternalTransactionState state = ExternalTranHelper.GetActiveTransactionState(graph, paymentTransaction.Select()); if (ExternalTranHelper.HasOpenCCProcTran(graph, state.ExternalTransaction)) { throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress); } if (!state.IsActive) { throw new PXException(Messages.ERR_CCNoTransactionToVoid); } if (state.IsRefunded) { throw new PXException(Messages.ERR_CCTransactionOfThisTypeInvalidToVoid); } if (ExternalTranHelper.IsExpired(state.ExternalTransaction)) { throw new PXException(Messages.TransactionHasExpired); } if (doc.Released == false) { graph.Actions.PressSave(); } ICCPayment toProc = graph.Caches[doc.GetType()].CreateCopy(doc) as ICCPayment; PXLongOperation.StartOperation(graph, delegate() { bool success = true; try { TransactionProcessor.ProcessVoidOrCredit(toProc, state.ExternalTransaction); } catch { success = false; throw; } finally { RunCallbacks((IBqlTable)doc, CCTranType.VoidOrCredit, success); } }); }
public virtual bool Credit(ICCPayment aPmtInfo, int aRefTranNbr, ref int aTranNbr) { Customer customer; CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer); CCProcTran authTran = _repository.GetCCProcTran(aRefTranNbr); if (authTran == null) { throw new PXException(Messages.ERR_CCTransactionToCreditIsNotFound, aRefTranNbr); } if (!MayBeCredited(authTran)) { throw new PXException(Messages.ERR_CCProcessingTransactionMayNotBeCredited, authTran.TranType); } if (!IsAuthorized(authTran)) { throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aRefTranNbr); } if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID)) { return(false); } CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID); if (procCenter == null) { throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, authTran.ProcessingCenterID, aRefTranNbr); } if (!(procCenter.IsActive ?? false)) { throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotActive, authTran.ProcessingCenterID, aRefTranNbr); } CCProcTran tran = new CCProcTran(); tran.Copy(aPmtInfo); tran.RefTranNbr = authTran.TranNbr; if (!aPmtInfo.CuryDocBal.HasValue) { tran.CuryID = authTran.CuryID; tran.Amount = authTran.Amount; } return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, authTran, customer.AcctCD, procCenter)); }
public void ProcessCredit(ICCPayment doc, IExternalTransaction tran) { CheckInput(doc, tran); Process(() => { TranOperationResult opRes = null; if (tran.TransactionID.HasValue) { opRes = _processingClass.Credit(doc, tran.TransactionID.Value); } else { opRes = _processingClass.Credit(doc, tran.TranNumber); } return(opRes); }); }
public virtual bool RecordCredit(ICCPayment aPmtInfo, string aRefPCTranNbr, string aExtTranRef, string aExtAuthNbr, out int?aTranNbr) { aTranNbr = null; if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID)) { return(false); } CCProcTran tran = new CCProcTran(); tran.Copy(aPmtInfo); CCProcTran origCCTran = null; if (!String.IsNullOrEmpty(aRefPCTranNbr)) { origCCTran = _repository.FindReferencedCCProcTran(aPmtInfo.PMInstanceID, aRefPCTranNbr); } if (origCCTran != null && (aPmtInfo.PMInstanceID == origCCTran.PMInstanceID)) { //Override Orig Doc Ref by those from orig CC Tran if any tran.RefTranNbr = origCCTran.TranNbr; tran.ProcessingCenterID = origCCTran.ProcessingCenterID; } else { CCProcessingCenter procCenter = _repository.FindProcessingCenter(aPmtInfo.PMInstanceID, aPmtInfo.CuryID); if (procCenter == null || string.IsNullOrEmpty(procCenter.ProcessingTypeName)) { throw new PXException(Messages.ERR_ProcessingCenterForCardNotConfigured); } CashAccount cashAccount = _repository.GetCashAccount(procCenter.CashAccountID); if (cashAccount.CuryID != aPmtInfo.CuryID) { throw new PXException(Messages.ProcessingCenterCurrencyDoesNotMatch, aPmtInfo.CuryID, cashAccount.CuryID); } tran.ProcessingCenterID = procCenter.ProcessingCenterID; tran.RefPCTranNumber = aRefPCTranNbr; } tran.PCTranNumber = aExtTranRef; tran.AuthNumber = aExtAuthNbr; tran.TranType = CCTranTypeCode.GetTypeCode(CCTranType.Credit); FillRecordedTran(tran); tran = _repository.InsertCCProcTran(tran); _repository.Save(); aTranNbr = tran.TranNbr; return(true); }
public static void CheckForHeldForReviewStatusAfterProc(IBqlTable aTable, CCTranType procTran, bool success) { ICCPayment doc = aTable as ICCPayment; if (doc != null && success) { var graph = PXGraph.CreateInstance <ARPaymentEntry>(); var query = new PXSelect <ExternalTransaction, Where <ExternalTransaction.docType, Equal <Required <ExternalTransaction.docType> >, And <ExternalTransaction.refNbr, Equal <Required <ExternalTransaction.refNbr> > > >, OrderBy <Desc <ExternalTransaction.transactionID> > >(graph); var result = query.Select(doc.DocType, doc.RefNbr); ExternalTransactionState state = ExternalTranHelper.GetActiveTransactionState(graph, result.RowCast <ExternalTransaction>()); if (state.IsOpenForReview) { throw new PXSetPropertyException(AR.Messages.CCProcessingTranHeldWarning, PXErrorLevel.RowWarning); } } }
protected virtual void RecordVoid(ICCPayment doc, V2.TransactionData tranData) { var procGraph = PXGraph.CreateInstance <CCPaymentProcessingGraph>(); TranRecordData tranRecordData = FormatTranRecord(tranData); tranRecordData.AuthCode = tranData.AuthCode; bool res = procGraph.RecordVoid(doc, tranRecordData); foreach (AfterTranProcDelegate callback in GetAfterVoidActions()) { callback((IBqlTable)doc, CCTranType.Void, true); } if (ReleaseAfterVoid) { ReleaseARDocument((IBqlTable)doc, CCTranType.Void, true); } }
public virtual IEnumerable CaptureOnlyCCPayment(PXAdapter adapter) { var methodName = GetClassMethodName(); PXTrace.WriteInformation($"{methodName} started."); AccessInfo info = this.Base.Accessinfo; var parameters = InputPaymentInfo.Current; if (parameters == null) { return(adapter.Get()); } if (string.IsNullOrEmpty(parameters.AuthNumber)) { if (InputPaymentInfo.Cache.RaiseExceptionHandling <InputPaymentInfo.authNumber>(parameters, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(InputPaymentInfo.authNumber).Name))) { throw new PXRowPersistingException(typeof(InputPaymentInfo.authNumber).Name, null, ErrorMessages.FieldIsEmpty, typeof(InputPaymentInfo.authNumber).Name); } return(adapter.Get()); } List <TPrimary> list = new List <TPrimary>(); foreach (TPrimary doc in adapter.Get <TPrimary>()) { CheckDocumentUpdatedInDb(doc); ICCPayment pDoc = GetPaymentDoc(doc); PXTrace.WriteInformation($"{methodName}. RefNbr:{pDoc.RefNbr}; UserName:{info.UserName}"); list.Add(doc); BeforeCaptureOnlyPayment(doc); var tranAdapter = new GenericExternalTransactionAdapter <ExternalTransactionDetail>(ExternalTransaction); var afterActions = GetAfterCaptureOnlyActions(); CCPaymentEntry paymentEntry = GetCCPaymentEntry(); foreach (var item in afterActions) { paymentEntry.AddAfterProcessCallback(item); } if (ReleaseAfterCaptureOnly) { paymentEntry.AddAfterProcessCallback(ReleaseARDocument); } paymentEntry.CaptureOnlyCCPayment(parameters, pDoc, tranAdapter); } return(list); }
public void CaptureOnlyCCPayment(InputPaymentInfo paymentInfo, ICCPayment doc, IExternalTransactionAdapter paymentTransaction) { if (doc == null || doc.CuryDocBal == null) { return; } IExternalTransaction extTran = ExternalTranHelper.GetActiveTransaction(paymentTransaction.Select()); if (ExternalTranHelper.HasOpenCCProcTran(graph, extTran)) { throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress); } if (string.IsNullOrEmpty(paymentInfo.AuthNumber)) { throw new PXException(Messages.ERR_CCExternalAuthorizationNumberIsRequiredForCaptureOnlyTrans); } if (doc.Released == false) { graph.Actions.PressSave(); } ICCPayment toProc = graph.Caches[doc.GetType()].CreateCopy(doc) as ICCPayment; PXLongOperation.StartOperation(graph, delegate() { bool success = true; try { IExternalTransaction tran = new ExternalTransaction(); tran.AuthNumber = paymentInfo.AuthNumber; TransactionProcessor.ProcessCaptureOnly(toProc, tran); } catch { success = false; throw; } finally { RunCallbacks((IBqlTable)toProc, CCTranType.CaptureOnly, success); } }); }
public void AuthorizeCCpayment(ICCPayment doc, IExternalTransactionAdapter paymentTransaction) { if (doc == null || doc.CuryDocBal == null) { return; } ExternalTransactionState state = ExternalTranHelper.GetActiveTransactionState(graph, paymentTransaction.Select()); if (ExternalTranHelper.HasOpenCCProcTran(graph, state.ExternalTransaction)) { throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress); } if (state.IsCaptured || state.IsPreAuthorized) { throw new PXException(Messages.ERR_CCPaymentAlreadyAuthorized); } if (doc.Released == false) { graph.Actions.PressSave(); } ICCPayment toProc = graph.Caches[doc.GetType()].CreateCopy(doc) as ICCPayment; PXLongOperation.StartOperation(graph, delegate() { bool success = true; try { TransactionProcessor.ProcessAuthorize(toProc, null); } catch { success = false; throw; } finally { RunCallbacks((IBqlTable)doc, CCTranType.AuthorizeOnly, success); } }); }
public bool TranStatusChanged(ICCPayment doc, int?tranId) { bool ret = false; IExternalTransaction storedExtTran = GetExtTrans().Where(i => i.TransactionID == tranId).FirstOrDefault(); CustomerPaymentMethod cpm = GetPaymentProcessing().Repository.GetCustomerPaymentMethod(doc.PMInstanceID); string procCenter = cpm?.CCProcessingCenterID; if (storedExtTran != null && procCenter != null) { bool supported = IsFeatureSupported(procCenter, CCProcessingFeature.TransactionGetter); if (supported) { V2.TransactionData tranData = GetPaymentProcessing().GetTransactionById(storedExtTran.TranNumber, cpm.CCProcessingCenterID); SelectedProcessingCenter = procCenter; string newProcStatus = GetProcessingStatus(tranData); if (storedExtTran.ProcessingStatus != newProcStatus) { if (tranData.TranType == V2.CCTranType.AuthorizeOnly) { RecordTran(doc, tranData, RecordAuth); ret = true; } if (tranData.TranType == V2.CCTranType.PriorAuthorizedCapture) { RecordTran(doc, tranData, RecordCapture); ret = true; } if (tranData.TranType == V2.CCTranType.AuthorizeAndCapture) { RecordTran(doc, tranData, RecordCapture); ret = true; } if (tranData.TranType == V2.CCTranType.Void) { RecordTran(doc, tranData, RecordVoid); ret = true; } } } } return(ret); }
protected virtual void RecordAuth(ICCPayment doc, V2.TransactionData tranData) { var procGraph = PXGraph.CreateInstance <CCPaymentProcessingGraph>(); TranRecordData tranRecordData = FormatTranRecord(tranData); if (tranData.ExpireAfterDays != null) { DateTime expirationDate = PXTimeZoneInfo.Now.AddDays(tranData.ExpireAfterDays.Value); tranRecordData.ExpirationDate = expirationDate; } bool res = procGraph.RecordAuthorization(doc, tranRecordData); foreach (AfterTranProcDelegate callback in GetAfterAuthorizeActions()) { callback((IBqlTable)doc, CCTranType.AuthorizeOnly, true); } if (ReleaseAfterAuthorize) { ReleaseARDocument((IBqlTable)doc, CCTranType.AuthorizeOnly, true); } }
public virtual IEnumerable ValidateCCPayment(PXAdapter adapter) { string methodName = GetClassMethodName(); PXTrace.WriteInformation($"{methodName} started."); List <TPrimary> list = new List <TPrimary>(); foreach (TPrimary doc in adapter.Get <TPrimary>()) { list.Add(doc); ICCPayment pDoc = GetPaymentDoc(doc); PXLongOperation.StartOperation(Base, delegate { IExternalTransaction tran = ExternalTranHelper.GetActiveTransaction(GetExtTrans()); if (tran != null) { TranStatusChanged(pDoc, tran.TransactionID); } }); } return(list); }
public virtual bool RecordCapture(ICCPayment aPmtInfo, string aExtTranRef, string aExtAuthNbr, Decimal?aAmount, ref int?aTranNbr) { if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID)) { return(false); } CCProcessingCenter procCenter = _repository.FindProcessingCenter(aPmtInfo.PMInstanceID, aPmtInfo.CuryID); if (procCenter == null || string.IsNullOrEmpty(procCenter.ProcessingTypeName)) { throw new PXException(Messages.ERR_ProcessingCenterForCardNotConfigured); } CashAccount cashAccount = _repository.GetCashAccount(procCenter.CashAccountID); if (cashAccount.CuryID != aPmtInfo.CuryID) { throw new PXException(Messages.ProcessingCenterCurrencyDoesNotMatch, aPmtInfo.CuryID, cashAccount.CuryID); } CCProcTran tran = new CCProcTran { PMInstanceID = aPmtInfo.PMInstanceID, OrigDocType = aPmtInfo.OrigDocType, OrigRefNbr = aPmtInfo.OrigRefNbr, DocType = aPmtInfo.DocType, RefNbr = aPmtInfo.RefNbr, CuryID = aPmtInfo.CuryID, Amount = aAmount ?? aPmtInfo.CuryDocBal, PCTranNumber = aExtTranRef, AuthNumber = aExtAuthNbr, PCResponseReasonText = Messages.ImportedExternalCCTransaction, ProcessingCenterID = procCenter.ProcessingCenterID }; this.RecordTransaction(ref aTranNbr, CCTranType.AuthorizeAndCapture, tran, procCenter); return(true); }
public void CreditCCPayment(ICCPayment doc, IExternalTransactionAdapter paymentTransaction) { if (doc == null || doc.CuryDocBal == null) { return; } IExternalTransaction extTran = ExternalTranHelper.GetActiveTransaction(paymentTransaction.Select()); if (ExternalTranHelper.HasOpenCCProcTran(graph, extTran)) { throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress); } if (doc.Released == false) { graph.Actions.PressSave(); } ICCPayment toProc = graph.Caches[doc.GetType()].CreateCopy(doc) as ICCPayment; PXLongOperation.StartOperation(graph, delegate() { bool success = true; try { IExternalTransaction tran = new ExternalTransaction(); tran.TranNumber = doc.RefTranExtNbr; TransactionProcessor.ProcessCredit(toProc, tran); } catch { success = false; throw; } finally { RunCallbacks((IBqlTable)doc, CCTranType.VoidOrCredit, success); } }); }