/** * {@inheritdoc} */ protected function composeDetails(PaymentInterface $payment, TokenInterface $token) { if ($payment->getDetails()) { return; } $order = $payment->getOrder(); $details = array(); $details['payment_method'] = $this->apiMethod($payment->getMethod()->getName()); $details['payment_type'] = 1; $details['checkout_url'] = $this->tokenFactory->createNotifyToken($token->getPaymentName(), $payment)->getTargetUrl(); $details['order_code'] = $order->getNumber() . '-' . $payment->getId(); $details['cur_code'] = $order->getCurrency(); $details['total_amount'] = round($order->getTotal() / 100, 2); $details['total_item'] = count($order->getItems()); $m = 0; foreach ($order->getItems() as $item) { $details['item_name' . $m] = $item->getId(); $details['item_amount' . $m] = round($item->getTotal() / $item->getQuantity() / 100, 2); $details['item_quantity' . $m] = $item->getQuantity(); $m++; } if (0 !== ($taxTotal = $this->calculateNonNeutralTaxTotal($order))) { $details['tax_amount'] = $taxTotal; } if (0 !== ($promotionTotal = $order->getAdjustmentsTotal(AdjustmentInterface::PROMOTION_ADJUSTMENT))) { $details['discount_amount'] = $promotionTotal; } if (0 !== ($shippingTotal = $order->getAdjustmentsTotal(AdjustmentInterface::SHIPPING_ADJUSTMENT))) { $details['fee_shipping'] = $shippingTotal; } $payment->setDetails($details); }
function it_should_mark_new_if_order_have_empty_payment_details(PaymentInterface $payment, GetStatusInterface $statusRequest) { $payment->getDetails()->willReturn(array()); $statusRequest->getModel()->willReturn($payment); $statusRequest->markNew()->shouldBeCalled(); $this->execute($statusRequest); }
/** * {@inheritDoc} */ protected function composeDetails(PaymentInterface $payment, TokenInterface $token) { if ($payment->getDetails()) { return; } $order = $payment->getOrder(); $total = $this->currencyConverter->convert($order->getTotal(), $order->getCurrency()); $payment->setDetails(array('amount' => round($total / 100, 2), 'currency' => $order->getCurrency())); }
/** * {@inheritDoc} */ protected function composeDetails(PaymentInterface $payment, TokenInterface $token) { if ($payment->getDetails()) { return; } $this->payment->execute($httpRequest = new GetHttpRequest()); $order = $payment->getOrder(); $details = array(); $details['AMOUNT'] = $order->getTotal(); $details['CLIENTEMAIL'] = $order->getCustomer()->getEmail(); $details['CLIENTUSERAGENT'] = $httpRequest->userAgent ?: 'Unknown'; $details['CLIENTIP'] = $httpRequest->clientIp; $details['CLIENTIDENT'] = $order->getCustomer()->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); }
/** * {@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(); $details = array(); $details['AMOUNT'] = $order->getTotal(); $details['CLIENTEMAIL'] = $order->getEmail(); $details['CLIENTUSERAGENT'] = $this->httpRequest->headers->get('User-Agent', 'Unknown'); $details['CLIENTIP'] = $this->httpRequest->getClientIp(); $details['CLIENTIDENT'] = $order->getUser() ? $order->getUser()->getId() : $order->getEmail(); $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); }
/** * {@inheritdoc} */ protected function composeDetails(PaymentInterface $payment, TokenInterface $token) { if ($payment->getDetails()) { return; } $order = $payment->getOrder(); $details = array(); $details['PAYMENTREQUEST_0_NOTIFYURL'] = $this->tokenFactory->createNotifyToken($token->getPaymentName(), $payment)->getTargetUrl(); $details['PAYMENTREQUEST_0_INVNUM'] = $order->getNumber() . '-' . $payment->getId(); $details['PAYMENTREQUEST_0_CURRENCYCODE'] = $order->getCurrency(); $details['PAYMENTREQUEST_0_AMT'] = round($order->getTotal() / 100, 2); $details['PAYMENTREQUEST_0_ITEMAMT'] = round($order->getTotal() / 100, 2); $m = 0; foreach ($order->getItems() as $item) { $details['L_PAYMENTREQUEST_0_AMT' . $m] = round($item->getTotal() / $item->getQuantity() / 100, 2); $details['L_PAYMENTREQUEST_0_QTY' . $m] = $item->getQuantity(); $m++; } if (0 !== ($taxTotal = $this->calculateNonNeutralTaxTotal($order))) { $details['L_PAYMENTREQUEST_0_NAME' . $m] = 'Tax Total'; $details['L_PAYMENTREQUEST_0_AMT' . $m] = round($taxTotal / 100, 2); $details['L_PAYMENTREQUEST_0_QTY' . $m] = 1; $m++; } if (0 !== ($promotionTotal = $order->getAdjustmentsTotal(AdjustmentInterface::PROMOTION_ADJUSTMENT))) { $details['L_PAYMENTREQUEST_0_NAME' . $m] = 'Discount'; $details['L_PAYMENTREQUEST_0_AMT' . $m] = round($promotionTotal / 100, 2); $details['L_PAYMENTREQUEST_0_QTY' . $m] = 1; $m++; } if (0 !== ($shippingTotal = $order->getAdjustmentsTotal(AdjustmentInterface::SHIPPING_ADJUSTMENT))) { $details['L_PAYMENTREQUEST_0_NAME' . $m] = 'Shipping Total'; $details['L_PAYMENTREQUEST_0_AMT' . $m] = round($shippingTotal / 100, 2); $details['L_PAYMENTREQUEST_0_QTY' . $m] = 1; } $payment->setDetails($details); }
public function it_generates_invoice_number_based_on(OrderInterface $order, PaymentInterface $payment) { $order->getId()->willReturn('001'); $payment->getId()->willReturn('1'); $this->generate($order, $payment)->shouldReturn('001-1'); }
/** * {@inheritdoc} */ public function supports(BasePaymentInterface $payment) { return $payment instanceof PaymentInterface && null !== $payment->getOrder() && null !== $payment->getOrder()->getChannel(); }
function it_should_set_error_flash_message_if_payment_status_unknown(TranslatorInterface $translator, FlashBagInterface $flashBag, PurchaseCompleteEvent $event, PaymentInterface $payment) { $payment->getState()->willReturn(PaymentInterface::STATE_UNKNOWN); $translator->trans('sylius.checkout.unknown', [], 'flashes')->shouldBeCalled()->willReturn('translated.sylius.checkout.unknown'); $flashBag->add('error', 'translated.sylius.checkout.unknown')->shouldBeCalled(); $this->addFlash($event); }
/** * {@inheritdoc} */ public function generate(OrderInterface $order, PaymentInterface $payment) { return $order->getId() . '-' . $payment->getId(); }