{"id":958,"date":"2023-08-28T14:30:35","date_gmt":"2023-08-28T06:30:35","guid":{"rendered":"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/%e4%b8%b2%e6%8e%a5%e8%aa%aa%e6%98%8e\/web-%e9%96%8b%e7%99%bc-onlinepay"},"modified":"2023-08-31T16:37:32","modified_gmt":"2023-08-31T08:37:32","slug":"web-%e9%96%8b%e7%99%bc-onlinepay","status":"publish","type":"docs","link":"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/%e4%b8%b2%e6%8e%a5%e8%aa%aa%e6%98%8e\/web-%e9%96%8b%e7%99%bc-onlinepay","title":{"rendered":"Web \u4e32\u63a5 OnlinePay"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>\u8857\u53e3\u652f\u4ed8 OnlinePay \u670d\u52d9\u652f\u63f4\u5df2\u4ecb\u63a5\u696d\u52d9\u7a97\u53e3\u4e26\u958b\u901a\u6b64\u670d\u52d9\u7684\u5e97\u92ea\u4e32\u63a5\u6b64\u529f\u80fd\uff0cAPP \u6216 Web \u53ef\u901a\u904e OnlinePay \u7522\u54c1\u5b8c\u6210\u60a8\u92b7\u552e\u5546\u54c1\u6216\u5167\u5bb9\u7684\u6536\u6b3e\u9700\u6c42\u3002<\/p>\n\n\n\n<p>\u6b64\u6587\u4ef6\u5c07\u6558\u8ff0\u5169\u7a2e\u4ecb\u63a5\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u6211\u6709 APP\uff0c\u4e14\u4ed8\u6b3e\u9801\u9762\u662f\u5728 Webview \u5167\u5be6\u4f5c<\/li><li>\u6211\u6709 PC \u7db2\u9801<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u6211\u6709 APP\uff0c\u4e14\u4ed8\u6b3e\u9801\u9762\u662f\u5728 Webview \u5167\u5be6\u4f5c<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">\u8f49\u5c0e\u6d41\u7a0b\uff1a \u60a8\u7684\u4ed8\u6b3e\u9801 -&gt; \u4ed8\u6b3e\u9023\u7d50\u8f49\u5c0e -&gt; \u78ba\u8a8d\u652f\u4ed8 -&gt; \u652f\u4ed8\u6210\u529f -&gt; \u56de\u5230\u60a8\u7684\u61c9\u7528<\/pre>\n\n\n\n<p>\u8aaa\u660e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4f7f\u7528\u8a02\u55ae\u5275\u5efa\u8fd4\u56de\u53c3\u6578 payment_url \u4f5c\u70ba\u8df3\u8f49\u9023\u7d50\u3002(<a href=\"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/api%e5%88%97%e8%a1%a8\/%e8%a8%82%e5%96%ae%e5%89%b5%e5%bb%ba-api#fan_hui_can_shu_Response_JSON_Body\">\u8a02\u55ae\u5275\u5efa API #\u8fd4\u56de\u53c3\u6578<\/a>)<\/li><li>\u7576\u652f\u4ed8\u6210\u529f\u6642\uff0c\u8857\u53e3\u652f\u4ed8\u6703\u5c07\u7528\u6236\u5c0e\u56de\u60a8\u8a02\u55ae\u5275\u5efa\u6642\u7684\u8acb\u6c42\u53c3\u6578 result_display_url\u3002(<a href=\"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/api%e5%88%97%e8%a1%a8\/%e8%a8%82%e5%96%ae%e5%89%b5%e5%bb%ba-api#qing_qiu_can_shu_Request_Parameter\">\u8a02\u55ae\u5275\u5efa API \u8acb\u6c42\u53c3\u6578<\/a>)<\/li><\/ul>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7528\u6236\u65bc\u8857\u53e3\u652f\u4ed8\u61c9\u7528\u4e2d\u4ed8\u6b3e\u6210\u529f\u5f8c\uff0c\u8857\u53e3\u652f\u4ed8\u670d\u52d9\u6703\u7acb\u5373\u5c07\u7528\u6236\u5c0e\u5411 result_display_url\u3002<\/li><li>\u82e5\u7528\u6236\u65bc\u8857\u53e3\u652f\u4ed8\u61c9\u7528\u4e2d\u4ed8\u6b3e\u5931\u6557\uff0c\u8857\u53e3\u652f\u4ed8\u670d\u52d9\u4e0d\u6703\u5c07\u7528\u6236\u5c0e\u56de\u60a8\u7684\u61c9\u7528\u3002<\/li><li>\u7528\u6236\u65bc\u975e\u652f\u4ed8\u6210\u529f\u7684\u60c5\u6cc1\u4e0b\uff0c\u81ea\u884c\u8fd4\u56de\u60a8\u7684\u61c9\u7528\u6642\uff0c\u9700\u8981\u81ea\u884c\u8655\u7406\u72c0\u614b\u3002\u5efa\u8b70\u4f7f\u7528 window.onpageshow \u76e3\u807d\u7528\u6236\u662f\u5426\u6709\u56de\u5230\u9801\u9762\uff0c\u91cd\u65b0\u5237\u65b0\u9801\u9762\u6216\u6aa2\u67e5\u7576\u524d\u72c0\u614b\u5448\u73fe\u5c0d\u61c9 UI\u3002<\/li><li>\u9084\u539f\u9801\u9762\u9700\u8003\u616e\u6642\u6a5f\uff0c\u8f03\u70ba\u8907\u96dc\uff0c\u56e0\u6b64\u5efa\u8b70\u4f5c\u6cd5\u662f\u65bc\u60a8\u7684\u4ed8\u6b3e\u9801\u9ede\u64ca\u6642\uff0c<mark style=\"background-color:#fffc00\" class=\"has-inline-color\">\u7531 JSAPI \u547c\u53eb APP \u5411\u5916\u958b\u555f\u7cfb\u7d71\u700f\u89bd\u5668\u9032\u884c\u4ed8\u6b3e\u9023\u7d50\u8f49\u5c0e\uff08JSAPI \u7531\u60a8\u7684 APP \u5be6\u4f5c\uff09<\/mark>\u3002<\/li><li><mark style=\"background-color:#fffc00\" class=\"has-inline-color\">\u4e0d\u5efa\u8b70 APP \u4f7f\u7528\u6700\u7d42\u8df3\u8f49\u9023\u7d50\u4f5c\u70ba\u5224\u65b7\u95dc\u9589 Webview \u7684\u6642\u6a5f\u3002<\/mark><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>\u76e3\u807d\u7528\u6236\u662f\u5426\u6709\u56de\u5230\u9801\u9762\uff0c\u91cd\u65b0\u5237\u65b0\u9801\u9762\u6216\u6aa2\u67e5\u7576\u524d\u72c0\u614b\u5448\u73fe\u5c0d\u61c9 UI\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\/\/ \u9801\u9762 mounted \naddEventListener(\"visibilitychange\", (event) =&gt; {\n    if (document.visibilityState === 'visible') {\n        window.location.reload();\n      }\n});<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li> \u4ed8\u6b3e\u9801\u9ede\u64ca\u6642\uff0c\u7531 JSAPI \u547c\u53eb APP \u5411\u5916\u958b\u555f\u7cfb\u7d71\u700f\u89bd\u5668\u9032\u884c\u4ed8\u6b3e\u9023\u7d50\u8f49\u5c0e\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\/\/ payment_url : \u547c\u53eb\u8a02\u55ae\u5275\u5efa API \u8fd4\u56de\u53c3\u6578\nfunction() {\n    jsapi.openBrowser(payment_url); \/\/ JSAPI \u7531\u60a8\u7684 APP \u5be6\u4f5c\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\uff08\u4e0d\u5efa\u8b70\uff09\u5728 Webview \u672c\u8eab\u9032\u884c\u4ed8\u6b3e\u9023\u7d50\u8f49\u5c0e\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\/\/ payment_url : \u547c\u53eb\u8a02\u55ae\u5275\u5efa API \u8fd4\u56de\u53c3\u6578\nfunction() {\n    window.location.href = payment_url;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6211\u6709 PC \u7db2\u7ad9<\/h2>\n\n\n\n<p>\u8f49\u5c0e\u6d41\u7a0b\uff1a \u60a8\u7684\u4ed8\u6b3e\u9801 -&gt; \u4ed8\u6b3e\u9023\u7d50\u8f49\u5c0e -&gt; \u7528\u6236\u6383\u63cf\u4ed8\u6b3e QR Code -&gt; \u78ba\u8a8d\u652f\u4ed8 -&gt; \u652f\u4ed8\u6210\u529f<\/p>\n\n\n\n<p>\u8aaa\u660e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4f7f\u7528\u8a02\u55ae\u5275\u5efa\u8fd4\u56de\u53c3\u6578 payment_url \u4f5c\u70ba\u8df3\u8f49\u9023\u7d50\u3002(<a href=\"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/api%e5%88%97%e8%a1%a8\/%e8%a8%82%e5%96%ae%e5%89%b5%e5%bb%ba-api#fan_hui_can_shu_Response_JSON_Body\">\u8a02\u55ae\u5275\u5efa API #\u8fd4\u56de\u53c3\u6578<\/a>)<\/li><li>\u4f7f\u7528\u8a02\u55ae\u5275\u5efa\u8fd4\u56de\u53c3\u6578 qr_img \uff0c\u5c07 QRCode \u5d4c\u5165\u4ed8\u6b3e\u7db2\u9801 \u3002(<a href=\"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/api%e5%88%97%e8%a1%a8\/%e8%a8%82%e5%96%ae%e5%89%b5%e5%bb%ba-api#fan_hui_can_shu_Response_JSON_Body\">\u8a02\u55ae\u5275\u5efa API #\u8fd4\u56de\u53c3\u6578<\/a>)<\/li><li>\u4f7f\u7528\u684c\u9762\u88dd\u7f6e\uff1a\u756b\u9762\u986f\u793a\u4ed8\u6b3e QR Code \uff0c\u7528\u6236\u4f7f\u7528\u624b\u6a5f\u88dd\u7f6e\u958b\u555f\u8857\u53e3\u652f\u4ed8 APP \u6383\u78bc\u4ed8\u6b3e\u3002<\/li><li>\u4f7f\u7528\u624b\u6a5f\u88dd\u7f6e\uff1a\u8857\u53e3\u652f\u4ed8\u670d\u52d9\u6703\u958b\u555f\u624b\u6a5f\u88dd\u7f6e\u4e0a\u7684\u8857\u53e3\u652f\u4ed8 APP \u9032\u884c\u4ed8\u6b3e\u3002<\/li><\/ul>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4f7f\u7528\u624b\u6a5f\u88dd\u7f6e\u700f\u89bd\u5668\u958b\u555f\uff0c\u8df3\u8f49\u6642\u9075\u5faa\u8a72\u700f\u89bd\u5668\u653f\u7b56\uff0c\u90e8\u5206\u700f\u89bd\u5668\u7981\u6b62\u975e\u7528\u6236\u89f8\u767c\u4e4b\u8df3\u8f49\u884c\u70ba\u3002\u5efa\u8b70\u7684\u505a\u6cd5\u662f\uff0c\u900f\u904e\u7528\u6236\u9ede\u64ca\u884c\u70ba\u8f49\u5c0e\u81f3\u4ed8\u6b3e\u9023\u7d50\u3002<\/li><li>\u4f7f\u7528\u624b\u6a5f\u88dd\u7f6e\u700f\u89bd\u5668\u958b\u555f\uff0c\u82e5\u7528\u6236\u7684\u624b\u6a5f\u88dd\u7f6e\u6c92\u6709\u5b89\u88dd\u8857\u53e3\u652f\u4ed8 APP\uff0c\u8857\u53e3\u652f\u4ed8\u670d\u52d9\u6703\u5617\u8a66\u5f15\u5c0e\u7528\u6236\u524d\u5f80\u61c9\u7528\u7a0b\u5f0f\u5546\u5e97\u4e0b\u8f09\u3002<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4f7f\u7528\u8a02\u55ae\u5275\u5efa\u8fd4\u56de\u53c3\u6578 payment_url \u4f5c\u70ba\u8df3\u8f49\u9023\u7d50<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"UTF-8\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" \/&gt;\n    &lt;meta name=\"description\" content=\"baru belajar html\"\n    &lt;title&gt; Hello World! &lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n   &lt;div&gt;\n     &lt;button id=\"paymentBtn\"&gt;\u8857\u53e3\u652f\u4ed8\u4ed8\u6b3e&lt;\/button&gt;\n   &lt;\/div&gt;\n\n   &lt;script&gt;\n      const paymentBtn = document.getElementById('paymentBtn');\n      function apiGetPaymentUrl() {\n        \/\/ \u60a8\u7684\u5f8c\u7aef\u8acb\u6c42\u8857\u53e3\u652f\u4ed8\u8a02\u55ae\u5275\u5efa API \uff0c\u8fd4\u56de\u53c3\u6578 payment_url\n        const payment_url = 'https:\/\/onlinepay.jkopay.com\/';\n\n        return payment_url;\n      }\n\n      async function startPayment() {\n        const payment_url = await apiGetPaymentUrl();\n\n        window.location.href = payment_url;\n      }\n\n      paymentBtn.onclick = startPayment;\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n","protected":false},"featured_media":0,"parent":43,"menu_order":4,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-958","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=958"}],"version-history":[{"count":4,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/958\/revisions"}],"predecessor-version":[{"id":963,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/958\/revisions\/963"}],"up":[{"embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/43"}],"prev":[{"title":"App \u4e32\u63a5 OnlinePay","link":"https:\/\/open-doc.jkos.com\/?docs=%e7%b7%9a%e4%b8%8a%e6%94%af%e4%bb%98onlinepay\/%e4%b8%b2%e6%8e%a5%e8%aa%aa%e6%98%8e\/app-%e4%b8%b2%e6%8e%a5-onlinepay","href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/966"}],"wp:attachment":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=958"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}