Topic
6 replies Latest Post - ‏2013-08-05T07:35:29Z by LindyHopper
Jacobo_Adolfo
Jacobo_Adolfo
27 Posts
ACCEPTED ANSWER

Pinned topic Command redirect to other domain

‏2013-07-02T12:59:32Z |

Hi!

I have to make a change in a Websphere Command. I'm extending OrderProcessCmd to check a business condition. If this condition is true, I must redirect the user to other domain (the payment gateway payment page, outside of Websphere Commerce). The question is how to do it.

In the extended command, y call:

super.performExecute(); //OrderProcessCmd

if (condition)

//go to Payment Gateway

            rsProperties.put(ECConstants.EC_VIEWTASKNAME, ECConstants.EC_GENERIC_REDIRECTVIEW);
            rsProperties.put(ECConstants.EC_REDIRECTURL,paymentGatewayUrl);             
            setResponseProperties(rsProperties);

 

But it doesn't work. Any clue to solve this please?

Thank you so much.

  • M.S.Vinoth
    M.S.Vinoth
    1 Post
    ACCEPTED ANSWER

    Re: Command redirect to other domain

    ‏2013-07-07T14:31:00Z  in response to Jacobo_Adolfo

    Hi,

    You need to add an entry in wc-server.xml to make it work. In the stores module block. inside <URLRedirectFilter> tag, add the domain that you to redirect to using <AllowedDomain /> tag

    • Jacobo_Adolfo
      Jacobo_Adolfo
      27 Posts
      ACCEPTED ANSWER

      Re: Command redirect to other domain

      ‏2013-07-08T06:12:10Z  in response to M.S.Vinoth

      Hi.

      I've inserted these lines on wc-server.xml:

                      <Module contextPath="/webapp/wcs/stores"
                          fileServletEnabled="false" name="Stores"
                          urlMappingPath="/servlet" webAlias="/wcsstore">
                          <InitParameters adapters="XML/HTTP, BrowserAdapter"
                              contextSetName="Store" handleDoubleClick="true"/>
                          <URLRedirectFilter enable="true">
                              <AllowedDomain name="paymentgateway.com"/>
                           </URLRedirectFilter>                    
                      </Module>

      But it does not work.

      The lines

                  rsProperties.put(ECConstants.EC_VIEWTASKNAME, ECConstants.EC_GENERIC_REDIRECTVIEW);
                  rsProperties.put(ECConstants.EC_REDIRECTURL,paymentGatewayUrl);    

      in the command for redirecting are ok?

       

      Thank you!

      • Raj.S
        Raj.S
        513 Posts
        ACCEPTED ANSWER

        Re: Command redirect to other domain

        ‏2013-07-08T08:26:45Z  in response to Jacobo_Adolfo

        If you are redirecting to a different domain, I do not think you will have to make any entry as such. What is the value of the paymentGatewayUrl set ? Is that the complete url of the external server ? What exception do you see in logs ?

         

        Rgds, Raj.

  • VikramAnusuri
    VikramAnusuri
    14 Posts
    ACCEPTED ANSWER

    Re: Command redirect to other domain

    ‏2013-07-08T10:05:15Z  in response to Jacobo_Adolfo

    Hi,

    We have also come across same scenario. We have used the below code. Hope this would help you.

    ((HttpServletResponse)(((ViewCommandContext)commandContext).getResponse())).sendRedirect("abcd@xyz.com");

    Regards,

    Vikram

    • Jacobo_Adolfo
      Jacobo_Adolfo
      27 Posts
      ACCEPTED ANSWER

      Re: Command redirect to other domain

      ‏2013-07-09T06:23:16Z  in response to VikramAnusuri

      Hi

      Thank you, but I want to do this without a sendRedirect, but at this moment, this is an option.

       

      Raj, the exception I see is "Command 'http://paymentgateway.com?xxx...' not found. WC is trying to redirect to a view, but this does not exists. Yes paymentGatewayUrl is the full url to the payment gateway.

       

      Thanks!

      • LindyHopper
        LindyHopper
        17 Posts
        ACCEPTED ANSWER

        Re: Command redirect to other domain

        ‏2013-08-05T07:35:29Z  in response to Jacobo_Adolfo

        You are constructing the redirect the correct way. Doing as Vikram has posted is by-passing the Commerce mechanism which incorporates OOTB security and parameter encoding and I would not recommend it.

        I would suggest you login to the Websphere Admin Console, navigate to: Troubleshooting -> Logs & Trace -> server1. Click on rthe Runtime tab and change the entry to:

        *=info: com.ibm.websphere.commerce.WC_SERVER=all

        Try your redirect and return the above entry to: *=info

        Now examine the trace.log in your server logs directory and see if you can see what is going on under the covers. You should be able to find the final redirect url that the IBM has constructed and try that in a browser to see if it works.

        Have you tried this in your wc-server.xml instead of the AllowedDomain...

        <AllowedHost name="www.paymentgateway.com"/>

        ...and then include the www. in your url?