PayController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace backend\controllers;
  3. use common\pay\PayForm;
  4. use Yii;
  5. class PayController extends BaseController
  6. {
  7. /**
  8. * 支付
  9. * @return \yii\web\Response
  10. */
  11. public function actionOutpay()
  12. {
  13. $model = new PayForm();
  14. $data = Yii::$app->getRequest()->post();
  15. $model->setAttributes($data);
  16. if ($model->outPay()) {
  17. $result['type'] = 'html';
  18. $result['html'] = $model->getOutPayResult();
  19. return $this->outJson(1, $result, 'OK');
  20. } else {
  21. return $this->outJson(0, [], $model->getErrors());
  22. }
  23. }
  24. /**
  25. * 异步回调
  26. * @return \yii\web\Response
  27. */
  28. public function actionNotify()
  29. {
  30. $model = new PayForm();
  31. $data = Yii::$app->getRequest()->post();
  32. if ($model->handleNotify($data)) {
  33. return $this->outJson(1, $model->getOutNotifyResult());
  34. } else {
  35. return $this->outJson(0, $model->getOutNotifyResult());
  36. }
  37. }
  38. /**
  39. * 同步回调
  40. * @return \yii\web\Response
  41. */
  42. public function actionReturn()
  43. {
  44. $model = new PayForm();
  45. $data = Yii::$app->getRequest()->post();
  46. if ($model->handleReturn($data)) {
  47. return $this->outJson(1, $model->getOutReturnResult());
  48. } else {
  49. return $this->outJson(0, $model->getOutReturnResult());
  50. }
  51. }
  52. }