2024-10-01 耶鲁沙冷
苹果CMS接入GOGO支付实现个人收款回调详细教程-1.png (193.88 KB, 下载次数: 0)
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支付,如果你需要多种支付方式切换,自行调整代码即可。原文链接:https://daomb.com/news/3870.html
本文版权:如无特别标注,本站文章均为原创。