Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        protected string GetProcessingStatus(V2.TransactionData tranData)
        {
            string tranStatusCode = CCTranStatusCode.GetCode(V2Converter.ConvertTranStatus(tranData.TranStatus));
            string tranTypeCode   = CCTranTypeCode.GetTypeCode(V2Converter.ConvertTranType(tranData.TranType.Value));
            string procStatus     = ExtTransactionProcStatusCode.GetStatusByTranStatusTranType(tranStatusCode, tranTypeCode);

            return(procStatus);
        }
        protected virtual int?GetOrCreatePaymentProfilrByTran(V2.TransactionData tranData, ICCPayment pDoc)
        {
            int?instanceID;

            try
            {
                V2.TranProfile profile = null;
                if (tranData.CustomerId != null && tranData.PaymentId != null)
                {
                    profile = new V2.TranProfile()
                    {
                        CustomerProfileId = tranData.CustomerId, PaymentProfileId = tranData.PaymentId
                    };
                    ICCPaymentProfile cpm = null;
                    try
                    {
                        cpm = PrepeareCpmRecord();
                    }
                    catch (Exception ex)
                    {
                        var v = ex;
                    }
                    cpm.CustomerCCPID = tranData.CustomerId;
                }

                ExternalTransactionState state = GetActiveTransactionState();
                if (profile == null && state.IsPreAuthorized)
                {
                    profile = GetCustomerProfileFromDoc(pDoc);
                }

                if (profile == null)
                {
                    profile = GetOrCreateCustomerProfileByTranId(tranData.TranID);
                }

                instanceID = GetInstanceId(profile);

                using (PXTransactionScope tran = new PXTransactionScope())
                {
                    if (instanceID == PaymentTranExtConstants.NewPaymentProfile)
                    {
                        instanceID = CreatePaymentProfile(profile);
                    }
                    CreateCustomerProcessingCenterRecord(profile);
                    tran.Complete();
                }
            }
            finally
            {
                NewCpm.Cache.Clear();
                NewCpmd.Cache.Clear();
            }
            pDoc.PMInstanceID = instanceID;
            return(instanceID);
        }
Esempio n. 4
0
        protected TranRecordData FormatTranRecord(V2.TransactionData tranData)
        {
            TranRecordData tranRecordData = new TranRecordData();

            tranRecordData.ExternalTranId     = tranData.TranID;
            tranRecordData.Amount             = tranData.Amount;
            tranRecordData.AuthCode           = tranData.AuthCode;
            tranRecordData.ResponseText       = tranData.ResponseReasonText;
            tranRecordData.ProcessingCenterId = SelectedProcessingCenter;
            tranRecordData.ValidateDoc        = false;
            tranRecordData.TranStatus         = CCTranStatusCode.GetCode(V2Converter.ConvertTranStatus(tranData.TranStatus));
            string cvvCode = CVVVerificationStatusCode.GetCCVCode(V2Converter.ConvertCardVerificationStatus(tranData.CcvVerificationStatus));

            tranRecordData.CvvVerificationCode = cvvCode;
            return(tranRecordData);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
 private void RecordTran(ICCPayment doc, V2.TransactionData tranData, Action <ICCPayment, V2.TransactionData> action)
 {
     ExternalTransaction.Cache.ClearQueryCache();
     PaymentTransaction.Cache.ClearQueryCache();
     action(doc, tranData);
 }
 public V2.TransactionData GetTransaction(string transactionId)
 {
     V2.ICCTransactionGetter processor = GetProcessor <V2.ICCTransactionGetter>();
     V2.TransactionData      result    = V2PluginErrorHandler.ExecuteAndHandleError(() => processor.GetTransaction(transactionId));
     return(result);
 }
 protected V2.TransactionData GetTranData(string tranId)
 {
     V2.TransactionData tranData = GetPaymentProcessing().GetTransactionById(tranId, SelectedProcessingCenter);
     return(tranData);
 }