❶ 用java怎么实现微信支付
具体方法步骤:
一、准备阶段:已认证微信号,且通过微信支付认证,这内个可以看微信文档,容很详细,这里就不再重复。
❷ 怎么用java调用微信支付接口
java调用微信支付接口方法:x0d=newRequestHandler(super.getRequest(),super.getResponse());x0dx0ax0dx0a//获取token//两小时内有效,两小时后重新获取x0dx0ax0dx0aToken=requestHandler.GetToken();x0dx0ax0dx0a//更新token到应用中x0dx0ax0dx0arequestHandler.getTokenReal();x0dx0ax0dx0aSystem.out.println("微信支付获取token=======================:"+Token);x0dx0ax0dx0ax0dx0ax0dx0a//requestHandler初始化x0dx0ax0dx0arequestHandler.init();x0dx0ax0dx0arequestHandler.init(appid,appsecret,appkey,partnerkey,key);x0dx0ax0dx0ax0dx0ax0dx0a//--------------------------------本地系统生成订单-------------------------------------x0dx0ax0dx0a//设置package订单参数x0dx0ax0dx0aSortedMappackageParams=newTreeMap();x0dx0ax0dx0apackageParams.put("bank_type","WX");//支付类型x0dx0ax0dx0apackageParams.put("body","xxxx");//商品描述x0dx0ax0dx0apackageParams.put("fee_type","1");//银行币种x0dx0ax0dx0apackageParams.put("input_charset","UTF-8");//字符集x0dx0ax0dx0apackageParams.put("notify_url","http://xxxx.com/xxxx/wxcallback");//通知地址这里的通知地址使用外网地址测试,注意80端口是否打开。x0dx0ax0dx0apackageParams.put("out_trade_no",no);//商户订单号x0dx0ax0dx0apackageParams.put("partner",partenerid);//设置商户号x0dx0ax0dx0apackageParams.put("spbill_create_ip",super.getRequest().getRemoteHost());//订单生成的机器IP,指用户浏览器端IPx0dx0ax0dx0apackageParams.put("total_fee",String.valueOf(rstotal));//商品总金额,以分为单位x0dx0ax0dx0ax0dx0ax0dx0a//设置支付参数x0dx0ax0dx0aSortedMapsignParams=newTreeMap();x0dx0ax0dx0asignParams.put("appid",appid);x0dx0ax0dx0asignParams.put("noncestr",noncestr);x0dx0ax0dx0asignParams.put("traceid",PropertiesUtils.getOrderNO());x0dx0ax0dx0asignParams.put("timestamp",timestamp);x0dx0ax0dx0asignParams.put("package",packageValue);x0dx0ax0dx0asignParams.put("appkey",this.appkey);x0dx0ax0dx0ax0dx0ax0dx0a//生成支付签名,要采用URLENCODER的原始值进行SHA1算法!x0dx0ax0dx0aStringsign="";x0dx0ax0dx0atry{x0dx0ax0dx0asign=Sha1Util.createSHA1Sign(signParams);x0dx0ax0dx0a}catch(Exceptione){x0dx0ax0dx0ae.printStackTrace();x0dx0ax0dx0a}x0dx0ax0dx0ax0dx0ax0dx0a//增加非参与签名的额外参数x0dx0ax0dx0asignParams.put("sign_method","sha1");x0dx0ax0dx0asignParams.put("app_signature",sign);//api支付拼包结束------------------------------------x0dx0ax0dx0ax0dx0ax0dx0a//获取=requestHandler.sendPrepay(signParams);x0dx0ax0dx0aSystem.out.println("prepayid:"+prepayid);x0dx0ax0dx0a//--------------------------------生成完成---------------------------------------------x0dx0ax0dx0ax0dx0ax0dx0a//生成预付快订单完成,返回给android,ios掉起微信所需要的参数。x0dx0ax0dx0aSortedMappayParams=newTreeMap();x0dx0ax0dx0apayParams.put("appid",appid);x0dx0ax0dx0apayParams.put("noncestr",noncestr);x0dx0ax0dx0apayParams.put("package","Sign=WXPay");x0dx0ax0dx0apayParams.put("partnerid",partenerid);x0dx0ax0dx0apayParams.put("prepayid",prepayid);x0dx0ax0dx0apayParams.put("appkey",this.appkey);x0dx0ax0dx0a//这里除1000是因为参数长度限制。x0dx0ax0dx0ainttime=(int)(System.currentTimeMillis()/1000);x0dx0ax0dx0apayParams.put("timestamp",String.valueOf(time));.out.println("timestamp:"+time);x0dx0ax0dx0ax0dx0ax0dx0a//签名x0dx0ax0dx0aStringpaysign="";x0dx0ax0dx0atry{x0dx0ax0dx0apaysign=Sha1Util.createSHA1Sign(payParams);x0dx0ax0dx0a}catch(Exceptione){x0dx0ax0dx0ae.printStackTrace();x0dx0ax0dx0a}x0dx0ax0dx0apayParams.put("sign",paysign);x0dx0ax0dx0ax0dx0ax0dx0a//拼json数据返回给客户端=newBasicDBObject();x0dx0ax0dx0abackObject.put("appid",appid);x0dx0ax0dx0abackObject.put("noncestr",payParams.get("noncestr"));x0dx0ax0dx0abackObject.put("package","Sign=WXPay");x0dx0ax0dx0abackObject.put("partnerid",payParams.get("partnerid"));x0dx0ax0dx0abackObject.put("prepayid",payParams.get("prepayid"));x0dx0ax0dx0abackObject.put("appkey",this.appkey);x0dx0ax0dx0abackObject.put("timestamp",payParams.get("timestamp"));x0dx0ax0dx0abackObject.put("sign",payParams.get("sign"));=dataObject.toString();x0dx0ax0dx0aSystem.out.println("backstr:"+backstr);;x0dx0ax0dx0ax0dx0ax0dx0a====================到此为止,预付款订单已生成,并且已返回客户端====================x0dx0ax0dx0ax0dx0ax0dx0a//坐等微信服务器通知,通知的地址就是生成预付款订单的notify_=newResponseHandler(request,response);x0dx0ax0dx0aresHandler.setKey(partnerkey);x0dx0ax0dx0a//创建请求对象x0dx0ax0dx0a//RequestHandlerqueryReq=newRequestHandler(request,response);x0dx0ax0dx0a//queryReq.init();x0dx0ax0dx0aif(resHandler.isTenpaySign()==true){x0dx0ax0dx0a//商户订单号x0dx0ax0dx0aStringout_trade_no=resHandler.getParameter("out_trade_no");x0dx0ax0dx0aSystem.out.println("out_trade_no:"+out_trade_no);x0dx0ax0dx0a//财付通订单号x0dx0ax0dx0aStringtransaction_id=resHandler.getParameter("transaction_id");x0dx0ax0dx0aSystem.out.println("transaction_id:"+transaction_id);x0dx0ax0dx0a//金额,以分为单位x0dx0ax0dx0aStringtotal_fee=resHandler.getParameter("total_fee");x0dx0ax0dx0a//如果有使用折扣券,discount有值,total_fee+discount=原请求的total_feex0dx0ax0dx0aStringdiscount=resHandler.getParameter("discount");x0dx0ax0dx0a//支付结果x0dx0ax0dx0aStringtrade_state=resHandler.getParameter("trade_state");x0dx0ax0dx0ax0dx0ax0dx0a//判断签名及结果x0dx0ax0dx0aif("0".equals(trade_state)){x0dx0ax0dx0a//------------------------------x0dx0ax0dx0a//即时到账处理业务开始x0dx0ax0dx0a//------------------------------.out.println("----------------业务逻辑执行-----------------");x0dx0ax0dx0ax0dx0ax0dx0a//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——x0dx0ax0dx0aSystem.out.println("----------------业务逻辑执行完毕-----------------");x0dx0ax0dx0aSystem.out.println("success");//请不要修改或删除.out.println("即时到账支付成功");x0dx0ax0dx0a//给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知x0dx0ax0dx0aresHandler.sendToCFT("success");x0dx0ax0dx0ax0dx0ax0dx0a//给微信服务器返回success否则30分钟通知8次x0dx0ax0dx0areturn"success";x0dx0ax0dx0a}else{x0dx0ax0dx0aSystem.out.println("通知签名验证失败");x0dx0ax0dx0aresHandler.sendToCFT("fail");x0dx0ax0dx0aresponse.setCharacterEncoding("utf-8");x0dx0ax0dx0a}x0dx0ax0dx0a}else{x0dx0ax0dx0aSystem.out.println("fail-Md5failed");
❸ java开发微信扫码支付,怎么做测试,公众账号ID,商户号这些怎么来
一、直接接入微信支付二、通过微信二次开发商的平台接入支付功能,三、在微信平台中加入微网页,四、通过第三方APP收款,
❹ 微信支付Java如何判断回调
微信支付Java判断回调方法:
微信支付完成支付调用的时候,在传入的参数中有一个是执行支付完成之后结果回调的参数,这个回调函数就是微信调用这个接口来将支付成功的结果。
❺ java中调用微信支付接口时当交易状态值NOTPAY是怎么支付,
关闭订单后再重新生成prepay_id
❻ 用Java怎么实现微信支付
具体方法步骤:
一、准备阶段:已认证微信号,且通过微信支付认证专,这个可以看微信文档,很详属细,这里就不再重复。