Пример #1
0
 public function executeConfirmation(sfWebRequest $request)
 {
     $paypal = new PayPal();
     $final = $paypal->doPayment();
     if ($final['ACK'] == 'Success') {
         $this->result = "Succeed!";
         /*        Array
         //            (
         //            [TOKEN] => EC-4AV72391LH8693509
         //            [TIMESTAMP] => 2012-10-10T13:40:58Z
         //            [CORRELATIONID] => b20d0c034074
         //            [ACK] => Success
         //            [VERSION] => 52.0
         //            [BUILD] => 3893058
         //            [TRANSACTIONID] => 27557320TK055573R
         //            [TRANSACTIONTYPE] => expresscheckout
         //            [PAYMENTTYPE] => instant
         //            [ORDERTIME] => 2012-10-10T13:40:56Z
         //            [AMT] => 900.00
         //            [FEEAMT] => 30.85
         //            [TAXAMT] => 0.00
         //            [CURRENCYCODE] => EUR
         //            [PAYMENTSTATUS] => Completed
         //            [PENDINGREASON] => None
         //            [REASONCODE] => None
         //            )
                 
              :*/
         // CONTRAT
         $contratMobilyrent = new MobilyrentContrat();
         $contratMobilyrent->setDatecontrat(date('Y-m-d'));
         $contratMobilyrent->setDatedepart($this->getUser()->getAttribute('datedepart'));
         $contratMobilyrent->setDateretourprevue($this->getUser()->getAttribute('dateretour'));
         $contratMobilyrent->setDateretourreelle($this->getUser()->getAttribute('dateretour'));
         $contratMobilyrent->setPrixjournalierconvenu($this->getUser()->getAttribute('voiture')->getTarifJour());
         $contratMobilyrent->setNocontrat($final['CORRELATIONID']);
         $contratMobilyrent->setKmdepart(0);
         $contratMobilyrent->setKmretour(0);
         $contratMobilyrent->setIsActivated(1);
         $contratMobilyrent->setMontantaccompte($this->getUser()->getAttribute('voiture')->getMobilyrentModele()->getCaution());
         $contratMobilyrent->save();
         //FACTURE
         $factureMobilyrent = new MobilyrentFacture();
         $factureMobilyrent->setDatefacture(date('Y-m-d'));
         $factureMobilyrent->setNofacture($final['CORRELATIONID']);
         $factureMobilyrent->setTotalfacture($this->getUser()->getAttribute('montantLocation'));
         $factureMobilyrent->setIsActivated(1);
         $factureMobilyrent->setMobilyrentContrat($contratMobilyrent);
         $factureMobilyrent->save();
         //PAIEMENT
         $paiementMobilyrent = new MobilyrentPaiement();
         $paiementMobilyrent->setNom("test");
         $paiementMobilyrent->setPrenom("test");
         $paiementMobilyrent->setAdresse("1 Allée colette");
         $paiementMobilyrent->setCodepostal("91270");
         $paiementMobilyrent->setDatepaiement(date('Y-m-d'));
         $paiementMobilyrent->setMontantpaiement($this->getUser()->getAttribute('montantLocation'));
         $paiementMobilyrent->setMobilyrentFacture($factureMobilyrent);
         $paiementMobilyrent->setIdtypepaiement(2);
         $paiementMobilyrent->setIdstatut(1);
         $paiementMobilyrent->save();
         //GET SF_GUARD_USER
         $user = Doctrine::getTable('sfGuardUser')->retrieveByUsername($this->getUser()->getAttribute('email_address'));
         //echo '<pre>';
         //print_r();
         //exit;
         //LOCATION
         $locationMobilyrent = new MobilyrentLocation();
         $locationMobilyrent->setMobilyrentContrat($contratMobilyrent);
         $locationMobilyrent->setMobilyrentVehicule($this->getUser()->getAttribute('voiture'));
         //$locationMobilyrent->setIduserprofile($this->getUser()->getGuardUser()->getProfile()->getId());
         $locationMobilyrent->setIduserprofile($user->getProfile()->getId());
         $locationMobilyrent->setIsActivated(1);
         $locationMobilyrent->save();
         $message = $this->getMailer()->compose(sfConfig::get('app_mail_saidi'), $this->getUser()->getAttribute('email_address'), '[Mobilyrent] - Reservation confirmée Mobilyrent location de voiture', '[Mobilyrent] - Reservation confirmée Mobilyrent location de voiture');
         $this->getMailer()->send($message);
     } else {
         $this->result = "Failure!";
     }
 }
