Esempio n. 1
0
        protected static string CreateMD5Hash(CommonPaymentRequest request, string secretKey)
        {
            string HASH_CONTENT   = string.Empty;
            string HASHED_CONTENT = string.Empty;

            HASH_CONTENT += Helper.GetLengthAsByte(request.Config.MERCHANT) + request.Config.MERCHANT;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Order.ORDER_REF) + request.Order.ORDER_REF;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Order.ORDER_DATE) + request.Order.ORDER_DATE;

            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_PNAME) + item.ORDER_PNAME;
            }
            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_PCODE) + item.ORDER_PCODE;
            }
            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_PINFO) + item.ORDER_PINFO;
            }
            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_PRICE) + item.ORDER_PRICE;
            }

            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_QTY) + item.ORDER_QTY;
            }
            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_VAT) + item.ORDER_VAT;
            }

            HASH_CONTENT += Helper.GetLengthAsByte(request.Order.ORDER_SHIPPING) + request.Order.ORDER_SHIPPING;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Config.PRICES_CURRENCY) + request.Config.PRICES_CURRENCY;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Order.DISCOUNT) + request.Order.DISCOUNT;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Customer.DESTINATION_CITY) + request.Customer.DESTINATION_CITY;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Customer.DESTINATION_STATE) + request.Customer.DESTINATION_STATE;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Customer.DESTINATION_COUNTRY) + request.Customer.DESTINATION_COUNTRY;
            HASH_CONTENT += Helper.GetLengthAsByte(request.Config.PAY_METHOD) + request.Config.PAY_METHOD;

            foreach (var item in request.Order.OrderItems)
            {
                HASH_CONTENT += Helper.GetLengthAsByte(item.ORDER_PRICE_TYPE) + item.ORDER_PRICE_TYPE;
            }
            HASH_CONTENT += Helper.GetLengthAsByte(request.Config.INSTALLMENT_OPTIONS) + request.Config.INSTALLMENT_OPTIONS;

            HASH_CONTENT += Helper.GetLengthAsByte(request.Config.TESTORDER) + request.Config.TESTORDER;

            HASHED_CONTENT = Helper.CreateHash(HASH_CONTENT, secretKey);
            return(HASHED_CONTENT);
        }
        public static string Execute(CommonPaymentRequest request, Options options)
        {
            var hashString = CreateMD5Hash(request, options.SecretKey);
            //return HttpCaller.PostDataReturnString(options.Url, hashString);


            StringBuilder builder = new StringBuilder();

            builder.Append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
            builder.Append("<html>");
            builder.Append("<body>");
            builder.Append("<form //action=\"" + options.Url + "\" method=\"post\" id=\"common_form\" >");
            builder.Append("<input type=\"hidden\" name=\"MERCHANT\" value=\"" + request.Config.MERCHANT + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"ORDER_REF\" value=\"" + request.Order.ORDER_REF + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BACK_REF\" value=\"" + request.Config.BACK_REF + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"ORDER_DATE\" value=\"" + request.Order.ORDER_DATE + "\"/>");

            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_PNAME[]\" value=\"" + item.ORDER_PNAME + "\"/>");
            }
            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_PCODE[]\" value=\"" + item.ORDER_PCODE + "\"/>");
            }
            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_PINFO[]\" value=\"" + item.ORDER_PINFO + "\"/>");
            }
            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_PRICE[]\" value=\"" + item.ORDER_PRICE + "\"/>");
            }
            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_PRICE_TYPE[]\" value=\"" + item.ORDER_PRICE_TYPE + "\"/>");
            }
            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_QTY[]\" value=\"" + item.ORDER_QTY + "\"/>");
            }
            foreach (var item in request.Order.OrderItems)
            {
                builder.Append("<input type=\"hidden\" name=\"ORDER_VAT[]\" value=\"" + item.ORDER_VAT + "\"/>");
            }

            builder.Append("<input type=\"hidden\" name=\"ORDER_SHIPPING\" value=\"" + request.Order.ORDER_SHIPPING + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_FNAME\" value=\"" + request.Customer.BILL_FNAME + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_LNAME\" value=\"" + request.Customer.BILL_LNAME + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_EMAIL\" value=\"" + request.Customer.BILL_EMAIL + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_PHONE\" value=\"" + request.Customer.BILL_PHONE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_FAX\" value=\"" + request.Customer.BILL_FAX + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_ADDRESS\" value=\"" + request.Customer.BILL_ADDRESS + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_ADDRESS2\" value=\"" + request.Customer.BILL_ADDRESS2 + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_ZIPCODE\" value=\"" + request.Customer.BILL_ZIPCODE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_CITY\" value=\"" + request.Customer.BILL_CITY + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_COUNTRYCODE\" value=\"" + request.Customer.BILL_COUNTRYCODE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"BILL_STATE\" value=\"" + request.Customer.BILL_STATE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_FNAME\" value=\"" + request.Delivery.DELIVERY_FNAME + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_LNAME\" value=\"" + request.Delivery.DELIVERY_LNAME + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_EMAIL\" value=\"" + request.Delivery.DELIVERY_EMAIL + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_PHONE\" value=\"" + request.Delivery.DELIVERY_PHONE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_COMPANY\" value=\"" + request.Delivery.DELIVERY_COMPANY + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_ADDRESS\" value=\"" + request.Delivery.DELIVERY_ADDRESS + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_ADDRESS2\" value=\"" + request.Delivery.DELIVERY_ADDRESS2 + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_ZIPCODE\" value=\"" + request.Delivery.DELIVERY_ZIPCODE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_CITY\" value=\"" + request.Delivery.DELIVERY_CITY + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_STATE\" value=\"" + request.Delivery.DELIVERY_STATE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DELIVERY_COUNTRYCODE\" value=\"" + request.Delivery.DELIVERY_COUNTRYCODE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"PRICES_CURRENCY\" value=\"" + request.Config.PRICES_CURRENCY + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DISCOUNT\" value=\"" + request.Order.DISCOUNT + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DESTINATION_CITY\" value=\"" + request.Customer.DESTINATION_CITY + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DESTINATION_STATE\" value=\"" + request.Customer.DESTINATION_STATE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"DESTINATION_COUNTRY\" value=\"" + request.Customer.DESTINATION_COUNTRY + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"PAY_METHOD\" value=\"" + request.Config.PAY_METHOD + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"TESTORDER\" value=\"" + request.Config.TESTORDER + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"LANGUAGE\" value=\"" + request.Config.LANGUAGE + "\"/>");
            builder.Append("<input type=\"hidden\" name=\"ORDER_HASH\" value=\"" + hashString + "\"/>");
            builder.Append("<input type=\"submit\" value=\"Öde\" style=\"display:none;\"/>");
            builder.Append("<noscript>");
            builder.Append("<br/>");
            builder.Append("<br/>");
            builder.Append("</noscript>");
            builder.Append("</form>");
            builder.Append("</body>");
            builder.Append("<script>document.getElementById(\"common_form\").submit();</script>");
            builder.Append("</html>");
            return(builder.ToString());
        }