| 
 
 之前写了一篇苹果CMSV10实现个人支付回调的简单教程,有朋友反应还是不会,于是现在弄了一个详细版本。  
如果你不太懂代码的,直接下载完整插件,按照使用说明操作就可以立马使用了。  
苹果CMSV10个人免签支付插件(接入GOGO支付)  
https://download.csdn.net/download/gogozhifu/20629627  
就设置了1个积分,支持一下哈(如果1个积分都木有,直接联系我发给你~)  
包含的文件如下截图:  
   
 
 
上面最简单粗暴的使用方式讲完了,下面给有需要自定义调整开发的朋友介绍一下这些代码内容。  
1.gogozhifu.html  
这个是后台配置用的页面。  
2.Gogozhifu.php  
这个是调起GOGO支付下单接口的方法,主要是使用了这个接口,具体跟多的参数和使用方法参考官方的文档即可。  
public function submit($user, $order, $params)
    {
        $appId = trim($GLOBALS['config']['pay']['gogozhifu']['appid']);
        $appSecret = trim($GLOBALS['config']['pay']['gogozhifu']['appsecret']);
        $url = "https://www.gogozhifu.com/shop/api/createOrder";
        //API参考文档:https://www.gogozhifu.com/develop.html#dev-services
        $payId = $order['order_code'];
        $param = 'userId' . $user['user_id'];
        $type = $params['paytype'];
        $price = $order['order_price'];
        $sign = md5($appId . $payId . $param . $type . $price. $appSecret);
        $data = [
            'payId' => $payId,
            'param' => $param,
            'type' => $type,
            'price' => $price,
            'sign' => $sign,
            'isHtml' => 1,
            'notifyUrl' => $GLOBALS['http_type'] . $_SERVER['HTTP_HOST'] . '/index.php/payment/notify/pay_type/gogozhifu',//通知地址
            'returnUrl' =>$GLOBALS['http_type'] . $_SERVER['HTTP_HOST'] . '/index.php/payment/notify/pay_type/gogozhifu',//跳转地址
        ];
        return $this->ggPost($url, $data);
    }  
3.Go.php  
为了避免修改User.php中原来的gopay方法,这里另外新建了一个Go控制器,里面有个gogozhifu方法来实现在线支付。可以参照着自己调整原来的代码合并成一个方法。  
public function gogozhifu()
    {
        $param = input();
        $order_code = htmlspecialchars(urldecode(trim($param['order_code'])));
        $order_id = intval((trim($param['order_id'])));
        $payment = strtolower(htmlspecialchars(urldecode(trim($param['payment']))));
        if (empty($order_code) && empty($order_id) && empty($payment)) {
            return $this->error(lang('param_err'));
        }
        if ($GLOBALS['config']['pay'][$payment]['appid'] == '') {
            return $this->error(lang('index/payment_status'));
        }
        //核实订单
        $where['order_id'] = $order_id;
        $where['order_code'] = $order_code;
        $where['user_id'] = $GLOBALS['user']['user_id'];
        $res = model('Order')->infoData($where);
        if ($res['code'] > 1) {
            return $this->error(lang('index/order_not'));
        }
        if ($res['info']['order_status'] == 1) {
            return $this->error(lang('index/order_payed'));
        }
        $cp = 'app\\common\\extend\\pay\\' . ucfirst($payment);
        if (class_exists($cp)) {
            $c = new $cp;
            $payment_res = $c->submit($this->user, $res['info'], $param);
        }
        if ($payment == 'gogozhifu') {
            echo $payment_res;
        }
    }  
4.pay.html  
这个文件我把它默认的其他乱七八糟的支付方式都去掉了,只保留了GOGO支付,如果你需要多种支付方式切换,自行调整代码即可。  
<form method="post" target="_blank" action="{:url('go/gogozhifu')}">
			<input type="hidden" name="order_id" value="{$info.order_id}">
			<input type="hidden" name="order_code" value="{$info.order_code}">
		<div class="line40">
			<p><span class="xiang">订单编号:</span>{$info.order_code}</p>
			<p><span class="xiang">订单金额:</span>{$info.order_price}元</p>
			<p>
				<span class="xiang">支付方式:</span>
				<a target="_blank" href="https://www.gogozhifu.com">GOGO支付</a>
				 - 免费注册使用、个人免签约、无手续费、实时回调
				<input type="hidden" name="payment" value="gogozhifu">
			</p>
			<p class="info-item" id="paytype_box">
				<span class="xiang">支付类型:</span>
				<select class="paytype" id="paytype" name="paytype">
					{maccms:foreach name=":explode(',',$config.gogozhifu.type)"}
					<option value ="{$vo}">
						{if condition="$vo==1"}微信
						{elseif condition="$vo==2"/}支付宝{/if}
					</option>
					{/maccms:foreach}
				</select>
			</p>
			<p><input type="submit" id="btn_submit" class="jifen2-button" value="确认"></p>
		</div>
		</form>  
 
好了,这样就OK了,还有其他问题的欢迎评论、私信交流~  
对你有帮助的话给我点个赞吧~ 
                
        
    
 
 |