让使用微信支付的朋友最快速度接入微信支付.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调用