In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "Thinkphp5.0 Alipay online payment order process how to achieve", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Thinkphp5.0 Alipay online payment order process how to achieve" it!
An example of the whole process of issuing an order for Thinkphp5.0 Alipay online payment, including creating the order, calling back the payment successfully to update the order status, and finally jumping to the merchant order details page
Alipay online payment controller code
Public function alipay () {/ / initiate Alipay to pay $order_no = date ("YmdHis"). Rand (100000, 999999); if (request ()-> isPost ()) {/ / payment form submission and evoke Alipay online payment / / call application\ index\ model\ Pay.php $Pay = new Pay; $result = $Pay- > alipay (['notify_url' = > request ()-> domain (). Url ('index/index/alipay_notify'),' return_url' = > request ()-> domain (). Url ('index/index/alipay_return'). "? order_no=". $order_no. "&",' out_trade_no' = > input ('post.orderid/s',', 'trim,strip_tags'),' subject' = > input ('post.subject/s',', 'trim,strip_tags') 'total_fee' = > input (' post.total_fee/f'), / / order amount Unit is meta 'body' = > input (' post.body/s',', 'trim,strip_tags'),]) If (! $result ['code']) {return $this- > error ($result [' msg']);} return $result ['msg'] } / / create order db ('order_sucaihuo')-> insert (array (' order_no' = > $order_no, 'order_money' = > 0.1, / / order amount' state' = > 0, / / payment status 0 is not paid, 1 has been paid 'uid' = > 1 / / user uid 'addtime' = > time (), / / time to place order' update_time' = > 0 / / payment time)) $this- > view- > orderid = $order_no; return $this- > fetch ();} / / Alipay client requests public function alipay_notify () {/ / Asynchronous order Notification $Pay = new Pay; $result = $Pay- > notify_alipay (); if ($result = = 'success') {$pay_info = $_ REQUEST $order_no = $pay_info ['out_trade_no']; $order_info = db (' order_sucaihuo')-> where ('order_no', $order_no)-> find (); / / Update if if unpaid ($order_info [' state'] = = 0) {$data ['trade_no'] = $pay_info [' trade_no'] $data ['state'] = 1; $data [' update_time'] = time (); db ('order_sucaihuo')-> where ("order_no", $order_no)-> update ($data);}} / / Test payment callback, linux remember to enable 777 write permission file_put_contents ("notify.txt", $result) File_put_contents ("request.txt", json_encode ($_ REQUEST);}
Order form
CREATE TABLE IF NOT EXISTS `order_ sucaihuo` (`id` int (11) unsigned NOT NULL, `uid` int (11) NOT NULL, `trade_ no` varchar (30) NOT NULL, `order_ no` varchar (150) DEFAULT NULL COMMENT 'transaction number', `order_ money` decimal (10Power2) DEFAULT '0.00transactions, `state`int (2) NOT NULL DEFAULT' 0percent, `addtime` int (10) NOT NULL, `update_ time` int (10) DEFAULT'0') ENGINE=MyISAM AUTO_INCREMENT=6718 DEFAULT CHARSET=utf8 At this point, I believe that everyone on the "Thinkphp5.0 Alipay online payment order process how to achieve" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.