Commit 2149102d by 冷斌

fix bug

parent ba894db6
......@@ -84,6 +84,9 @@ class Api_Charge extends PhalApi_Api {
return $rs;
}
var_dump(get_class((new Wxpay())));
die;
$orderinfo=array(
"uid"=>$uid,
"touid"=>$uid,
......
<?php
use Yansongda\Pay\Pay;
/**
* composer require yansongda/pay -vvv
*
* Class Wxpay
* @package common\models\payment\wx
*/
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 Pay::wechat($config);
}
public function getOpenid()
{
return (new JsApiPay())->GetOpenid($this->config());
}
public function getUserInfo($openid, $accessToken)
{
return (new JsApiPay())->getUserInfo($openid, $accessToken);
}
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) {
\Yii::error($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