mobilecashier.d6243.alipaydev.com:12200?alipay_exterface_invoke_assign_target=invoke_e49649dc7dbc7e6a84e4de998cbfbbb5&alipay_exterface_invoke_assign_sign=_emww78n2_cg_l_n_em_o_x3_t_kija_ci_cap_p_t2h_vb4_synj0_g_q_v_j_veuvy%2Bn_upg_a%3D%3D
引用外部库: 1. JAVA SE 12.0.1 2. alipay-sdk-java-4.5.0.ALL-sources.jar 3. alipay-sdk-java-4.5.0.ALL.jar 4. bcprov-jdk15on-1.62-sources.jar 5. bcprov-jdk15on-1.62.jar 6. commons-logging-1.1.1-sources.jar 7. commons-logging-1.1.1.jar - 代码如下:
String gateway="https://openapi.alipaydev.com/gateway.do";
String app_id="2016092500594774";
String app_privateKey="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7YIOCmA20pXEm9dleTOoZfgadEfoetZLhzeOsZgVfjRsmmxaOeRAaW0RTxh/87RG7O7Rz3+TF2/J/Sjf8boBD/dfKsaBbHI6FzdKDMSHoRmeUEhZZUESa6ICice/hqhqAUx1l4Xc3VvNsSUJkvjtW5MfR/zPh4d+PJOvB8nW3mgKdq5OHLSWdIZzXF5oAt1sRvWHb/M6zTUPP2D4fkNTXfrRL8H1XUDTZyZfUN5GJsPdhFGlKvIYu7Qu3WCYUpEq3bB4vnuYD1XrsUqLw7COEE8Xx4yo/rVHBdE/QyPD64xRrspWmwWpqwpBQonM6CSJTPYA0WTjacRlMDD1LaP/RAgMBAAECggEAEoHI23g7OlFw6KE1s/uyz4vECXWCF9BlToowZ5G4DCT6voho5O+OKJxFFmUmOawMqUqPWzaM+QHtZKcm+nbLkmubCbkbloQui4a1uSF8MN3rUxOqQ24LKKW4NtM8FzTe4zfSWoK3bK7Y4iQmO58Sa1WzasljDXdqxk+mPYS+HcEb7+bC1MDLKo2AtD1xOPmyJ0FhaG/iCbtqz8pkOK9LQXQ0jgr2kME8t33pdmV8DTGyeU6r1oejPkESjRdYFCNSYLFztbfbGzIIUSu25n3BZu9QU1hW/jg3ye5dgosza2ztZTGP/L/lOjdGy2pVEb/KNTYEuzPsOLbKOQvajJD8AQKBgQDyCentNd3Ao/SLGfUlMUXY+c4SkvZ0AwHVOGvi1LHMgaAEthROyyfqPgdCuQlAzCZ+uAfhFa1advI2YfJr05uwy5RQF5LvNzMBwCuxBarvmhuKgl0ZpWHZb2HTWmekNDj/zA551hoVghs5/WKq+SGRW8D9LrO3aX2ToHZeMSUJwQKBgQDGL27OKZ4t1BefpoHANqtS1aE2xavjG6bjGCWaaNQy0idgW/Ck45F5DK+WjCJ4+W2I4A5ENvp0xQ7aT238jvf4ZynGI0u5TH2iDthbyIE8ll/hKLRxPPN5L015xtV++nWvc+bSC0UNt2U2BqNOwZAL2Fo5pm0r1QyPIQDJxOXaEQKBgCc04+fA6gLijCJcOhGkQaQ8Et1/YNy5//oCAbfkrEhsVvdsZy28SuLu2U49mvocF8A/H0ees04MJoAYraQ5yuaAk63Fo8+MKX8HGgy61k2psPxm0Z3t5EPMfxQ1eMRokTMeYtnpjKAfSznBidIYOQ/KxSA+CG6Vb/oR7Bql61IBAoGBAIFaPjEzermgv9aFIBTr2cCUDMgqFrmBt9hrT0fL+gw9nFPJTnTgz3c5r3VMe8eHzVVUIBun4qrKX5pf04LPccvg0aQwL2F/KlTW6aJmaOu5nlTgc32hcax8Ek5UV86r/JoKxPH9RxHfzKCJjpd9wN3qVWFhXcoJIUxeFxyadgdxAoGBAMkWAmSfMNl5lUR62g5GOZlzpYiBwl6nCPazs4o0sl0swySyfibT5MX3I8g12m1uLqvXSbR3PhBWp1gIDeCrkir0QsUScz0zvXJLDpoIWFYWfargo3DW2jzndCtlFQ71R4FvCLsq4TnCqrCJc0mju1K+VYvp/2kVqPnRe/IR+5rd";
String app_cert_path="appCertPublicKey_2016092500594774.crt";
String alipay_cert_path="alipayCertPublicKey_RSA2.crt";
String alipay_root_cert_path="alipayRootCert.crt";
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
certAlipayRequest.setServerUrl(gateway);
certAlipayRequest.setAppId(app_id);
certAlipayRequest.setPrivateKey(app_privateKey);
certAlipayRequest.setFormat("json");
certAlipayRequest.setCharset("UTF-8");
certAlipayRequest.setSignType("RSA2");
certAlipayRequest.setCertPath(app_cert_path);
certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path);
certAlipayRequest.setRootCertPath(alipay_root_cert_path);
DefaultAlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest);
AlipayFundTransAppPayRequest request = new AlipayFundTransAppPayRequest();
request.setBizContent("{" +
"\"out_biz_no\":\""+getRandomFileName()+"\"," +
"\"trans_amount\":\"8.88\"," +
"\"product_code\":\"STD_RED_PACKET\"," +
"\"biz_scene\":\"PERSONAL_PAY\"," +
"\"remark\":\"拼手气红包\"," +
"\"order_title\":\"钉钉拼手气红包\"," +
"\"business_params\":\"{\\\"sub_biz_scene\\\":\\\"REDPACKET\\\",\\\"payer_binded_alipay_uid:\\\"2088102177237745\\\"}\"" +
"}");
AlipayFundTransAppPayResponse response = alipayClient.certificateExecute(request);
{
"out_biz_no":"7386020191017",
"trans_amount":"8.88",
"product_code":"STD_RED_PACKET",
"biz_scene":"PERSONAL_PAY",
"remark":"拼手气红包",
"order_title":"钉钉拼手气红包",
"business_params":"{"sub_biz_scene":"REDPACKET","payer_binded_alipay_uid:"2088102177237745"}"
}
10月 17, 2019 11:55:46 上午 com.alipay.api.internal.util.AlipayLogger _logCommError
严重: 2019-10-17 11:55:46^_^alipay.fund.trans.app.pay^_^null^_^127.0.0.1^_^Mac OS X^_^alipay-sdk-java-4.5.0.ALL^_^https://openapi.alipaydev.com/gateway.do?app_cert_sn=f0909e13848a0a628360503b29ce3725&charset=UTF-8&alipay_root_cert_sn=6bc29aa3b4d406c43483ffea81e08d22&method=alipay.fund.trans.app.pay&sign=Nqt%2F9lQb9bLioZ3XgQ9fWvygDPPBrnYeEFjN9MZSJ9n78Na2QfranZxBlOvE01HPIitRkrx9IjUebRgsADKn6TsJWH6Yd32i%2BOVEdUtzBfLEVhTfS4AlWDKrpVwrDvyLVg3i0HfwVd%2BB6uploLNwV0P5yh3GtkLGDCF8fu6wADqIbzYG%2BMS2imZ03cDPtK6mZsNPRDt6NwyEhNdBd9cNM87o9h1lqUoeGBNn3%2FpiwAKNNFI24PvRW72FUStFz%2BYPQOVo8OrwMdSwbo2KFmvg4nMeUha7UOgAmkWgHBajK0x0WvvLekb1BXV7xbSXFs2ED%2Bx2%2FtJUEQ3oMR3NnYrimA%3D%3D&version=1.0&app_id=2016092500594774&sign_type=RSA2×tamp=2019-10-17+11%3A55%3A46&alipay_sdk=alipay-sdk-java-4.5.0.ALL&format=json^_^HTTP_ERROR_302^_^unknown protocol: mobilecashier.d6243.alipaydev.com
10月 17, 2019 11:55:46 上午 com.alipay.api.internal.util.AlipayLogger logBizError
严重: com.alipay.api.AlipayApiException: java.net.MalformedURLException: unknown protocol: mobilecashier.d6243.alipaydev.com
com.alipay.api.AlipayApiException: com.alipay.api.AlipayApiException: java.net.MalformedURLException: unknown protocol: mobilecashier.d6243.alipaydev.com
at com.alipay.api.AbstractAlipayClient._certificateExecute(AbstractAlipayClient.java:275)
at com.alipay.api.AbstractAlipayClient.certificateExecute(AbstractAlipayClient.java:229)
at com.alipay.api.AbstractAlipayClient.certificateExecute(AbstractAlipayClient.java:223)
at com.alipay.api.AbstractAlipayClient.certificateExecute(AbstractAlipayClient.java:217)
at qrcode.alipay.trade.app.pay.qrcode_app_pay.main(qrcode_app_pay.java:59)
Caused by: com.alipay.api.AlipayApiException: java.net.MalformedURLException: unknown protocol: mobilecashier.d6243.alipaydev.com
at com.alipay.api.AbstractAlipayClient.doPost(AbstractAlipayClient.java:1009)
at com.alipay.api.AbstractAlipayClient._certificateExecute(AbstractAlipayClient.java:237)
... 4 more
Caused by: java.net.MalformedURLException: unknown protocol: mobilecashier.d6243.alipaydev.com
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1963)
at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1958)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:551)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1957)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1525)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:246)
at com.alipay.api.internal.util.WebUtils.getResponseAsString(WebUtils.java:436)
at com.alipay.api.internal.util.WebUtils.doPost(WebUtils.java:155)
at com.alipay.api.internal.util.WebUtils.doPost(WebUtils.java:116)
at com.alipay.api.AbstractAlipayClient.doPost(AbstractAlipayClient.java:1005)
... 5 more
Caused by: java.net.MalformedURLException: unknown protocol: mobilecashier.d6243.alipaydev.com
at java.base/java.net.URL.<init>(URL.java:657)
at java.base/java.net.URL.<init>(URL.java:546)
at java.base/sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2659)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1843)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3084)
at java.base/java.net.URLConnection.getContentType(URLConnection.java:519)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentType(HttpsURLConnectionImpl.java:398)
at com.alipay.api.internal.util.WebUtils.getResponseAsString(WebUtils.java:433)
... 8 more
WebUtils.getResponseAsString(HttpURLConnection) line: 436
WebUtils.doPost(String, String, byte[], int, int, String, int) line: 155
WebUtils.doPost(String, Map<String,String>, String, int, int, String, int) line: 116
DefaultAlipayClient(AbstractAlipayClient).doPost(AlipayRequest<T>, String, String, String) line: 1005
DefaultAlipayClient(AbstractAlipayClient)._certificateExecute(AlipayRequest<T>, String, String) line: 237
DefaultAlipayClient(AbstractAlipayClient).certificateExecute(AlipayRequest<T>, String, String) line: 229
DefaultAlipayClient(AbstractAlipayClient).certificateExecute(AlipayRequest<T>, String) line: 223
DefaultAlipayClient(AbstractAlipayClient).certificateExecute(AlipayRequest<T>) line: 217
qrcode_app_pay.main(String[]) line: 60
//SDK文件WebUtils.class
protected static String getResponseAsString(HttpURLConnection conn) throws IOException {
String charset = getResponseCharset(conn.getContentType());
InputStream es = conn.getErrorStream();
if (es == null) {
//conn.getInputStream() 出现异常
//异常信息 unknown protocol: mobilecashier.d6243.alipaydev.com
return getStreamAsString(conn.getInputStream(), charset);
} else {
String msg = getStreamAsString(es, charset);
if (StringUtils.isEmpty(msg)) {
throw new IOException(conn.getResponseCode() + ":" + conn.getResponseMessage());
} else {
throw new IOException(msg);
}
}
}
#conn->delegate->respones
sun.net.www.MessageHeader@120f102b14 pairs: {null: HTTP/1.1 302 Found}{Server: Tengine/2.1.0}{Date: Thu, 17 Oct 2019 04:10:10 GMT}{Content-Type: application/octet-stream}{Connection: keep-alive}{Set-Cookie: zone=GZ00B; Domain=.alipaydev.com; Path=/}{location: mobilecashier.d6243.alipaydev.com:12200?alipay_exterface_invoke_assign_target=invoke_1845fdc8e294331080cb3ae27698daa3&alipay_exterface_invoke_assign_sign=_s_ln7d2_t_a_k_a_zfnx02f62_fev%2B_x32_qpm8ukh5_qo_xv%2F_wy2iy_hr2_i_xp4_qz_a%3D%3D}{connection: keep-alive}{content-length: 0}{set-cookie: JSESSIONID=8E05DCCF71F78EF8E8D1C3268E3ACAC4; Path=/; HttpOnly}{set-cookie: ALIPAYJSESSIONID=GZ00wcmu50ldarQsnJi2qwg2teuSJdsuperapiGZ00; Domain=.alipaydev.com; Path=/}{set-cookie: ctoken=xobwl7Tev1kFc61-; Domain=.alipaydev.com; Path=/}{Set-Cookie: spanner=r7Gde3HSucXTedbI2QGl1ewBN9Uv8Bn2Xt2T4qEYgj0=;path=/;secure;}{Via: gateway-2-1-2.daily.alipay.net[302],11.166.43.162:80[302]}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。