Ejemplo n.º 1
0
 public function run()
 {
     Yii::app()->clientScript->registerScriptFile($this->assetUrl . '/assets/jquery.payment.js');
     Yii::app()->clientScript->registerScriptFile($this->assetUrl . '/assets/wscreditcardform.js');
     $arrEnabledCreditCardLabel = array_map(function ($creditCard) {
         return $creditCard->label;
     }, CreditCard::model()->enabled()->findAll());
     $this->render('creditcardform', array('model' => $this->model, 'form' => $this->form, 'arrEnabledCreditCardLabel' => $arrEnabledCreditCardLabel, 'strCardTypeNotSupported' => Yii::t('checkout', MultiCheckoutForm::DISABLED_CARD_TYPE)));
 }
Ejemplo n.º 2
0
 public function actionDeleteCards()
 {
     Yii::import('application.extensions.vendor.autoload', true);
     Httpful\Bootstrap::init();
     Balanced\Bootstrap::init();
     Balanced\Settings::$api_key = Yii::app()->params['balancedAPISecret'];
     if (isset($_POST['data'])) {
         $dataString = $_POST['data'];
         $data = json_decode($dataString);
         $user_ID = $this->getUser()->User_ID;
         foreach ($data as $card) {
             $cardModel = CreditCard::model()->findByPk($card);
             if ($cardModel->User_ID == $user_ID) {
                 $cardModel->Active = 0;
                 $cardModel->save();
                 $balancedCard = Balanced\Card::get($cardModel->URI);
                 $balancedCard->is_valid = false;
                 $balancedCard->save();
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Check the credit card type.
  * @param $attribute The attribute name.
  * @param $params Additional parameters defined in the rules.
  * @return void
  */
 public function validateCardType($attribute, $params)
 {
     if (empty($this->cardType) === true) {
         // If the card type isn't sent, we allow it and rely on the payment
         // processor to decline if invalid.
         Yii::log('Unable to validate card type - card type is empty.', 'info', 'application.' . __CLASS__ . '.' . __FUNCTION__);
         return;
     }
     $arrEnabledCreditCardLabel = array_map(function ($creditCard) {
         return $creditCard->label;
     }, CreditCard::model()->enabled()->findAll());
     if (in_array($this->cardType, $arrEnabledCreditCardLabel) === false) {
         $this->addError($attribute, Yii::t('checkout', static::DISABLED_CARD_TYPE, array('{card type}' => $this->cardType)));
     }
 }
Ejemplo n.º 4
0
 public function actionCardtypes()
 {
     if ($this->_allowAdvancedPayments === false) {
         _xls_404();
     }
     $model = new CreditCard();
     $pk = Yii::app()->getRequest()->getPost('pk');
     $name = Yii::app()->getRequest()->getPost('name');
     $value = Yii::app()->getRequest()->getPost('value');
     if ($pk) {
         CreditCard::model()->updateByPk($pk, array($name => $value));
         echo "success";
     }
     $this->render("cardtypes", array('model' => $model));
 }
Ejemplo n.º 5
0
 /**
  * @return array
  */
 public function getCardTypes()
 {
     return CHtml::listData(CreditCard::model()->findAllByAttributes(array('enabled' => 1), array('order' => 'sort_order,label')), 'validfunc', 'label');
 }