Announcement Announcement Module
Collapse
No announcement yet.
Spring webflow PayPal integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring webflow PayPal integration

    We are using spring webflow 2 with spring mvc to build our web application. Our application has various payment methods. One of them is PayPal. When user selects PayPal, our app will forward the request to the PayPal website using externalRedirect as part of the end-state of the flow. User will log in to PayPal and will Pay for the item. Once the user completes the payment, paypal will forward the request back to our webflow application at the confirmation page which is one of the views in the flow.
    Is there is way to enter a particular view-state within the flow once the request comes back from PayPal?

  • #2
    AFAIK, you cant go into the middle of a flow ..i had the same situation, so i created a seperate flow for my redirect usecase with the right entry states and view states applicable for that usecase. You can reuse all the underlying views etc but you need another flow xml which defines how the flow will look like for your redirect usecase.

    Comment


    • #3
      Thanks for your response. Thats very helpful. One of the issues with starting a new flow is that all the flowScope variables created by the original flow that triggered the externalRedirect to payPal are no longer available. The option is to put these variable in the HttpSession. Ideally, we would like to redirect to paypal from a view-state in the flow and come back from paypal and joins the flow using the flowExecutorId and an eventId in the url request parameter. However, the externalRedirect only seem to work with end-states which means all scope variable are cleared after the redirect.

      Comment


      • #4
        You may be able to redirect manually without using an end state

        Code:
        <view-state id="reviewCart">
            <transition on="pay">
                <evaluate expression="payAction" />
            </transition>
        </view-state>
        Code:
        public class PayAction extends AbstractAction {
            public Event doExecute(RequestContext context) {
        	context.getExternalContext().requestExternalRedirect(location)
                return success();
            }
        }

        Comment


        • #5
          Found a way to return back to some state in the flow.
          1. Pass RequestContext to action method.
          2. get session id from HttpServletRequest
          3. pass this session id to return/cancel url


          public void SomeServiceMethod(Object someObjects, RequestContext context) {
          //get http request
          HttpServletRequest request = (HttpServletRequest)
          context.getExternalContext().getNativeRequest();
          //generate Spring Webflow return URL
          String url = request.getRequestURL() +
          ";jsessionid="+ request.getSession().getId() + "?" +
          request.getQueryString();

          String paypalCancelUrl = url + "&_eventId=cancel";
          String paypalApprovedUrl = url + "&_eventId=approved";

          ....
          }


          http://dwolgar.blogspot.com/

          Comment


          • #6
            Im bringing up this topic.
            I tried Dwolgars solution in many differences but its not working.

            Forwarding and paying on paypal site is OK now with the DoExecute method posted earlier.
            I think im missing something on EventID.
            This is how my approved url looks like:
            Code:
            	private void sessionmanager(RequestContext context) {
            HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getNativeRequest();
            //generate Spring Webflow return URL
            String url = request.getRequestURL()+";jsessionid="+ request.getSession().getId() + "?" +
                            request.getQueryString();
            String paypalCancelUrl   = url + "&_eventId=end-state";
            String paypalApprovedUrl = url + "&_eventId=approved";
            }
            flow.xml: (Just for testing i want to redirect to second flow page, when paypal returns)
            Code:
            <view-state id="view-state-1" view="sampleflow/view-state-1">
                	<transition on="success" to="view-state-2"/>
                	<transition on="cancel" to="end-state"/>
                	<transition on="approved" to="view-state-2"/>
            </view-state>
            But it doesnt redirect.
            Here the complete URL what paypal is redirecting the browser to:
            Code:
            http://localhost:8080/testpaysys/sampleflow;jsessionid=D693C9D4A2681CA6FF18E7C7078EA971?null&_eventId=approved
            Any ideas? (Can come in private also, if its confidental)

            Comment

            Working...
            X