u1jodi1q 发表于 2024-7-29 23:50:05

wordpress外贸独立站对接第三方支付通道easylink


    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">前言</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">做跨境电商<span style="color: black;">怎样</span>收款是所有商家都需要关注的。自由度最高的是基于wordpress的外贸独立站,独立站建好以后需要对接收款通道。easylink是香港的支付通道。下面分享对接过程。</p><img src="https://mmbiz.qpic.cn/mmbiz_png/lJtdNy6AmD4K1qDSOvWAF05D7vV6QMmPYTLUgpPkrWQ1gDfQ2WiaXtMGezAWeGkvicpyj3lOTLjZYdPGXYFXggkA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">支付引导<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">支付流程</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">交易流程<span style="color: black;">指的是</span><span style="color: black;">拜访</span>网站的客户从<span style="color: black;">选取</span>商品下单到支付成功的<span style="color: black;">全部</span>流程。</p><img src="https://mmbiz.qpic.cn/mmbiz_png/lJtdNy6AmD4K1qDSOvWAF05D7vV6QMmPcF5knRnibcBLxtjhTteicky3LJMMFxYXTzAMEfPMBQ9icNEGWr7yEYQVg/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">支付流程<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">插件<span style="color: black;">研发</span></span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">熟练</span><span style="color: black;">全部</span>流程后,就要<span style="color: black;">按照</span>通道<span style="color: black;">供给</span>的接口文档编写代码。代码编写的<span style="color: black;">重点</span>模块有签名函数,有订单提交,异步<span style="color: black;">通告</span>处理,同步<span style="color: black;">转</span>函数等。</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">签名</span></h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">本通道采用sha256加密方式</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">buildMysign</span><span style="color: black;">($sort_para,&nbsp;$key,&nbsp;$sign_type&nbsp;=&nbsp;<span style="color: black;">"MD5"</span>)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$prestr&nbsp;=&nbsp;createLinkstring&nbsp;(&nbsp;$sort_para&nbsp;);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$prestr&nbsp;=&nbsp;$prestr&nbsp;.<span style="color: black;">&amp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.&nbsp;$key;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mysgin&nbsp;=&nbsp;sign&nbsp;(&nbsp;$prestr,&nbsp;$sign_type&nbsp;);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$mysgin;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">createLinkstring</span><span style="color: black;">($para)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arg&nbsp;=&nbsp;<span style="color: black;">""</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">foreach</span>($para<span style="color: black;">as</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$key&nbsp;=&gt;&nbsp;$val)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>&nbsp;($key&nbsp;==&nbsp;<span style="color: black;">"accessKey"</span>&nbsp;||&nbsp;$key&nbsp;==&nbsp;<span style="color: black;">"merchantCardNumber"</span>&nbsp;||&nbsp;$key&nbsp;==&nbsp;<span style="color: black;">"BankId"</span>&nbsp;||&nbsp;$key&nbsp;==&nbsp;<span style="color: black;">"merReserved"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">)</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">continue</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">else</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arg&nbsp;.=&nbsp;$key&nbsp;.&nbsp;<span style="color: black;">"="</span>&nbsp;.&nbsp;$val&nbsp;.&nbsp;<span style="color: black;">"&amp;"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arg&nbsp;=&nbsp;rtrim($arg,&nbsp;<span style="color: black;">&amp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$arg;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">paraFilter</span><span style="color: black;">($para)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$para_filter&nbsp;=&nbsp;<span style="color: black;">array</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;();</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">foreach</span>&nbsp;($para&nbsp;<span style="color: black;">as</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$key&nbsp;=&gt;&nbsp;$val)&nbsp;{</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$para_filter&nbsp;[$key]&nbsp;=&nbsp;$para&nbsp;[$key];</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$para_filter;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">argSort</span><span style="color: black;">($para)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ksort&nbsp;(&nbsp;$para&nbsp;);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reset&nbsp;(&nbsp;$para&nbsp;);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$para;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">sign</span><span style="color: black;">($prestr,&nbsp;$sign_type&nbsp;=&nbsp;<span style="color: black;">MD5</span>)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sign&nbsp;=&nbsp;;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$sign&nbsp;=&nbsp;hash($sign_type,&nbsp;$prestr);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$sign;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">订单提交</span></h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">订单提交是组织好官方需要的字段,<span style="color: black;">经过</span>api接口提交并获取结果</p><span style="color: black;"><span style="color: black;">class</span>&nbsp;<span style="color: black;">Submit</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;<span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">buildRequestPara</span><span style="color: black;">($para_temp)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;$key&nbsp;=&nbsp;<span style="color: black;">********</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>&nbsp;&nbsp;$sign_method&nbsp;=&nbsp;<span style="color: black;">SHA256</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;$para_filter&nbsp;=&nbsp;paraFilter($para_temp);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;$para_sort&nbsp;=&nbsp;argSort($para_filter);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$mysign&nbsp;=&nbsp;buildMysign($para_sort,&nbsp;trim($key),&nbsp;strtoupper(trim($sign_method)));</p>&nbsp;&nbsp;$para_sort[<span style="color: black;">accessKey</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">]&nbsp;=&nbsp;$mysign;</p>&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$para_sort;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;}</p>&nbsp;<span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">getMsg</span><span style="color: black;">($para_temp,&nbsp;$gateway)</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;$respondData&nbsp;=&nbsp;;</p>&nbsp;&nbsp;$para&nbsp;=&nbsp;<span style="color: black;">$this</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">-&gt;buildRequestPara($para_temp);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$ch&nbsp;=&nbsp;curl_init&nbsp;($gateway);</p>&nbsp;&nbsp;curl_setopt&nbsp;(&nbsp;$ch,&nbsp;CURLOPT_RETURNTRANSFER,&nbsp;<span style="color: black;">true</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;curl_setopt&nbsp;(&nbsp;$ch,&nbsp;CURLOPT_BINARYTRANSFER,&nbsp;<span style="color: black;">true</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>curl_setopt&nbsp;(&nbsp;$ch,&nbsp;CURLOPT_SSL_VERIFYPEER,<span style="color: black;">false</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;curl_setopt&nbsp;(&nbsp;$ch,&nbsp;CURLOPT_POSTFIELDS,&nbsp;$para);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;$output&nbsp;=&nbsp;curl_exec&nbsp;(&nbsp;$ch&nbsp;);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;curl_close&nbsp;(&nbsp;$ch&nbsp;);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$respondData&nbsp;=&nbsp;json_decode($output);</p>&nbsp;&nbsp;<span style="color: black;">return</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$respondData;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">异步<span style="color: black;">通告</span></span></h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在用户支付成功后,通道会主动发起支付成功的<span style="color: black;">通告</span>到网站。需要专门的函数来处理支付结果。</p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">check_easylink_ipn_response</span><span style="color: black;">()</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;<span style="color: black;">global</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$woocommerce,&nbsp;$wpdb;</p>&nbsp;&nbsp;<span style="color: black;">require_once</span>(<span style="color: black;">"lib/notify.class.php"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;<span style="color: black;">if</span>&nbsp;(($_SERVER[<span style="color: black;">REQUEST_METHOD</span>]&nbsp;===&nbsp;<span style="color: black;">POST</span>)&nbsp;&amp;&amp;&nbsp;preg_match(<span style="color: black;">"/wc_easylink_notify/i"</span>,&nbsp;$_SERVER[<span style="color: black;">REQUEST_URI</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">]))&nbsp;{</p>&nbsp;&nbsp;&nbsp;$Notify&nbsp;=&nbsp;<span style="color: black;">new</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;Notify();</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$verify_result&nbsp;=&nbsp;$Notify-&gt;verifyNotify();</p>&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;(&nbsp;$verify_result&nbsp;)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>&nbsp;($_POST[<span style="color: black;">"respCode"</span>]&nbsp;!=&nbsp;<span style="color: black;">"00"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error_log(<span style="color: black;">__METHOD__</span>&nbsp;.&nbsp;PHP_EOL&nbsp;.&nbsp;$_POST[<span style="color: black;">"respMsg"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">]);</p>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span style="color: black;">elseif</span>(&nbsp;$_POST[<span style="color: black;">status</span>]&nbsp;==&nbsp;<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sref&nbsp;=&nbsp;$_POST[<span style="color: black;">paymentId</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">];</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$statustr&nbsp;=&nbsp;<span style="color: black;">$this</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">-&gt;easylink_processing;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$check_query&nbsp;=&nbsp;$wpdb-&gt;get_results(<span style="color: black;">"SELECT&nbsp;order_id,order_state,mref&nbsp;FROM&nbsp;{$wpdb-&gt;prefix}easylink_data&nbsp;WHERE&nbsp;sref&nbsp;=&nbsp;"</span>.addslashes($sref).<span style="color: black;">""</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">,&nbsp;ARRAY_A);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$check_query_count&nbsp;=&nbsp;count($check_query);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>(&nbsp;$check_query_count&nbsp;&gt;=&nbsp;<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>($check_query[<span style="color: black;">0</span>][<span style="color: black;">order_state</span>]&nbsp;==&nbsp;<span style="color: black;">I</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query&nbsp;=&nbsp;<span style="color: black;">"update&nbsp;{$wpdb-&gt;prefix}easylink_data&nbsp;set&nbsp;order_state=C&nbsp;&nbsp;where&nbsp;sref="</span>.addslashes($sref).<span style="color: black;">""</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$wpdb-&gt;query($query);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$inv_id&nbsp;=&nbsp;$check_query[<span style="color: black;">0</span>][<span style="color: black;">order_id</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">];</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mref&nbsp;=&nbsp;$check_query[<span style="color: black;">0</span>][<span style="color: black;">mref</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">];</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$order&nbsp;=&nbsp;<span style="color: black;">new</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;WC_Order($inv_id);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$order-&gt;update_status($statustr,&nbsp;__(<span style="color: black;">Order&nbsp;has&nbsp;been&nbsp;paid&nbsp;by&nbsp;ID:</span>&nbsp;.&nbsp;$mref,&nbsp;<span style="color: black;">easylink-for-woocommerce</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">));</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wc_reduce_stock_levels(&nbsp;$order-&gt;get_id()&nbsp;);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_post_meta(&nbsp;$inv_id,&nbsp;<span style="color: black;">_paid_date</span>,&nbsp;current_time(<span style="color: black;">mysql</span>),&nbsp;<span style="color: black;">true</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update_post_meta(&nbsp;$inv_id,&nbsp;<span style="color: black;">_transaction_id</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">,&nbsp;wc_clean($mref)&nbsp;);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$order-&gt;payment_complete(wc_clean($mref));</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$woocommerce-&gt;cart-&gt;empty_cart();</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;}</p>&nbsp;&nbsp;&nbsp;<span style="color: black;">//接口返回</span>&nbsp;&nbsp;&nbsp;<span style="color: black;">exit</span>(<span style="color: black;">success</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;}</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">同步<span style="color: black;">转</span></span></h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在网站处理支付成功的<span style="color: black;">信息</span>的<span style="color: black;">同期</span>,客户浏览器需要<span style="color: black;">转</span>到支付成功页面。</p><span style="color: black;"><span style="color: black;">function</span>&nbsp;<span style="color: black;">check_easylink_return</span><span style="color: black;">()</span>&nbsp;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;<span style="color: black;">global</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;$woocommerce,&nbsp;$wpdb;</p>&nbsp;&nbsp;<span style="color: black;">if</span>&nbsp;(($_SERVER[<span style="color: black;">REQUEST_METHOD</span>]&nbsp;===&nbsp;<span style="color: black;">GET</span>)&nbsp;&amp;&amp;&nbsp;preg_match(<span style="color: black;">"/wc_easylink_return/i"</span>,&nbsp;$_SERVER[<span style="color: black;">REQUEST_URI</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">]))&nbsp;{</p>&nbsp;&nbsp;&nbsp;<span style="color: black;">//error_log(__METHOD__&nbsp;.&nbsp;PHP_EOL&nbsp;.print_r($_GET,&nbsp;true));</span>&nbsp;&nbsp;&nbsp;$mref&nbsp;=&nbsp;$_GET[<span style="color: black;">mref</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">];</p>&nbsp;&nbsp;&nbsp;sleep(<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p>$check_query&nbsp;=&nbsp;$wpdb-&gt;get_results(<span style="color: black;">"SELECT&nbsp;order_id,order_state&nbsp;FROM&nbsp;{$wpdb-&gt;prefix}easylink_data&nbsp;WHERE&nbsp;mref&nbsp;=&nbsp;"</span>.addslashes($mref).<span style="color: black;">""</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">,&nbsp;ARRAY_A);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$check_query_count&nbsp;=&nbsp;count($check_query);</p>&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>($check_query_count&nbsp;&gt;=&nbsp;<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">){</p>&nbsp;&nbsp;&nbsp;&nbsp;$inv_id&nbsp;=&nbsp;$check_query[<span style="color: black;">0</span>][<span style="color: black;">order_id</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">];</p>&nbsp;&nbsp;&nbsp;&nbsp;$inv_state&nbsp;=&nbsp;$check_query[<span style="color: black;">0</span>][<span style="color: black;">order_state</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">];</p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">switch</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">(&nbsp;$inv_state&nbsp;)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">case</span>&nbsp;<span style="color: black;">C</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">:</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$order&nbsp;=&nbsp;<span style="color: black;">new</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;WC_Order($inv_id);</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wp_redirect(esc_url_raw(add_query_arg(<span style="color: black;">key</span>,&nbsp;$order-&gt;get_order_key(),&nbsp;add_query_arg(<span style="color: black;">order-received</span>,&nbsp;$inv_id,&nbsp;<span style="color: black;">$this</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">-&gt;get_return_url($order)))));</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">break</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">default</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wp_redirect(&nbsp;wc_get_cart_url()&nbsp;);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">exit</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;wp_redirect(home_url());</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;}</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">完整的支付插件</span></h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">【支付插件】woocommerce对接香港支付通道easylink</p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">插件设置</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">插件安装<span style="color: black;">经过</span>wordpress的后台页面上传<span style="color: black;">而后</span>激活<span style="color: black;">就可</span>,设置<span style="color: black;">亦</span>非常简单。</p><img src="https://mmbiz.qpic.cn/mmbiz_png/lJtdNy6AmD4K1qDSOvWAF05D7vV6QMmPIliaN3IHOFBxHGpZedmIibib7QdglDUib0HTibbAicOh05jHPKrpclptFnfA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">插件设置




星☆雨 发表于 2024-8-24 14:07:24

楼主节操掉了,还不快捡起来!

星☆雨 发表于 2024-9-10 03:47:04

你的话语如春风拂面,让我心生暖意。

大哥 发表于 2024-9-10 15:53:24

楼主继续加油啊!外链论坛加油!

7wu1wm0 发表于 2024-10-8 02:57:00

论坛的成功是建立在我们诚恳、务实、高效、创新和团结合作基础上,我们要把这种精神传递下去。

nykek5i 发表于 2024-10-12 17:55:53

你字句如珍珠,我珍藏这份情。

nykek5i 发表于 2024-10-13 18:31:39

“BS”(鄙视的缩写)‌

b1gc8v 发表于 2024-10-26 14:18:29

同意、说得对、没错、我也是这么想的等。

1fy07h 发表于 2024-11-14 19:10:16

seo常来的论坛,希望我的网站快点收录。
页: [1]
查看完整版本: wordpress外贸独立站对接第三方支付通道easylink