public function makePurchase($amount, $transaction, \Maxim\CMSBundle\Entity\User $user, $item, $ip, $status, $date)
 {
     $em = $this->getDoctrine()->getManager();
     try {
         $purchase = new Purchase();
         $purchase->setAmount($amount);
         $purchase->setDate(new \DateTime(date("Y-m-d H:i:s", strtotime($date))));
         $purchase->setTransaction($transaction);
         $purchase->setStatus($status);
         $purchase->setIp($ip);
         $purchase->setUser($user);
         $purchase->setStoreItem($item);
         $purchase->setName($user->getUsername());
         $em->persist($purchase);
         $em->flush();
         return;
     } catch (\Exception $ex) {
         $logger = $this->get('logger');
         $logger->error('SHOP: ' . $ex->getMessage());
     }
 }
 /**
  * @param $item
  * @param User $user
  * @param $amount
  * @param $discount
  * @param $status
  * @param $name
  * @param $ip
  * @param $transaction
  * @param $delivery
  * @return Purchase
  */
 public function createPurchase($item, User $user, $amount, $discount, $status, $name, $ip, $transaction, $delivery)
 {
     $em = $this->doctrine;
     try {
         $purchase = new Purchase();
         $purchase->setDate(new \DateTime("now"));
         $purchase->setStatus($status);
         $purchase->setIp($ip);
         $purchase->setUser($user);
         $purchase->setAmount($amount);
         $purchase->setName($name);
         $purchase->setStoreItem($item);
         $purchase->setTransaction($transaction);
         $purchase->setItemDelivery($delivery);
         $purchase->setDiscount($discount);
         $em->persist($purchase);
         $em->flush();
         $this->logger->info("[IPN]Purchase made for user: " . $name);
         return $purchase;
     } catch (\Exception $ex) {
         $logger = $this->logger;
         $logger->error('STORE: ' . $ex->getMessage());
     }
 }