❶ 用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怎麼實現微信支付
具體方法步驟:
一、准備階段:已認證微信號,且通過微信支付認證專,這個可以看微信文檔,很詳屬細,這里就不再重復。