Note that there are some explanatory texts on larger screens.

plurals
  1. POPaypal IPN Spring MVC - Java
    text
    copied!<p>My notify url is not working even it is already activated in paypal. Is there something wrong with my code in the form? i have the same notify url in paypal account. By the way, I'm using heroku,spring mvc. Thanks. I hope you can help me.</p> <pre><code>&lt;form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr"&gt; &lt;input type="hidden" name="cmd" value="_donations"/&gt; &lt;input type="hidden" name="business" value="1234businessaccount@gmail.com"/&gt; &lt;input type="hidden" name="item_name" value="${student.lastname }, ${student.firstname}"/&gt; &lt;input type="hidden" name="currency_code" value="PHP"/&gt; &lt;input type="hidden" name="lc" value="PH"/&gt; &lt;input type="hidden" name="rm" value="2"/&gt; &lt;input type="hidden" name="return" value="http://atriev.herokuapp.com/"/&gt; &lt;input type="hidden" name="cancel_return" value="http://atriev.herokuapp.com/atriev-index.html"/&gt; &lt;input type="hidden" name="notify_url" value="http://atriev.herokuapp.com/paypal.html"/&gt; </code></pre> <p>paypal.jsp</p> <pre><code>&lt;%@ page import="java.util.*" %&gt; &lt;%@ page import="java.net.*" %&gt; &lt;%@ page import="java.io.*" %&gt; &lt;% // read post from PayPal system and add 'cmd' Enumeration en = request.getParameterNames(); String str = "cmd=_notify-validate"; while(en.hasMoreElements()){ String paramName = (String)en.nextElement(); String paramValue = request.getParameter(paramName); str = str + "&amp;" + paramName + "=" + URLEncoder.encode(paramValue); } // post back to PayPal system to validate // NOTE: change http: to https: in the following URL to verify using SSL (for increased security). // using HTTPS requires either Java 1.4 or greater, or Java Secure Socket Extension (JSSE) // and configured for older versions. URL u = new URL("https://www.sandbox.paypal.com/cgi-bin/webscr"); URLConnection uc = u.openConnection(); uc.setDoOutput(true); uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); PrintWriter pw = new PrintWriter(uc.getOutputStream()); pw.println(str); pw.close(); BufferedReader in = new BufferedReader( new InputStreamReader(uc.getInputStream())); String res = in.readLine(); in.close(); // assign posted variables to local variables String itemName = request.getParameter("item_name"); String itemNumber = request.getParameter("item_number"); String paymentStatus = request.getParameter("payment_status"); String paymentAmount = request.getParameter("mc_gross"); String paymentCurrency = request.getParameter("mc_currency"); String txnId = request.getParameter("txn_id"); String receiverEmail = request.getParameter("receiver_email"); String payerEmail = request.getParameter("payer_email"); if(res.equals("VERIFIED")) { // check that paymentStatus=Completed // check that txnId has not been previously processed // check that receiverEmail is your Primary PayPal email // check that paymentAmount/paymentCurrency are correct // process payment } else if(res.equals("INVALID")) { // log for investigation } else { // error } %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload