NotifyController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\YunfastPay\api\modules\v1\controllers;
  3. use addons\YunfastPay\common\services\NotifyService;
  4. use addons\YunfastPay\common\services\YunPayService;
  5. use Yii;
  6. use yii\helpers\Json;
  7. use yii\web\Controller;
  8. use function addons\YunfastPay\common\encrypt;
  9. /**
  10. * 支付回调控制器
  11. * Class NotifyController
  12. * @package addons\YunfastPay\api\modules\v1\controllers
  13. */
  14. class NotifyController extends Controller
  15. {
  16. public $enableCsrfValidation = false;
  17. /**
  18. * 首页
  19. *
  20. * @return void
  21. */
  22. public function actionIndex()
  23. {
  24. $msg = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input");
  25. $mall_id = $this->request->get('mall_id');
  26. $type = $this->request->get('type');
  27. if (empty($msg)) {
  28. # 如果没有数据,直接返回失败
  29. echo "数据有误";exit;
  30. }
  31. if (empty($mall_id)) {
  32. Yii::error('银典支付缺少mall-id');
  33. die;
  34. }
  35. $service = new NotifyService(['mall_id' => $mall_id]);
  36. $service->check($msg, $type);
  37. echo "{\"respCode\" : \"0000\", \"respMsg\" : \"成功\"}";
  38. }
  39. }