This example for everyone to share the thinkphp integrated payment code, for your reference, the specific content as follows
Download: Payment SDK
Put the payment SDK under the third-party class library vendor, please remember to change the merchant information inside the WxPay.Config.php to your public number information , in order to avoid causing the loss of funds.
PHP-Side code
Public function Pay () { //merchant basic information, can be written dead inside WxPay.Config.php, other detailed reference wxpayconfig.php vendor (' Pay.jsapi '); $tools = new \jsapipay (); $openid = $tools->getopenid (); $Out _trade_no=date (' YHis '). Rand (100,1000); $Total _fee= ' test '; $Body = ' Don't say anything '; $Total _fee=1; $input = new \wxpayunifiedorder (); $input->setbody ($Body); $input->setout_trade_no ($Out _trade_no); $input->settotal_fee ($Total _fee); $input->setnotify_url ("http://xx.xxx.com/pay/notify.php"); $input->settrade_type ("JSAPI"); $input->setopenid ($openId); $order = \wxpayapi::unifiedorder ($input); $this->jsapiparameters = $tools->getjsapiparameters ($order);
HTML-side code
Secure payment
Confirm Payment
It's so simple.
The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support the script home.