Ejemplo n.º 1
0
 public override string ProcessFormString(Order order, PaymentService.PageWithPaymentButton page)
 {
     return(new PaymentFormHandler
     {
         FormName = "pay",
         Method = FormMethod.POST,
         Page = page,
         //Url = string.Format("https://{0}/pay/order.cfm", Sandbox ? "test.paysecure.ru" : PayUrl),//"secure.paysecure.ru"
         Url = Sandbox ? "https://test.paysecure.ru/pay/order.cfm" : UrlWorkingMode, //"secure.paysecure.ru"
         InputValues = new Dictionary <string, string>
         {
             { "Merchant_ID", MerchantID.ToString() },
             { "OrderNumber", order.Number },
             { "Delay", Delay ? "1" : "0" },
             { "OrderAmount", order.Sum.ToString().Replace(",", ".") },
             { "OrderCurrency", CurrencyCode },
             { "URL_RETURN", CancelUrl },
             { "URL_RETURN_OK", SuccessUrl },
             { "URL_RETURN_NO", FailUrl },
             //{"CardPayment", CardPayment ? "1" : "0"},
             //{"WebMoneyPayment", WebMoneyPayment ? "1" : "0"},
             //{"PayCashPayment", PayCashPayment ? "1" : "0"},
             //{"QiwiBeelinePayment", QiwiBeelinePayment ? "1" : "0"},
             //{"AssistIDCCPayment", AssistIdCcPayment ? "1" : "0"},
             { "TestMode", Sandbox ? "1" : "0" }
         }
     }.ProcessRequest());
 }
Ejemplo n.º 2
0
        public override string ProcessResponse(HttpContext context)
        {
            if (Sandbox)
            {
                return(NotificationMessahges.TestMode);
            }
            if (string.IsNullOrEmpty(context.Request["ordernumber"]) && string.IsNullOrWhiteSpace(context.Request["billnumber"]))
            {
                return(NotificationMessahges.InvalidRequestData);
            }
            string orderNumber = context.Request["ordernumber"];
            string billnumber  = context.Request["billnumber"];

            try
            {
                if (Delay)
                {
                    //if 2 stage
                    var client = new WebClient();
                    var data   =
                        client.UploadValues(
                            //string.Format("https://{0}/charge/charge.cfm", Sandbox ? "test.paysecure.ru" : PayUrl),//"secure.paysecure.ru"
                            Sandbox ? "https://test.paysecure.ru/charge/charge.cfm" : UrlWorkingMode,//"secure.paysecure.ru"
                            new NameValueCollection
                    {
                        { "Billnumber", billnumber },
                        { "Merchant_ID", MerchantID.ToString() },
                        { "Login", Login },
                        { "Password", Password },
                        //XML
                        { "Format", "3" }
                    });


                    var xml   = new XmlDocument();
                    var temp  = Encoding.UTF8.GetString(data).ToLower();
                    var start = temp.IndexOf("<!doctype");
                    var end   = temp.IndexOf("]>");
                    temp = temp.Remove(start, (end + 2) - start);
                    xml.LoadXml(temp);
                    if (xml.DocumentElement != null && xml.DocumentElement.Name != "result")
                    {
                        throw new Exception("Invalid XML response");
                    }
                    if (xml.DocumentElement != null)
                    {
                        var orders = xml.DocumentElement.SelectNodes(string.Format("descendant::order[ordernumber='{0}' and response_code='AS000' and orderstate='Approved' ]", orderNumber.ToLower()));
                        if (orders != null && orders.Count > 0)
                        {
                            OrderService.PayOrder(OrderService.GetOrderIdByNumber(orderNumber), true);
                        }
                        else
                        {
                            return(NotificationMessahges.InvalidRequestData);
                        }
                    }
                }
                else
                {
                    //if 1 stage
                    OrderService.PayOrder(OrderService.GetOrderIdByNumber(orderNumber), true);
                }
                return(NotificationMessahges.SuccessfullPayment(orderNumber));
            }
            catch (Exception ex)
            {
                return(NotificationMessahges.LogError(ex));
            }
        }