private function composeDetails(PaymentInterface $payment, TokenInterface $token)
 {
     $order = $payment->getOrder();
     $details = [];
     $details['hash'] = $token->getHash();
     $details['p24_amount'] = $order->getTotal();
     $details['p24_email'] = $order->getEmail();
     $details['p24_payment_id'] = $payment->getId();
     $details['p24_session_id'] = $payment->getId() . time();
     $details['p24_desc'] = sprintf("Zamówienie zawierające %d produktów na całkowitą kwotę %01.2f", $order->getItems()->count(), $order->getTotal() / 100);
     $payment->setDetails($details);
 }
 function it_executes_request(InvoiceNumberGeneratorInterface $invoiceNumberGenerator, CurrencyConverterInterface $currencyConverter, Convert $request, PaymentInterface $payment, OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant, ProductInterface $product)
 {
     $request->getTo()->willReturn('array');
     $payment->getId()->willReturn(19);
     $order->getId()->willReturn(92);
     $order->getId()->willReturn(92);
     $order->getCurrencyCode()->willReturn('PLN');
     $order->getTotal()->willReturn(22000);
     $order->getItems()->willReturn([$orderItem]);
     $order->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(0);
     $order->getOrderPromotionTotal()->willReturn(0);
     $order->getShippingTotal()->willReturn(2000);
     $orderItem->getVariant()->willReturn($productVariant);
     $orderItem->getDiscountedUnitPrice()->willReturn(20000);
     $orderItem->getQuantity()->willReturn(1);
     $productVariant->getProduct()->willReturn($product);
     $product->getName()->willReturn('Lamborghini Aventador Model');
     $request->getSource()->willReturn($payment);
     $payment->getOrder()->willReturn($order);
     $invoiceNumberGenerator->generate($order, $payment)->willReturn('19-92');
     $currencyConverter->convertFromBase(22000, 'PLN')->willReturn(88000);
     $currencyConverter->convertFromBase(20000, 'PLN')->willReturn(80000);
     $currencyConverter->convertFromBase(2000, 'PLN')->willReturn(8000);
     $details = ['PAYMENTREQUEST_0_INVNUM' => '19-92', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'PLN', 'PAYMENTREQUEST_0_AMT' => 880.0, 'PAYMENTREQUEST_0_ITEMAMT' => 880.0, 'L_PAYMENTREQUEST_0_NAME0' => 'Lamborghini Aventador Model', 'L_PAYMENTREQUEST_0_AMT0' => 800.0, 'L_PAYMENTREQUEST_0_QTY0' => 1, 'L_PAYMENTREQUEST_0_NAME1' => 'Shipping Total', 'L_PAYMENTREQUEST_0_AMT1' => 80.0, 'L_PAYMENTREQUEST_0_QTY1' => 1];
     $request->setResult($details)->shouldBeCalled();
     $this->execute($request);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function clickPayButtonForGivenPayment(PaymentInterface $payment)
 {
     $table = $this->getElement('table');
     $row = $this->tableAccessor->getRowWithFields($this->getElement('table'), ['#' => $payment->getId()]);
     $actions = $this->tableAccessor->getFieldFromRow($table, $row, 'Action');
     $actions->clickLink('Pay');
 }
Example #4
0
 public function updateOrderOnPayment(PaymentInterface $payment)
 {
     $order = $payment->getOrder();
     if (null === $order) {
         throw new \RuntimeException(sprintf('Cannot retrieve Order from Payment with id %s', $payment->getId()));
     }
     $total = 0;
     foreach ($order->getPayments() as $payment) {
         if ($payment->getState() === PaymentInterface::STATE_COMPLETED) {
             $total += $payment->getAmount();
         }
     }
     if ($total === $order->getTotal()) {
         $this->factory->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_CONFIRM, true);
     }
 }
 /**
  * @param PaymentInterface $payment
  * @param TokenInterface   $token
  *
  * @throws LogicException
  */
 protected function composeDetails(PaymentInterface $payment, TokenInterface $token)
 {
     if ($payment->getDetails()) {
         return;
     }
     if (!$this->httpRequest) {
         throw new LogicException('The action can be run only when http request is set.');
     }
     $order = $payment->getOrder();
     $details = array();
     $details['AMOUNT'] = $order->getTotal();
     $details['CLIENTEMAIL'] = $order->getUser()->getEmail();
     $details['HIDECLIENTEMAIL'] = 'yes';
     $details['CLIENTUSERAGENT'] = $this->httpRequest->headers->get('User-Agent', 'Unknown');
     $details['CLIENTIP'] = $this->httpRequest->getClientIp();
     $details['CLIENTIDENT'] = $order->getUser()->getId();
     $details['DESCRIPTION'] = sprintf('Order containing %d items for a total of %01.2f', $order->getItems()->count(), $order->getTotal() / 100);
     $details['ORDERID'] = $payment->getId();
     $payment->setDetails($details);
 }
