Results 1 to 6 of 6

Thread: Spring webflow PayPal integration

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    3

    Default 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. #2
    Join Date
    Mar 2010
    Location
    Boston, MA
    Posts
    316

    Default

    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.

  3. #3
    Join Date
    May 2010
    Posts
    3

    Default

    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.

  4. #4
    Join Date
    May 2008
    Posts
    53

    Default

    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();
        }
    }

  5. #5
    Join Date
    Jul 2011
    Posts
    1

    Default

    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/

  6. #6
    Join Date
    Oct 2012
    Posts
    9

    Default

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •