Exemplo n.º 1
0
		public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
			var response = new SagePayResponse();
			response.Status = GetStatus(bindingContext.ValueProvider);
			response.VendorTxCode = GetFormField(VendorTxCode, bindingContext.ValueProvider);
			response.VPSTxId = GetFormField(VPSTxId, bindingContext.ValueProvider);
			response.VPSSignature = GetFormField(VPSSignature, bindingContext.ValueProvider);
			response.StatusDetail = GetFormField(StatusDetail, bindingContext.ValueProvider);
			response.TxAuthNo = GetFormField(TxAuthNo, bindingContext.ValueProvider);
			response.AVSCV2 = GetFormField(AVSCV2, bindingContext.ValueProvider);
			response.AddressResult = GetFormField(AddressResult, bindingContext.ValueProvider);
			response.PostCodeResult = GetFormField(PostCodeResult, bindingContext.ValueProvider);
			response.CV2Result = GetFormField(CV2Result, bindingContext.ValueProvider);
			response.GiftAid = GetFormField(GiftAid, bindingContext.ValueProvider);
			response.ThreeDSecureStatus = GetFormField(ThreeDSecureStatus, bindingContext.ValueProvider);
			response.CAVV = GetFormField(CAVV, bindingContext.ValueProvider);
			response.AddressStatus = GetFormField(AddressStatus, bindingContext.ValueProvider);
			response.PayerStatus = GetFormField(PayerStatus, bindingContext.ValueProvider);
			response.CardType = GetFormField(CardType, bindingContext.ValueProvider);
			response.Last4Digits = GetFormField(Last4Digits, bindingContext.ValueProvider);
			response.DeclineCode = GetFormField(DeclineCode, bindingContext.ValueProvider);
			response.ExpiryDate = GetFormField(ExpiryDate, bindingContext.ValueProvider);
			response.FraudResponse = GetFormField(FraudResponse, bindingContext.ValueProvider);
			response.BankAuthCode = GetFormField(BankAuthCode, bindingContext.ValueProvider);
			return response;
		}
Exemplo n.º 2
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var response = new SagePayResponse();

            response.Status             = GetStatus(bindingContext.ValueProvider);
            response.VendorTxCode       = GetFormField(VendorTxCode, bindingContext.ValueProvider);
            response.VPSTxId            = GetFormField(VPSTxId, bindingContext.ValueProvider);
            response.VPSSignature       = GetFormField(VPSSignature, bindingContext.ValueProvider);
            response.StatusDetail       = GetFormField(StatusDetail, bindingContext.ValueProvider);
            response.TxAuthNo           = GetFormField(TxAuthNo, bindingContext.ValueProvider);
            response.AVSCV2             = GetFormField(AVSCV2, bindingContext.ValueProvider);
            response.AddressResult      = GetFormField(AddressResult, bindingContext.ValueProvider);
            response.PostCodeResult     = GetFormField(PostCodeResult, bindingContext.ValueProvider);
            response.CV2Result          = GetFormField(CV2Result, bindingContext.ValueProvider);
            response.GiftAid            = GetFormField(GiftAid, bindingContext.ValueProvider);
            response.ThreeDSecureStatus = GetFormField(ThreeDSecureStatus, bindingContext.ValueProvider);
            response.CAVV          = GetFormField(CAVV, bindingContext.ValueProvider);
            response.AddressStatus = GetFormField(AddressStatus, bindingContext.ValueProvider);
            response.PayerStatus   = GetFormField(PayerStatus, bindingContext.ValueProvider);
            response.CardType      = GetFormField(CardType, bindingContext.ValueProvider);
            response.Last4Digits   = GetFormField(Last4Digits, bindingContext.ValueProvider);
            return(response);
        }
Exemplo n.º 3
0
        public ActionResult PaymentNotification(SagePayResponse response)
        {
            if (response != null)
            {
                tbl_Orders order = ECommerceService.GetOrderByVendorCode(response.VendorTxCode, this.DomainID);
                if (order != null)
                {
                    if (response.IsSignatureValid(order.SecurityKey, DomainService.GetSettingsValue(BL.SettingsKey.sagePayVendorName, this.DomainID)))
                    {
                        long txAuthCode = 0;
                        long.TryParse(response.TxAuthNo, out txAuthCode);

                        ECommerceService.UpdateOrderPayment(response.VendorTxCode, response.AddressResult, response.AddressStatus, response.AVSCV2, response.CAVV,
                            response.CV2Result, response.GiftAid.Equals("1") ? true : false, response.PostCodeResult, response.Last4Digits, response.PayerStatus,
                            order.SecurityKey, response.Status.ToString(), txAuthCode, response.VPSTxId, response.ThreeDSecureStatus, order.TxType, order.Currency, order.OrderID);

                        switch (response.Status)
                        {
                            case ResponseType.Abort:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_Aborted);
                                break;
                            case ResponseType.Authenticated:
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.Paid);
                                break;
                            case ResponseType.Invalid:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_Invalid);
                                break;
                            case ResponseType.Malformed:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_Malformed);
                                break;
                            case ResponseType.NotAuthed:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_NotAuthed);
                                break;
                            case ResponseType.Ok:
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.Paid);
                                break;
                            case ResponseType.Registered:
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.Paid);
                                break;
                            case ResponseType.Rejected:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_Rejected);
                                break;
                            case ResponseType.Unknown:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_Unknown);
                                break;
                            default:
                                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                                ECommerceService.UpdateOrderPaymentStatus(order.OrderID, BL.PaymentStatus.SagePay_Error);
                                break;
                        }

                        return new SagePayMvc.ActionResults.ValidOrderResult(response.VendorTxCode, response);
                    }

                    Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'. Invalid signature.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                    return new SagePayMvc.ActionResults.InvalidSignatureResult(response.VendorTxCode);
                }

                Log.Error(String.Format("Payment failed for order '{0}', status: '{1}', details '{2}'. Can not find order in our database.", response.VendorTxCode, response.Status.ToString(), response.StatusDetail));
                return new SagePayMvc.ActionResults.TransactionNotFoundResult(response.VendorTxCode);
            }

            Log.Error("Payment failed, no response.");
            return new SagePayMvc.ActionResults.ErrorResult();
        }
Exemplo n.º 4
0
        public ActionResult PaymentSuccess(SagePayResponse response)
        {
            tbl_Orders order = null;
            if (response != null)
                order = ECommerceService.GetOrderByVendorCode(response.VendorTxCode, DomainID);

            return RedirectToAction("ThankYou", "Website", new { orderID = order != null ? order.OrderID : 0 });
        }
Exemplo n.º 5
0
        public ActionResult PaymentFailed(SagePayResponse response)
        {
            tbl_Orders order = null;
            if (response != null)
                order = ECommerceService.GetOrderByVendorCode(response.VendorTxCode, this.DomainID);

            return RedirectToAction("PaymentError", "Website", new { orderID = order != null ? order.OrderID : 0, errorMessage = order.Status });
        }