{"id":1530,"date":"2023-03-25T15:12:29","date_gmt":"2023-03-25T07:12:29","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1530"},"modified":"2023-04-27T21:43:47","modified_gmt":"2023-04-27T13:43:47","slug":"alipay-app-payment-synchronously-returns-business-data-for-signature-verification-and-processing","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/alipay-app-payment-synchronously-returns-business-data-for-signature-verification-and-processing\/","title":{"rendered":"\u652f\u4ed8\u5b9dAPP\u652f\u4ed8\u540c\u6b65\u8fd4\u56de\u4e1a\u52a1\u6570\u636e\u9a8c\u7b7e\u53ca\u5904\u7406\u91c7\u5751"},"content":{"rendered":"<p>1\u3001\u652f\u4ed8\u5b9d\u540c\u6b65\u8fd4\u56de\u7684<code>urlParams<\/code>\u8f6c<code>Map<\/code>\u53c2\u6570\u65f6\uff0c\u5fc5\u987b\u914d\u7f6e\u53c2\u6570<code>limit<\/code>\u63a7\u5236\u6a21\u5f0f\u5e94\u7528\u7684\u6b21\u6570\uff0c\u56e0\u4e3a<code>sign<\/code>\u5b57\u6bb5\u5927\u6982\u7387\u5305\u542b<code>=<\/code>\u53f7\uff0c\u53ef\u80fd\u5bfc\u81f4\u4ee5<code>=<\/code>\u53f7\u5206\u5272\u4e0d\u80fd\u8fbe\u5230\u9884\u671f\u7ed3\u679c<br \/>\n2\u3001\u9a8c\u7b7e\u4e32\u4e0d\u4ee5\u53c2\u6570\u81ea\u7136\u6392\u5e8f\u8fdb\u884c\u62fc\u63a5\uff0c\u800c\u662f\u4ee5\u652f\u4ed8\u5b9d\u53c2\u6570\u9ed8\u8ba4\u6392\u5e8f\uff0c\u56e0\u6b64\u539f\u4e32\u65e0\u9700\u91cd\u65b0\u6392\u5e8f\uff0c\u53ea\u9700\u5254\u9664<code>sign<\/code>\u53ca<code>sign_type<\/code>\u5b57\u6bb5\u5373\u53ef<br \/>\n3\u3001\u53c2\u6570\u6570\u636e\u90fd\u662f\u5e26\u53cc\u5f15\u53f7\u7684\uff0c\u4f7f\u7528\u65f6\u6ce8\u610f\u5904\u7406\u6389\u53cc\u5f15\u53f7<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-java\">public static void main(String[] args) {\n    \/\/\u652f\u4ed8\u5b9dAPP\u652f\u4ed8\u540c\u6b65\u8fd4\u56de\u4e1a\u52a1\u6570\u636e\n    String response = &quot;_input_charset=\\&quot;UTF-8\\&quot;&amp;appenv=\\&quot;system=android^version=1.0.0\\&quot;&amp;body=\\&quot;alipay online payment body\\&quot;&amp;currency=\\&quot;THB\\&quot;&amp;forex_biz=\\&quot;FP\\&quot;&amp;notify_url=\\&quot;http:\/\/www.yezhou.cc\/notify\/alipay_global_notify.php\\&quot;&amp;out_trade_no=\\&quot;ali20200306094135648\\&quot;&amp;partner=\\&quot;2088621924635293\\&quot;&amp;payment_type=\\&quot;1\\&quot;&amp;product_code=\\&quot;NEW_WAP_OVERSEAS_SELLER\\&quot;&amp;seller_id=\\&quot;2088621924635293\\&quot;&amp;service=\\&quot;mobile.securitypay.pay\\&quot;&amp;subject=\\&quot;alipay online payment subject\\&quot;&amp;total_fee=\\&quot;50.5\\&quot;&amp;success=\\&quot;true\\&quot;&amp;sign_type=\\&quot;RSA\\&quot;&amp;sign=\\&quot;X2vX5TWU960D5UpZNzhpN4T9WSa5NBG10bL5zKxEJ+VJHxZh9m82eNJDu62BsEBmg2MhA0+C\/VxAdwMxJCwSgsDnnzngi670nHoUXYMfhJdzcBr8JkbOliixRHtgiK9sSbkBU03TRx5EKSLi52OF29ZHV6NXSQQH21juGNCyxmM=\\&quot;&quot;;\n\n    Map&lt;String, String&gt; map = getUrlParams(response);\n    System.out.println(JSON.toJSONString(map));\n    \/\/\u6392\u9664sign\u53casign_type\u53c2\u6570\n    String src = response.replace(String.format(&quot;&amp;sign=%s&quot;, map.get(&quot;sign&quot;)), &quot;&quot;)\n        .replace(String.format(&quot;&amp;sign_type=%s&quot;, map.get(&quot;sign_type&quot;)), &quot;&quot;);\n    System.out.println(src);\n\n    String pubKey = &quot;MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDS92pDVyWNT7dzG9zH0opH44z9FayCZTX5iqGUxUjPi667IkyaqrsmDPqKsJp47lJ29lzs+Qv8zjPPdmnxjFteMrfpc4ui24gL1iZnchwX87Ox\/+Xrm8HFmKlhmUO9n\/QgTT+Nz1RGMEN1+HijvsoAhS0TS8XjSfzRkrwvK2pJQIDAQAB&quot;;\n    String sign = &quot;X2vX5TWU960D5UpZNzhpN4T9WSa5NBG10bL5zKxEJ+VJHxZh9m82eNJDu62BsEBmg2MhA0+C\/VxAdwMxJCwSgsDnnzngi670nHoUXYMfhJdzcBr8JkbOliixRHtgiK9sSbkBU03TRx5EKSLi52OF29ZHV6NXSQQH21juGNCyxmM=&quot;;\n\n    \/\/\u53c2\u6570\u81ea\u7136\u6392\u5e8f\n    \/\/String src = &quot;_input_charset=\\&quot;UTF-8\\&quot;&amp;appenv=\\&quot;system=android^version=1.0.0\\&quot;&amp;body=\\&quot;alipay online payment body\\&quot;&amp;currency=\\&quot;THB\\&quot;&amp;forex_biz=\\&quot;FP\\&quot;&amp;notify_url=\\&quot;http:\/\/www.yezhou.cc\/notify\/alipay_global_notify.php\\&quot;&amp;out_trade_no=\\&quot;ali20200306094135648\\&quot;&amp;partner=\\&quot;2088621924635293\\&quot;&amp;payment_type=\\&quot;1\\&quot;&amp;product_code=\\&quot;NEW_WAP_OVERSEAS_SELLER\\&quot;&amp;seller_id=\\&quot;2088621924635293\\&quot;&amp;service=\\&quot;mobile.securitypay.pay\\&quot;&amp;subject=\\&quot;alipay online payment subject\\&quot;&amp;success=\\&quot;true\\&quot;&amp;total_fee=\\&quot;50.5\\&quot;&quot;;\n    \/\/\u652f\u4ed8\u5b9d\u53c2\u6570\u9ed8\u8ba4\u6392\u5e8f\n    \/\/String src = &quot;_input_charset=\\&quot;UTF-8\\&quot;&amp;appenv=\\&quot;system=android^version=1.0.0\\&quot;&amp;body=\\&quot;alipay online payment body\\&quot;&amp;currency=\\&quot;THB\\&quot;&amp;forex_biz=\\&quot;FP\\&quot;&amp;notify_url=\\&quot;http:\/\/www.yezhou.cc\/notify\/alipay_global_notify.php\\&quot;&amp;out_trade_no=\\&quot;ali20200306094135648\\&quot;&amp;partner=\\&quot;2088621924635293\\&quot;&amp;payment_type=\\&quot;1\\&quot;&amp;product_code=\\&quot;NEW_WAP_OVERSEAS_SELLER\\&quot;&amp;seller_id=\\&quot;2088621924635293\\&quot;&amp;service=\\&quot;mobile.securitypay.pay\\&quot;&amp;subject=\\&quot;alipay online payment subject\\&quot;&amp;total_fee=\\&quot;50.5\\&quot;&amp;success=\\&quot;true\\&quot;&quot;;\n\n    boolean result = RSAUtil.checkSign(pubKey, src, sign);\n    System.out.println(result);\n}\n\npublic static Map&lt;String, String&gt; getUrlParams(String param) {\n    Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();\n    if (StringUtils.isBlank(param)) {\n        return map;\n    }\n    String[] params = param.split(&quot;&amp;&quot;);\n    for (int i = 0; i &lt; params.length; i++) {\n        if (StringUtils.isNotBlank(params[i])) {\n            String[] p = params[i].split(&quot;=&quot;, 2);  \/\/\u5fc5\u987b\u914d\u7f6e\u53c2\u6570limit\u63a7\u5236\u6a21\u5f0f\u5e94\u7528\u7684\u6b21\u6570\uff0c\u56e0\u4e3asign\u5b57\u6bb5\u5927\u6982\u7387\u5305\u542b=\u53f7\n            if (p.length == 2) {\n                map.put(p[0], p[1]);\n            }\n        }\n    }\n    return map;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u652f\u4ed8\u5b9d\u540c\u6b65\u8fd4\u56de\u7684urlParams\u8f6cMap\u53c2\u6570\u65f6\uff0c\u5fc5\u987b\u914d\u7f6e\u53c2\u6570limit\u63a7\u5236\u6a21\u5f0f\u5e94\u7528\u7684\u6b21\u6570\uff0c\u56e0\u4e3asign\u5b57 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[372],"tags":[],"class_list":["post-1530","post","type-post","status-publish","format-standard","hentry","category-alipay"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1530"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1530\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}