In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The purpose of this article is to share with you the content about how Thinkphp5 implements Wechat code scanning payment. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Thinkphp5 kernel integrates Wechat scan payment instance complete source code, ThinkPHP framework integrates Wechat scan payment, built-in installation instructions and order table for compressed package
Open the home page to generate the order and display the payment QR code
Public function index () {$wechat = new Wechat (); $data ['order'] = date (' Ymd'). Substr (implode (NULL, array_map ('ord', str_split (substr (uniqid (), 7, 13), 1)), 0,8); / / order No. $data [' set'] = "Test"; $data ['money'] = 0.01; $data [' userid'] = 1 If (! Db::execute ('INSERT INTO order_sucaihuo (uid,order_no,order_money,addtime) VALUES)', [$data ['userid'], $data [' order'], $data ['money'], time ()]) {return' failed, please try again!' ;} $url = $wechat- > send ($data); $data ['url'] =' http://paysdk.weixin.qq.com/example/qrcode.php?data='. $url; / / return'
'; return view (' index', $data);}
Callback to verify and change the order status
If ($WeChatNotify- > notify ($xml) = = true) {file_put_contents ('. / time.txt', date ("Y-m-d H:i:s")) / / $WeChatNotify- > getValues () gets the key-value pair converted from xml to array. / / the merchant order number / / total_fee corresponding to out_trade_no is a multiple of 100 of the order amount, that is, the amount paid by total_fee/100 / / there are several key-value pairs that can be printed out if needed. Trust the official definition of $data = $WeChatNotify- > getValues () File_put_contents ('. / data.txt', json_encode ($data)); if (empty ($data) | | empty ($data ['out_trade_no']) | | empty ($data [' total_fee']) {return;} $orderData = Db::query ("SELECT * FROM order_sucaihuo WHERE order_no='". $data ['out_trade_no']. "'AND state=0"); if (empty ($orderData)) {return;} $orderData = $orderData [0]; if ($orderData [' order_money']! = $data ['total_fee'] / 100) {return;} $orderResult = Db::execute ("UPDATE order_sucaihuo SET state=1,update_time=". Time (). If (! $orderResult) {return;} return "SUCCESS";} Thank you for reading! This is the end of the article on "how Thinkphp5 implements Wechat code scanning payment". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.