Пример #2
0
 public function executeConfirmation(sfWebRequest $request)
 {
     $paypal = new PayPal();
     $final = $paypal->doPayment();
     if ($final['ACK'] == 'Success') {
         $this->result = "Succeed!";
         // CONTRAT
         $contratMobilyrent = new MobilyrentContrat();
         $contratMobilyrent->setDatecontrat(date('Y-m-d'));
         $contratMobilyrent->setDatedepart($this->getUser()->getAttribute('datedepart'));
         $contratMobilyrent->setDateretourprevue($this->getUser()->getAttribute('dateretour'));
         $contratMobilyrent->setDateretourreelle($this->getUser()->getAttribute('dateretour'));
         $contratMobilyrent->setPrixjournalierconvenu($this->getUser()->getAttribute('voiture')->getTarifJour());
         $contratMobilyrent->setNocontrat($final['CORRELATIONID']);
         $contratMobilyrent->setKmdepart(0);
         $contratMobilyrent->setKmretour(0);
         $contratMobilyrent->setIsActivated(1);
         $contratMobilyrent->setMontantaccompte($this->getUser()->getAttribute('voiture')->getMobilyrentModele()->getCaution());
         $contratMobilyrent->save();
         //FACTURE
         $factureMobilyrent = new MobilyrentFacture();
         $factureMobilyrent->setDatefacture(date('Y-m-d'));
         $factureMobilyrent->setNofacture($final['CORRELATIONID']);
         $factureMobilyrent->setTotalfacture($this->getUser()->getAttribute('montantLocation'));
         $factureMobilyrent->setIsActivated(1);
         $factureMobilyrent->setMobilyrentContrat($contratMobilyrent);
         $factureMobilyrent->save();
         //PAIEMENT
         $paiementMobilyrent = new MobilyrentPaiement();
         $paiementMobilyrent->setNom($this->getUser()->getGuardUser()->getLastName());
         $paiementMobilyrent->setPrenom($this->getUser()->getGuardUser()->getFirstName());
         $paiementMobilyrent->setAdresse($this->getUser()->getGuardUser()->getProfile()->getAdresse());
         $paiementMobilyrent->setCodepostal($this->getUser()->getGuardUser()->getProfile()->getCodepostal());
         $paiementMobilyrent->setDatepaiement(date('Y-m-d'));
         $paiementMobilyrent->setMontantpaiement($this->getUser()->getAttribute('montantLocation'));
         $paiementMobilyrent->setMobilyrentFacture($factureMobilyrent);
         $paiementMobilyrent->setIdtypepaiement(2);
         $paiementMobilyrent->setIdstatut(1);
         $paiementMobilyrent->save();
         //GET SF_GUARD_USER
         $user = Doctrine::getTable('sfGuardUser')->retrieveByUsername($this->getUser()->getAttribute('email_address'));
         $locationMobilyrent = new MobilyrentLocation();
         $locationMobilyrent->setMobilyrentContrat($contratMobilyrent);
         $locationMobilyrent->setMobilyrentVehicule($this->getUser()->getAttribute('voiture'));
         $locationMobilyrent->setIduserprofile($this->getUser()->getGuardUser()->getProfile()->getId());
         //$locationMobilyrent->setIduserprofile($user->getProfile()->getId());
         $locationMobilyrent->setIsActivated(1);
         $locationMobilyrent->save();
         $message = $this->getMailer()->compose(sfConfig::get('app_mail_saidi'), $this->getUser()->getAttribute('email_address'), '[Mobilyrent] - Reservation confirmée Mobilyrent location de voiture', '[Mobilyrent] - Reservation confirmée Mobilyrent location de voiture');
         $this->getMailer()->send($message);
         $startDate = $this->getUser()->getAttribute('datedepart');
         $startTime = $this->getUser()->getAttribute('heuredepart');
         $endDate = $this->getUser()->getAttribute('dateretour');
         $endTime = $this->getUser()->getAttribute('heureretour');
         $title = $this->getUser()->getGuardUser()->getName();
         $voitureObject = $this->getUser()->getAttribute('voiture');
         $content = "Reservation de la voiture:" . ' ' . $voitureObject->getNoimmatriculation();
         $startDate = "{$startDate}T{$startTime}";
         $endDate = "{$endDate}T{$endTime}";
         $this->setPlanning($startDate, $endDate, $title, $content);
     } else {
         $this->result = "Failure!";
     }
 }