public function actionPayment() { $headers = Yii::$app->request->getHeaders(); if ($headers->has('X-TERMINAL')) { Yii::$app->response->format = Response::FORMAT_JSON; $model = new PaymentForm(); if ($model->hasError()) { return $model->getError(); } $transaction = Transaction::create(); $connector = new CateringConnector(); $response = $connector->pay($transaction); if (in_array($response['status'], ['error', 'redirect'])) { return $response; } $transaction->is_fulfilled = true; $transaction->save(); return ['status' => 'success']; } Yii::$app->getSession()->set('payer.account_type', Yii::$app->request->get('account_type')); $bills = Bill::find()->where(['enabled' => true])->select('denomination')->asArray()->all(); $denominations = []; foreach ($bills as $bill) { $denominations[] = $bill['denomination']; } Yii::$app->get('xmlrpc')->enableBillTypes(); return $this->render('payment', ['denominations' => implode(', ', $denominations)]); }
public function actionResendFailed() { $transactions = Transaction::findAll(['is_fulfilled' => false]); if (count($transactions) === 0) { echo "There are no failed transactions\n"; return; } $connector = new CateringConnector(); foreach ($transactions as $transaction) { $response = $connector->pay($transaction); if ($response['status'] === 'success') { echo 'Transaction ' . $transaction->id . " SUCCEEDED\n"; $transaction->is_fulfilled = true; $transaction->save(); } else { echo 'Transaction ' . $transaction->id . " FAILED\n"; } } }