YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

PDT not working properly--Java Options
DebraM
#1 Posted : Monday, April 25, 2005 1:12:26 PM
Rank: Starting Member

Groups: Registered

Joined: 4/25/2005
Posts: 2
Location: ,
Hi, I have been trying to get the Java sample to work for me. I used the one that I found on here: - - - - - - - - - - - - - <%@ page import="java.util.*" %> <%@ page import="java.net.*" %> <%@ page import="java.io.*" %> <% // read post from PayPal system and add 'cmd' String str = "cmd=_notify-synch"; Enumeration en = request.getParameterNames(); while(en.hasMoreElements()){ String paramName = (String)en.nextElement(); String paramValue = request.getParameter(paramName); str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue); } String auth_token = "4mGzP4D6fY0suAEYr7KQWeUvTApUHJkOFPEM9-Sj8-bp-Lj7p8h7EiuI128"; str = str + "&at=" + auth_token; // 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(); out.println("el status es: "+ res); out.println("string: "+ str); String [] temp = null; String message = ""; if (res.equals("SUCCESS")){ while ( (res=in.readLine()) != null ){ temp = res.split("="); if (temp[0].equals("address_name")){ message = message + "<b>Customer Name:</b> " + temp[1] + "<br>"; } if (temp[0].equals("item_name")){ message = message + "<b>Item Name: </b>" + temp[1] + "<br>"; } if (temp[0].equals("mc_gross")){ message = message + "<b>Amount: </b>" + temp[1] + "<br>"; } }; } else if(res.equals("FAIL")){ out.println("Please check the error log. The transaction has a Fail response"); } in.close(); %> - - - - - - - - - - I have only changed the token to my sandbox token, and the sandbox URL is added. Any help would be appreciated. You can find the sandbox button at the VERY BOTTOM of my webpage: http://www.geocities.com/learnnplayhcc/clientpages Auto return is turned on, as is PDT. The return page is: http://www.geocities.com...nplayhcc/clientpaymentpp but all that shows up there is the Java as if it is only text. Any help? I keep making donations of $1.00 at webites in order to find one with a return page. Note-- I am a daycare provider. So please speak in layman's terms. :) Thanks. - - - Forgot to mention; I use ACEHTML 5. And Mozille Firefox.
Sponsor  
 
DebraM
#2 Posted : Monday, April 25, 2005 2:55:16 PM
Rank: Starting Member

Groups: Registered

Joined: 4/25/2005
Posts: 2
Location: ,
Well, I am glad to see folks reading.. but I need HELP PLEASE. I do understand that Java is not Javascript. But I tried the other PDT scripts and could not get even close to what I have now. Any help??????
PayPalStephen
#3 Posted : Monday, April 25, 2005 4:40:47 PM
Rank: Starting Member

Groups: Registered

Joined: 10/17/2002
Posts: 2,139
Location: ,
Hello,

Have you tired your script on a different host? Brinkster or another one that offers free script hosting, to make sure it is not an issue with geocities?

Stephen Ivaskevicius
PayPal/eBay, Inc.
www.paypal.com/pdn
redahmeid
#4 Posted : Saturday, February 04, 2006 7:18:58 PM
Rank: Starting Member

Groups: Registered

Joined: 1/26/2006
Posts: 2
Location: ,
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by DebraM
[br]Hi, I have been trying to get the Java sample to work for me. I used the one that I found on here:
- - - - - - - - - - - - -

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

String str = "cmd=_notify-synch";

Enumeration en = request.getParameterNames();
while(en.hasMoreElements()){
String paramName = (String)en.nextElement();
String paramValue = request.getParameter(paramName);
str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue);
}


String auth_token = "4mGzP4D6fY0suAEYr7KQWeUvTApUHJkOFPEM9-Sj8-bp-Lj7p8h7EiuI128";
str = str + "&at=" + auth_token;


// 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();
out.println("el status es: "+ res);
out.println("string: "+ str);
String [] temp = null;
String message = "";
if (res.equals("SUCCESS")){
while ( (res=in.readLine()) != null ){
temp = res.split("=");
if (temp[0].equals("address_name")){
message = message + "&lt;b&gt;Customer Name:&lt;/b&gt; " + temp[1] + "&lt;br&gt;";
}
if (temp[0].equals("item_name")){
message = message + "&lt;b&gt;Item Name: &lt;/b&gt;" + temp[1] + "&lt;br&gt;";
}
if (temp[0].equals("mc_gross")){
message = message + "&lt;b&gt;Amount: &lt;/b&gt;" + temp[1] + "&lt;br&gt;";
}
};

}
else if(res.equals("FAIL")){
out.println("Please check the error log. The transaction has a Fail response");

}
in.close();

%&gt;


- - - - - - - - - -
I have only changed the token to my sandbox token, and the sandbox URL is added. Any help would be appreciated. You can find the sandbox button at the VERY BOTTOM of my webpage:
http://www.geocities.com...arnnplayhcc/clientpages

Auto return is turned on, as is PDT. The return page is:
http://www.geocities.com...playhcc/clientpaymentpp

but all that shows up there is the Java as if it is only text. Any help? I keep making donations of $1.00 at webites in order to find one with a return page. Note-- I am a daycare provider. So please speak in layman's terms. :) Thanks.

- - - Forgot to mention; I use ACEHTML 5. And Mozille Firefox.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

My guess here is that you are trying to run a JSP on a on java webserver. In layman terms, what you have is not script, so doesn't run on the browser but runs on the server in the background, so the server needs to be able to handle it. Geocities, I'm afraid, probably doesn't handle server side java.

Sorry
gourav_ajmani
#5 Posted : Wednesday, January 17, 2007 7:12:55 AM
Rank: Starting Member

Groups: Registered

Joined: 12/27/2006
Posts: 13
Location: ,
Hi All,I am new to java ,And the project which has given to me is to integrate the payapal at our site.I have integrated that.
Now the problem is once my customer is done with his payment,he should me returned back to my site and also he should be able to see his transaction details at my sitPage.

I Have written a Servlet which will be called on the click of Pay at paypal site.but I guess the servlet is not working

The code that i have wrriten is :


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class PdtServlet extends AbstractTeleTrakController {


protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
TeleTrakDatabaseException, TeleTrakGeneralException {



DirectCallDeligate directCallDeligate = new DirectCallDeligate(request);
String action = request.getParameter("userAction");
String page="";
String paypalTransactionId=null;
Map paramterMap=request.getParameterMap();
int noOfParameters=paramterMap.size();

System.out.println("noOfParameters==>"+noOfParameters);

//Returned From paypal
String firstName=null;
String lastName=null;
String paymentStatusFromPaypal=null;
String paymentAmount=null;
String currency=null;
String customValueWeHaveSend=null;
int dealerId=0;
int noOfTollFreeNos;
int totalCharges;
String paymentMethod="";

if(noOfParameters==1){
//Paypal is pinging our servlet with tx code
paypalTransactionId=request.getParameter("tx");

PayPalHelper payPalHelper = new PayPalHelper();
String identityToken= payPalHelper.getPdTIdentity();
OutputStreamWriter streamWriter=null;
HttpURLConnection urlConnection=null;
BufferedReader reader=null;
String urlToBePosted =payPalHelper.getPayPalSiteURL();
StringBuffer dataToPostBuffer = new StringBuffer();

try{
dataToPostBuffer.append("cmd=");
dataToPostBuffer.append("_notify-synch");
dataToPostBuffer.append("&tx=");
dataToPostBuffer.append(paypalTransactionId);
dataToPostBuffer.append("at=");
dataToPostBuffer.append(identityToken);
URL url = new URL(urlToBePosted);
urlConnection = (HttpURLConnection)url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestMethod("POST");
streamWriter = new OutputStreamWriter(urlConnection.getOutputStream());
streamWriter.write(dataToPostBuffer.toString());
streamWriter.flush();
Properties paypalProperties = new Properties();
paypalProperties.load(urlConnection.getInputStream());

reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
StringBuffer returnBuffer = new StringBuffer();
String lineToRead;
while((lineToRead=reader.readLine())!=null){
returnBuffer.append(lineToRead);
}//end of while

firstName = paypalProperties.getProperty("first_name");
lastName=paypalProperties.getProperty("last_name");
paymentAmount=paypalProperties.getProperty("payment_gross");
currency= paypalProperties.getProperty("mc_currency");
customValueWeHaveSend= paypalProperties.getProperty("custom");



//if("SUCCESS".equalsIgnoreCase(returnBuffer.toString().substring(0,7))==true){
paymentStatusFromPaypal= paypalProperties.getProperty(payPalHelper.getPayPalPdtPaymentStatusField());

if(paymentStatusFromPaypal.equalsIgnoreCase("Completed")){
//Payment is sucess



}

if(paymentStatusFromPaypal.equalsIgnoreCase("Failed")){
System.out.println("Failed=========>");
}

if(paymentStatusFromPaypal.equalsIgnoreCase("Processed")){
System.out.println("payment has been accepted and processed===>");

}

if(paymentStatusFromPaypal.equalsIgnoreCase("Denied")){
System.out.println("Payment has been denied===>");

}

if(paymentStatusFromPaypal.equalsIgnoreCase("Expired")){
System.out.println("Payment has been Expired===>");

}
if(paymentStatusFromPaypal.equalsIgnoreCase("Pending")){
System.out.println("Payment has been Pending===>");

}


//}


}catch(Exception ex){
System.out.println("Exception Occured While taking value from paypal pdt");
ex.printStackTrace();
}
page="/Creditcard.jsp";

}else{

}//end of if





}//end of method

}//end of serlvet

Can anyone plz me help me out.

And if possible plz do reply at gourav@logixworld.com

Regards
Gourav
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.387 seconds.