public ProcessDetailsResponse ProcessStandardTransaction(PaypointPaymentDetailsModel model)
        {
            var validateCardFullResponse =
                _secvpn.validateCardFull(new validateCardFullRequest(_paypointSettings.AccountName,
                                                                     _paypointSettings.VPNPassword,
                                                                     _cartModel.CartGuid.ToString(),
                                                                     RequestHelper.GetIP(), model.NameOnCard,
                                                                     model.CardNumber,
                                                                     _paypointHelper.GetTotal(_cartModel.TotalToPay),
                                                                     _paypointHelper.GetDate(model.EndMonth,
                                                                                             model.EndYear),
                                                                     model.CardIssueNumber,
                                                                     _paypointHelper.GetDate(model.StartMonth,
                                                                                             model.StartYear),
                                                                     _paypointHelper.GetOrderDetails(_cartModel),
                                                                     _paypointHelper.GetAddress(
                                                                         _cartModel.ShippingAddress,
                                                                         _cartModel.OrderEmail),
                                                                     _paypointHelper.GetAddress(
                                                                         _cartModel.BillingAddress,
                                                                         _cartModel.OrderEmail),
                                                                     _paypointHelper.GetOptions(model)));

            var response = _paypointHelper.ParseResponse(validateCardFullResponse.validateCardFullReturn);

            return(response["code"] != "A"
                       ? GetFailureResponse(response)
                       : GetSuccessResponse(response));
        }
        public ActionResult Form(PaypointPaymentDetailsModel model)
        {
            _paypointPaymentService.SetModel(model);

            if (!_cartModel.CanPlaceOrder)
            {
                _cartModel.CannotPlaceOrderReasons.ForEach(s => TempData.ErrorMessages().Add(s));
                return(_uniquePageService.RedirectTo <PaymentDetails>());
            }

            var response = _paypointPaymentService.ProcessDetails(model, Url.Action("Response3DSecure", "Paypoint", null, Request.Url.Scheme));

            if (response.Requires3DSecure)
            {
                TempData["redirect-details"] = response.RedirectDetails;
                return(RedirectToAction("Redirect3DSecure", "Paypoint"));
            }

            if (response.PaymentSucceeded)
            {
                var order = _orderPlacementService.PlaceOrder(_cartModel, o =>
                {
                    o.PaymentStatus      = PaymentStatus.Paid;
                    o.PaidDate           = CurrentRequestData.Now;
                    o.AuthorisationToken = response.PaypointPaymentDetails.AuthCode;
                    o.ShippingStatus     = ShippingStatus.Unshipped;
                });
                return(_uniquePageService.RedirectTo <OrderPlaced>(new { id = order.Guid }));
            }

            TempData["error-details"]  = response.FailureDetails;
            TempData["paypoint-model"] = model;
            return(_uniquePageService.RedirectTo <PaymentDetails>());
        }
        public string GetOptions(PaypointPaymentDetailsModel model)
        {
            var options = string.Format("test_status={0},card_type={1},cv2={2},mail_customer=false",
                                        _paypointSettings.IsLive ? "live" : "true", model.CardType,
                                        model.CardVerificationCode);

            if (!_paypointSettings.IsLive)
            {
                options += ",dups=false";
            }
            return(options);
        }
示例#4
0
 public ProcessDetailsResponse ProcessDetails(PaypointPaymentDetailsModel model, string threeDSecureUrl)
 {
     try
     {
         var disable3Dsecure = _paypointSettings.Admin3DSecureDisable && CurrentRequestData.CurrentUserIsAdmin;
         return(_paypointSettings.ThreeDSecureEnabled && !disable3Dsecure
                    ? _paypointRequestService.Process3DSecureTransaction(model, threeDSecureUrl)
                    : _paypointRequestService.ProcessStandardTransaction(model));
     }
     catch (Exception exception)
     {
         CurrentRequestData.ErrorSignal.Raise(exception);
         return(new ProcessDetailsResponse {
             ErrorOccurred = true
         });
     }
 }
        public ProcessDetailsResponse Process3DSecureTransaction(PaypointPaymentDetailsModel model, string threeDSecureUrl)
        {
            _cartModel.CartGuid = _paypoint3DSecureHelper.ResetCartGuid();
            _paypoint3DSecureHelper.SetCartGuid(_cartModel.CartGuid);
            _paypoint3DSecureHelper.SetOrderAmount(_cartModel.TotalToPay);

            var threeDSecureEnrolmentRequestResponse =
                _secvpn.threeDSecureEnrolmentRequest(
                    new threeDSecureEnrolmentRequestRequest(_paypointSettings.AccountName,
                                                            _paypointSettings.VPNPassword,
                                                            _cartModel.CartGuid.ToString(),
                                                            RequestHelper.GetIP(),
                                                            model.NameOnCard, model.CardNumber,
                                                            _paypointHelper.GetTotal(_cartModel.TotalToPay),
                                                            _paypointHelper.GetDate(model.EndMonth,
                                                                                    model.EndYear),
                                                            model.CardIssueNumber,
                                                            _paypointHelper.GetDate(model.StartMonth,
                                                                                    model.StartYear),
                                                            _paypointHelper.GetOrderDetails(_cartModel),
                                                            _paypointHelper.GetAddress(
                                                                _cartModel.ShippingAddress,
                                                                _cartModel.OrderEmail),
                                                            _paypointHelper.GetAddress(
                                                                _cartModel.BillingAddress, _cartModel.OrderEmail),
                                                            _paypointHelper.GetOptions(model), "0",
                                                            RequestHelper.GetAcceptHeaders(),
                                                            RequestHelper.UserAgent(),
                                                            _paypointSettings.MPIMerchantName,
                                                            _paypointSettings.MPIMerchantUrl,
                                                            _paypointSettings.MPIDescription, "", "", ""));

            var response = _paypointHelper.ParseResponse(threeDSecureEnrolmentRequestResponse.threeDSecureEnrolmentRequestReturn);

            return(response["valid"] != "true"
                ? GetFailureResponse(response)
                : (response["mpi_status_code"] == "200"
                    ? GetRedirectResponse(threeDSecureUrl, response)
                    : response["code"] == "A"
                        ? GetSuccessResponse(response)
                        : GetFailureResponse(response)));
        }
示例#6
0
 public void SetModel(PaypointPaymentDetailsModel model)
 {
     _cartSessionManager.SetSessionValue(PaypointPaymentModelKey, _getUserGuid.UserGuid, model, SessionDataTimeoutDefaults.PaymentInfo, true);
 }