Example #6
0
 public function updateOrderOnPayment(PaymentInterface $payment)
 {
     /** @var $order OrderInterface */
     $order = $payment->getOrder();
     if (null === $order) {
         throw new \RuntimeException(sprintf('Cannot retrieve Order from Payment with id %s', $payment->getId()));
     }
     $total = 0;
     if (PaymentInterface::STATE_COMPLETED === $payment->getState()) {
         $payments = $order->getPayments()->filter(function (PaymentInterface $payment) {
             return PaymentInterface::STATE_COMPLETED === $payment->getState();
         });
         if ($payments->count() === $order->getPayments()->count()) {
             $order->setPaymentState(PaymentInterface::STATE_COMPLETED);
         }
         $total += $payment->getAmount();
     } else {
         $order->setPaymentState($payment->getState());
     }
     if ($total >= $order->getTotal()) {
         $this->factory->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_CONFIRM, true);
     }
 }
 /**
  * {@inheritDoc}
  */
 protected function composeDetails(PaymentInterface $payment, TokenInterface $token)
 {
     if ($payment->getDetails()) {
         return;
     }
     if (!$this->httpRequest) {
         throw new LogicException('The action can be run only when http request is set.');
     }
     $order = $payment->getOrder();
     $this->payment->execute($obtainCreditCardRequest = new ObtainCreditCardRequest($order));
     $details = array();
     $details['AMOUNT'] = $order->getTotal();
     $details['CLIENTEMAIL'] = $order->getUser()->getEmail();
     $details['CLIENTUSERAGENT'] = $this->httpRequest->headers->get('User-Agent', 'Unknown');
     $details['CLIENTIP'] = $this->httpRequest->getClientIp();
     $details['CLIENTIDENT'] = $order->getUser()->getId();
     $details['DESCRIPTION'] = sprintf('Order containing %d items for a total of %01.2f', $order->getItems()->count(), $order->getTotal() / 100);
     $details['ORDERID'] = $payment->getId();
     $details['CARDCODE'] = new SensitiveValue($obtainCreditCardRequest->getCreditCard()->getNumber());
     $details['CARDCVV'] = new SensitiveValue($obtainCreditCardRequest->getCreditCard()->getSecurityCode());
     $details['CARDFULLNAME'] = new SensitiveValue($obtainCreditCardRequest->getCreditCard()->getCardholderName());
     $details['CARDVALIDITYDATE'] = new SensitiveValue(sprintf('%02d-%02d', $obtainCreditCardRequest->getCreditCard()->getExpiryMonth(), substr($obtainCreditCardRequest->getCreditCard()->getExpiryYear(), -2)));
     $payment->setDetails($details);
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function clickPayButtonForGivenPayment(PaymentInterface $payment)
 {
     $this->getDocument()->clickLink(sprintf('pay_%s', $payment->getId()));
 }