怎样微信支付退款失败原因失败退款

微信退款是需要证书的&
以在windows为例,解压之后的文件
双击.p12结尾的文件,导入证书,会要求输入密码,密码就是商户ID,注意一定要是在自己的商户平台上下载的证书,不然会提示密码错误。
封装了一个RefundVo对象,字段设定根据官方文档
public class RefundVo {
private String mchId;
private String deviceI
private String nonceS
private String signT
private String transactionId;
private String outTradeNo;
private String outRefundNo;
private int totalF
private int refundF
private String refundFeeT
private String opUserId;
private String refundA
//省略get set方法
设置各个参数
String key = "xxxxxxx";
RefundVo vo = new RefundVo();
vo.setOutTradeNo("0333");//商户订单号(微信订单号二选一即可)
vo.setAppid("appid");
vo.setMchId("mchid");
vo.setOutRefundNo("0333");//某付款的定单号
vo.setTotalFee(1);//订单金额
vo.setRefundFee(1);退款金额
vo.setOpUserId("");//默认商户号
String certificatePath = "E:/工作/cert/apiclient_cert.p12";//证书的绝对路径
refund(key ,vo,certificatePath );
封装退款的结果
public class RefundResult {
private String returnC
private String returnM
private String resultC
private String errC
private String errCodeD
private String mchId;
private String deviceI
private String nonceS
private String transactionId;
private String outTradeNo;
private String outRefundNo;
private String refundId;
* ORIGINAL—原路退款
* BALANCE—退回到余额
private String refundC
* 申请退款金额
private int refundF
* 退款金额
private int settlementRefundF
private int totalF
private int settlementTotalF
private String feeT
private int cashF
private int cashRefundF
//省略set get方法
退款的方法
public RefundResult refund(String key,RefundVo vo,String certificatePath){
RefundResult refundResult = new RefundResult();
vo.setNonceStr(RandomUtil.wechatRandomString());//设置随机字符串
vo.setSign(new RefundBuilder().build(vo));//设置签名
check(vo);//检查参数
//将参数放入Map中
Map&String,String& params=new RefundBuilder().getParams(vo);
//转成Xml形式的String
String xml=XmlParseUtils.assembleXml(params);
&appid&wx0ec43b&/appid&
&mch_id&&/mch_id&
&nonce_str&6cefdb308e1e2e8aabd48cf79e546a02&/nonce_str&
&op_user_id&&/op_user_id&
&out_refund_no&&/out_refund_no&
&out_trade_no&&/out_trade_no&
&refund_fee&1&/refund_fee&
&total_fee&1&/total_fee&
&transaction_id&&/transaction_id&
&sign&FE56DD4AA85C0EECA82C&/sign&
//调用微信接口
result = HttpClientUtils.executeBySslPost(refundURL,xml,vo.getCertificatePath(),vo.getRefundVo().getMchId());//发送http请求
//接收xml解析的结果
Map&String, String& map = new HashMap&String,String&();
//返回结果为xml形式,转成map然后封装成refundResult即可
map = XmlParseUtils.parseXml(result);
refundResult = new RefundResultBuilder().build(map);
private void check(RefundVo vo){
if (VerifyUtils.isEmpty(vo.getAppid())) {
throw new PayException("申请退款参数为空——appid");
if (VerifyUtils.isEmpty(vo.getMchId())) {
throw new PayException("申请退款参数为空——mch_id");
if (VerifyUtils.isEmpty(vo.getNonceStr())) {
throw new PayException("申请退款参数为空——nonce_str");
if (VerifyUtils.isEmpty(vo.getSign())) {
throw new PayException("申请退款参数为空——sign");
if (VerifyUtils.isEmpty(vo.getTransactionId()) && VerifyUtils.isEmpty(vo.getOutTradeNo())) {
throw new PayException("申请退款参数为空——transaction_id或者out_trade_no");
if (VerifyUtils.isEmpty(vo.getOutRefundNo())) {
throw new PayException("申请退款参数为空——out_refund_no");
if (VerifyUtils.isEmpty(vo.getTotalFee())) {
throw new PayException("申请退款参数为空——total_fee");
if (VerifyUtils.isEmpty(vo.getRefundFee())) {
throw new PayException("申请退款参数为空——refund_fee");
if (VerifyUtils.isEmpty(vo.getOpUserId())) {
throw new PayException("申请退款参数为空——op_user_id");
public class RefundBuilder extends SignBuilder {
public Map&String, String& getParams(Refund vo) {
Map&String,String& params = new HashMap&String, String&();
if(VerifyUtils.isNotEmpty(vo.getAppid())){
params.put("appid",vo.getAppid());
if (VerifyUtils.isNotEmpty(vo.getMchId())) {
params.put("mch_id", vo.getMchId());
if (VerifyUtils.isNotEmpty(vo.getDeviceInfo())) {
params.put("device_info", vo.getDeviceInfo());
if(VerifyUtils.isNotEmpty(vo.getNonceStr())){
params.put("nonce_str",vo.getNonceStr());
if (VerifyUtils.isNotEmpty(vo.getSign())) {
params.put("sign", vo.getSign());
if (VerifyUtils.isNotEmpty(vo.getSignType())) {
params.put("sign_type", vo.getSignType());
if (VerifyUtils.isNotEmpty(vo.getTransactionId())) {
params.put("transaction_id", vo.getTransactionId());
if (VerifyUtils.isNotEmpty(vo.getOutTradeNo())) {
params.put("out_trade_no", vo.getOutTradeNo());
if (VerifyUtils.isNotEmpty(vo.getOutRefundNo())) {
params.put("out_refund_no", vo.getOutRefundNo());
if (VerifyUtils.isNotEmpty(vo.getTotalFee())) {
params.put("total_fee",Integer.toString(vo.getTotalFee()));
if (VerifyUtils.isNotEmpty(vo.getRefundFee())) {
params.put("refund_fee", Integer.toString(vo.getRefundFee()));
if (VerifyUtils.isNotEmpty(vo.getRefundFeeType())) {
params.put("refund_fee_type",vo.getRefundFeeType());
if (VerifyUtils.isNotEmpty(vo.getOpUserId())) {
params.put("op_user_id",vo.getOpUserId());
if (VerifyUtils.isNotEmpty(vo.getRefundAccount())) {
params.put("refund_account",vo.getRefundAccount());
http执行的方法
public static String executeBySslPost(String url, String body,String certificatePath,String password) throws Exception {
String result = "";
//指定读取证书格式为PKCS12
KeyStore keyStore = KeyStore.getInstance("PKCS12");
//读取本机存放的PKCS12证书文件
FileInputStream instream = new FileInputStream(new File(certificatePath));
//指定PKCS12的密码(商户ID)
keyStore.load(instream, password.toCharArray());
} finally {
instream.close();
SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, password.toCharArray()).build();
//指定TLS版本
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[]{"TLSv1"}, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
//设置httpclient的SSLSocketFactory
CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
HttpPost httppost = new HttpPost(url);
StringEntity reqEntity = new StringEntity(body, "UTF-8");
httppost.setEntity(reqEntity);
System.out.println("Executing request: " + httppost.getRequestLine());
CloseableHttpResponse response = null;
response = httpclient.execute(httppost);
result = EntityUtils.toString(response.getEntity(),"UTF-8");
} catch (Exception e) {
e.printStackTrace();
log.error("请求失败", e);
throw new RuntimeException(e);
} finally {
response.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
log.error("请求失败", e);
throw new RuntimeException(e);
} finally {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
最终的返回结果
System.out.println(JSON.toJSONString(result,true));
阅读(...) 评论()没有更多推荐了,
不良信息举报
举报内容:
微信支付之退款
举报原因:
原文地址:
原因补充:
最多只允许输入30个字
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!转账支付失败后微信发起退款通知--在线法律咨询|律师365(64365.com)
大家都在搜:
微信扫一扫 免费问律师
手机扫一扫 法律兜里装
转账支付失败后微信发起退款通知
转账支票背书:支票仅限于在其票据交换区域内背书转让。支票出票人向规定区域以外的收款人出票的,背书人向规定区域以外的被背书人转让票据的,区域外的银行不予受理,但出票人、背书人仍应承担票据责任。以背书转让的票据,背书应当连续。持票人以背书的连续,证明其票据权利。非经背书转让,而以其他合法方式取得票据的,依法举证,证明其票据权利。
1分钟提交法律咨询 2000多位 信得过的好律师 为您提供专业解答
(咨询请说明来自律师365)
地区:江苏 苏州|解答问题:39950条
一般是这样的
相关法律咨询
我和男朋友谈了两三个月,他在我身上花了一两万,我问他拿钱,他也没拒绝我,现在分手了,他拿微信记录和支付宝转账记录要起诉我。让我还钱。我想问,支付宝转账记录和微信记录能起诉我吗?
我和他说我没钱用了,他说有他呢,他给我。然后他自己主动每天100的生活费,转到我支付宝里,现在分手了,就起诉我,让我吃不了兜着走,说他家族企业有多大有多大。还和我父母对骂,疯狂砸门。说我们不报警,我们就是他爸妈。如果他起诉我,我有权利维护自己吗?因为现在我微信把他删了,没有什么了。他说他有。如果他造假怎么办
一个微信上认识的办信用卡,收年费5万多,支付宝转账的,他说他出车祸了之后他老婆给我发微信说他死了,给我退钱,到现在没退也没有回微信,请问我还怎么办?谢谢律师
您好,可以起诉,要求对方返还,借款纠纷一般可以在原告的经常居住地或者户籍所在地进行起诉,主张对方返还,一般简易程序3个月,普通程序6个月
在微信买的东西,商家发来的货却很明显不一样,现在要求退货,卖家不同意结果把我拉黑了,金额5500,微信直接转账方式,聊天记录还在,该怎么办
需要看一下详细资料。如果可以,你可以把详细情况方面拿给我看一下。可以在工作时间拨打我的电话。
关注此问题的人还看了
相关法律知识
相关律师回复
牛秀颖律师 最近回复:
章丽婷律师 最近回复:
李炜衡律师 最近回复:
周边专业律师
扫描二维码
更多惊喜等着您!
立即提问、免费短信回复
律师365,优质法律服务平台
400-64365-60服务时间:周一至周六8:00~22:00服务指南平台保障律师入驻常见问题
Copyright(C) 成都六四三六五科技有限公司 版权所有 蜀ICP备号 增值电信业务经营许可证(川B2-)
1002律师在线
2378今日解答微信支付Pos操作——四、退款_腾讯视频
三倍流畅播放
1080P蓝光画质
新剧提前看
1080P蓝光画质
纯净式无框播放器
三倍流畅播放
扫一扫 手机继续看
下载需先安装客户端
{clientText}
客户端特权:
3倍流畅播放
当前播放至 {time}
扫一扫 手机继续看
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要
副标题要不要微信支付失败钱扣了怎么办
微信支付失败一般钱是可以返回的,但是遇到微信支付失败钱扣了就该棘手了,一般遇到这种状况,该紧急致电微信人工服务。
失败一般钱是可以返回的,但是遇到微信支付失败钱扣了就该棘手了,一般遇到这种状况,请紧急致电微信人工服务。
遇到微信支付失败钱扣了怎么办呢?全国免费客服热线:(400-002-0047)人工服务热线:(400-002-0047) 办理查询、转账、提现、投诉、退款、充值、维权、资金解冻、等等!
失败钱扣了的原因可能有系统延迟问题,刷新一下,也有可能是中途被中断支付。例如刚开通的微信,它是有微信支付限额的,如果超出范围会被中断支付。如果钱扣了可以拨打人工服务电话。
精彩不断,文章连连看:
网络营销教学参考导航
网络营销知识库
网络营销工具与资源}

我要回帖

更多关于 微信退款证书验证失败 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信