k_rollo
k_rollo

Reputation: 5472

Redirect to Struts 2 action class after user completes PayPal purchase

I am using the PayPal Sandbox in my Struts 2 web project.

I have a payment-method.jsp that contains the PayPal form:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">     
    <!-- other stuff -->

    <input type="hidden" name="return" value="payment">
    <input type="hidden" name="cancel_return" value="http://localhost:8080/mysite/payment-method.jsp">

    <!-- payment button -->                     
</form>

I have specified the return value as payment.

I have defined the action in my struts.xml:

<action name="payment" class="com.mypackage.action.PaymentAction">
    <result>/transaction-result.jsp</result>
</action>

But it's returning to the PayPal Sandbox homepage.

How do I redirect to an action (instead of an actual page) after the user completes their transaction in PayPal?

(The cancel_return works by the way.)

Upvotes: 1

Views: 383

Answers (2)

T L Patel
T L Patel

Reputation: 86

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/ProfileAndTools/

first read this document and give your action url in return url in your paypal account.

And set Auto Return to on.

no, you cant check on localhost if u have live url then check on live.

Upvotes: 1

Rookie007
Rookie007

Reputation: 1219

if you want to redirect to action then

you change this

 <action name="payment" class="ph.watchy.action.PaymentAction">
<result>/transaction-result.jsp</result>
<result name="index" type="redirect">/index.jsp</result>

to

  <action name="payment" class="ph.watchy.action.PaymentAction">
   <result>/transaction-result.jsp</result>
   <result name="index" type="redirect">ActionToberedireected</result>
  </action>

Give action instead of index.jsp to which you want to redirect ..

Upvotes: 0

Related Questions