Пример #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';
     }
 }
Пример #2
0
 function XMLProcess($cadena, $firma)
 {
     $this->xmlResponse = "";
     $firmaCorrecta = $this->validateSign($cadena, $firma);
     if ($firmaCorrecta != 1) {
         return "Los datos han sido alterados. Error al verificar la firma digital";
     }
     $cadena = urldecode($cadena);
     $d3 = new TripleDESEncryption();
     $cadena = $d3->decrypt($cadena, $this->xmlGenerateKey, $this->IV);
     $this->xmlResponse = $cadena;
     $sbDatos = split(";", $cadena);
     $num = count($sbDatos);
     if ($num > 0) {
         $sbDatos[0] = strtoupper($sbDatos[0]);
         $this->AuthorizationState = $sbDatos[0];
         if ($sbDatos[0] == "Y") {
             if ($num > 1) {
                 $this->AuthorizationCode = $sbDatos[1];
                 if (!is_numeric($sbDatos[1])) {
                     return "El código de autorización debe ser un valor numérico.";
                 }
             } else {
                 $this->AuthorizationCode = "";
                 return "El código de autorización es obligatorio.";
             }
         } else {
             if ($sbDatos[0] == "N") {
                 $this->AuthorizationCode = "";
             } else {
                 return "El estado de autorización tiene un valor incorrecto. (" . $sbDatos[0] . ")";
             }
         }
     } else {
         $this->AuthorizationState = "";
         return "El estado de autorización es obligatorio.";
     }
     $i = 2;
     if ($num > $i) {
         $this->ErrorCode = $sbDatos[$i];
     } else {
         $this->ErrorCode = "";
     }
     $i++;
     if ($num > $i) {
         $this->ErrorDetails = $sbDatos[$i];
     } else {
         $this->ErrorDetails = "";
     }
     $i++;
     if ($num > $i) {
         $this->LocalID = $sbDatos[$i];
     } else {
         $this->LocalID = "";
     }
     /*i++;
     		if (array_count_values($sbDatos) > i)
     			$this->MerchantID = $sbDatos[i];
     		else
     			$this->MerchantID = "";
     		*/
     $i++;
     if ($num > $i) {
         $this->TransacctionID = $sbDatos[$i];
     } else {
         $this->TransacctionID = "";
     }
     $i++;
     if ($num > $i) {
         $this->CurrencyID = $sbDatos[$i];
     } else {
         $this->CurrencyID = "";
     }
     $i++;
     if ($num > $i) {
         $this->TransacctionValue = $sbDatos[$i];
     } else {
         $this->TransacctionValue = "0";
     }
     $i++;
     if ($num > $i) {
         $this->TaxValue1 = $sbDatos[$i];
     } else {
         $this->TaxValue1 = "0";
     }
     $i++;
     if ($num > $i) {
         $this->TaxValue2 = $sbDatos[$i];
     } else {
         $this->TaxValue2 = "0";
     }
     $i++;
     if ($num > $i) {
         $this->TipValue = $sbDatos[$i];
     } else {
         $this->TipValue = "0";
     }
     $i++;
     if ($num > $i) {
         $this->SourceDescription = $sbDatos[$i];
     } else {
         $this->SourceDescription = "";
     }
     $i++;
     if ($num > $i) {
         $this->Referencia1 = $sbDatos[$i];
     } else {
         $this->Referencia1 = "";
     }
     $i++;
     if ($num > $i) {
         $this->Referencia2 = $sbDatos[$i];
     } else {
         $this->Referencia2 = "";
     }
     $i++;
     if ($num > $i) {
         $this->Referencia3 = $sbDatos[$i];
     } else {
         $this->Referencia3 = "";
     }
     $i++;
     if ($num > $i) {
         $this->Referencia4 = $sbDatos[$i];
     } else {
         $this->Referencia4 = "";
     }
     $i++;
     if ($num > $i) {
         $this->Referencia5 = $sbDatos[$i];
     } else {
         $this->Referencia5 = "";
     }
     return $firmaCorrecta;
 }