Home >Backend Development >PHP Tutorial >PHP implements WeChat payment function development code sharing

PHP implements WeChat payment function development code sharing

小云云
小云云Original
2018-03-09 16:53:086569browse

This article mainly introduces the development process of PHP WeChat payment in detail. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.

1. Development environment
Thinkphp 3.2.3
WeChat: Service account, certified
Development domain name: http://test.paywechat.com (since The defined domain name is not accessible from the external network)

2. Requires relevant documents and permissions
WeChat payment needs to be activated
WeChat public platform developer documentation: http:// mp.weixin.qq.com/wiki/home/index.html
WeChat Payment Developer Documentation: https://pay.weixin.qq.com/wiki/doc/api/index.html
WeChat Payment SDK download address: https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_1

3. Development
Download WeChat To pay for the PHP version of the SDK, the file directory is as shown below:

PHP implements WeChat payment function development code sharing

PHP implements WeChat payment function development code sharing

Put the Cert and Lib directories of the WeChat payment SDK Thinkphp, the directory is

PHP implements WeChat payment function development code sharing

Now we will introduce the WeChat payment authorization directory issue. The first is to fill in the payment authorization directory in the WeChat payment development configuration,

PHP implements WeChat payment function development code sharing

Then fill in the js interface security domain.

PHP implements WeChat payment function development code sharing

Finally set the web page authorization

PHP implements WeChat payment function development code sharing

PHP implements WeChat payment function development code sharing

After these settings are completed, it is basically half completed. Pay attention to the set directory and the directory in my thinkphp.

PHP implements WeChat payment function development code sharing

4. WeChat payment configuration

PHP implements WeChat payment function development code sharing

Fill in the relevant configuration correctly.




##[php] view plain copy


  1. ##/**

  2. ##* Configure account information

  3. */

  4. ##class WxPayConfig

  5. ##{

  6. //========[Basic information settings]==================== =================

  7. //

  8. /**

  9. * TODO: Modify the configuration here to apply for your own merchant information

  10. * WeChat public account information configuration

  11. ## *

  12. ## * APPID : APPID bound to payment (must be configured, can be viewed in the account opening email)
  13. *
  14. * MCHID: Merchant ID (must be configured, can be viewed in the account opening email)
  15. *
  16. * KEY: Merchant payment key, refer to the account opening email settings (must be configured, log in to the merchant platform to set it yourself )
  17. * Setting address: https://pay.weixin.qq.com/index.php/account/api_cert
  18. ## *
  19. ## * APPSECRET: Public account secert (only required for JSAPI payment, log in to the public platform and enter the developer center to set),

  20. ## * Obtain address: https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN

  21. * @var string

  22. ## */

  23. const APPID = '' ;

  24. ##const

    MCHID = '';

  25. ##const
  26. KEY = '';

  27. const
  28. APPSECRET = '';

  29. ##//=======【 Certificate path settings】======================================
  30. /**
  31. * TODO :Set the merchant certificate path
  32. * Certificate path, please note that the absolute path should be filled in (only required for refunds and order cancellations, you can log in Merchant platform download,
  33. * API certificate download address: https://pay.weixin.qq.com/index.php/account/api_cert, you need to install the merchant operation certificate before downloading)

  34. ## * @var path

  35. */

  36. const SSLCERT_PATH = '. ./cert/apiclient_cert.pem';

  37. const SSLKEY_PATH = '../cert/apiclient_key.pem';

  38. ##//========[curl proxy settings]======================== ============

  39. ##/**

  40. ## * TODO: Set the proxy machine here. Set it only when you need a proxy. If you don’t need a proxy, please set it to 0.0.0.0 and 0
  41. ## * This routine uses the HTTP POST method through curl. The proxy server can be modified here,
  42. * The default is CURL_PROXY_HOST=0.0.0.0 and CURL_PROXY_PORT=0, the proxy is not enabled at this time (set it if necessary)
  43. * @var unknown_type
  44. ##*/

  45. const CURL_PROXY_HOST = "0.0.0.0";// "10.152.18.220";

  46. ##const CURL_PROXY_PORT = 0; //8080;

  47. ##//========[Report information configuration]================================== ====

  48. ##/**

  49. * TODO: Interface call reporting level, default error reporting (note: reporting timeout is [1s], reporting regardless of success or failure [Never throw an exception],

  50. * Will not affect the interface calling process), after turning on the reporting, it is convenient for WeChat monitoring request calls For quality, it is recommended to at least

  51. * Enable error reporting.

  52. ## * Reporting level, 0. Close reporting; 1. Only errors are reported; 2. Full reporting
  53. * @var int
  54. ##*/
  55. const
  56. REPORT_LEVENL = 1;

    }

