checkSign($arr, $sign, $order_no, $price, $real_price, $is_bill_no = 0, $bill_no); } /** * 返回跳转 * @param array $data * @return void [type] [description] */ function redirect(array $data) { // TODO: Implement redirect() method. } /** * 检查支付信息 * @return void [type] 0=失败,1=成功 */ function check() { // TODO: Implement check() method. } /** * 构建订单提交数组 * @return array */ function buildOrder(): array { $arr['payKey'] = $this->paymentConfig['merchant_id']; $arr['payWayCode'] = 'ZITOPAY'; $arr['orderNo'] = $this->dataAccess->orderSn; $arr['orderPrice'] = $this->dataAccess->money; $arr['productName'] = $this->dataAccess->goodsName ?? 'GoodsName'; $arr['payTypeCode'] = $this->dataAccess->payType; $arr['notifyUrl'] = $this->notifyUrl; $arr['returnUrl'] = $this->redirectUrl; $arr['orderIp'] = $this->getRealIp(); $arr['orderDate'] = date('Ymd', time()); $arr['orderTime'] = date('YmdHis', time()); $arr['orderPeriod'] = 30; $arr['remark'] = $this->dataAccess->goodsName ?? 'GoodsName'; $arr['field1'] = $this->dataAccess->goodsName ?? 'GoodsName'; $arr['sign'] = $this->buildSign($arr, $this->paymentConfig['merchant_md5_secret']); return $arr; } /** * 生成签名函数 * @param array $param * @param string $merchantSecret * @return mixed */ function buildSign(array $param, $merchantSecret) { ksort($param); $a = ''; foreach ($param as $x => $x_value) { if ($x_value) { $a = $a . $x . '=' . $x_value . '&'; } } return strtoupper(md5($a . 'paySecret=' . $merchantSecret)); } /** * 基础配置 * @return void */ function config() { $this->apiUrl = "http://api.quanyinzf.com:8050/rb-pay-web-gateway/scanPay/initPayIntf"; } /** * 设置返回类型 * @param string $type */ function setReturnType($type = 'HTML') { // TODO: Implement setReturnType() method. } /** * 发起支付函数 * @return mixed */ function goPay() { $order_info = $this->buildOrder(); $json = $this->goPayCurl($this->apiUrl, $order_info); $ret = json_decode($json, 1); if (!$ret || $ret['result'] !== 'success' || !$ret['code_url']) { Render('', -5989); } $this->apiUrl = $ret['code_url']; $dpgateName = ''; switch ($this->dataAccess->payType) { case 'ZITOPAY_ALI_SCAN': $dpgateName = '支付宝'; break; case 'ZITOPAY_WX_SCAN': $dpgateName = '微信'; break; case 'ZITOPAY_QQ_SCAN': $dpgateName = 'QQ'; break; case 'JPAY_JDPAY': $dpgateName = '京东钱包'; break; case 'ZITOPAY_UNION_SCAN': $dpgateName = '银联'; break; default: $this->prePay(1); } $this->prePay(1, $this->apiUrl, $dpgateName); } }