1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\service\api;
- use app\service\ConfServiceFacade;
- use laytp\traits\Error;
- use think\facade\Cache;
- use think\facade\Config;
- use think\facade\Request;
- use Xunhu\Hupijiao\Hupijiao;
- class Hupijiaopay
- {
- use Error;
- /**
- * phpmailer对象
- */
- protected $client;
- protected $pay;
- private $config;
- /**
- * 构造函数
- */
- public function __construct()
- {
- global $_GPC;
- $pay = ConfServiceFacade::groupGet('system.pay', true);
- if(empty($pay)){
- return $this->error('未配置支付接口参数');
- }
- $this->pay=$pay;
- $apiUrl='https://api.xunhupay.com/payment';
- if(!empty($pay['hupijiao_gateway'])){
- $ex = explode('/do.html',$pay['hupijiao_gateway']);
- $apiUrl=$ex[0];
- }
- $this->config = [
- 'app_id' => $pay['hupijiao_appid'], // 配置商户号
- 'app_secret' => $pay['hupijiao_appsecret'], // 配置密钥
- 'api_url'=>$apiUrl
- ];
- }
- public function pay($post){
- // 初始化
- $Hupijiao=new Hupijiao($this->config);
- $data=$post;
- //回调地址,服务器post发送成功支付参数到此地址
- //异步跳转地址,支付成功后跳转地址
- $data['wap_url']=!empty($this->pay['hupijiao_gateway'])?$this->pay['hupijiao_gateway']:'https://api.xunhupay.com/payment';
- $response=$Hupijiao->request('wx_native',$data);
- return $response;
- }
- }
|