Start posting the code now:




# #[php] view plain copy


  1. ##namespace Wechat\ Controller;

  2. ##use

    Think\Controller;

  3. /**

  4. ## * Parent class controller, need to inherit
  5. * @file ParentController.class.php
  6. ## * @author Gary
  7. # * @date August 4, 2015

  8. * @todu

  9. */

  10. ##class ParentController extends Controller {

  11. protected $options = array (

  12. 'token' => '', // Fill in the key you set

  13. ##'encodingaeskey' => '', // Fill in the EncodingAESKey for encryption

  14. 'appid' => '', // Fill in the advanced The app id of the calling function

  15. ##'appsecret'

    => '', // Fill in the key for the advanced calling function

  16.  'debug' => false,  

  17.  'logcallback' => ''  

  18.  );   

  19.  public $errCode = 40001;   

  20.  public $errMsg = "no access";   

  21.   

  22.  /** 

  23.  * 获取access_token 

  24.  * @return mixed|boolean|unknown 

  25.  */  

  26.  public function getToken(){  

  27.  $cache_token = S('exp_wechat_pay_token');  

  28.  if(!empty($cache_token)){  

  29.  return $cache_token;  

  30.  }  

  31.  $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s';  

  32.  $url = sprintf($url,$this->options['appid'],$this->options['appsecret']);   

  33.  $result = $this->http_get($url);  

  34.  $result = json_decode($result,true);   

  35.  if(empty($result)){  

  36.  return false;  

  37.  }   

  38.  S('exp_wechat_pay_token',$result['access_token'],array('type'=>'file','expire'=>3600));  

  39.  return $result['access_token'];  

  40.  }  

  41.   

  42.  /**

  43. ## * Send customer service message

  44. * @param array $data Message structure {"touser":"OPENID","msgtype":"news","news":{...}}

  45. */  

  46.  public function sendCustomMessage($data){  

  47.  $token = $this->getToken();  

  48.  if (empty($token)) return false;   

  49.  $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s';  

  50.  $url = sprintf($url,$token);  

  51.  $result = $this->http_post($url,self::json_encode($data));  

  52.  if ($result)  

  53.  {  

  54.  $json = json_decode($result,true);  

  55. if (!$json || !empty($json['errcode'])) {

  56. $this->errCode = $json['errcode' ];  

  57. #$this->errMsg = $json['errmsg'];  

  58. #return false;  

  59. }

  60. return $json;  

  61. }

  62. return false;  

  63. }

  64. #

  65.  /**

  66. ## * Send template message

  67. * @param unknown $data

  68. ## * @return boolean|unknown

  69. */  

  70.  

    public function sendTemplateMessage($data){  

  71.  

    $token = $this->getToken();  

  72.  

    if (empty($token)) return false;  

  73.  

    $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s";  

  74.  $url = sprintf($url,$token);  

  75.  $result = $this->http_post($url,self::json_encode($data));  

  76.  if ($result)  

  77.  {  

  78.  $json = json_decode($result,true);  

  79. if (!$json || !empty($json['errcode'])) {

  80. $this->errCode = $json['errcode' ];  

  81. #$this->errMsg = $json['errmsg'];  

  82. #return false;  

  83. }

  84. return $json;  

  85. }

  86. return false;  

  87. }

  88. #

  89.   

  90.  public function getFileCache($name){  

  91.  return S($name);  

  92.  }  

  93.   

  94.  /**

  95. ## * WeChat API does not support Chinese escaped json structure

  96. * @param array $arr

  97. */  

  98.  static function json_encode($arr) {  

  99.  $parts = array ();  

  100.  $is_list = false;  

  101.  //Find out if the given array is a numerical array  

  102.  $keys = array_keys ( $arr );  

  103.  $max_length = count ( $arr ) - 1;  

  104.  if (($keys [0] === 0) && ($keys [$max_length] === $max_length )) { //See if the first key is 0 and last key is length - 1  

  105.  $is_list = true;  

  106.  for($i = 0; $i count ( $keys ); $i ++) { //See if each key correspondes to its position  

  107.  if ($i != $keys [$i]) { //A key fails at position check.  

  108.   $is_list = false; //It is an associative array.  

  109.   break;  

  110.  }  

  111.  }  

  112.  }  

  113.  foreach ( $arr as $key => $value ) {  

  114.  if (is_array ( $value )) { //Custom handling for arrays  

  115.  if ($is_list)  

  116.   $parts [] = self::json_encode ( $value ); /* :RECURSION: */  

  117.  else  

  118.   $parts [] = '"' . $key . '":' . self::json_encode ( $value ); /* :RECURSION: */  

  119.  } else {  

  120.  $str = '';  

  121.  if (! $is_list)  

  122.   $str = '"' . $key . '":';  

  123.  //Custom handling for multiple data types  

  124.  if (!is_string ( $value ) && is_numeric ( $value ) && $value

  125.   $str .= $value//Numbers  

  126.  elseif ($value === false)  

  127.  $str .= 'false'//The booleans  

  128.  elseif ($value === true)  

  129.  $str .= 'true';  

  130.  else  

  131.   $str .= '"' . addslashes ( $value ) . '"'//All other things  

  132.  // :TODO: Is there any more datatype we should be in the lookout for? (Object?)  

  133.  $parts [] = $str;  

  134.  }  

  135.  }  

  136.  $json = implode ( ','$parts );  

  137.  if ($is_list)  

  138. return '[' . $json . ']'; //Return numerical JSON

  139. ##return '{' . $json . '}'; //Return associative JSON

  140. }

  141. /**

  142. +--------------------------------- ----------------------------

  143. * Generate random string

  144. +------------------ ----------------------------------------

  145. * @param int $length The length of the random string to be generated

  146. * @param string $type Random code type: 0, numbers + upper and lower case letters; 1, numbers; 2, lower case letters; 3, upper case letters; 4, special characters; -1, numbers + upper and lower case letters + special characters

  147.  +---------------------------------------------------------- 

  148.  * @return string 

  149.  +---------------------------------------------------------- 

  150.  */  

  151.  static public function randCode($length = 5, $type = 2){  

  152.  $arr = array(1 => "0123456789", 2 => "abcdefghijklmnopqrstuvwxyz", 3 => "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4 => "~@#$%^&*(){}[]|");  

  153.  if ($type == 0) {  

  154.  array_pop($arr);  

  155.  $string = implode(""$arr);  

  156.  } elseif ($type == "-1") {  

  157.  $string = implode(""$arr);  

  158.  } else {  

  159.  $string = $arr[$type];  

  160.  }  

  161.  $count = strlen($string) - 1;  

  162.  $code = '';  

  163.  for ($i = 0; $i $length$i++) {  

  164.  $code .= $string[rand(0, $count)];  

  165.  }  

  166.  return $code;  

  167.  }   

  168.   

  169.   

  170.  /** 

  171.  * GET 请求 

  172.  * @param string $url 

  173.  */  

  174.  private function http_get($url){  

  175.  $oCurl = curl_init();  

  176.  if(stripos($url,"https://")!==FALSE){  

  177.  curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);  

  178.  curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);  

  179.  curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1  

  180.  }  

  181.  curl_setopt($oCurl, CURLOPT_URL, $url);  

  182.  curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );  

  183.  $sContent = curl_exec($oCurl);  

  184.  $aStatus = curl_getinfo($oCurl);  

  185.  curl_close($oCurl);  

  186.  if(intval($aStatus["http_code"])==200){  

  187.  return $sContent;  

  188.  }else{  

  189.  return false;  

  190.  }  

  191.  }  

  192.   

  193.  /**

  194. ## * POST request

  195. # # * @param string $url

  196. ## * @param array $param

  197. * @param boolean $post_file Whether to upload files

  198. ## * @return string content
  199. */
  200.   

     
  201. private
  202.  function http_post($url,$param,$post_file=false){  

     
  203. $oCurl
  204.  = curl_init();  

  205.  if(stripos($url,"https://")!==FALSE){  

  206.  curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);  

  207.  curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);  

  208.  curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1  

  209.  }  

  210.  if (is_string($param) || $post_file) {  

  211.  $strPOST = $param;  

  212.  } else {  

  213.  $aPOST = array();  

  214.  foreach($param as $key=>$val){  

  215.  $aPOST[] = $key."=".urlencode($val);  

  216.  }  

  217.  $strPOST = join("&"$aPOST);  

  218.  }  

  219.  curl_setopt($oCurl, CURLOPT_URL, $url);  

  220.  curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );  

  221.  curl_setopt($oCurl, CURLOPT_POST,true);  

  222.  curl_setopt($oCurl, CURLOPT_POSTFIELDS,$strPOST);  

  223.  $sContent = curl_exec($oCurl);  

  224.  $aStatus = curl_getinfo($oCurl);  

  225.  curl_close($oCurl);  

  226.  if(intval($aStatus["http_code"])==200){  

  227.  return $sContent;  

  228.  }else{  

  229.  return false;  

  230.  }  

  231.  }  

  232. }  




[php] view plain copy


  1. namespace Wechat\Controller;  

  2. use Wechat\Controller\ParentController;  

  3. /**

  4. ## * WeChat payment test controller

  5. * @file TestController.class.php

  6. ## * @author Gary

  7. ## * @date August 4, 2015

  8. * @todu

  9. */

      

  10. class TestController extends ParentController {  

  11.  private $_order_body = 'xxx';  

  12.  private $_order_goods_tag = 'xxx';  

  13.  public function __construct(){  

  14.  parent::__construct();  

  15.  require_once ROOT_PATH."Api/lib/WxPay.Api.php";  

  16.  require_once ROOT_PATH."Api/lib/WxPay.JsApiPay.php";  

  17.  }  

  18.   

  19. public function index(){

  20. //①. Get user openid

  21. ## $tools = new \JsApiPay();

  22. # #$openId = $tools->GetOpenid();

  23. //②. Unified order placement

  24. ##$input

    = new \WxPayUnifiedOrder();

  25. #//Product description
  26. ##$input
  27. ->SetBody(

    $this->_order_body); ##//Additional data, you can add the data you need, and WeChat will return an asynchronous callback This data will be appended

  28. $input->SetAttach('xxx');

  29. //Merchant order number

  30. ##$out_trade_no = \WxPayConfig::MCHID.date("YmdHis");

  31. ##$input->SetOut_trade_no($out_trade_no);

  32. #//Total amount, the total amount of the order, can only be an integer, the unit is cents

  33. $input

    ->SetTotal_fee(1);

  34. //Transaction start time

  35. $input

    ->SetTime_start(date("YmdHis"));

  36. //Transaction end time

  37. $input->SetTime_expire(date("YmdHis ", time() + 600));

  38. ##//Product tag

  39. ##$input->SetGoods_tag($this->_order_goods_tag);

  40. #//Notification address, receive WeChat payment asynchronous notification callback address SITE_URL=http://test .paywechat.com/Charge

  41. ##$notify_url
  42. = SITE_URL. '/index.php/Test/notify.html';

  43. $input
  44. ->SetNotify_url($notify_url);

    ##/ /Trade Type
  45. ##$input

  46. ->SetTrade_type(
  47. "JSAPI"); ##$input

    ->SetOpenid(
  48. $openId

    );

  49. $order = \WxPayApi::unifiedOrder($input);

  50. $jsApiParameters = $tools->GetJsApiParameters($order);

  51. ##//Get the shared delivery address js function parameters

  52. ##$editAddress = $tools->GetEditAddressParameters();

  53. ## $this

    ->assign('openId',$openId);

  54. ##$this
  55. ->assign('jsApiParameters',$jsApiParameters);

    ##$this
  56. ->assign (

    'editAddress',$editAddress);

  57. $this->display();

  58. # # }

  59. #/**

  60. ## * Asynchronous notification callback method

  61. */

  62. public

    function notify (){

  63. ##require_once
  64. ROOT_PATH."Api/lib/notify.php ";

    ##$notify
  65. =

    new \PayNotifyCallBack(); ##$notify

  66. ->Handle(false);
  67. //The IsSuccess here is a method customized by me. I will post the code of this file later for reference.

  68. $is_success

  69. =
  70. $notify ->IsSuccess();

  71.  $bdata = $is_success['data'];   

  72.  //支付成功  

  73.  if($is_success['code'] == 1){   

  74.  $news = array(  

  75.   'touser' => $bdata['openid'],  

  76.   'msgtype' => 'news',  

  77.   'news' => array (  

  78. 'articles'=> array (

  79. array(

  80. ##'title' => 'Order payment successful',

  81. ##​

    'description' => "Payment amount: {$bdata['total_fee']}\n".

  82. ##"WeChat order number: {$bdata['transaction_id']}\n"

  83. 'picurl'

    => '',

  84. 'url'

    => ''

  85. )
  86. ## )
  87. )
  88. ## );

  89. //Send WeChat payment notification

  90. # #$this->sendCustomMessage($news);

  91. }else{//Payment failed

  92. }

  93. ## }

  94. ##/**

  95. ## * Payment success page
  96. * Unreliable callbacks
  97. */
  98. public
  99. function ajax_PaySuccess(){

  100. //Order number
  101. $out_trade_no
  102. = I('post.out_trade_no');

  103. //Payment amount

  104. $ total_fee = I('post.total_fee');

  105. /*Related logic processing*/

  106. ## }

Paste template HTML




##[xhtml]

view plain copy


  1. #html>
  2. ##

    head>

  3. ##meta http-equiv="content-type" content="text/html;charset=utf-8" />

  4. ##meta name="viewport" content="width= device-width, initial-scale=1"/>

  5. ##< ;

    title>WeChat payment sample-paymenttitle >

  6. script type= "text/javascript">

  7. ## //Call WeChat JS api payment

  8. function jsApiCall()

  9. {

  10. WeixinJSBridge.invoke(

  11. ## 'getBrandWCPayRequest',

  12. {$jsApiParameters},

  13. function(res){

  14. ## WeixinJSBridge.log( res.err_msg);
  15. ## //Cancel payment
  16. ## if(

    res.err_msg
  17. == 'get_brand_wcpay_request:cancel'){

    ## //Event logic for processing payment cancellation

  18. ## }else if(res.err_msg

    == "get_brand_wcpay_request:ok"){
  19. /*Use the above method to determine the front-end return. The WeChat team solemnly reminds:

  20. res.err_msg will be used when the user pays Returns ok after success, but it does not guarantee that it is absolutely reliable

  21. ## Here you can use Ajax to submit to the background and process some logs, such as ajax_PaySuccess in the Test controller. method.

  22. */

  23. }

  24. alert(res.err_code+res.err_desc+res.err_msg);

  25. ## }
  26. );
  27.  }  

  28.   

  29.  function callpay()  

  30.  {  

  31.  if (typeof WeixinJSBridge == "undefined"){  

  32.  if( document.addEventListener ){  

  33.  document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);  

  34.  }else if (document.attachEvent){  

  35.  document.attachEvent('WeixinJSBridgeReady', jsApiCall);   

  36.  document.attachEvent('onWeixinJSBridgeReady', jsApiCall);  

  37.  }  

  38.  }else{  

  39.  jsApiCall();  

  40.  }  

  41.  }  

  42.  //获取共享地址  

  43.  function editAddress()  

  44.  {  

  45.  WeixinJSBridge.invoke(  

  46.  'editAddress',  

  47.  {$editAddress},  

  48.  function(res){  

  49.  var value1 = res.proviceFirstStageName;  

  50.  var value2 = res.addressCitySecondStageName;  

  51.  var value3 = res.addressCountiesThirdStageName;  

  52.  var value4 = res.addressDetailInfo;  

  53.  var tel = res.telNumber;   

  54.  alert(value1 + value2 + value3 + value4 + ":" + tel);  

  55.  }  

  56.  );  

  57.  }  

  58.   

  59.  window.onload = function(){  

  60.  if (typeof WeixinJSBridge == "undefined"){  

  61.  if( document.addEventListener ){  

  62.  document.addEventListener('WeixinJSBridgeReady', editAddress, false);  

  63.  }else if (document.attachEvent){  

  64.  document.attachEvent('WeixinJSBridgeReady', editAddress);   

  65.  document.attachEvent('onWeixinJSBridgeReady', editAddress);  

  66.  }  

  67.  }else{  

  68.  editAddress();  

  69.  }  

  70.  };  

  71.   

  72.  script>  

  73. head>  

  74. body>  

  75.  br/>  

  76. font color= "#9ACD32">b>The payment amount for this order isspan style="color:#f00;font-size:50px">1 pointspan>b>font>< ;br/>br/>

  77.  p align="center">  

  78.  button style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer; color:white; font-size:16px;" type="button" onclick="callpay()" >立即支付button>  

  79.  p>  

  80. ##body>

  81. ##html>

  82. notify.php file code, here is a custom method newly added in the official file.





#[php]

view plain

copy


    ##require_once
  1. ROOT_PATH."Api/lib/WxPay.Api.php";

  2. require_once
  3. ROOT_PATH.'Api/lib/WxPay.Notify.php';

  4. require_once
  5. ROOT_PATH.'Api/lib/log.php';

  6.   

  7. //初始化日志  

  8. $logHandlernew \CLogFileHandler(ROOT_PATH."/logs/".date('Y-m-d').'.log');  

  9. $log = \Log::Init($logHandler, 15);  

  10.   

  11. class PayNotifyCallBack extends WxPayNotify  

  12. {  

  13.  protected $para = array('code'=>0,'data'=>'');  

  14.  //查询订单  

  15.  public function Queryorder($transaction_id)  

  16.  {  

  17.  $input = new \WxPayOrderQuery();  

  18.  $input->SetTransaction_id($transaction_id);  

  19.  $result = \WxPayApi::orderQuery($input);  

  20.  \Log::DEBUG("query:" . json_encode($result));  

  21.  if(array_key_exists("return_code"$result)  

  22.  && array_key_exists("result_code"$result)  

  23.  && $result["return_code"] == "SUCCESS"  

  24.  && $result["result_code"] == "SUCCESS")  

  25.  {  

  26.  return true;  

  27.  }  

  28. $this->para['code'] = 0;

  29. $this->para['data'] = '';

  30. ##return false;

  31. }

  32. //Rewrite the callback processing function

  33. ##public function NotifyProcess($data, &$msg)

  34. {

  35. ##\Log::DEBUG(
  36. " call back:"

    . json_encode($data));

  37. $notfiyOutput

    = array();

  38. if(!array_key_exists("transaction_id", $data)){

  39. $msg = "Input parameters are incorrect";

  40. $this->para['code'] = 0;

  41. $this->para['data'] = '';

  42. ##return false;

  43. }

  44. //Query the order to determine if the order is genuine sex

  45. if(!$this->Queryorder($ data["transaction_id"])){

  46. # #$msg = "Order query failed";

  47. $this->para['code'] = 0;

  48. $this->para['data'] = '';

  49. #return false;

  50. }

  51. $this->para['code'] = 1;

  52. $this->para['data'] = $data;

  53. return true;

  54. }

  55. /**

  56. ## * Custom method to detect whether the callback on WeChat is successful

  57. * @return multitype:number string

  58. */

  59. ##public function IsSuccess(){

  60. ##return

    $this->para;

    ## }
  61. }
  62. This is basically completed. You can open
http://test.paywechat on WeChat. com/Charge/index.php/Test/index/

Related recommendations:

detailed explanation of nodejs implementation of WeChat payment function example

Thinkphp integrates WeChat payment function

How to add this WeChat payment function to the PC website

The above is the detailed content of PHP implements WeChat payment function development code sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn