Exemple #1
0
        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);
        }
Exemple #2
0
        public V2.ProcessingInput GetProcessingInput(V1.CCTranType aTranType, V1.ProcessingInput inputData)
        {
            if (inputData == null)
            {
                throw new ArgumentNullException(nameof(inputData));
            }
            V2.CCTranType      tranType = ToV2(aTranType);
            V2.ProcessingInput result   = new V2.ProcessingInput()
            {
                TranType   = tranType,
                Amount     = inputData.Amount,
                CuryID     = inputData.CuryID,
                OrigTranID = aTranType == V1.CCTranType.CaptureOnly ? null : inputData.OrigRefNbr,
                AuthCode   = aTranType == V1.CCTranType.CaptureOnly ? inputData.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   = inputData.DocType;
            result.DocumentData.DocRefNbr = inputData.DocRefNbr;
            FillDocumentData(result);
            return(result);
        }
        public virtual void SyncPaymentTransactionById(TPrimary doc, IEnumerable <string> tranIds)
        {
            if (!IsFeatureSupported(SelectedProcessingCenter, CCProcessingFeature.PaymentHostedForm))
            {
                return;
            }
            ICCPayment pDoc = GetPaymentDoc(doc);

            using (PXTransactionScope scope = new PXTransactionScope())
            {
                foreach (string tranId in tranIds)
                {
                    IEnumerable <PaymentTransactionDetail> existsTran = base.PaymentTransaction.Select().RowCast <PaymentTransactionDetail>();
                    PaymentTransactionDetail storedTran = existsTran.FirstOrDefault(i => i.PCTranNumber == tranId);
                    if (storedTran != null && storedTran.TranStatus == CCTranStatusCode.Approved)
                    {
                        continue;
                    }
                    var tranData = GetTranData(tranId);
                    if (storedTran != null && CCTranStatusCode.GetCode(V2Converter.ConvertTranStatus(tranData.TranStatus)) == storedTran.TranStatus)
                    {
                        continue;
                    }
                    if (tranData?.CustomerId != null && !SuitableCustomerProfileId(tranData?.CustomerId))
                    {
                        continue;
                    }

                    try
                    {
                        PXTrace.WriteInformation($"Synchronize tran. TranId = {tranData.TranID}, TranType = {tranData.TranType}, DocNum = {tranData.DocNum}, " +
                                                 $"SubmitTime = {tranData.SubmitTime}, Amount = {tranData.Amount}, PCCustomerID = {tranData.CustomerId}, PCCustomerPaymentID = {tranData.PaymentId}");
                    }
                    catch (Exception ex)
                    {
                        var v = ex;
                    }
                    V2.CCTranType tranType = tranData.TranType.Value;

                    if (tranType == V2.CCTranType.Void)
                    {
                        RemoveSyncLock(doc);
                        RecordVoid(pDoc, tranData);
                    }

                    if (tranType == V2.CCTranType.AuthorizeOnly)
                    {
                        if (tranData.TranStatus == V2.CCTranStatus.Approved)
                        {
                            GetOrCreatePaymentProfilrByTran(tranData, pDoc);
                        }
                        RemoveSyncLock(doc);
                        RecordAuth(pDoc, tranData);
                    }

                    if (tranType == V2.CCTranType.AuthorizeAndCapture)
                    {
                        if (tranData.TranStatus == V2.CCTranStatus.Approved)
                        {
                            GetOrCreatePaymentProfilrByTran(tranData, pDoc);
                        }
                        RemoveSyncLock(doc);
                        RecordCapture(pDoc, tranData);
                    }

                    if (tranType == V2.CCTranType.CaptureOnly)
                    {
                        if (tranData.TranStatus == V2.CCTranStatus.Approved)
                        {
                            GetOrCreatePaymentProfilrByTran(tranData, pDoc);
                        }
                        RemoveSyncLock(doc);
                        RecordCapture(pDoc, tranData);
                    }
                    scope.Complete();
                }
            }
        }
Exemple #4
0
 public static CCTranType ConvertTranType(V2.CCTranType v2TranType)
 {
     return(Mapper.Map <CCTranType>(v2TranType));
 }