| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace backend\controllers;
- use common\pay\BasePayHandler;
- use common\pay\PayForm;
- use Yii;
- class PayController extends BaseController
- {
- /**
- * 支付
- * @return \yii\web\Response
- */
- public function actionOutpay()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post();
- $model->setAttributes($data);
- if ($model->outPay()) {
- $result['type'] = 'html';
- $result['html'] = $model->getOutPayResult();
- return $this->outJson(1, $result, 'OK');
- } else {
- return $this->outJson(0, [], $model->getErrors());
- }
- }
- /**
- * 异步回调
- * @return \yii\web\Response
- */
- public function actionNotify()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post();
- if ($model->handleNotify($data)) {
- return $this->outJson(1, $model->getOutNotifyResult());
- } else {
- return $this->outJson(0, $model->getOutNotifyResult());
- }
- }
- /**
- * 同步回调
- * @return \yii\web\Response
- */
- public function actionReturn()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post();
- if ($model->handleReturn($data)) {
- return $this->outJson(1, $model->getOutReturnResult());
- } else {
- return $this->outJson(0, $model->getOutReturnResult());
- }
- }
- /**
- * 退款
- * @return \yii\web\Response
- */
- public function actionRefund()
- {
- $payType = 3;
- $handler = BasePayHandler::getPayHandlerByPayType($payType);
- $res = $handler->outRefund();
- return $this->outJson(1, $res);
- }
- }
|