thinkphp integrated micro-credit payment code sharing _php instance

Source: Internet
Author: User

This example for you to share the thinkphp integrated micro-credit payment code for your reference, the specific content as follows

Download: Payment SDK

To place the micro-credit 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 , so as to avoid 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 = ' Say nothing '; 
  $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); 
  $this->display (); 

 html-side code

<!doctype html>  

It's as simple as that.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.