Esempio n. 1
0
        public PaymentCallbackResult ProcessPaymentCallback(Transaction transaction, string dts_reference, HttpSessionStateBase session)
        {
            var gateway = GetDatacashGateway(transaction.Id);

            var paymentDetails = new PaymentDetails
            {
                Amount        = transaction.AmountInc.AsDecimal(0) + transaction.DeliveryCost.AsDecimal(0),
                CardNumber    = dts_reference,
                CaptureMethod = CaptureMethod.ECOMM
            };

            var addressDetails = session["BillingAddress"] as BillingAddress;

            DataCashPayment payment = new DataCashPayment(transaction);

            var paymentResponse = gateway.ProcessHccPayment(paymentDetails, addressDetails, payment.DatacashReference);

            _transactionService.LogPaymentInformation(transaction, gateway.Response.DocumentXML.OuterXml, true);
            payment.DatacashReference = gateway.Response.DatacashReference;
            //Probably a little paranoid to add this here, but means the journalling's done, even if there's an exception thrown later.
            _transactionService.Update(transaction);

            if (paymentResponse == BiteDatacashGateway.ResponseStatus.SendThreeDSecureRequest)
            {
                payment.AcsUrl = gateway.Response.acsUrl;
                payment.PaReq  = gateway.Response.PAReqMessage;
                payment.MD     = String.Format("{0}|{1}", payment.DatacashReference,
                                               gateway.Response.TransactionReference);
                _transactionService.Update(transaction);
                return(PaymentCallbackResult.RedirectTo3dSecure);
            }
            else
            {
                if (paymentResponse == BiteDatacashGateway.ResponseStatus.Accepted)
                {
                    _transactionService.ProcessSuccessfulPayment(transaction);
                }
                else if (paymentResponse == BiteDatacashGateway.ResponseStatus.ThreeDSecureNotEnrolled)
                {
                    _transactionService.ProcessSuccessfulPayment(transaction);
                }
                else
                {
                    _transactionService.ProcessFailedPayment(transaction, TransactionStatus.CardRefused);
                }
                return(PaymentCallbackResult.RedirectToReceipt);
            }
        }
        public ActionResult Payment3dSecureIframe()
        {
            var transaction = _transactionService.GetById(BasketContext.Current.TransactionId.Value);

            DataCashPayment payment = new DataCashPayment(transaction);

            string hostUrl = Request.Url.Scheme + "://" + Request.ServerVariables["HTTP_HOST"];
            Payment3dSecureIframeViewModel model = new Payment3dSecureIframeViewModel
            {
                AcsUrl  = payment.AcsUrl,
                PaReq   = payment.PaReq,
                MD      = payment.MD,
                TermUrl = new Uri(new Uri(Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped)), Url.Action("Payment3dSecureCallback")).AbsolutePath
            };

            return(View(model));
        }
        public ActionResult Payment3dSecureCallback(string MD, string pares)
        {
            var mdParts = MD.Split('|');
            //this is the datacash reference number...
            var datacash_reference = mdParts[0];

            //this holds our order id..
            var ourReference = BiteDatacashGateway.GetTransactionIDFromTransactionReference(mdParts[1]);

            var transaction = _transactionService.GetById(long.Parse(ourReference));

            if (transaction != null)
            {
                try
                {
                    DataCashPayment payment = new DataCashPayment(transaction);

                    var gateway = new BiteDatacashGateway(this.DataCashId, this.DataCashPassword,
                                                          transaction.Id.ToString(), "GBP", this.PurchaseDescription,
                                                          DeviceUsed.PC, this.ReportedUrl, HttpContext);

                    var ThreeDSecureResponse = gateway.ProcessAuthorisation(datacash_reference, pares);
                    _transactionService.LogPaymentInformation(transaction, gateway.Response, false);

                    if (ThreeDSecureResponse == BiteDatacashGateway.ResponseStatus.Accepted)
                    {
                        _transactionService.ProcessSuccessfulPayment(transaction);
                    }
                    else
                    {
                        _transactionService.ProcessFailedPayment(transaction, TransactionStatus.CardRefused);
                    }
                }
                catch (Exception e)
                {
                    //Should we be failing this or not??  Wasn't in Bite version.
                    _transactionService.ProcessFailedPayment(transaction, TransactionStatus.CardRefused);
                    //error process 3dsecure postback
                }
                return(View(transaction.Id));
            }
            return(null);
        }
