123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\controller;
- use kjpay\kjpay;
- use think\Db;
- /**
- * 公众号支付接口
- */
- class Publicpay extends Common
- {
- protected $noNeedLogin = [''];
- protected $noNeedRight = '*';
- public function _initialize()
- {
- parent::_initialize();
- }
- /**
- * 微信支付
- */
- public function wxpay() {
- // 获取公共参数
- $config = config("publicPay");
- //商户订单号,商户网站订单系统中唯一订单号,必填
- $out_trade_no = date('YmdHis').rand(10000, 99999);
- //商户号
- $merchant_no = $config["merchant_no"];
- //密钥
- $key = $config["key"];
- // 实例化支付类
- $kjpay = new kjpay();
- //请求的参数(注:不同支付接口请求参数略有不同,具体请参照接口文档)
- $param = array(
- 'merchant_no' => $merchant_no,
- 'merchant_order_no' => $out_trade_no,
- //异步通知的地址
- 'notify_url' => $config["notify_url"],
- //同步跳转的地址
- //'return_url' => 'http://www.kj-pay.com',
- 'start_time' => date('YmdHis'),
- 'trade_amount' => 0.01,
- 'goods_name' => "商品名称",
- 'goods_desc' => "商品描述",
- 'user_ip' => $kjpay->get_wx_ip(),
- 'pay_sence' => '{"type":"Wap","wap_url":"https://www.kk30.com","wap_name":"快快网络"}',
- 'sign_type' => 1
- );
- //签名
- $sign = $kjpay->local_sign($param, $key);
- $param['sign'] = $sign;
- $res = $kjpay->getdata("http://商户后台查询请求地址/wechar/wap_pay", $param);
- $list = json_decode($res, true);
- echo "<pre>";
- print_r($list);
- echo "<pre>";
- }
- }
|