public function sendPurchaseConfirmationMessage(Invoice $invoice, $amount)
    {
        $templateName = 'PaymentBundle:Email:sale.confirmation.html.twig';
        $toEmail = $invoice->getTransaction()->getActor()->getEmail();

      
        $orderUrl = $this->router->generate('payment_checkout_showinvoice', array('number' => $invoice->getInvoiceNumber()), UrlGeneratorInterface::ABSOLUTE_URL);

        $context = array(
            'order_number' => $invoice->getTransaction()->getTransactionKey(),
            'amount'         => $amount,
            'payment_type'   => $invoice->getTransaction()->getPaymentMethod()->getName(),
            'order_url'      => $orderUrl,
        );

        $this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
        
        //send email to optic to confirm purchase
        //check empty bank number account
        $templateName = 'PaymentBundle:Email:sale.confirmation.actor.html.twig';
        $productItems = $invoice->getTransaction()->getItems();
        $actor = $productItems->first()->getProduct()->getActor();
        if($actor instanceof Actor) {
            $toEmail = $actor->getEmail();
            $token = null;
            if($actor->getBankAccountNumber() == ''){
                $token = sha1(uniqid());
                $date = new \DateTime();
                $actor->setBankAccountToken($token);
                $actor->setBankAccountTime($date->getTimestamp());
                $this->manager->persist($actor);
                $this->manager->flush();
            }
            $context = array(
                'order_number' => $invoice->getTransaction()->getTransactionKey(),
                'products' => $productItems,
                'token' => $token,
                'actor' => $actor
            );

            $this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
        }
        
    }