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 searchPayment($params)
 {
     $pageSize = Yii::$app->params['pageSize'];
     $query = PaymentForm::find();
     $dataProvider->sort->attributes['id'] = ['asc' => ['id' => SORT_ASC], 'desc' => ['id' => SORT_DESC]];
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => $pageSize]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'student_id' => $this->student_id, 'payment_description' => $this->payment_description, 'transaction' => $this->transaction, 'paid_amount' => $this->paid_amount]);
     return $dataProvider;
 }
 protected function findPayments($id)
 {
     if (($payments = PaymentForm::find()->where(['assessment_id' => $id])->orderBy(['id' => SORT_DESC])->all()) !== null) {
         return $payments;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
<?php

use app\models\Options;
use yii\helpers\Html;
use app\models\AssessmentForm;
use app\models\PaymentForm;
$this->title = implode(' ', [$model->student->first_name, $model->student->middle_name, $model->student->last_name]);
$payments = PaymentForm::find()->where(['assessment_id' => $assessment[0]->id])->orderBy(['id' => SORT_DESC])->all();
?>
<div class="ui two column stackable grid">
    <div class="four wide column">
        <div class="column">
            <?php 
echo $this->render('_card', ['model' => $model]);
?>
        </div>
    </div>
    <div class="nine wide column">
        <div class="column">
            <?php 
echo $this->render('_detail', ['model' => $model, 'assessment' => $assessment[0], 'payments' => $payments]);
?>
        </div>
    </div>
    <div class="three wide column">
        <div class="column">
            <?php 
echo Options::render(['scenario' => Yii::$app->controller->action->id, 'id' => $model->id]);
?>
        </div>
    </div>
 /**
  * Finds the Payment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Payment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PaymentForm::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }