365ktz.com-2021年国产精品无码,97超视频碰碰碰,99国产这里只有精品视频,男生操男生网站,免费黄片观看入口,免费无码又爽又刺激高潮影片,国产亚洲Av手机在线播放,亚洲无码中文字幕在线一区二区三区

wordpress支付插件開發,php支付插件開發實例

二次開發 admin 發布時間:2024-08-10 09:58:47 瀏覽:
最近為客戶開發了一個wordpress的開發實例,現在分享出來給大家。
本文為大家介紹支付網關 API 創建自定義支付網關的方法。
wordpress的電商功能,WooCommerce已經進行了包裝,因此在WooCommerce框架下開發支付網關插件
WooCommerce有 4 種類型的支付網關:
 
基于表單 – 這種方法中,用戶必須點擊表單中的提交按鈕,然后跳轉到第三方支付網關的網站處理支付。如 PayPal 標準接口, Authorize.net DPM,支付寶。
基于 iFrame – 這種方法在 iframe 內加載網關支付系統,如: SagePay 表單, PayPal 高級接口。
直接支付 – 如果使用這種支付方法,在結帳頁面當點擊 ‘下訂單’ 的同時,已經支付成功了。  如: PayPal Pro, Authorize.net AIM
線下支付 – 沒有線上處理過程. 如: Cheque, Bank Transfer
 
1.首先按照插件的開發規則,開發好插件的源碼,然后在wordpress后臺進行上傳即可。
2.本文主要講支付插件的開發。
add_action( 'plugins_loaded', 'init_your_gateway_class' );
 
function init_your_gateway_class() {
  class WC_Gateway_Your_Gateway extends WC_Payment_Gateway {}
}
function add_your_gateway_class( $methods ) {
$methods[] = 'WC_Gateway_Your_Gateway'; 
return $methods;
}
 
add_filter( 'woocommerce_payment_gateways', 'add_your_gateway_class' );
 
 
public function process_payment( $order_id ) {
 
$order = wc_get_order( $order_id );
 
file_put_contents("wulog.txt", date('Y-m-d H:i:s')."--order_id[" . $order_id . "]\r\n",FILE_APPEND);
file_put_contents("wulog.txt", date('Y-m-d H:i:s')."--order[" . json_encode($order) . "]\r\n",FILE_APPEND);
$data=$_REQUEST;
file_put_contents("wulog.txt", date('Y-m-d H:i:s')."--_REQUEST[" . json_encode($_REQUEST) . "]\r\n",FILE_APPEND);
 
 
$mdkey='kr0x9p6zhouabwca4o6ato9otyeiz11g';
$args = array(
'pay_memberid'=> 10055,
'pay_orderid'=> $order_id,
'pay_applydate'=> date('Y-m-d H:i:s'),
'pay_bankcode'=> '918',
'pay_notifyurl'=> 'https://www.abc.vip/asiabillmain/pay/webhook_shop.php',
'pay_callbackurl'=> 'https://www.abc.vip/asiabillmain/pay/webhook_shop.php',
'pay_amount'=> $order->get_total(),
 
);
$data['order_no']=$order_id;
$data['orderAmount']=$order->get_total();
$sign=$this->Make_Sign($args,$mdkey);
$args['pay_md5sign'] = $sign;
$args['pay_productname'] = 'online';
$args['pay_productdesc'] = 'online';
$args['pay_producturl'] = 'https://www.abc.vip/product/black-printed-coffee-mug/';
$args['pay_buyer'] = $data['billing_first_name'].' '.$data['billing_last_name'];
$args['pay_address'] = $data['billing_address_1'];
$args['pay_phone'] =  $data['billing_phone'];
$args['pay_email'] =  $data['billing_email'];
$args['pay_website'] =  'www.shoprong.vip';
$args['pay_currency'] =  'usd';
$args['pay_type'] = 'app';
$url='https://www.xxx.com/Pay_Index.html';
$response = $this->PostCurl( $url, $args );
//$response=preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function('$matches', 'return iconv("UCS-2BE","UTF-8",pack("H*", $matches[1]));'), $response); 
$response = $this->decodeUnicode($response);
file_put_contents("wulog.txt", date('Y-m-d H:i:s')."--response[" . $response . "]\r\n",FILE_APPEND);
$result=json_decode($response,true);
if ($result['returncode']=='00')
{
$data['transaction_id']=$result['transaction_id'];
$jumpUrl=$result['payUrl'].'?'.http_build_query($data);
//$jumpUrl=urlencode($jumpUrl);
file_put_contents("wulog.txt", date('Y-m-d H:i:s')."--jumpUrl[" . $jumpUrl . "]\r\n",FILE_APPEND);
//header("Location: ".$jumpUrl);
return array(
'result' => 'success',
'redirect' => $jumpUrl
);
}
else
{
wc_add_notice(  'The order is duplicated. Please try again.', 'error' );
return;
}
 
 
}
 
開發后的支付頁面如下圖所示:
 
wordpress.png
 
大家有需要可以跟我聯系:QQ:804752009
 

在線咨詢

點擊這里給我發消息售前咨詢專員

點擊這里給我發消息售后服務專員

在線咨詢

免費通話

24h咨詢:0475-2793529


如您有問題,可以咨詢我們的24H咨詢電話!

免費通話

微信掃一掃

微信聯系
返回頂部
主站蜘蛛池模板: 黄山市| 克什克腾旗| 靖西县| 西贡区| 都昌县| 望奎县| 射洪县| 丹棱县| 虎林市| 唐河县| 拉孜县| 大同市| 南京市| 平阴县| 赤水市| 乌恰县| 石首市| 平度市| 长沙市| 乌海市| 昌图县| 易门县| 太白县| 将乐县| 通江县| 石阡县| 惠安县| 阳谷县| 普格县| 西藏| 荣昌县| 凉城县| 合阳县| 托里县| 仁怀市| 武宁县| 吴旗县| 武川县| 洪江市| 北京市| 巩留县|