Search code examples
springspring-roospring-webflow

Spring Web Flow with Paypal


Hy!

Im integrating Paypal payment in Spring Web flow.

The app forwards the request to the PayPal website using externalRedirect.(setExpresscheckout) User logs in to PayPal and pays for the item. Once the user completes the payment, paypal forwards the request back to the flow. Is there is way to enter a particular view-state within the flow once the request comes back from PayPal?

I tried this, but doesnt work:

This is part of the paypalcontroller, where i set the return urls to paypal:

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:

<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>

this is the url what is generated by session manager code, and paypal redirects to it:

http://localhost:8080/testpaysys/sampleflow;jsessionid=D693C9D4A2681CA6FF18E7C7078EA971?null&_eventId=approved

The approved eventID seems not working, i get to the flow, but to the starting state.(doesnt redirect to state 2)

What am i missing?


Solution

  • you will need to use the execution key. you should use flowExecutionUrl in the return url that you are building in your controller.
    you can access it through context.getFlowExecutionUrl()