资源简介
该demo是本人测试过的,里面的坑爹的配置都已经在注释中说明位置,压缩包解压后就是web项目,jar包均可用,先看readme文件,根据文件进行操作应该没有问题的。有问题欢迎留言
代码片段和文件信息
package com.shusheng.refund;
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License Version 2.0 (the
* “License“); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing
* software distributed under the License is distributed on an
* “AS IS“ BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation please see
* .
*
*/
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
import java.net.URL;
import java.security.KeyStore;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
/**
* This example demonstrates how to create secure connections with a custom SSL
* context.
*/
public class ClientCustomSSL {
//商户号
//微信公众平台:“微信支付”--》“商户信息”--》“商户号”,将该值赋值给partner
private static String partner = “xxxx“;
//p12证书的位置
//微信公众平台:“微信支付”--》“商户信息”--》“交易数据”--》“详情请登录微信支付商户平台查看”(登录)--》“API安全”--》“API证书”--》“下载证书”
//下载证书后将apiclient_cert.p12放在src目录下面(出于安全考虑,请自行下载自己的证书)
private static String apiclient_certLocation = “apiclient_cert.p12“;
public static String doRefund(String urlString data) throws Exception {
KeyStore keyStore = KeyStore.getInstance(“PKCS12“);
URL url2 = ClientCustomSSL.class.getClassLoader().getResource(apiclient_certLocation);
URI uri = url2.toURI();
FileInputStream instream = new FileInputStream(new File(uri));//P12文件目录
try {
keyStore.load(instream partner.toCharArray());
} finally {
instream.close();
}
SSLContext sslcontext = SSLContexts.custom()
.loadKeyMaterial(keyStore partner.toCharArray())//这里也是写密码的
.build();
SSLConnectionSoc
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-03-21 00:48 weChatPayRefund\
文件 529 2016-03-20 23:24 weChatPayRefund\.classpath
文件 318 2016-03-20 23:24 weChatPayRefund\.myme
文件 1758 2016-03-21 00:48 weChatPayRefund\.project
目录 0 2016-03-20 23:24 weChatPayRefund\.settings\
文件 500 2016-03-20 23:24 weChatPayRefund\.settings\.jsdtscope
文件 364 2016-03-20 23:24 weChatPayRefund\.settings\org.eclipse.jdt.core.prefs
文件 483 2016-03-20 23:24 weChatPayRefund\.settings\org.eclipse.wst.common.component
文件 252 2016-03-20 23:24 weChatPayRefund\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2016-03-20 23:24 weChatPayRefund\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2016-03-20 23:24 weChatPayRefund\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2016-03-20 23:24 weChatPayRefund\WebRoot\
目录 0 2016-03-20 23:24 weChatPayRefund\WebRoot\me
文件 36 2016-03-20 23:24 weChatPayRefund\WebRoot\me
目录 0 2016-03-20 23:24 weChatPayRefund\WebRoot\WEB-INF\
目录 0 2016-03-21 08:33 weChatPayRefund\WebRoot\WEB-INF\classes\
目录 0 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\classes\com\
目录 0 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\
目录 0 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\
文件 4531 2016-03-21 00:05 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\ClientCustomSSL.class
文件 2174 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\MD5Util.class
文件 3529 2016-03-21 08:34 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\RefundUtil.class
文件 6319 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\RequestHandler.class
文件 3399 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\Sha1Util.class
文件 3416 2016-03-20 23:52 weChatPayRefund\WebRoot\WEB-INF\classes\com\shusheng\refund\TenpayUtil.class
文件 125 2016-03-21 08:33 weChatPayRefund\WebRoot\WEB-INF\classes\readme
目录 0 2016-03-20 23:47 weChatPayRefund\WebRoot\WEB-INF\lib\
文件 62050 2016-01-15 23:26 weChatPayRefund\WebRoot\WEB-INF\lib\commons-logging-1.1.3.jar
文件 44598 2016-01-15 23:26 weChatPayRefund\WebRoot\WEB-INF\lib\commons-logging-api-1.1.jar
文件 313898 2016-01-15 23:26 weChatPayRefund\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar
文件 590004 2016-01-15 23:26 weChatPayRefund\WebRoot\WEB-INF\lib\httpclient-4.3.4.jar
............此处省略17个文件信息
相关资源
- 仿微信源码
- Android 高仿微信头像裁切 源码程序
- Android 高仿微信实时聊天 基于百度云
- 支付宝 阿里支付 付款 交易查询 退款
- Android项目源码仿微信APP源码登录注册
- 仿微信图片选择AndroidStudio版
- android高仿微信聊天界面,语音,表情
- 微信发送或转发任意语音消息
- 微信聊天记录查看器.apk
- 2018最新个人免签支付宝、微信、QQ钱
- Android 高仿微信6.0主界面程序源码
- 智能切换适配微信6.6.1
- eclipse打jar包,unity微信登录,方便高
- 用Java实现的微信支付Demo
- 微信企业号java版开发
- 微信公众号现金红包java版
- 基于微信小程序的点餐系统
- itchat4j的jar包和源码 -- 用Java扩展个人
- Android 应用微信授权登录微信分享de
- 校园代领快递APP
- 微信支付java版完整demo-Eclipse项目包含
- Android高仿微信的聊天界面
- java 微信退款接口
- 微信支付 java版demo
- java开发微信公众号完整
- Java实现微信支付demo
- 仿微信朋友圈android源代码,亲测可用
- 微信飞机大战,JAVA版,设计完美,
- java微信分享源码
- Android ActionBar应用实战,高仿微信主界
评论
共有 条评论