• 大小: 1.79MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-02
  • 语言: 其他
  • 标签: allinpay  通联  支付  

资源简介

allinpay 支付的实例代码,这只是部分,需要其它的请联系我。 帮忙找

资源截图

代码片段和文件信息

package com.allinpay.syb.lib;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Map;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;

import org.apache.commons.logging.Log;

public class HttpConnectionUtil {
private HttpURLConnection conn;
private String connectUrl;

public HttpConnectionUtil(String connectUrl){
this.connectUrl = connectUrl;
}

public void init() throws Exception{
URL url = new URL(connectUrl);
System.setProperty(“java.protocol.handler.pkgs“ “javax.net.ssl“);
    HostnameVerifier hv = new HostnameVerifier() {
         public boolean verify(String urlHostName SSLSession session) {
         return urlHostName.equals(session.getPeerHost());
         }
    };
    HttpsURLConnection.setDefaultHostnameVerifier(hv);
     URLConnection conn = url.openConnection();
     conn.setDoInput(true);
     conn.setDoOutput(true);
     conn.setReadTimeout(60000);
     conn.setConnectTimeout(30000);
     if (conn instanceof HttpsURLConnection){
     HttpsURLConnection httpsConn = (HttpsURLConnection)conn;
     httpsConn.setSSLSocketFactory(SSLUtil.getInstance().getSSLSocketFactory());
     } else if (conn instanceof HttpURLConnection){
     HttpURLConnection httpConn = (HttpURLConnection)conn;
     } else {
     throw new Exception(“不是http/https协议的url“);
     }
     this.conn = (HttpURLConnection)conn;
     initDefaultPost();
}

public void destory(){
try{
if(this.conn!=null){
this.conn.disconnect();
}
}catch(Exception e){

}
}

    private void initDefaultPost() throws Exception{
     conn.setDoOutput(true);
     conn.setDoInput(true);
     conn.setRequestMethod(“POST“);
     conn.setUseCaches(false);
     conn.setInstanceFollowRedirects(true);
     conn.setRequestProperty(“Content-Type“ “application/x-www-form-urlencoded“);
    }
    
    public byte[] postParams(Map paramsboolean readreturn) throws IOException {
     StringBuilder outBuf = new StringBuilder();
     boolean isNotFirst = false;
     for (Map.Entry entry: params.entrySet()){
     if (isNotFirst)
     outBuf.append(‘&‘);
     isNotFirst = true;
     outBuf
     .append(entry.getKey())
     .append(‘=‘)
     .append(URLEncoder.encode(entry.getValue() “UTF-8“));
     }
     System.out.println(“参数:“+outBuf.toString());
     return postParams(outBuf.toString()readreturn);
    }
    
    public byte[] postParams(String messageboolean readreturn) throws IOException {
     DataOutputStream out = new DataOutputStream(conn.getOutputStream());
     out.write(message.getBytes(“UTF-8“));
     out.close();
     if(readreturn){
     return 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-12-25 13:27  unionorder_demo\
     目录           0  2016-12-25 13:27  unionorder_demo\java\
     目录           0  2017-07-27 09:37  unionorder_demo\java\uniondemo\
     文件         841  2016-07-13 10:40  unionorder_demo\java\uniondemo\.classpath
     文件        1042  2016-09-25 23:15  unionorder_demo\java\uniondemo\.project
     目录           0  2017-07-27 09:37  unionorder_demo\java\uniondemo\.settings\
     文件         503  2016-07-13 10:40  unionorder_demo\java\uniondemo\.settings\.jsdtscope
     文件          88  2016-07-13 10:46  unionorder_demo\java\uniondemo\.settings\org.eclipse.core.resources.prefs
     文件         395  2016-07-13 10:40  unionorder_demo\java\uniondemo\.settings\org.eclipse.jdt.core.prefs
     文件         455  2016-07-13 10:40  unionorder_demo\java\uniondemo\.settings\org.eclipse.wst.common.component
     文件         345  2016-07-13 10:40  unionorder_demo\java\uniondemo\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2016-07-13 10:40  unionorder_demo\java\uniondemo\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2016-07-13 10:40  unionorder_demo\java\uniondemo\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\WebContent\
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\WebContent\meta-INF\
     文件          39  2016-07-13 10:40  unionorder_demo\java\uniondemo\WebContent\meta-INF\MANIFEST.MF
     目录           0  2017-07-27 09:37  unionorder_demo\java\uniondemo\WebContent\WEB-INF\
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\
     文件      232019  2015-11-12 10:58  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\commons-beanutils-1.8.3.jar
     文件      575389  2015-11-12 10:57  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\commons-collections-3.2.1.jar
     文件      284220  2015-11-12 10:51  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\commons-lang-2.6.jar
     文件       62050  2015-11-12 10:56  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\commons-logging-1.1.3.jar
     文件       86487  2015-11-12 10:55  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\ezmorph-1.0.6.jar
     文件      159123  2015-11-12 10:37  unionorder_demo\java\uniondemo\WebContent\WEB-INF\lib\json-lib-2.4-jdk15.jar
     文件        1082  2016-07-13 12:05  unionorder_demo\java\uniondemo\WebContent\WEB-INF\web.xml
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\build\
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\build\classes\
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\build\classes\com\
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\build\classes\com\allinpay\
     目录           0  2016-12-25 13:27  unionorder_demo\java\uniondemo\build\classes\com\allinpay\syb\
     目录           0  2017-07-27 09:37  unionorder_demo\java\uniondemo\build\classes\com\allinpay\syb\lib\
............此处省略74个文件信息

评论

共有 条评论