1 | <?php |
||
21 | class PayController extends \yii\web\Controller |
||
22 | { |
||
23 | /** |
||
24 | * @return Module|\yii\base\Module |
||
25 | */ |
||
26 | public function getMerchantModule() |
||
30 | |||
31 | /** |
||
32 | * Disable CSRF validation for POST requests we receive from outside |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function beforeAction($action) |
||
43 | |||
44 | /** |
||
45 | * @return Response |
||
46 | */ |
||
47 | public function actionCancel() |
||
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | public function actionReturn() |
||
65 | |||
66 | /** |
||
67 | * @param string $transactionId |
||
68 | * @throws BadRequestHttpException |
||
69 | * @return array |
||
70 | */ |
||
71 | public function actionCheckReturn($transactionId) |
||
85 | |||
86 | /** |
||
87 | * Action is designed to get the system notification from payment system, |
||
88 | * process it and report success or error for the payment system. |
||
89 | * @return null|string |
||
90 | */ |
||
91 | public function actionNotify() |
||
98 | |||
99 | /** |
||
100 | * Check notifications. |
||
101 | * TODO: implement actual request check and proper handling. |
||
102 | * @return array |
||
103 | */ |
||
104 | public function checkNotify() |
||
110 | |||
111 | public function actionDeposit() |
||
122 | |||
123 | /** |
||
124 | * Renders depositing buttons for given request data. |
||
125 | * |
||
126 | * @param array $data request data: |
||
127 | * - `sum` - the amount of payment without fees |
||
128 | * - `currency` - the currency of transaction |
||
129 | * - `finishPage/Url` - page or URL to redirect user after the payment |
||
130 | * - `returnPage/Url` - page or URL to return user from payment system on success |
||
131 | * - `cancelPage/Url` - page or URL to return user from payment system on fail |
||
132 | * - `notifyPage/Url` - page or URL used by payment system to notify us on successful payment |
||
133 | * @return \yii\web\Response |
||
134 | */ |
||
135 | public function renderDeposit(array $data) |
||
145 | |||
146 | /** |
||
147 | * Performs purchase request. |
||
148 | * @void |
||
149 | */ |
||
150 | public function actionRequest() |
||
174 | } |
||
175 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: