source/index/recharge_wxapp_pay.ctrl.php

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
  class recharge_wxapp_payControl extends skymvc{
  	
  	public function __construct(){
  		parent::__construct();
  	}
  	
  	public function onDefault(){
  		
  	}
		
  	public function getWeixin(){
  			$wid=get_post('wid','i');
  			if($wid){
  			$where=" id=".$wid;
  			}else{
  			$where="";
  			}
  			$wx=M("open_wxapp")->selectRow(array("where"=>$where,"order"=>"id DESC"));
  			return $wx;
  	}
  	public function onGo(){
  	 
  		 
  		$INWXAPP=true;
  		require_once ROOT_PATH."api/wxpay/lib/WxPay.Config.php";
			$wx=$this->getWeixin();	
			if(empty($wx)){
				exit("微信支付未配置");
			}  
			WxPayConfig::init($wx);
			require_once  (ROOT_PATH.'/api/wxpay/lib/WxAppPay.Api.php');
			
			
			$openid=get('openid','h'); 
			$money=get("money","r",2);
			$userid=M("login")->userid;
			$orderno=get('orderno','h');
			$order=M("recharge")->selectRow(array("where"=>" orderno='".$orderno."' "));
			$order_product="产品购买".$userid; 
			$input = new WxPayUnifiedOrder();  
			//         文档提及的参数规范:商家名称-销售商品类目  
			$input->SetBody($order_product);  
			//         订单号应该是由小程序端传给服务端的,在用户下单时即生成,demo中取值是一个生成的时间戳  
			$input->SetOut_trade_no($orderno);  
			//         费用应该是由小程序端传给服务端的,在用户下单时告知服务端应付金额,demo中取值是1,即1分钱  
			$input->SetTotal_fee($order['money']*100);  
			$input->SetNotify_url(HTTP_HOST."/index.php/recharge_wxapp_pay/notify");//需要自己写的notify.php  
			$input->SetTrade_type("JSAPI");  
			//         由小程序端传给后端或者后端自己获取,写自己获取到的,  
			$input->SetOpenid($openid);  
			//         向微信统一下单,并返回order,它是一个array数组  
			
		 
			$order = WxPayApi::unifiedOrder($input); 
			 
			//         json化返回给小程序端  
			//header("Content-Type: application/json");  
			echo $this->getJsApiParameters($order);  
    }  
后面还有 54 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。