In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.