/** * {@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); }
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 let(ContainerInterface $container, HttpRequestVerifierInterface $httpRequestVerifier, TokenInterface $token, Request $request, CartProviderInterface $cartProvider, RegistryInterface $payum, GatewayInterface $gateway, EventDispatcherInterface $eventDispatcher, DoctrinRegistryInterface $doctrine, ObjectManager $objectManager, Session $session, FlashBagInterface $flashBag, TranslatorInterface $translator) { $session->getFlashBag()->willReturn($flashBag); $doctrine->getManager()->willReturn($objectManager); $token->getGatewayName()->willReturn('aGatewayName'); $payum->getGateway('aGatewayName')->willReturn($gateway); $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); $this->setName('purchase'); $this->setContainer($container); }
function let(ContainerInterface $container, HttpRequestVerifierInterface $httpRequestVerifier, TokenInterface $token, Request $request, RequestStack $requestStack, CartProviderInterface $cartProvider, RegistryInterface $payum, PaymentInterface $payment, EventDispatcherInterface $eventDispatcher, DoctrinRegistryInterface $doctrine, ObjectManager $objectManager, Session $session, FlashBagInterface $flashBag, TranslatorInterface $translator, FactoryInterface $factory) { $requestStack->getCurrentRequest()->willReturn($request); $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('request')->willReturn($request); $container->get('request_stack')->willReturn($requestStack); $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); }
/** * @param Payment $payment * @param TokenInterface $token * * @return FormBuilderInterface */ protected function createPaymentFormBuilder(Payment $payment, TokenInterface $token = null) { return $this->formFactory->createNamedBuilder('', 'form', $payment, ['method' => 'POST', 'action' => $token ? $token->getTargetUrl() : null, 'data_class' => Payment::class, 'csrf_protection' => false, 'attr' => ['class' => 'payum-obtain-missing-details'], 'allow_extra_fields' => true]); }