Hi Jayeshps, I have implemented a wicket pay with paypal button a few weeks ago.
The beauty of working with wicket is that you do not have to hard-code and hide the html parameters you pass to paypal on your html. It can all be done on the AjaxButton.onSubmit(); I am assuming you're familiar with the parameter's passed to paypal, if not, here is a good example: http://www.onlineinteract.com/wiki/viewpage.php?pageId=179 <http://www.onlineinteract.com/wiki/viewpage.php?pageId=179> Also, an explanation of each parameter can be found here <https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HF009YW> . Ok, onto the code: Inside the AjaxButton.onSubmit() button, you need to construct the URL with parameters to pass to paypal: An example url is this: https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1&no_shipping=1&no_note=1&custom=0A566EC9F6AC27E9¤cy_code=GBP&lc=GB&bn=business_BuyNow_WPS_GB&return=https://localhost:8443/paymentpage/sucessParameters&cancel_return=https://localhost:8443/paymentpage/cancelParameters¬ify_url=https://localhost:8443/paypalipnprocess&[email protected]&item_name_1=entry_test_test&item_number_1=DB3BE2BD0BFC8D03&amount_1=0.30 Notice how all parameters are separated by '&'. You can produce the above URL from the server side, avoiding posting all of the above info in hidden fields on the HTML form post parameters. The way I have implemented is as follow: AjaxButton.onSubmit() { setResponsePage(new PayPalPaymentGatewayExampleClass(parameters to construct the url)); } I've attached the PayPalPaymentGatewayExampleClass which extends RedirectPage2 on this post. PayPalPaymentGatewayExampleClass.java <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/PayPalPaymentGatewayExampleClass.java> RedirectPage2.html <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/RedirectPage2.html> RedirectPage2.java <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/RedirectPage2.java> PayPalPaymentGatewayExampleClass builds the URL with the necessary parameters before posting the request to Paypal. Notice that on RedirectPage2 I throw new RedirectToUrlException( url.toString() ); That's because I was having trouble to properly rediderct a page running wicket on production mode. I spent days trying to find a solution. Finally, I had to settle for the workaround but functional RedirectToUrlException. Part 2, processing the IPN: Once the payment has taken place, Paypal will send the IPN request to you. If you haven't played with Paypal's IPN simulator, you can do so here <https://developer.paypal.com/developer/ipnSimulator> . Remember to provide a valid url to IPN handler URL since IPN is a 3rd party trying to contact your application. localhost will not do. More on IPN <https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/> . Although, based on your post, you are already familiar with it. As explained on this picture: <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/IPN_auth_flow.gif> and on this link:http://codeoftheday.blogspot.co.uk/2013/07/paypal-button-and-instant-payment_6.html, Paypal sends an IPN message, which if the URL is valid, automatically sends a http 200 response back. Then you need to send the exact IPN message back to Paypal with the code "cmd=_notify-validate" (valid at time of writing). When Paypal replies to you with a valid code, only then is advisable to do your back end processing of the payments and everything else you need to do. I've attached the code for PayPalIPNProcessingPortal class which is an empty page and should be a bookmarkable page. If you read through the code and try to understand it, it might be better than me trying to explain step by step. PayPalIPNProcessingPortal.java <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/PayPalIPNProcessingPortal.java> PayPalIPNProcessingPortal.html <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/PayPalIPNProcessingPortal.html> IPN_Parameter.java <http://apache-wicket.1842946.n4.nabble.com/file/n4670405/IPN_Parameter.java> Let me know if you have any questions. I am sorry if my code doesn't seem clear enough. I work from home and although I try to make the code as readable as possible for my future self, I don't have a team member to code-review with. All the best =0) Lucas -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Paypal-Integration-in-wicket-tp4670325p4670405.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
