讓使用微信支付的朋友最快速度接入微信支付.php
兩行代碼解決微信支付提供的各類服務, 開箱即用, 可擴展性超強(只需根據服務的上下行協議定義協議類後, 放入工廠便可獲取調用結果).java
全部服務在單元測試類(WXPayClientTest.java)中均已測試經過, 下行參數response.isSuccess == true
表示服務調用成功.segmentfault
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_1api
String nonceStr = SDKUtils.genRandomStringByLength(32); UnifiedOrderRequest request = new UnifiedOrderRequest("wuspace-899",SDKUtils.genOutTradeNo(),1, "192.168.1.1", asyncNotifyUrl, "NATIVE", nonceStr); UnifiedOrderResponse response = wxPayClient.execute(request); Assert.assertNotNull(response); LOG.info(JSON.toJSONString(response));
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_1微信
String nonceStr = SDKUtils.genRandomStringByLength(32); UnifiedOrderRequest request = new UnifiedOrderRequest("wuspace-899",SDKUtils.genOutTradeNo(), 1, "192.168.1.1", asyncNotifyUrl, "JSAPI", nonceStr); request.setOpenId("oKVmeuHht8J0Ni58CSNe474AHA3E"); UnifiedOrderResponse response = wxPayClient.execute(request); Assert.assertNotNull(response); LOG.info(JSON.toJSONString(response));
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_1架構
String nonceStr = SDKUtils.genRandomStringByLength(32); UnifiedOrderRequest request = new UnifiedOrderRequest("wuspace-899",SDKUtils.genOutTradeNo(), 1, "192.168.1.1", asyncNotifyUrl, "APP", nonceStr); UnifiedOrderResponse response = wxPayClient.execute(request); Assert.assertNotNull(response); LOG.info(JSON.toJSONString(response));
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2app
String nonceStr = SDKUtils.genRandomStringByLength(32); String customerOpenId = "oKVmeuHht8J0Ni58CSNe474AHA3E"; MchPayRequest mchPayRequest = new MchPayRequest(SDKUtils.genOutTradeNo(), customerOpenId, "NO_CHECK", 100, "xxxx年xx月結算", "192.168.1.1", nonceStr); MchPayResponse response = wxPayVIPClient.execute(mchPayRequest); Assert.assertNotNull(response); LOG.info(JSON.toJSONString(response));
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_4&index=6dom
String nonceStr = SDKUtils.genRandomStringByLength(32); RefundRequest request = new RefundRequest("T15121416014891124211768", SDKUtils.genOutRefundNo(), 1, 1, "112102020", nonceStr); RefundResponse response = wxPayVIPClient.execute(request); Assert.assertNotNull(response); LOG.info(JSON.toJSONString(response));
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_7異步
String notifyTxt = "<xml>\n" + " <appid><![CDATA[wx2421b1c4370eccdcd]]></appid>\n" + " <attach><![CDATA[支付測試]]></attach>\n" + " <bank_type><![CDATA[CFT]]></bank_type>\n" + " <fee_type><![CDATA[CNY]]></fee_type>\n" + " <is_subscribe><![CDATA[Y]]></is_subscribe>\n" + " <mch_id><![CDATA[10000100]]></mch_id>\n" + " <nonce_str><![CDATA[5d2b6c2a8db53831f7eda20af46e531c]]></nonce_str>\n" + " <openid><![CDATA[oUpF8uMEb4qRXf22hE3X68TekukE]]></openid>\n" + " <out_trade_no><![CDATA[1409811653]]></out_trade_no>\n" + " <result_code><![CDATA[SUCCESS]]></result_code>\n" + " <return_code><![CDATA[SUCCESS]]></return_code>\n" + " <sign><![CDATA[B552ED6B279343CB493C5DD0D78AB241]]></sign>\n" + " <sub_mch_id><![CDATA[10000100]]></sub_mch_id>\n" + " <time_end><![CDATA[20140903131540]]></time_end>\n" + " <total_fee>1</total_fee>\n" + " <trade_type><![CDATA[JSAPI]]></trade_type>\n" + " <transaction_id><![CDATA[1004400740201409030005092168]]></transaction_id>\n" + "</xml>"; PayNotifyResponse response = wxPayClient.parseNotify(notifyTxt, PayNotifyResponse.class); Assert.assertNotNull(response); LOG.info(JSON.toJSONString(response));
文檔詳見: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
目前公司未使用, 待續......
該SDK設計了一個服務工廠, 該工廠中包含HTTP執行器/返回數據解析方式(json/xml)/入參數據格式(json/xml)構造等, 開發人員須要增長服務僅須要根據服務協議文檔編寫上下行協議, 並在協議中指明API接口和返回數據類型, 再將上行協議放入工廠中執行便可; 可參考已完成的服務協議進行擴展編寫.
微信服務號SDK-兩行代碼解決API調用
支付寶支付SDK-兩行代碼解決支付
平安銀行銀企直連SDK-兩行代碼解決API調用