Hi all,

I am trying to develop a new payment type for the spanish TVP called Pasat4B.

First of all this TPV is a bit wierd as it has 3 steps. 1 you have to vent your merchant code and order id using post, 2 you receive an ok to a page with that order number and merchant code and then you can send the order details using plain text so the bank redirect to their payment page to type de credir card details.

My first problem is in the fisrt step, when I user the RepotePost.Post() pasing values. After do the response.write, it does the context.Response.End() and this gives me an exception. Next is the code wraped with a try to check that is failing.

/// <summary>
        /// Post
        /// </summary>
        public void Post()
        {
            var context = HttpContext.Current;
            context.Response.Clear();
            context.Response.Write("<html><head>");
            context.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", FormName));
            context.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", FormName, Method, Url));
            for (int i = 0; i < inputValues.Keys.Count; i++)
                context.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", HttpUtility.HtmlEncode(inputValues.Keys[i]), HttpUtility.HtmlEncode(inputValues[inputValues.Keys[i]])));
            context.Response.Write("</form>");
            context.Response.Write("</body></html>");
            try
            {
                context.Response.End();
            }
            catch (Exception)
            {
                throw;
            }
          
            //context.ApplicationInstance.CompleteRequest();

        }


My payment first step is very simple. I have copied the sermepa payment and set all the necesary pages to retrieve some data from the administration. The PostProcessPayment() method has the nect code

public string PostProcessPayment(Order order)
        {

            //Notificación On-Line
            string strDs_Merchant_MerchantURL = CommonHelper.GetStoreLocation(false) + "Pasat4bReturn.aspx";

            

            //Numero de pedido
            string strDs_Merchant_Order = order.OrderId.ToString();
            //Código de comercio
            string strDs_Merchant_MerchantCode = IoC.Resolve<ISettingManager>().GetSettingValue("PaymentMethod.Pasat4b.FUC");

            ////Creamos el POST
            RemotePost remotePostHelper = new RemotePost();
            remotePostHelper.FormName = "form1";
            remotePostHelper.Url = GetPasat4bUrl();
            remotePostHelper.Method = "POST";


            remotePostHelper.Add("order", strDs_Merchant_Order);
            remotePostHelper.Add("store", strDs_Merchant_MerchantCode);

            remotePostHelper.Post();

            //StringBuilder builder = new StringBuilder();
            //builder.Append(GetPasat4bUrl());
            //builder.AppendFormat("?order={0}&store={1}", strDs_Merchant_Order, strDs_Merchant_MerchantCode);
            //HttpContext.Current.Response.Redirect(builder.ToString());
            return string.Empty;
        }

It seems that something is wrong in the payment page as it cant do the response.end but I cant see nothing...

Also I have some other doubts about implementing this kind of payment. Should I create anew aspx page to receive the bank ok and send the order details back. I did so but I am not sure it is the best way to do it.

Has anyone else done this payment_ Help please. I am wasting a lot of time.

Thanks very much!