Commit e12b29b7 by 冷斌

fix bug

parent e8adf203
......@@ -181,8 +181,9 @@ class Api_Charge extends PhalApi_Api {
require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
$wx_config = [
'wechat' => [
'appid' => 'wxa6bcebff7f4c5a3f',
'appSecret' => '4b7d6cd67fc566659fd1d9bd399dbcba',
// 'appid' => 'wxa6bcebff7f4c5a3f',
'app_id' => 'wx31ac4d2b862fa9c0',
// 'appSecret' => '4b7d6cd67fc566659fd1d9bd399dbcba',
'mch_id' => '1582052881',
'key' => 'XCthxXszMdXiybUZnJBxyVgyVnV4zPuQ',
'notify_url' => 'http://www.seals-live.com/index.php?g=Appapi&m=pay&a=notify_wx',
......
<?php
class Wxpay
{
protected function config()
{
return [
'appid' => '', // app 开放平台的APPID
'app_id' => '', // 公众号 APPID
'miniapp_id' => '', //小程序 APPID
'appSecret' => '', // 公众号 秘钥
'mch_id' => '', // 商户号 id
'key' => '', // 商户 key
'notify_url' => '/pay/wx',
'cert_client' => __DIR__ . '/apiclient_cert.pem', // optional, 退款,红包等情况时需要用到
'cert_key' => __DIR__ . '/apiclient_key.pem',// optional, 退款,红包等情况时需要用到
];
}
protected function getWx()
{
$config = $this->config();
return Yansongda\Pay\Pay::wechat($config);
}
public function scan(array $order)
{
$wx = $this->getWx()->scan($order);
return [
'id' => $order['out_trade_no'],
'qr' => $wx->code_url,
];
}
public function app(array $order)
{
$data = $this->getWx()->app($order);
return json_decode($data, true);
}
public function pos(array $order)
{
// $order = [
// 'out_trade_no' => time(),
// 'body' => 'subject-测试',
// 'total_fee' => '1',
// 'auth_code' => '1354804793001231564897',
// ];
return $this->getWx()->pos($order);
}
public function transfer(array $order)
{
// $order = [
// 'partner_trade_no' => '', //商户订单号
// 'openid' => '', //收款人的openid
// 'check_name' => 'NO_CHECK', //NO_CHECK:不校验真实姓名\FORCE_CHECK:强校验真实姓名
// // 're_user_name'=>'张三', //check_name为 FORCE_CHECK 校验实名的时候必须提交
// 'amount' => '1', //企业付款金额,单位为分
// 'desc' => '帐户提现', //付款说明
// ];
return $this->getWx()->transfer($order);
}
public function mini(array $order)
{
// $order = [
// 'out_trade_no' => time(),
// 'body' => 'subject-测试',
// 'total_fee' => '1',
// 'openid' => 'onkVf1FjWS5SBxxxxxxxx',
// ];
return $this->getWx()->miniapp($order)->toArray();
}
public function html(array $order, $isH5 = false, $isScan = false)
{
// $order = [
// 'out_trade_no' => time(),
// 'body' => 'subject-测试',
// 'total_fee' => '1',
// 'openid' => 'onkVf1FjWS5SBxxxxxxxx',
// ];
if ($isH5) {
return $this->getWx()->wap($order)->send();
}
if ($isScan) {
return $this->scan($order);
}
return $this->getWx()->mp($order)->toArray();
}
public function notify($callback)
{
$wx = $this->getWx();
try {
$data = $wx->verify();
$r = call_user_func_array($callback, [$data]);
if (!empty($r)) {
return $wx->success()->send();
}
} catch (\Exception $e) {
$e->getMessage();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment