コード例 #1
0
        //Метод, вызываемый при удачной оплате
        public W1ActionResult SuccessPayment()
        {
            PaymentService paymentService;
            string content;
            RequestWorking requestWorking;
            Dictionary<string, string> formFields;
            bool isAcceptedCheckSum = true;
            Payment payment;
            PaymentRepository paymentRepository;

            paymentService = new PaymentService();
            requestWorking = new RequestWorking();//this.Request);

            formFields = requestWorking.GetFormDictionary(this.Request.Form);

            //Поиск и обновление присланного платежа
            if (!formFields.ContainsKey("WMI_PAYMENT_NO"))
                return new W1ActionResult(paymentService.MakeResponseToW1("RETRY",
                    "Отсутствует параметр WMI_PAYMENT_NO"));
            if (!formFields.ContainsKey("WMI_PAYMENT_NO"))
                return new W1ActionResult(paymentService.MakeResponseToW1("RETRY",
                    "Отсутствует параметр WMI_PAYMENT_NO"));
            if (!formFields.ContainsKey("WMI_ORDER_STATE"))
                return new W1ActionResult(paymentService.MakeResponseToW1("RETRY",
                    "Отсутствует параметр WMI_ORDER_STATE"));
            if (formFields["WMI_ORDER_STATE"].ToUpper() != "ACCEPTED")
                return new W1ActionResult(paymentService.MakeResponseToW1("RETRY",
                        "Неверное состояние " + formFields["WMI_ORDER_STATE"]));

            //Наверное, сигнутура отключена в настройках
            if (formFields.ContainsKey("WMI_SIGNATURE"))
            {
                isAcceptedCheckSum = paymentService.CheckSignature(formFields);
                if (!isAcceptedCheckSum)
                    return new W1ActionResult(paymentService.MakeResponseToW1("RETRY",
                    "Неверная подпись " + formFields["WMI_SIGNATURE"]));
            }
            //OK, no comments
            //фиксируем
            paymentRepository = (PaymentRepository)this._paymentRepository;
            //связаны 1:1
            payment = (Payment)this._paymentRepository.FindById(
                Convert.ToInt32(formFields["WMI_PAYMENT_NO"]));
            payment.isPayed = true;
            paymentRepository.Edit(payment);

            return new W1ActionResult(paymentService.MakeResponseToW1("OK",
                    "Заказ #" + formFields["WMI_PAYMENT_NO"] + " оплачен!"));
        }
コード例 #2
0
        //Метод, вызываемый при неудачной оплате
        public W1ActionResult FailPayment()
        {
            PaymentService paymentService;
            string content;

            paymentService = new PaymentService();
            //RETRY
            content = paymentService.MakeResponseToW1("RETRY",
                "Server is not availables temporary");
            return new W1ActionResult(content);
        }