1
I got the following code from Paypal’s git hub. I am making recurring payments and would like to receive notification in the system when there is cancellation. Thus, I could block the provision of my services if the user cancels. I have Servlet code, but I don’t know how to get it to respond on my JSF system. I’ve already peed on web.xml.
package br.com.spacnet.util;
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.paypal.core.LoggingManager;
import com.paypal.ipn.IPNMessage;
import br.com.spacnet.util.Configuration;
public class IPNListenerServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/*
* receiver for PayPal ipn call back.
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// For a full list of configuration parameters refer in wiki page.
// (https://github.com/paypal/sdk-core-java/wiki/SDK-Configuration-Parameters)
Map<String,String> configurationMap = Configuration.getConfig();
IPNMessage ipnlistener = new IPNMessage(request,configurationMap);
boolean isIpnVerified = ipnlistener.validate();
String transactionType = ipnlistener.getTransactionType();
Map<String,String> map = ipnlistener.getIpnMap();
LoggingManager.info(IPNListenerServlet.class, "******* IPN (name:value) pair : "+ map + " " +
"######### TransactionType : "+transactionType+" ======== IPN verified : "+ isIpnVerified);
}
}
My web.xml is like this:
<servlet>
<description></description>
<display-name>IPNListenerServlet</display-name>
<servlet-name>IPNListenerServlet</servlet-name>
<servlet-class>com.sample.ipn.IPNListenerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>IPNListenerServlet</servlet-name>
<url-pattern>/IPNListener</url-pattern>
</servlet-mapping>
You should map your Servlet with the correct package, in your case
br.com.spacnet.util
and notcom.sample.ipn
.– Wakim
Thank you, Cesarmiguel, thank you. But even if I map correctly now, when I call http://localhost:8080/meusite/admin/IPN/ipnMensagem.jsp, nothing is printed in the Tomcat output window...
– LeoPinheiroDeSouza