public function paymentBitpay(User $user, $mcuser, StoreItem $item)
 {
     //https://bitpay.com/api/invoice
     # item price calculations
     $total = $item->getAmount() * 1;
     $tax = 0;
     if ($item->getTax() > 0) {
         $tax = $total * ($item->getTax() / 100);
     }
     # get custom field
     $custom = array("user_id" => $user->getId(), "amount" => $total, "name" => $mcuser, "ip" => $user->getLastip(), "item_id" => $item->getId(), "discount" => $item->getReduction());
     # start REST call
     $rest = $this->get('maxim_cms.rest.helper');
     $apiKey = "WV3IhdH0ysNsWSJtieYlLygwblFEJAXMo3tIWvH0I";
     $uname = base64_encode($apiKey);
     $data = array("price" => $total, "currency" => "GBP", "notificationURL" => "http://google.com", "posData" => $custom);
     $data = json_encode($data);
     $length = strlen($data);
     $headers = array('Content-Type: application/json', "Content-Length: {$length}", "Authorization: Basic {$uname}");
     $rest->open("https://bitpay.com/api/invoice");
     $curl = $rest->getCurl();
     # set extra curls
     curl_setopt($curl, CURLOPT_PORT, 443);
     curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
     // verify certificate
     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
     // check existence of CN and verify that it matches hostname
     curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
     curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
     $holder = $rest->execute(RESTHelper::METHOD_POST, $headers, $data)->getData();
     # the data contains the array
     $holder = json_decode($holder, true);
     return new \Symfony\Component\HttpFoundation\Response($holder["url"] . "&view=iframe&theme=dark");
     //return $this->redirect("https://coinbase.com/checkouts/" . $holder['button']['code']);
 }
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->add('name', 'text', array('label' => 'Item name'))->add('description', 'textarea', array('label' => 'Item description', 'attr' => array('class' => 'redactor-init', 'style' => 'width: 683px;')))->add('amount', 'money', array('label' => 'Item price', 'currency' => $this->configs['currency']))->add('tax', 'percent', array('label' => 'Item tax'))->add('duration', 'integer', array('label' => 'Item duration (in seconds)'))->add('visible', 'checkbox', array('label' => 'Item visibility'))->add('type', 'choice', array('multiple' => false, 'choices' => StoreItem::getTypeList()))->add('command', 'textarea', array('label' => 'Item Command', 'attr' => array('class' => 'redactor-init', 'style' => 'width: 683px;height: 250px;', 'data-editor' => "sql")))->add('image', 'text', array('label' => 'Item image'))->add('reduction', 'money', array('label' => 'Item reduction', 'currency' => $this->configs['currency']))->add('sort', 'integer', array('label' => 'Item priority'))->add('storeCategory', 'entity', array('class' => 'Maxim\\CMSBundle\\Entity\\StoreCategory'))->add('website', 'entity', array('class' => 'Maxim\\CMSBundle\\Entity\\Website'));
 }