Пример #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));
        }
Пример #2
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);
        }
Пример #3
0
        public void ProcessResult(string password2,
                                  string paymentId,
                                  string price,
                                  string crc,
                                  int expectedPaymentId,
                                  decimal expectedPrice)
        {
            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.Not.Null);
            Assert.That(robokassaPaymentResult.PaymentId, Is.EqualTo(expectedPaymentId));
            Assert.That(robokassaPaymentResult.Price, Is.EqualTo(expectedPrice));
        }