<?php
namespace backend\controllers;

use backend\models\RemitApi;
use Yii;
use yii\web\Controller;

class RemitController extends Controller
{
    public $enableCsrfValidation = false;

    /**
     * 打款异步回调
     * @return string
     */
    public function actionNotify()
    {
        $remitNo = trim(Yii::$app->getRequest()->get('remitNo'));
        if ($remitNo == '' || ($remitNo = Yii::$app->getSecurity()->unmaskToken($remitNo)) == '') {
            return 'invalid request';
        }
        if (Yii::$app->getRequest()->getIsPost()) {
            $data = Yii::$app->getRequest()->post();
        } else {
            $data = Yii::$app->getRequest()->get();
        }
        $api = new RemitApi();
        $result = $api->callNotify($data);
        return $result['data'];
    }
}