/** * {@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 let(ContainerInterface $container, HttpRequestVerifierInterface $httpRequestVerifier, TokenInterface $token, Request $request, CartProviderInterface $cartProvider, RegistryInterface $payum, PaymentInterface $payment, EventDispatcherInterface $eventDispatcher, DoctrinRegistryInterface $doctrine, ObjectManager $objectManager, Session $session, FlashBagInterface $flashBag, TranslatorInterface $translator, FactoryInterface $factory) { $session->getFlashBag()->willReturn($flashBag); $doctrine->getManager()->willReturn($objectManager); $token->getPaymentName()->willReturn('aPaymentName'); $payum->getPayment('aPaymentName')->willReturn($payment); $httpRequestVerifier->verify($request)->willReturn($token); $httpRequestVerifier->invalidate($token)->willReturn(null); $container->get('payum.security.http_request_verifier')->willReturn($httpRequestVerifier); $container->get('sylius.cart_provider')->willReturn($cartProvider); $container->get('payum')->willReturn($payum); $container->get('event_dispatcher')->willReturn($eventDispatcher); $container->get('session')->willReturn($session); $container->get('doctrine')->willReturn($doctrine); $container->has('doctrine')->willReturn(true); $container->get('translator')->willReturn($translator); $container->get('sm.factory')->willReturn($factory); $this->setName('purchase'); $this->setContainer($container); }
/** * {@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); }