You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.8 KiB
76 lines
1.8 KiB
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: travis
|
|
* Date: 2019/12/12
|
|
* Time: 15:59
|
|
*/
|
|
|
|
namespace api\controllers;
|
|
|
|
|
|
use api\logic\WxPaymentLogic;
|
|
use yii\filters\auth\HttpBearerAuth;
|
|
use yii\helpers\ArrayHelper;
|
|
use yii\web\Response;
|
|
use Yii;
|
|
use yii\web\BadRequestHttpException;
|
|
|
|
class WxPaymentController extends CommonController
|
|
{
|
|
public $modelClass = 'backend\modules\shop\models\ars\Order';
|
|
public $className = 'api\logic\WxPaymentLogic';
|
|
|
|
public function behaviors()
|
|
{
|
|
return ArrayHelper::merge(parent::behaviors(), [
|
|
'authenticatior' => [
|
|
'class' => HttpBearerAuth::className(),
|
|
'except' => ['notify', 'test'],
|
|
]
|
|
]);
|
|
}
|
|
|
|
public function actions()
|
|
{
|
|
$action = parent::actions();
|
|
unset($action['index']);
|
|
unset($action['update']);
|
|
unset($action['view']);
|
|
unset($action['delete']);
|
|
$action['options'] = [
|
|
'class' => 'yii\rest\OptionsAction',
|
|
'collectionOptions' => ['PUT', 'GET', 'OPTIONS']
|
|
];
|
|
return $action;
|
|
}
|
|
|
|
public function actionWeb()
|
|
{
|
|
return $this->object->wxPayment(WxPaymentLogic::PAY_TYPE_WEB);
|
|
}
|
|
|
|
public function actionMiniProgram()
|
|
{
|
|
return $this->object->wxPayment(WxPaymentLogic::PAY_TYPE_MINI_PROGRAM);
|
|
}
|
|
|
|
/**
|
|
* @return array|bool
|
|
* @throws BadRequestHttpException
|
|
* @throws \yii\base\InvalidConfigException
|
|
* @throws \yii\httpclient\Exception
|
|
* 异步回调
|
|
*/
|
|
public function actionNotify()
|
|
{
|
|
Yii::$app->response->format = Response::FORMAT_XML;
|
|
return $this->object->notify();
|
|
}
|
|
|
|
public function actionTest()
|
|
{
|
|
$data = Yii::$app->request->getBodyParam('notify');/*int 商品id*/
|
|
return $data;
|
|
}
|
|
}
|