簡體   English   中英

PayPal與Java集成

[英]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());
        }

    }

您遇到的問題是您的Web服務器(如apache,weblogic等)沒有安裝貝寶的證書,就像您的Web瀏覽器安裝了證書一樣。
即在weblogic中,您使用keytool來安裝證書,您可以在此站點sslLabs中驗證您的簽名算法

這是掃描結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM