thinkphp integrated WeChat payment code sharing _php instance

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.