function do_payment() { $amount = $this->input->get('amount'); $r = new PayPal(); $r->doExpressCheckout($amount, 'Da Greatest Library You Ever Seen'); $final = $r->doPayment(); if ($final['ACK'] == 'Success') { echo 'Succeed!'; } else { echo 'Error!'; } }
<?php require_once './paypal/paypal.php'; require_once './paypal/httprequest.php'; //Load PHPMailer Class require_once 'phpmailer/class.phpmailer.php'; //Use this form for production server $r = new PayPal(true); //Use this form for sandbox tests // $r = new PayPal(); $final = $r->doPayment(); if ($final['ACK'] == 'Success') { $payment = $r->getCheckoutDetails($final['TOKEN']); //If payment from PayPal is successful, send out our thankyou email $first_name = $payment['FIRSTNAME']; $last_name = $payment['LASTNAME']; $name = $first_name . ' ' . $last_name; $email = $payment['EMAIL']; $amount = $payment['CUSTOM']; $amount = explode("|", $amount, 2); $amount = $amount[0]; $date = $payment['TIMESTAMP']; $date = strtotime($date); // Build and send the email *using PHPMailer $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 0; $mail->SMTPAuth = true; $mail->Host = $mailConfig['host']; $mail->Port = 587; $mail->Username = $mailConfig['user'];
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!"; } }
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!"; } }