Esempio n. 4
0
        public long?Process3dSecureCallback(string MD, string pares)
        {
            var mdParts = MD.Split('|');
            //this is the datacash reference number...
            var datacash_reference = mdParts[0];

            //this holds our order id..
            var ourReference = BiteDatacashGateway.GetTransactionIDFromTransactionReference(mdParts[1]);

            var transaction = GetTransaction(long.Parse(ourReference));

            if (transaction != null)
            {
                try
                {
                    DataCashPayment payment = new DataCashPayment(transaction);

                    var gateway = GetDatacashGateway(transaction.Id);

                    var ThreeDSecureResponse = gateway.ProcessAuthorisation(datacash_reference, pares);
                    _transactionService.LogPaymentInformation(transaction, gateway.Response, false);

                    if (ThreeDSecureResponse == BiteDatacashGateway.ResponseStatus.Accepted)
                    {
                        _transactionService.ProcessSuccessfulPayment(transaction);
                    }
                    else
                    {
                        _transactionService.ProcessFailedPayment(transaction, TransactionStatus.CardRefused);
                    }
                }
                catch (Exception e)
                {
                    //Should we be failing this or not??  Wasn't in Bite version.
                    _transactionService.ProcessFailedPayment(transaction, TransactionStatus.CardRefused);
                    //error process 3dsecure postback
                }
                return(transaction.Id);
            }
            return(null);
        }
        public ActionResult Payment3dSecureIframe(long tid)
        {
            var transaction = _b2bCheckoutService.GetTransaction(tid);

            if (transaction == null || transaction.TransactionStatus != TransactionStatus.AwaitingPayment)
            {
                return(HttpNotFound());
            }

            DataCashPayment payment = new DataCashPayment(transaction);

            Payment3dSecureIframeViewModel model = new Payment3dSecureIframeViewModel
            {
                AcsUrl  = payment.AcsUrl,
                PaReq   = payment.PaReq,
                MD      = payment.MD,
                TermUrl = new Uri(new Uri(Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped)), Url.Action("Payment3dSecureCallback")).AbsoluteUri
            };

            ColonyContext.Response.CurrentTemplate = "Empty";
            return(View(model));
        }
        public ActionResult MakePayment(PaymentViewModel model)
        {
            var transaction = _transactionService.GetById(long.Parse(model.TransactionId));

            var gateway = new BiteDatacashGateway(this.DataCashId, this.DataCashPassword,
                                                  transaction.Id.ToString(), "GBP", this.PurchaseDescription,
                                                  DeviceUsed.PC, this.ReportedUrl, HttpContext);

            var paymentDetails = new PaymentDetails
            {
                Amount        = model.Amount,
                CardNumber    = model.CardNumber,
                IssueNumber   = model.IssueNumber,
                ExpiryMonth   = model.ExpiryMonth,
                ExpiryYear    = model.ExpiryYear,
                SecureCode    = model.Cv2,
                CaptureMethod = CaptureMethod.ECOMM
            };

            if (!String.IsNullOrEmpty(model.StartYear))
            {
                paymentDetails.StartMonth = model.StartMonth;
                paymentDetails.StartYear  = model.StartYear;
            }

            XmlDocument xml = new XmlDocument();

            xml.LoadXml(transaction.CheckOutXml);

            var billingXml = xml.SelectSingleNode("");

            var addressDetails = new BillingAddress
            {
                AddressLine1 = billingXml.SelectSingleNode("").Value,
                AddressLine2 = billingXml.SelectSingleNode("").Value,
                AddressLine3 = billingXml.SelectSingleNode("").Value,
                AddressLine4 = billingXml.SelectSingleNode("").Value,
                Postcode     = billingXml.SelectSingleNode("").Value
            };

            var paymentResponse = gateway.ProcessPayment(paymentDetails, addressDetails, _transactionService.GetPaymentReference(transaction));

            _transactionService.LogPaymentInformation(transaction, gateway.Response, true);

            if (paymentResponse == BiteDatacashGateway.ResponseStatus.SendThreeDSecureRequest)
            {
                DataCashPayment payment = new DataCashPayment(transaction);

                var datacashReference = gateway.Response.DatacashReference;
                payment.AcsUrl = gateway.Response.acsUrl;
                payment.PaReq  = gateway.Response.PAReqMessage;
                payment.MD     = String.Format("{0}|{1}", gateway.Response.DatacashReference,
                                               gateway.Response.TransactionReference);

                payment.Update();

                return(RedirectToAction("Payment3dSecureContainer"));
            }
            else
            {
                if (paymentResponse == BiteDatacashGateway.ResponseStatus.Accepted)
                {
                    _transactionService.ProcessSuccessfulPayment(transaction);
                }
                else if (paymentResponse == BiteDatacashGateway.ResponseStatus.ThreeDSecureNotEnrolled)
                {
                    _transactionService.ProcessFailedPayment(transaction, TransactionStatus.ThreeDSecureNotEnrolled);
                }
                else
                {
                    _transactionService.ProcessFailedPayment(transaction, TransactionStatus.CardRefused);
                }
                return(RedirectToAction("Receipt", "OnlinePayments", new { transactionId = transaction.Id }));
            }
        }