{"id":61,"date":"2020-09-23T16:36:28","date_gmt":"2020-09-23T08:36:28","guid":{"rendered":"http:\/\/blog.kijk.top\/?p=61"},"modified":"2026-04-02T17:32:33","modified_gmt":"2026-04-02T09:32:33","slug":"%e6%94%af%e4%bb%98%e5%ae%9d%e5%be%ae%e4%bf%a1%e6%94%af%e4%bb%98%e7%9a%84%e7%ae%80%e5%8d%95%e5%b0%81%e8%a3%85-easypay","status":"publish","type":"post","link":"http:\/\/blog.kijk.top\/?p=61","title":{"rendered":"\u652f\u4ed8\u5b9d&#038;\u5fae\u4fe1\u652f\u4ed8\u7684\u7b80\u5355\u5c01\u88c5-EasyPay"},"content":{"rendered":"\n<p>\u5fae\u4fe1\u548c\u652f\u4ed8\u5b9d\u7684\u652f\u4ed8SDK\u6709\u65f6\u5019\u8c03\u8bd5\u771f\u7684\u5f88\u8ba9\u4eba\u6293\u72c2\uff0c\u4e3a\u4e86\u80fd\u591f\u8ba9\u652f\u4ed8\u53d8\u5f97\u987a\u5229\u4e00\u70b9\u5c31\u81ea\u5df1\u5199\u4e86\u4e2a\u5f88\u7b80\u5355\u7684\u5c01\u88c5\uff08Java\u7248\u672c\uff09\uff0c\u53d6\u540d\uff1aEasyPay\u3002<\/p>\n\n\n\n<p>\u9879\u76ee\u5730\u5740\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/liangdodo\/easypay-sdk\" target=\"_blank\"><span class=\"has-inline-color has-vivid-cyan-blue-color\">https:\/\/github.com\/liangdodo\/easypay-sdk<\/span><\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#df0421\" class=\"has-inline-color\">\u6ce8\uff1a\u7531\u4e8e\u672c\u9879\u76ee\u521b\u5efa\u65f6\u95f4\u6bd4\u8f83\u4e45\u8fdc\uff0c\u53ef\u80fd\u4e0e\u652f\u4ed8\u5e73\u53f0\u6700\u65b0\u7248\u672c\u7684\u63a5\u53e3\u4f1a\u6709\u51fa\u5165\uff0c\u6240\u4ee5\u4f7f\u7528\u65f6\u8bf7\u53c2\u8003\u65e7\u6587\u6863\u3002<\/mark><\/p>\n\n\n\n<p>\u5fae\u4fe1\u53c2\u8003\u6587\u6863\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/index.html\" target=\"_blank\">https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/index.html<\/a><\/p>\n\n\n\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>\u4e00\u3001\u5728\u4f60\u9879\u76ee\u7684pom.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4f9d\u8d56<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!--\u6dfb\u52a0\u79c1\u6709\u4ed3\u5e93--&gt;\n&lt;repositories&gt;\n        &lt;repository&gt;\n            &lt;id&gt;easypay-sdk-release&lt;\/id&gt;\n            &lt;name&gt;easypay-sdk-release Repository&lt;\/name&gt;\n            &lt;url&gt;http:\/\/nexus.kijk.top:7001\/content\/repositories\/easypay-sdk-release\/&lt;\/url&gt;\n            &lt;releases&gt;\n                &lt;enabled&gt;true&lt;\/enabled&gt;\n            &lt;\/releases&gt;\n            &lt;snapshots&gt;\n                &lt;enabled&gt;false&lt;\/enabled&gt;\n            &lt;\/snapshots&gt;\n        &lt;\/repository&gt;\n&lt;\/repositories&gt;\n\n&lt;!--\u6dfb\u52a0easypay-sdk\u4f9d\u8d56--&gt;\n&lt;dependencies&gt;\n         &lt;dependency&gt;\n            &lt;groupId&gt;com.nossiac.jx&lt;\/groupId&gt;\n            &lt;artifactId&gt;easypay-sdk&lt;\/artifactId&gt;\n            &lt;version&gt;1.0-RELEASES&lt;\/version&gt;\n\n            &lt;exclusions&gt;\n                &lt;exclusion&gt;\n                    &lt;groupId&gt;org.slf4j&lt;\/groupId&gt;\n                    &lt;artifactId&gt;slf4j-simple&lt;\/artifactId&gt;\n                &lt;\/exclusion&gt;\n            &lt;\/exclusions&gt;\n\n        &lt;\/dependency&gt;\n&lt;\/dependencies&gt;\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u4e8c\u3001\u521d\u59cb\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        \/\/\u914d\u7f6e\u652f\u4ed8\u5b9d\n        AlipayConfig alipayConfig=new AlipayConfig();\n        alipayConfig.setAppId(\"\u652f\u4ed8\u5b9dAPPID\");\n        alipayConfig.setAppPrivateKey(\"\u5546\u6237\u79c1\u94a5\");\n        alipayConfig.setAlipayPublicKey(\"\u652f\u4ed8\u5b9d\u516c\u94a5\");\n        alipayConfig.setNotifyUrl(\"\u5f02\u6b65\u901a\u77e5URL\");\n\n        \/\/\u914d\u7f6e\u5fae\u4fe1\n        WxpayConfig wxpayConfig=new WxpayConfig();\n        wxpayConfig.setAppID(\"\u5fae\u4fe1APPID\");\n        wxpayConfig.setMchID(\"\u5fae\u4fe1MchId\");\n        wxpayConfig.setCertPath(\"\u5fae\u4fe1\u652f\u4ed8\u8bc1\u4e66\u8def\u5f84\uff08\u9000\u6b3e\u7b49\u9700\u8981\u7528\u5230\uff09\");\n        wxpayConfig.setKey(\"\u5fae\u4fe1\u652f\u4ed8Key\");\n        wxpayConfig.setSignType(WXPayConstants.SignType.HMACSHA256);\/\/\u7b7e\u540d\u65b9\u5f0f\n        wxpayConfig.setNotifyUrl(\"\u5f02\u6b65\u901a\u77e5URL\");\n\n        \/\/\u521b\u5efaeasyPayService\u5bf9\u8c61\n        EasyPayService easyPayService = new EasyPayServiceImpl();\n        easyPayService.setAlipayConfig(alipayConfig);\/\/\u8bbe\u7f6e\u652f\u4ed8\u5b9d\u914d\u7f6e\u53c2\u6570\n        easyPayService.setWxpayConfig(wxpayConfig);\/\/\u8bbe\u7f6e\u5fae\u4fe1\u914d\u7f6e\u53c2\u6570<\/code><\/pre>\n\n\n\n<p>\u4e09\u3001\u53d1\u8d77\u652f\u4ed8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        \/\/\u586b\u5145\u548c\u8bbe\u7f6e\u652f\u4ed8\u53c2\u6570\n        EasyPayRequest easyPayRequest=new EasyPayRequest();\n        easyPayRequest.setTradeNo(\"123456789\");\/\/\u8ba2\u5355\u53f7\n        easyPayRequest.setAmount(0.01F);\/\/\u652f\u4ed8\u91d1\u989d\n        easyPayRequest.setSubject(\"\u6d4b\u8bd5\u652f\u4ed8\");\/\/\u652f\u4ed8\u6807\u9898\n        easyPayRequest.setBody(\"\u9644\u52a0\u5185\u5bb9\");\/\/\u9644\u52a0\u5185\u5bb9\n        easyPayRequest.setOpenid(\"xxx\");\/\/\u5fae\u4fe1JsApi\u7b49\u652f\u4ed8\u65f6\u5fc5\u4f20\n        easyPayRequest.setProductId(\"xxx\");\/\/\u5fae\u4fe1Native\u652f\u4ed8\u65f6\u5fc5\u4f20\n        easyPayRequest.setTimeout(600);\/\/\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\uff08\u79d2\uff09\n        easyPayRequest.setReturnUrl(\"http:\/\/xxxxx.html\");\/\/\u652f\u4ed8\u5b9d\u7f51\u9875\u652f\u4ed8\u4ed8\u6b3e\u5b8c\u540e\u8981\u8df3\u8f6c\u5230\u7684\u7684\u9875\u9762URL\n        easyPayService.setEasyPayRequest(easyPayRequest);\/\/\u8bbe\u7f6e\u8bf7\u6c42\u6570\u636e\u5bf9\u8c61\n        easyPayService.setEasyPayType(EasyPayTypeEnum.WXPAY_NATIVE);\/\/\u8bbe\u7f6e\u652f\u4ed8\u65b9\u5f0f(\u652f\u4ed8\u65b9\u5f0f\u9644\u5728\u672c\u6587\u672b\u5c3e\u5904)\n\n        \/\/\u53d1\u8d77\u652f\u4ed8\u8bf7\u6c42\n\tObject obj= easyPayService.pay();\/\/\u53d1\u8d77\u652f\u4ed8\n        System.out.println(JSON.toJSONString(obj));\/\/\u6253\u5370\u8fd4\u56de\u7ed3\u679c<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u56db\u3001\u56de\u8c03\u901a\u77e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/**\n     * \u652f\u4ed8\u5b9d\u5f02\u6b65\u901a\u77e5\n     *\/\n    @PostMapping(value = \"\/alipay\/notify\")\n    public String alipayNotify(@RequestParam Map&lt;String,String&gt; notifyData) {\n        \/\/System.out.println(notifyMap);\n        easyPayService.setEasyPayPlatform(EasyPayPlatformEnum.ALIPAY);\/\/\u8bbe\u7f6e\u652f\u4ed8\u5e73\u53f0\uff08\u652f\u4ed8\u5e73\u53f0\u9644\u5728\u672c\u6587\u672b\u5c3e\u5904\uff09\n        EasyPayNotify easyPayNotify=easyPayService.notify(notifyData);\n        System.out.println(easyPayNotify);\n\n        if(easyPayNotify!=null){\n            AlipayNotify alipayNotify=easyPayNotify.getAlipayNotify();\n\n            \/\/\u652f\u4ed8\u6210\u529f\n            if(alipayNotify.getTradeStatus().equals(\"TRADE_SUCCESS\")){\n\n                \/\/\u6ce8\uff1a\u652f\u4ed8\u5b9d\u53ea\u9000\u6b3e\u90e8\u5206\u91d1\u989d\u65f6\u4e5f\u4f1a\u89e6\u53d1\u56de\u8c03\u901a\u77e5\uff0c\u6240\u4ee5\u9700\u8981\u8fc7\u6ee4\u6389\u9000\u6b3e\u89e6\u53d1\u7684\u56de\u8c03\u901a\u77e5\uff0c\uff08\u652f\u4ed8\u5b9d\u7684\u5947\u8469\u903b\u8f91....\uff09\n                if(\n                        null!=notifyData.get(\"out_biz_no\") &amp;&amp;\n                        null!=notifyData.get(\"refund_fee\") &amp;&amp;\n                        null!=notifyData.get(\"gmt_refund\")\n                ){\n                    return \"success\";\n                }\n                 \/\/easyPayNotify\u548calipayNotify\u5bf9\u8c61\u91cc\u6709\u4f60\u9700\u8981\u7684\u6570\u636e\uff0c\u8bf7\u81ea\u884c\u67e5\u770b\n                \/\/\u8fd9\u91cc\u5199\u4f60\u7684\u4e1a\u52a1\u903b\u8f91\u4ee3\u7801......\n            }\n\n            return \"success\";\n        }\n\n        return \"fail\";\n    }\n\n\n    \/**\n     * \u5fae\u4fe1\u5f02\u6b65\u901a\u77e5\n     *\/\n    @PostMapping(value=\"\/wxpay\/notify\",produces = MediaType.TEXT_XML_VALUE)\n    public String wxpayNotify(@RequestBody String notifyData){\n        easyPayService.setEasyPayPlatform(EasyPayPlatformEnum.WXPAY);\/\/\u8bbe\u7f6e\u652f\u4ed8\u5e73\u53f0\n        EasyPayNotify easyPayNotify=easyPayService.notify(notifyData);\n        System.out.println(easyPayNotify);\n\n        if(easyPayNotify!=null){\n            \/\/\u652f\u4ed8\u6210\u529f\n            WxpayNotify wxpayNotify=easyPayNotify.getWxpayNotify();\n\n            if(wxpayNotify.getResultCode().equals(\"SUCCESS\")){\n                \/\/easyPayNotify\u548cwxpayNotify\u5bf9\u8c61\u91cc\u6709\u4f60\u9700\u8981\u7684\u6570\u636e\uff0c\u8bf7\u81ea\u884c\u67e5\u770b\n                \/\/\u8fd9\u91cc\u5199\u4f60\u7684\u4e1a\u52a1\u903b\u8f91\u4ee3\u7801......\n            }\n\n            return \"&lt;xml&gt;&lt;return_code&gt;&lt;!&#91;CDATA&#91;SUCCESS]]&gt;&lt;\/return_code&gt;&lt;return_msg&gt;&lt;!&#91;CDATA&#91;OK]]&gt;&lt;\/return_msg&gt;&lt;\/xml&gt;\";\n        }\n\n        return \"&lt;xml&gt;&lt;return_code&gt;&lt;!&#91;CDATA&#91;FAIL]]&gt;&lt;\/return_code&gt;&lt;return_msg&gt;&lt;!&#91;CDATA&#91;OK]]&gt;&lt;\/return_msg&gt;&lt;\/xml&gt;\";\n    }<\/code><\/pre>\n\n\n\n<p>\u4e94\u3001\u8ba2\u5355\u9000\u6b3e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u8ba2\u5355\u9000\u6b3e\nEasyRefundRequest easyRefundRequest=new EasyRefundRequest();\neasyRefundRequest.setTradeNo(\"\u60a8\u7684\u5546\u6237\u5355\u53f7\");\/\/\u5546\u6237\u8ba2\u5355\u53f7\neasyRefundRequest.setRefundNo(\"\u4f60\u7684\u9000\u6b3e\u5355\u53f7\");\/\/\u5546\u6237\u9000\u6b3e\u5355\u53f7\uff08\u5546\u6237\u7cfb\u7edf\u81ea\u5df1\u751f\u6210\uff09\neasyRefundRequest.setTotalAmount(100.00);\/\/\u8be5\u7b14\u8ba2\u5355\u7684\u539f\u59cb\u603b\u91d1\u989d\neasyRefundRequest.setRefundAmount(25.00);\/\/\u8be5\u7b14\u8ba2\u5355\u8981\u9000\u6b3e\u7684\u91d1\u989d\neasyRefundRequest.setRefundCause(\"\u9000\u6b3e\u539f\u56e0\");\/\/\u9000\u6b3e\u539f\u56e0\n\t\t\ntry {\n\t\t\t\n    easyPayService.setEasyPayPlatform(EasyPayPlatformEnum.WXPAY);\/\/\u8bbe\u7f6e\u652f\u4ed8\u5e73\u53f0\n    EasyRefundResponse easyRefundResponse = easyPayService.refund(easyRefundRequest);\/\/\u53d1\u8d77\u9000\u6b3e\u8bf7\u6c42\n\t\t\t\n    if (0 != easyRefundResponse.getCode()) {\n        \/\/\u4ee3\u7801\u4e0d\u4e3a0\uff0c\u8868\u793a\u9000\u6b3e\u5931\u8d25\n    }else{\n        System.out.println(easyRefundResponse);\n        \/\/\u9000\u6b3e\u6210\u529f\u4e1a\u52a1\u903b\u8f91...\n    }\n\t\t\t\n}catch (EasyPayException e){\n  System.out.println(e.getMessage());\n}<\/code><\/pre>\n\n\n\n<p>\u516d\u3001\u8ba2\u5355\u67e5\u8be2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>         \/\/\u67e5\u8be2\u8ba2\u5355\n\t EasyQueryRequest easyQueryRequest=new EasyQueryRequest();\/\/\u521b\u5efa\u67e5\u8be2\u5bf9\u8c61\n         easyQueryRequest.setTradeNo(\"\u60a8\u7684\u5546\u6237\u8ba2\u5355\u53f7\");\/\/\u8981\u67e5\u8be2\u7684\u8ba2\u5355\u53f7\n         \/\/easyQueryRequest.setPayTradeNo(\"\u5fae\u4fe1\u6216\u652f\u4ed8\u5b9d\u8ba2\u5355\u53f7\");\/\/\u4e5f\u53ef\u7528\u652f\u4ed8\u5e73\u53f0\u7684\u8ba2\u5355\u53f7\u8fdb\u884c\u67e5\u8be2\n\n\t try {\n\t\teasyPayService.setEasyPayPlatform(EasyPayPlatformEnum.WXPAY);\/\/\u8bbe\u7f6e\u652f\u4ed8\u5e73\u53f0\n\t\tEasyQueryResponse easyQueryResponse=easyPayService.orderQuery(easyQueryRequest);\n\t\tSystem.out.println(easyQueryResponse);\n\t }catch (EasyPayException e){;\n\t\tSystem.out.println(e.getMessage());\n\t }<\/code><\/pre>\n\n\n\n<p>\u4e03\u3001\u9000\u6b3e\u67e5\u8be2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/\/\u9000\u6b3e\u67e5\u8be2\n    EasyQueryRequest easyQueryRequest=new EasyQueryRequest();\n    easyQueryRequest.setTradeNo(\"\u60a8\u7684\u5546\u6237\u8ba2\u5355\u53f7\");\/\/\u5546\u6237\u8ba2\u5355\u53f7\n    easyQueryRequest.setRefundNo(\"\u60a8\u7684\u5546\u6237\u9000\u6b3e\u5355\u53f7\");\/\/\u5546\u6237\u9000\u6b3e\u5355\u53f7\n    \n    try {\n            easyPayService.setEasyPayPlatform(EasyPayPlatformEnum.WXPAY);\/\/\u8bbe\u7f6e\u652f\u4ed8\u5e73\u53f0\n            EasyQueryResponse easyQueryResponse=easyPayService.refundQuery(easyQueryRequest);\n            System.out.println(easyQueryResponse);\n        }catch (EasyPayException e){\n            System.out.println(e.getMessage());\n        }<\/code><\/pre>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">\u9644\uff1a<\/mark><\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u652f\u4ed8\u5e73\u53f0\u679a\u4e3e\uff1a<\/mark><\/p>\n\n\n\n<p>EasyPayPlatformEnum.UNKNOWN \/\/\u672a\u77e5\u7684\u652f\u4ed8\u5e73\u53f0<\/p>\n\n\n\n<p>EasyPayPlatformEnum.ALIPAY \/\/\u652f\u4ed8\u5b9d<\/p>\n\n\n\n<p>EasyPayPlatformEnum.WXPAY \/\/\u5fae\u4fe1<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u652f\u4ed8\u65b9\u5f0f\u679a\u4e3e<\/mark><\/p>\n\n\n\n<p>EasyPayTypeEnum.UNKNOWN  \/\/\u672a\u77e5\u7684\u652f\u4ed8\u65b9\u5f0f<br>EasyPayTypeEnum.ALIPAY_APP \/\/\u652f\u4ed8\u5b9dapp\u652f\u4ed8<br>EasyPayTypeEnum.ALIPAY_PAGE \/\/\u652f\u4ed8\u5b9dpage\u652f\u4ed8<br>EasyPayTypeEnum.ALIPAY_WAP \/\/\u652f\u4ed8\u5b9dwap\u652f\u4ed8<br>EasyPayTypeEnum.ALIPAY_QRCODE \/\/\u652f\u4ed8\u5b9d\u4e8c\u7ef4\u7801\u652f\u4ed8<\/p>\n\n\n\n<p>EasyPayTypeEnum.WXPAY_JSAPI    \/\/\u5fae\u4fe1\u516c\u4f17\u8d26\u53f7\/\u5c0f\u7a0b\u5e8f\u652f\u4ed8<br>EasyPayTypeEnum.WXPAY_MWEB \/\/\u5fae\u4fe1H5\u652f\u4ed8<br>EasyPayTypeEnum.WXPAY_NATIVE \/\/\u5fae\u4fe1Native\u652f\u4ed8\uff08\u626b\u7801\u652f\u4ed8\uff09<br>EasyPayTypeEnum.WXPAY_APP \/\/\u5fae\u4fe1APP\u652f\u4ed8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u4fe1\u548c\u652f\u4ed8\u5b9d\u7684\u652f\u4ed8SDK\u6709\u65f6\u5019\u8c03\u8bd5\u771f\u7684\u5f88\u8ba9\u4eba\u6293\u72c2\uff0c\u4e3a\u4e86\u80fd\u591f\u8ba9\u652f\u4ed8\u53d8\u5f97\u987a\u5229\u4e00\u70b9\u5c31\u81ea\u5df1\u5199\u4e86\u4e2a\u5f88\u7b80\u5355\u7684\u5c01\u88c5\uff08Java [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.kijk.top\/index.php?rest_route=\/wp\/v2\/posts\/61"}],"collection":[{"href":"http:\/\/blog.kijk.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.kijk.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.kijk.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.kijk.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61"}],"version-history":[{"count":26,"href":"http:\/\/blog.kijk.top\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":308,"href":"http:\/\/blog.kijk.top\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions\/308"}],"wp:attachment":[{"href":"http:\/\/blog.kijk.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.kijk.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.kijk.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}