{"id":1587,"date":"2023-03-25T19:48:24","date_gmt":"2023-03-25T11:48:24","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1587"},"modified":"2023-04-27T21:29:12","modified_gmt":"2023-04-27T13:29:12","slug":"wechat-payment-failed-to-obtain-sandbox-key-confirm-if-the-transaction-key-is-correct","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/wechat-payment-failed-to-obtain-sandbox-key-confirm-if-the-transaction-key-is-correct\/","title":{"rendered":"\u5fae\u4fe1\u652f\u4ed8\uff1a\u83b7\u53d6\u6c99\u7bb1\u5bc6\u94a5\u5931\u8d25,\u786e\u8ba4\u4ea4\u6613\u5bc6\u94a5\u662f\u5426\u6b63\u786e"},"content":{"rendered":"<p>\u5fae\u4fe1\u652f\u4ed8\u6c99\u7bb1\u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/jsapi.php?chapter=23_1&amp;index=2\">https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/jsapi.php?chapter=23_1&#038;index=2<\/a><\/p>\n<h2>\u95ee\u9898\u63cf\u8ff0<\/h2>\n<p>\u6309\u7167\u5b98\u7f51\u5f00\u53d1\u6587\u6863\u8bf7\u6c42\u6c99\u76d2\u652f\u4ed8\u63a5\u53e3\u5bc6\u94a5<\/p>\n<p><!-- more --><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u5b57\u6bb5\u540d<\/th>\n<th style=\"text-align: center;\">\u5b57\u6bb5<\/th>\n<th style=\"text-align: center;\">\u5fc5\u586b<\/th>\n<th style=\"text-align: center;\">\u793a\u4f8b\u503c<\/th>\n<th style=\"text-align: center;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: center;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">\u5546\u6237\u53f7<\/td>\n<td style=\"text-align: center;\">mch_id<\/td>\n<td style=\"text-align: center;\">\u662f<\/td>\n<td style=\"text-align: center;\">5K8264ILTKCH16CQ2502SI8ZNMTM67VS<\/td>\n<td style=\"text-align: center;\">String(32)<\/td>\n<td style=\"text-align: center;\">\u968f\u673a\u5b57\u7b26\u4e32\uff0c\u4e0d\u957f\u4e8e32\u4f4d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u968f\u673a\u5b57\u7b26\u4e32<\/td>\n<td style=\"text-align: center;\">nonce_str<\/td>\n<td style=\"text-align: center;\">\u662f<\/td>\n<td style=\"text-align: center;\">5K8264ILTKCH16CQ2502SI8ZNMTM67VS<\/td>\n<td style=\"text-align: center;\">String(32)<\/td>\n<td style=\"text-align: center;\">\u968f\u673a\u5b57\u7b26\u4e32\uff0c\u4e0d\u957f\u4e8e32\u4f4d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u7b7e\u540d<\/td>\n<td style=\"text-align: center;\">sign<\/td>\n<td style=\"text-align: center;\">\u662f<\/td>\n<td style=\"text-align: center;\">5K8264ILTKCH16CQ2502SI8ZNMTM67VS<\/td>\n<td style=\"text-align: center;\">String(32)<\/td>\n<td style=\"text-align: center;\">\u7b7e\u540d\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53d1\u751f\u9519\u8bef: <strong>\u83b7\u53d6\u6c99\u7bb1\u5bc6\u94a5\u5931\u8d25,\u786e\u8ba4\u4ea4\u6613\u5bc6\u94a5\u662f\u5426\u6b63\u786e<\/strong><\/p>\n<h2>\u539f\u56e0\u5206\u6790<\/h2>\n<p>\u7b7e\u540d\u51fa\u9519\uff0c\u53c2\u8003<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/native_sl.php?chapter=4_3\" title=\"\u5b89\u5168\u89c4\u8303\">\u5b89\u5168\u89c4\u8303<\/a><\/p>\n<p>POST\u7684\u6570\u636e\u91cc\u9762\u6ca1\u6709\u5546\u6237\u76f8\u5173\u7684API_KEY\uff0c\u4f46\u662f\u51e1\u662f\u8c03\u7528\u63a5\u53e3\u7684\u7b7e\u540d\uff0c\u5728StringA\u6309ASCII\u7801\u62fc\u63a5\u5b8c\u8bf7\u6c42\u53c2\u6570\u4e4b\u540e\uff0c\u90fd\u9700\u8981\u5728\u7ed3\u5c3e\u52a0\u4e0akey\u503c\uff0c\u8be5\u503c\u5728\u5fae\u4fe1\u5546\u6237\u5e73\u53f0\u53ef\u67e5\u5230<\/p>\n<pre><code class=\"language-java\">\/**\n * \u7b7e\u540d\u5b57\u7b26\u4e32\n *\n * @param text    \u9700\u8981\u7b7e\u540d\u7684\u5b57\u7b26\u4e32\n * @param key     \u5bc6\u94a5\n * @param charset \u7f16\u7801\u683c\u5f0f\n * @return        \u7b7e\u540d\u7ed3\u679c\n *\/\npublic static String sign(String text, String key, String charset) {\n    text = text + &quot;&amp;key=&quot; + key;\n    return DigestUtils.md5Hex(getContentBytes(text, charset));\n}<\/code><\/pre>\n<p>\u9519\u8befpreStr:<\/p>\n<pre><code>preStr = &quot;appid=wxd930ea5d5a258f8f&amp;mch_id=10000100&amp;nonce_str=ibuaiVcKdpRxkhJA&quot;; <\/code><\/pre>\n<p>\u6b63\u786epreStr:<\/p>\n<pre><code>preStr = &quot;appid=wxd930ea5d5a258f8f&amp;mch_id=10000100&amp;nonce_str=ibuaiVcKdpRxkhJA&amp;key=xxxxxxxxxxxxxx&quot;; <\/code><\/pre>\n<p>\u7136\u540e\u518d\u5c06preStr\u505aMD5\u6216sha256\u52a0\u5bc6\u8fd0\u7b97\uff0c\u5e76\u8f6c\u4e3a\u5927\u5199\u3002\u5f97\u5230\u6b63\u786e\u8fd4\u56desandbox_signkey\uff0c\u53ef\u4ee5\u6b64\u505a\u540e\u7eed\u6c99\u76d2\u6d4b\u8bd5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u4fe1\u652f\u4ed8\u6c99\u7bb1\u6587\u6863\uff1ahttps:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/jsapi.p [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[371],"tags":[],"class_list":["post-1587","post","type-post","status-publish","format-standard","hentry","category-wechat-pay"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1587","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=1587"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1587\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}