Esempio n. 1
0
        public ActionResult Result()
        {
            RobokassaApi           robokassaApi  = ApiFactory.GetRobokassaApi(WebSettingsConfig.Instance);
            RobokassaPaymentResult paymentResult = robokassaApi.ProcessResult(Request.Params);

            if (paymentResult == null)
            {
                LoggerWrapper.RemoteMessage(LoggingType.Error,
                                            "PaymentController.Result. PaymentResult is null. Params={0}",
                                            HttpContextHelper.ParamsToString(Request.Params, RobokassaApi.IsValidParamName));
                return(Content(ERROR_MESSAGE));
            }

            var  purchasedGoogsQuery = new PurchasedGoodsQuery();
            bool isSuccess           = purchasedGoogsQuery.SuccessfullyPurchased(paymentResult.PaymentId, paymentResult.Price);

            if (!isSuccess)
            {
                LoggerWrapper.RemoteMessage(LoggingType.Error,
                                            "PaymentController.Result. SuccessfullyPurchased вернул false. PaymentId={0}, Price={1}, Params={2}",
                                            paymentResult.PaymentId, paymentResult.Price,
                                            HttpContextHelper.ParamsToString(Request.Params, RobokassaApi.IsValidParamName));
                return(Content(ERROR_MESSAGE));
            }

            LoggerWrapper.RemoteMessage(LoggingType.Info,
                                        "PaymentController.Result. Прошла оплата на сумму {0} с идентификатором {1}",
                                        MoneyFormatter.ToRubles(paymentResult.Price), paymentResult.PaymentId);

            string response = robokassaApi.GetResponseResultOk(paymentResult.PaymentId);

            return(Content(response));
        }
Esempio n. 2
0
        /// <summary>
        /// Метод вызывается платежной системой после оплаты и после сообщения нам о платеже(см. метод Result <see cref="Result"/>)
        /// </summary>
        /// <returns></returns>
        //[HttpPost]
        public ActionResult Success()
        {
            RobokassaApi           robokassaApi  = ApiFactory.GetRobokassaApi(WebSettingsConfig.Instance);
            RobokassaPaymentResult paymentResult = robokassaApi.ProcessSuccess(Request.Params);

            if (paymentResult == null)
            {
                LoggerWrapper.RemoteMessage(LoggingType.Error,
                                            "PaymentController.Success. PaymentResult is null. Params={0}",
                                            HttpContextHelper.ParamsToString(Request.Params, RobokassaApi.IsValidParamName));
                return(GetFailView());
            }

            var            purchasedGoogsQuery = new PurchasedGoodsQuery();
            PurchasedGoods purchasedGoods      = purchasedGoogsQuery.Get(paymentResult.PaymentId);

            if (purchasedGoods == null)
            {
                LoggerWrapper.RemoteMessage(LoggingType.Error,
                                            "PaymentController.Success. GetUniqueDownloadId не вернул уникальный идентификатор скачивания. PaymentId={0}, Price={1}, Params={2}",
                                            paymentResult.PaymentId, paymentResult.Price,
                                            HttpContextHelper.ParamsToString(Request.Params, RobokassaApi.IsValidParamName));
                return(GetFailView());
            }

            LoggerWrapper.RemoteMessage(LoggingType.Info,
                                        "PaymentController.Success. Перед тем как сообщить пользователю об успешном платеже на сумму {0} с идентификатором {1}",
                                        MoneyFormatter.ToRubles(paymentResult.Price), paymentResult.PaymentId);

            return(GetSuccessView(purchasedGoods));
        }
Esempio n. 3
0
        /// <summary>
        /// Метод вызывается платежной системой если платеж не удался
        /// </summary>
        /// <returns></returns>
        //[HttpPost]
        public ActionResult Fail()
        {
            RobokassaApi           robokassaApi  = ApiFactory.GetRobokassaApi(WebSettingsConfig.Instance);
            RobokassaPaymentResult paymentResult = robokassaApi.ProcessFail(Request.Params);

            if (paymentResult == null)
            {
                LoggerWrapper.RemoteMessage(LoggingType.Error,
                                            "PaymentController.Fail. PaymentResult is null. Params={0}",
                                            HttpContextHelper.ParamsToString(Request.Params, RobokassaApi.IsValidParamName));
                return(GetCancelView());
            }

            var  purchasedGoogsQuery = new PurchasedGoodsQuery();
            bool isSuccess           = purchasedGoogsQuery.FailedPurchased(paymentResult.PaymentId);

            if (!isSuccess)
            {
                LoggerWrapper.RemoteMessage(LoggingType.Error,
                                            "PaymentController.Fail. FailedPurchased вернул false. PaymentId={0}, Price={1}, Params={2}",
                                            paymentResult.PaymentId, paymentResult.Price,
                                            HttpContextHelper.ParamsToString(Request.Params, RobokassaApi.IsValidParamName));
                return(GetCancelView());
            }

            LoggerWrapper.RemoteMessage(LoggingType.Info,
                                        "PaymentController.Fail. Перед тем как сообщить пользователю об отменене платежа на сумму {0} с идентификатором {1}",
                                        MoneyFormatter.ToRubles(paymentResult.Price), paymentResult.PaymentId);

            return(GetCancelView());
        }
Esempio n. 4
0
        public void ProcessResultNull(string password2, string paymentId, string price, string crc)
        {
            var securityParams       = new RobokassaSecurityParams(LOGIN, PASSWORD1, password2);
            var robokassaApi         = new RobokassaApi(securityParams);
            NameValueCollection pars = CreateNameValueCollection(paymentId, price, crc);

            RobokassaPaymentResult robokassaPaymentResult = robokassaApi.ProcessResult(pars);

            Assert.That(robokassaPaymentResult, Is.Null);
        }
Esempio n. 5
0
        public void ProcessFail(string paymentId,
                                string price,
                                int expectedPaymentId,
                                decimal expectedPrice)
        {
            var securityParams       = new RobokassaSecurityParams(LOGIN, PASSWORD1, PASSWORD2);
            var robokassaApi         = new RobokassaApi(securityParams);
            NameValueCollection pars = CreateNameValueCollection(paymentId, price, null);

            RobokassaPaymentResult robokassaPaymentResult = robokassaApi.ProcessFail(pars);

            Assert.That(robokassaPaymentResult, Is.Not.Null);
            Assert.That(robokassaPaymentResult.PaymentId, Is.EqualTo(expectedPaymentId));
            Assert.That(robokassaPaymentResult.Price, Is.EqualTo(expectedPrice));
        }