Example #1
0
 public function successPaymentAction(Request $request)
 {
     $gbl_email_support = $this->container->getParameter('gbl_email_support');
     $raw_post_data = file_get_contents('php://input');
     $raw_post_array = explode('&', $raw_post_data);
     $myPost = array();
     foreach ($raw_post_array as $keyval) {
         $keyval = explode('=', $keyval);
         if (count($keyval) == 2) {
             $myPost[$keyval[0]] = urldecode($keyval[1]);
         }
     }
     // read the post from PayPal system and add 'cmd'
     $req = 'cmd=_notify-validate';
     if (function_exists('get_magic_quotes_gpc')) {
         $get_magic_quotes_exists = true;
     }
     foreach ($myPost as $key => $value) {
         if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
             $value = urlencode(stripslashes($value));
         } else {
             $value = urlencode($value);
         }
         $req .= "&{$key}={$value}";
     }
     // STEP 2: Post IPN data back to paypal to validate
     $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
     if (!($res = curl_exec($ch))) {
         // error_log("Got " . curl_error($ch) . " when processing IPN data");
         curl_close($ch);
         exit;
     }
     curl_close($ch);
     // STEP 3: Inspect IPN validation result and act accordingly
     if (strcmp($res, "VERIFIED") == 0) {
         $session = $this->getRequest()->getSession();
         $firstname = $session->get('firstname');
         $lastname = $session->get('lastname');
         $email = $session->get('email');
         $password = $session->get('password');
         $phone = $session->get('phone');
         $state = $session->get('state');
         $address = $session->get('address');
         $address2 = $session->get('address2');
         $city = $session->get('city');
         $fax = $session->get('fax');
         $business = $session->get('business');
         $overview = $session->get('overview');
         $twitter = $session->get('twitter');
         $google = $session->get('google');
         $linkedin = $session->get('linkedin');
         $video = $session->get('video');
         $id = $session->get('id');
         $planid = $session->get('planid');
         $logo = $session->get('logo');
         $file = $session->get('file');
         $facebook = $session->get('facebook');
         $pincode = $session->get('pincode');
         $country = 'US';
         // set country USA
         $type = 2;
         $status = 1;
         $realtor = new User();
         $realtor->setFirstName($firstname);
         $realtor->setLastName($lastname);
         $realtor->setPassword(md5($password));
         $realtor->setEmail($email);
         $realtor->setPhone($phone);
         $realtor->setState($state);
         $realtor->setAddress($address);
         $realtor->setAddress2($address2);
         $realtor->setCity($city);
         $realtor->setCountry($country);
         $realtor->setType($type);
         $realtor->setStatus($status);
         $realtor->setPinCode($pincode);
         $realtor->setFax($fax);
         $realtor->setBusinessName($business);
         $realtor->setOverview($overview);
         $realtor->setPlanId($planid);
         if (isset($logo) && $logo != "") {
             $realtor->setLogo($logo);
         } else {
             $realtor->setLogo('company.jpeg');
         }
         $realtor->setTwitter($twitter);
         $realtor->setFacebook($facebook);
         $realtor->setGoogle($google);
         $realtor->setLinkedin($linkedin);
         $realtor->setVideo($video);
         if (isset($file) && $file != "") {
             $realtor->setImage($file);
         } else {
             $realtor->setImage('default_user_image.jpeg');
         }
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($realtor);
         $em->flush();
         $reviewerId = $realtor->getId();
         $website_url = $this->container->getParameter('website_url');
         //get website url
         $confirmationLink = $website_url . "/confirmed/registration/" . $reviewerId;
         //registration link
         $message = \Swift_Message::newInstance()->setSubject('Registration')->setFrom($gbl_email_support)->setTo($email)->setBody($this->renderView('RARWebBundle:Email:registration.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'Password' => $password, 'email' => $email, 'confirm')));
         $this->get('mailer')->send($message);
         mail($to, $subject, $txt, $headers);
         //send mail
         $realtorId = $realtor->getId();
         $item_name = $_POST['item_name'];
         $item_number = $_POST['item_number'];
         $payment_status = $_POST['payment_status'];
         $payment_amount = $_POST['mc_gross'];
         $payment_currency = $_POST['mc_currency'];
         $txn_id = $_POST['txn_id'];
         $receiver_email = $_POST['receiver_email'];
         $payer_email = $_POST['payer_email'];
         $address = $_POST['address_street'];
         $zipcode = $_POST['address_zip'];
         $state = $_POST['address_state'];
         $city = $_POST['address_city'];
         $country = $_POST['address_country'];
         $datefields = $_POST["payment_date"];
         $time = $datefields[0];
         if ($item_name == 'Half-Yearly') {
             $recuringPeriod = 2;
         } elseif ($item_name == 'Yearly') {
             $recuringPeriod = 3;
         } elseif ($item_name == 'Monthly') {
             $recuringPeriod = 1;
         }
         $payment = new Payment();
         $payment->setAmount($payment_amount);
         $payment->setTransactionId($txn_id);
         $payment->setPlanId($planid);
         $payment->setUserId($realtorId);
         $payment->setRecuringPeriod($recuringPeriod);
         //$payment->setCreationTimeStamp($datefields);
         $em->persist($payment);
         $em->flush();
         $message = \Swift_Message::newInstance()->setSubject('Payment')->setFrom($gbl_email_support)->setTo($email)->setBody($this->renderView('RARWebBundle:Email:payment.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'amount' => $payment_amount, 'transactionId' => $txn_id, 'email' => $email, 'datefields' => $datefields)));
         $this->get('mailer')->send($message);
         /*$date=date("Y/m/d.");
         		$headers = "MIME-Version: 1.0" . "\r\n";
         		$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
         		$headers .= 'From: <*****@*****.**>' . "\r\n";
         		$to = $payer_email;
         		$subject = "Payment detail/reviewarealtor.com";
         		$txt='Hello '. $firstname.' '. $lastname.',<br><br>You have selected the premium plan on reviewarealtor.com on  '.$datefields.'<br><br>Your transaction Details are as under: <br>Amount: <b>'.'$'.$payment_amount.'</b><br>TransactionId: <b>'.	$txn_id.'</b>';
         		mail($to,$subject,$txt,$headers); //send mail*/
     }
     return $this->render('RARWebBundle:Page:registerus.html.twig');
 }
Example #2
0
 public function successAction()
 {
     $gbl_email_support = $this->container->getParameter('gbl_email_support');
     $raw_post_data = file_get_contents('php://input');
     //print_r($raw_post_data);die;
     $raw_post_array = explode('&', $raw_post_data);
     $myPost = array();
     foreach ($raw_post_array as $keyval) {
         $keyval = explode('=', $keyval);
         if (count($keyval) == 2) {
             $myPost[$keyval[0]] = urldecode($keyval[1]);
         }
     }
     // read the post from PayPal system and add 'cmd'
     $req = 'cmd=_notify-validate';
     if (function_exists('get_magic_quotes_gpc')) {
         $get_magic_quotes_exists = true;
     }
     foreach ($myPost as $key => $value) {
         if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
             $value = urlencode(stripslashes($value));
         } else {
             $value = urlencode($value);
         }
         $req .= "&{$key}={$value}";
     }
     // STEP 2: Post IPN data back to paypal to validate
     $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
     if (!($res = curl_exec($ch))) {
         // error_log("Got " . curl_error($ch) . " when processing IPN data");
         curl_close($ch);
         exit;
     }
     curl_close($ch);
     // STEP 3: Inspect IPN validation result and act accordingly
     if (strcmp($res, "VERIFIED") == 0) {
         $session = $this->getRequest()->getSession();
         if (!$session->get('userId') || $session->get('userId') == '') {
             return $this->redirect($this->generateUrl('rar_web_login'));
         }
         $item_name = $_POST['item_name'];
         $item_number = $_POST['item_number'];
         $payment_status = $_POST['payment_status'];
         $payment_amount = $_POST['mc_gross'];
         $payment_currency = $_POST['mc_currency'];
         $txn_id = $_POST['txn_id'];
         $receiver_email = $_POST['receiver_email'];
         $payer_email = $_POST['payer_email'];
         $address = $_POST['address_street'];
         $zipcode = $_POST['address_zip'];
         $state = $_POST['address_state'];
         $city = $_POST['address_city'];
         $country = $_POST['address_country'];
         $datefields = $_POST["payment_date"];
         $time = $datefields[0];
         if ($item_name == 'Half-Yearly') {
             $recuringPeriod = 2;
         } elseif ($item_name == 'Yearly') {
             $recuringPeriod = 3;
         } elseif ($item_name == 'Monthly') {
             $recuringPeriod = 1;
         }
         $id = $session->get('userId');
         $em = $this->getDoctrine()->getEntityManager();
         $plan = $em->createQueryBuilder()->select('Plan')->update('RARAdminBundle:User', 'Plan')->set('Plan.plan_id', ':planId')->setParameter('planId', 2)->set('Plan.subscription_type_id', ':subId')->setParameter('subId', $recuringPeriod)->where('Plan.id = :id')->setParameter('id', $id)->getQuery()->getResult();
         //	echo "<pre>";print_r( $datefields);die;
         $payment = new Payment();
         $payment->setAmount($payment_amount);
         $payment->setTransactionId($txn_id);
         $payment->setPlanId(2);
         $payment->setRecuringPeriod($recuringPeriod);
         $payment->setUserId($session->get('userId'));
         //$payment->setCreationTimeStamp($datefields);
         $em->persist($payment);
         $em->flush();
         $em = $this->getDoctrine()->getEntityManager();
         $userDetail = $em->createQueryBuilder()->select('user')->from('RARAdminBundle:User', 'user')->where('user.id=:userId')->setParameter('userId', $id)->getQuery()->getArrayResult();
         $firstname = $userDetail[0]['first_name'];
         $lastname = $userDetail[0]['last_name'];
         /*$date=date("Y/m/d.");
         		$headers = "MIME-Version: 1.0" . "\r\n";
         		$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
         		$headers .= 'From: <*****@*****.**>' . "\r\n";
         		$to = $payer_email;
         		$subject = "Payment detail/reviewarealtor.com";
         		$txt='Hello '. $firstname.' '. $lastname.',<br><br>You have change the basic plan to premium plan on reviewarealtor.com on  '.$datefields.'<br><br>Your transaction Details are as under: <br>Amount: <b>'.'$'.$payment_amount.'</b><br>TransactionId: <b>'.	$txn_id.'</b>';
         		mail($to,$subject,$txt,$headers); //send mail
         		   	*/
         $message = \Swift_Message::newInstance()->setSubject('Change Plan')->setFrom($gbl_email_support)->setTo($payer_email)->setBody($this->renderView('RARWebBundle:Email:changePlan.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'paymentAmount' => $payment_amount, 'TransactionId' => $txn_id, 'datefields' => $datefields)));
         $this->get('mailer')->send($message);
         return $this->render('RARWebBundle:Page:success.html.twig');
     }
     return $this->render('RARWebBundle:Page:success.html.twig');
 }