普陀 发表于 2024-9-30 12:01:29

苹果CMS接入GOGO支付实现个人收款回调详细教程

之前写了一篇苹果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支付,如果你需要多种支付方式切换,自行调整代码即可。

71777 发表于 2024-10-6 17:51:07

回复领积分下模版噜!
页: [1]
查看完整版本: 苹果CMS接入GOGO支付实现个人收款回调详细教程