예제 #1
0
 /**
  * Generate url
  * @param AESBase $aes
  * @return string
  */
 public function generateUrl($aes)
 {
     if (!$aes || !$aes instanceof AESBase) {
         throw new Exception('Invalid param');
     }
     //trans_id &pkg&price&back_url&Information
     $link = $this->getTransactionId() . '&' . $this->getPackageName() . '&' . $this->getPrice() . '&' . $this->getBackUrl() . '&' . $this->getInformation();
     $link = $aes->encrypt($link);
     return self::BASE_URL . '?sp_id=' . $this->getSpId() . '&link=' . $link;
 }
예제 #2
0
 public function actionVasRegister()
 {
     $package_id = Yii::app()->request->getParam('package');
     $phone = yii::app()->user->getState('msisdn');
     $back_link = Yii::app()->request->getParam('back_link', '');
     if ($back_link != '') {
         Yii::app()->session['back_link'] = $back_link;
     }
     if (isset($_GET['link'])) {
         $requestData = $this->aes->decrypt("{$_GET['link']}");
         $composition = explode('&', $requestData);
         $transactionID = $composition[0];
         $msisdnResponse = $composition[1];
         $confirm = $composition[2];
         $transactionVAS = VasGateModel::model()->findByAttributes(array('transaction_id' => $transactionID));
         $package_id = $transactionVAS->package_id;
         if ($confirm == 1) {
             if (Formatter::formatPhone($phone) == Formatter::formatPhone($msisdnResponse)) {
                 $this->_register($phone, $package_id, true);
                 $this->redirect(Yii::app()->session['back_link']);
             }
         } else {
             $this->redirect($this->createUrl("/site"));
         }
     } else {
         $check_promotion = $this->check_promotion($phone);
         $pDetail = PackageModel::model()->findByPk($package_id);
         $price = $pDetail->fee;
         $packageCode = $pDetail->code;
         /*if($check_promotion){
               $price = 0;
           }*/
         if ($check_promotion) {
             $price = 0;
             if ($package_id == 1) {
                 $fee = ' 2000 đồng/1 ngày';
             } else {
                 $fee = ' 7000 đồng/7 ngày';
             }
             $fee .= "|| Khuyến mại 5 ngày";
         } else {
             if ($package_id == 1) {
                 $fee = '1 ngày';
             } else {
                 $fee = '7 ngày';
             }
         }
         $convmap = array(0x80, 0xffff, 0, 0xffff);
         $fee = mb_encode_numericentity($fee, $convmap, 'UTF-8');
         $fee = str_replace("&#", "##", $fee);
         $vasGate = new VasGateModel();
         $vasGate->transaction_id = time() . $phone;
         $vasGate->package_id = $pDetail->id;
         $vasGate->information = $pDetail->code;
         $vasGate->price = $price;
         if ($vasGate->save()) {
             $urlGen = new UrlGenerator($this->spId, $vasGate->transaction_id, $packageCode, $price, 'http://amusic.vn/account/vasRegister', $fee);
             $url = $urlGen->generateUrl($this->aes);
             $this->redirect($url);
         }
         $this->redirect('/');
     }
 }
예제 #3
0
 public function __construct($key, $iv)
 {
     parent::__construct($key, $iv);
 }