[英]PayPal Integration with java
我正在嘗試使用以下代碼集與Paypal
連接,但是當我運行此代碼時,我得到了error-。
]
它正在與其他網址(例如Google)一起使用。
線程“主”中的異常javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路徑構建失敗:sun.security.provider.certpath.SunCertPathBuilderException:無法找到到請求目標的有效證書路徑
碼:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
@SuppressWarnings({ "deprecation" })
public class HttpURLConnectionExample {
public static void main(String[] args) throws UnsupportedOperationException, IOException {
@SuppressWarnings("unused")
final String USER_AGENT = "Mozilla/5.0";
boolean test = true;
String url = "";
url += (test)? "https://www.sandbox.paypal.com/cgi-bin/webscr?" : "https://www.paypal.com/cgi-bin/webscr?";
String ownerEmail="mail2nkmishra-facilitator-1@gmail.com";
url += "business=" + ownerEmail + "&";
url += "cmd=" + "_xclick" + "&";
url += "amount=" + "20.00" + "&";
url += "item_name=" + "user_signup" + "&";
url += "item_number=" + "item_number" + "&";
url += "quantity=" + "1" + "&";
url += "currency_code=" + "USD" + "&";
url += "no_shipping=" + "1" + "&";
url += "rm=" + "2";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
// add request header
request.addHeader("User-Agent", "Mozilla/5.0");
HttpResponse response = client.execute(request);
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " +
response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.