Developer forum

Forum » Development » Custom CheckoutHandler Redireccion

Custom CheckoutHandler Redireccion

Jose Caudevilla
Reply

Hello:

 

I have to implement a custom CheckoutHandler , it works well, but when the tpv process is finished it not return to the DynamicWeb Receipt page order.

The TPV has a parameter (Ds_Merchant_UrlOK ) that redirects to the specific url it all works well. 

How can i get orderID and the orderSecret after the TPV process is complete?

 

Here is the code of the ChekoutHandler:

 

    [AddInDescription("Payment system, http://www.redsys.es/")]
    [AddInName("Pago con tarjeta a traves de Santander")]
    public class SantanderGateway : CheckoutHandler
    {

        [AddInParameter("Error template")]
        [AddInParameterEditor(typeof(TemplateParameterEditor), "folder=templates/eCom7/CheckoutHandler/Santander/Error")]
        public string ErrorTemplate { get; set; }
        [AddInParameter("Post template")]
        [AddInParameterEditor(typeof(TemplateParameterEditor), "folder=templates/eCom7/CheckoutHandler/Santander/Post")]
        public string PostTemplate { get; set; }
        [AddInParameterEditor(typeof(TextParameterEditor), "")]
        public string fucCode { get; set; }
        [AddInParameterEditor(typeof(TextParameterEditor), "")]
        public string terminalCode { get; set; }
        [AddInParameterEditor(typeof(TextParameterEditor), "")]
        public string UrlRecibirRespuestaTPV { get; set; }
        [AddInParameterEditor(typeof(TextParameterEditor), "")]
        public string claveAdministracion { get; set; }
        [AddInParameter("Test mode")]
        [AddInParameterEditor(typeof(YesNoParameterEditor), "")]
        public bool TestMode { get; set; }
        [AddInParameter("Form template"), AddInParameterGroup("Template settings:"), AddInParameterEditor(typeof(TemplateParameterEditor), "folder=templates/eCom7/CheckoutHandler/Santander/Form")]
        public string FormTemplate { get; set; }

        //PARAMETROS SANTANDER GATEWAY
        [AddInParameter("Número de comercio (FUC)"), AddInParameterGroup("Ds_Merchant_MerchantCode"), AddInParameterEditor(typeof(TextParameterEditor), "NewGUI=true;")]
        public string Ds_Merchant_MerchantCode { get; set; }

        [AddInParameter("Tipo de operacion"), AddInParameterGroup("Ds_Merchant_TransactionType"), AddInParameterEditor(typeof(TextParameterEditor), "NewGUI=true;")]
        public string Ds_Merchant_TransactionType { get; set; }

        [AddInParameter("Moneda del terminal"), AddInParameterGroup("Ds_Merchant_Currency"), AddInParameterEditor(typeof(TextParameterEditor), "NewGUI=true;")]
        public string Ds_Merchant_Currency { get; set; }

        [AddInParameter("Número de terminal"), AddInParameterGroup("Ds_Merchant_Terminal"), AddInParameterEditor(typeof(TextParameterEditor), "NewGUI=true;")]
        public string Ds_Merchant_Terminal { get; set; }

        [AddInParameter("Clave secreta de encriptación"), AddInParameterGroup("DS_MERCHANT_TERMINAL"), AddInParameterEditor(typeof(TextParameterEditor), "NewGUI=true;")]
        public string Clave_encriptacion { get; set; }

        [AddInParameter("DS_MERCHANT_TERMINAL"), AddInParameterGroup("DS_MERCHANT_TERMINAL"), AddInParameterEditor(typeof(TextParameterEditor), "NewGUI=true;")]
        public string Ds_Merchant_UrlOK { get; set; }


        public SantanderGateway()
        {
            ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;
        }

        public override string Redirect(Order order)
        {

            return "";
        }
        

        public override string StartCheckout(Order order)
        {
            RedsysAPI redsys = new RedsysAPI();
            string redSysUrl = "https://sis-t.redsys.es:25443/sis/realizarPago";

            redsys.SetParameter("DS_MERCHANT_AMOUNT", Convert.ToInt32(order.Price.Price * 100).ToString() );
            redsys.SetParameter("DS_MERCHANT_ORDER" , order.Id );

            //redsys.SetParameter("DS_MERCHANT_MERCHANTCODE", fucCode);
            redsys.SetParameter("DS_MERCHANT_MERCHANTCODE", Ds_Merchant_MerchantCode);

            redsys.SetParameter("DS_MERCHANT_CURRENCY", Ds_Merchant_Currency); //codigo moneda euros
            redsys.SetParameter("DS_MERCHANT_TRANSACTIONTYPE", Ds_Merchant_TransactionType); //CODIGO 0 - tipo de operacion normal

            //redsys.SetParameter("DS_MERCHANT_TERMINAL" , terminalCode);
            redsys.SetParameter("DS_MERCHANT_TERMINAL", Ds_Merchant_Terminal);


            
            redsys.SetParameter("Ds_Merchant_UrlOK", Ds_Merchant_UrlOK);
            //redsys.SetParameter("DS_MERCHANT_PAN", "4548812049400004");
            //redsys.SetParameter("DS_MERCHANT_MERCHANTURL" , "http://dw972r320.local.dynamicweb.dk/Default.aspx?ID=5");
            //redsys.SetParameter("DS_MERCHANT_EXPIRYDATE", "1220"); //fecha de expiracion de la tarjeta
            //redsys.SetParameter("DS_MERCHANT_CVV2", "123"); //codigo CVV de la tarjeta de credito

            //crear parametros del comercio
            string param = redsys.createMerchantParameters();
            //firma
            //string sig = redsys.createMerchantSignature(claveAdministracion);
            string sig = redsys.createMerchantSignature("sq7HjrUOBfKmC576ILgskD5srU870gJ7");

            //Comprobar si se esta en entorno de test

            return "<form action=\"" + redSysUrl + "\" method=\"post\">" +
                        "<input type=\"hidden\" name=\"Ds_SignatureVersion\" value=\"HMAC_SHA256_V1\"/>" +
                        "<input type=\"hidden\" size=\"100\" id=\"Ds_MerchantParameters\" name=\"Ds_MerchantParameters\" value=\"" + param + "\">" +
                        "<input type=\"hidden\"  size=\"50\" id=\"Ds_Signature\"  name=\"Ds_Signature\" value=\"" + sig + "\">" +
                        "<input type=\"submit\" value=\"Realizar Pago\">" +
                    "<form>";
        }
        



        protected override string Render(Order order, Template template)
        {
            Template form_template = new Template(PostTemplate);

            return base.Render(order, form_template);
        }
        public override string RenderInlineForm(Order order)
        {
            Template template = new Template(PostTemplate);
            return template.Html;
        }
    }

 

 

Regards,

Jose.

 

 

 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jose

They are properties on the order object.

BR Nicolai

Votes for this answer: 1
 
Jose Caudevilla
Reply

You're right!

Thanks Nicolai.

Jose,

Regards.

 

You must be logged in to post in the forum