Example #1
0
 public function actionDpostprocess($xmlReq)
 {
     //Yii::app()->request->enableCsrfValidation = false;
     $lsdata = $xmlReq;
     $d3 = new TripleDESEncryption();
     $llave = "N2dYKcI9ivQEPlHN0/TCBJHp1c7OYtV5";
     $iv = "JbEFFDiOkRc=";
     $lsdata = $d3->decrypt($lsdata, $llave, $iv);
     list($datos, $aut, $Cre, $mes, $ttar, $sub, $Iva, $Ice, $Int, $Tot, $tNo, $cD, $tipo) = split('[&]', $lsdata);
     list($p0, $DATOS) = split('[=]', $datos);
     list($p1, $AUT) = split('[=]', $aut);
     list($p3, $CRE) = split('[=]', $Cre);
     list($p4, $MES) = split('[=]', $mes);
     list($p5, $TTAR) = split('[=]', $ttar);
     list($p6, $SUB) = split('[=]', $sub);
     list($p7, $IVA) = split('[=]', $Iva);
     list($p8, $ICE) = split('[=]', $Ice);
     list($p9, $INT) = split('[=]', $Int);
     list($p10, $TOT) = split('[=]', $Tot);
     list($p11, $TNO) = split('[=]', $tNo);
     list($p12, $CD) = split('[=]', $cD);
     list($p13, $TIPO) = split('[=]', $tipo);
     $logs = new Logs();
     $logs->type = "POSTPROCESS";
     $logs->description = "TIPO:" . $TIPO . "DATOS:" . $DATOS . "AUT:" . $AUT . "CRE:" . $CRE . "MES:" . $MES . "TTAR:" . $TTAR . "SUB:" . $SUB . "IVA:" . $IVA . "ICE:" . $ICE . "INT:" . $INT . "TOTAL:" . $TOT . "TNO:" . $TNO . "CD:" . $CD;
     $logs->creation_date = date("Y-m-d H:i:s");
     $logs->save();
     if ($TIPO == 'P') {
         $sell = Sell::findOne($DATOS);
         $user = User::findOne($sell->user_id);
         $id = $user->id;
         $sell->status = "COMPLETE";
         $carshop = CarShop::find()->where(['user_id' => $sell->user_id])->all();
         if ($sell->save()) {
             foreach ($carshop as $item) {
                 $detail = new Detail();
                 $detail->product_id = $item->product_id;
                 $detail->quantity = $item->quantity;
                 $detail->sell_id = $DATOS;
                 $detail->sap_id = $item->sap_id;
                 $detail->save();
             }
             CarShop::deleteAll("user_id = {$id}");
             $dinerstransaction = new DinersTransaction();
             $dinerstransaction->fecha = date("Ymd");
             $dinerstransaction->hora = date("His");
             $dinerstransaction->orden = $TNO;
             $dinerstransaction->marca = $TTAR;
             $dinerstransaction->subtotal = strval($SUB / 100);
             $dinerstransaction->iva = strval($IVA / 100);
             $dinerstransaction->impuesto = "0.00";
             $dinerstransaction->interes = "0.00";
             $dinerstransaction->total = strval($TOT / 100);
             $dinerstransaction->autorizacion = $AUT;
             $dinerstransaction->ruc = "1790241483001";
             $dinerstransaction->credito = $CRE;
             $dinerstransaction->meses = $MES;
             $dinerstransaction->estado = $TIPO;
             $dinerstransaction->conciliado = "";
             $dinerstransaction->extra = "n/a";
             $dinerstransaction->save();
             $email = Yii::$app->mailer->compose('transaction', ['name' => $user->names, 'aut' => $sell->transactionid, 'total' => $TOT / 100])->setFrom('*****@*****.**')->setTo($user->username)->setSubject($user->names . " " . "tu transacción fue completada con éxito")->send();
             if ($email) {
                 echo 'ESTADO=OK';
             } else {
                 echo 'ESTADO=KO';
             }
         } else {
             echo 'ESTADO=KO';
         }
     } else {
         echo 'ESTADO=KO';
     }
 }
 function CreateXMLGENERATEKEY()
 {
     $this->xmlGenerateKeyEnc = "";
     $d3 = new TripleDESEncryption();
     $this->xmlGenerateKey = $d3->generateKey();
     //encripta la llave
     $rsa = new RSAEncryption();
     $rsa->setPublicKey($this->CipherPublicKey);
     $this->xmlGenerateKeyEnc = $rsa->encrypt($this->xmlGenerateKey);
     $this->xmlGenerateKeyEnc = urlencode($this->xmlGenerateKeyEnc);
     return $this->xmlGenerateKeyEnc;
 }