public function getParametersFromOrder(OrderInterface $order) { $params = array('amount' => round($order->getPaymentInstruction()->getAmount(), 2), 'currency' => $order->getPaymentInstruction()->getCurrency(), 'returnUrl' => $this->router->generate('payment_successful', array('order' => $order->getId()), RouterInterface::ABSOLUTE_URL), 'notifyUrl' => $this->router->generate("hyper_ads.omnipay.ipn.bitpay", array(), RouterInterface::ABSOLUTE_URL), 'transactionSpeed' => $this->transactionSpeed, 'fullNotifications' => $this->fullNotifications, 'orderId' => $order->getOrderNumber(), 'description' => $this->translator->trans('payment.info', array('%orderNumber%' => $order->getOrderNumber()), 'HyperAdsBundle')); if (!empty($this->notificationEmail)) { $params['notifyEmail'] = $this->notificationEmail; } $params['transactionId'] = json_encode(array('hash' => $this->hashGenerator->hashOrder($order), 'posData' => $this->getPosData($order))); return $params; }
public function retrieveUrlForOrder(OrderInterface $order) { $paymentMethod = $this->getPaymentMethodFromSystemName($order->getPaymentInstruction()->getPaymentSystemName()); /** @var $gateway \Omnipay\Common\AbstractGateway */ $gateway = $this->container->get('hyper_ads.payment.gateway.' . $paymentMethod); /** @var $response \Omnipay\BitPay\Message\PurchaseResponse */ $response = $gateway->purchase($this->getParameters($order))->send(); if ($response->isRedirect()) { return $response->getRedirectUrl(); } elseif (!$response->isSuccessful()) { throw new PaymentException('Problem with getting payment URL. Cause: ' . $response->getMessage()); } else { throw new PaymentException('Payment that does not return redirects to the payment page are not supported'); } }
private function getHash(OrderInterface $order) { return $order->getId() . '_' . $order->getPaymentInstruction()->getId(); }
/** * @return \JMS\Payment\CoreBundle\Model\PaymentInterface */ private function getPaymentFromOrder(OrderInterface $order) { if (null === ($pendingTransaction = $order->getPaymentInstruction()->getPendingTransaction())) { $this->logger->info('Pending transaction for order not found', array('orderId' => $order->getId(), 'requestId' => $this->request->getId())); $payment = $this->pluginController->createPayment($order->getPaymentInstruction()->getId(), round($order->getPaymentInstruction()->getAmount() - $order->getPaymentInstruction()->getDepositedAmount(), 2)); } else { $payment = $pendingTransaction->getPayment(); } return $payment; }