当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderInterface::getPayments方法代码示例

本文整理汇总了PHP中Sylius\Component\Core\Model\OrderInterface::getPayments方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderInterface::getPayments方法的具体用法?PHP OrderInterface::getPayments怎么用?PHP OrderInterface::getPayments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sylius\Component\Core\Model\OrderInterface的用法示例。


在下文中一共展示了OrderInterface::getPayments方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

    function it_applies_payment_charges(
        $adjustmentRepository,
        $delegatingFeeCalculator,
        AdjustmentInterface $adjustment,
        OrderInterface $order,
        PaymentSubjectInterface $payment,
        PaymentMethodInterface $paymentMethod
    ) {
        $order->removeAdjustments('payment')->shouldBeCalled();
        $order->getPayments()->willReturn(array($payment))->shouldBeCalled();

        $order->calculateTotal()->shouldBeCalled();

        $payment->getState()->willReturn('new')->shouldBeCalled();
        $payment->getMethod()->willReturn($paymentMethod);
        $paymentMethod->getName()->willReturn('testPaymentMethod');

        $delegatingFeeCalculator->calculate($payment)->willReturn(50);

        $adjustmentRepository->createNew()->willReturn($adjustment)->shouldBeCalled();
        $adjustment->setType('payment')->shouldBeCalled();
        $adjustment->setAmount(50)->shouldBeCalled();
        $adjustment->setDescription('testPaymentMethod')->shouldBeCalled();

        $order->addAdjustment($adjustment)->shouldBeCalled();

        $this->applyPaymentCharges($order);
    }
开发者ID:kriswillis,项目名称:Sylius,代码行数:28,代码来源:PaymentChargesProcessorSpec.php

示例2: updateExistingPaymentsStates

 /**
  * @param OrderInterface $order
  */
 private function updateExistingPaymentsStates(OrderInterface $order)
 {
     foreach ($order->getPayments() as $payment) {
         $this->cancelPaymentStateIfNotStarted($payment);
     }
     $this->paymentManager->flush();
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:10,代码来源:PaymentProcessor.php

示例3: resolvePaymentState

 /**
  * {@inheritdoc}
  */
 public function resolvePaymentState(OrderInterface $order)
 {
     $paymentState = PaymentInterface::STATE_NEW;
     if ($order->hasPayments()) {
         $payments = $order->getPayments();
         $completedPaymentTotal = 0;
         foreach ($payments as $payment) {
             if (PaymentInterface::STATE_COMPLETED === $payment->getState()) {
                 $completedPaymentTotal += $payment->getAmount();
             }
         }
         if ($completedPaymentTotal >= $order->getTotal()) {
             // Payment is completed if we have received full amount.
             $paymentState = PaymentInterface::STATE_COMPLETED;
         } else {
             // Payment is processing if one of the payment is.
             if ($payments->exists(function ($key, $payment) {
                 return in_array($payment->getState(), [PaymentInterface::STATE_PROCESSING, PaymentInterface::STATE_PENDING]);
             })) {
                 $paymentState = PaymentInterface::STATE_PROCESSING;
             }
         }
     }
     $order->setPaymentState($paymentState);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:28,代码来源:StateResolver.php

示例4: applyPaymentCharges

 /**
  * @param OrderInterface $order
  */
 public function applyPaymentCharges(OrderInterface $order)
 {
     $order->removeAdjustments(AdjustmentInterface::PAYMENT_ADJUSTMENT);
     $order->calculateTotal();
     foreach ($order->getPayments() as $payment) {
         $this->addAdjustmentIfForNotCancelled($order, $payment);
     }
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:11,代码来源:PaymentChargesProcessor.php

示例5:

 function it_sets_not_started_payments_as_cancelled_while_creating_payment($paymentManager, $paymentFactory, OrderInterface $order, PaymentInterface $existingPayment, PaymentInterface $payment)
 {
     $existingPayment->getState()->willReturn('new');
     $order->getPayments()->willReturn(array($existingPayment))->shouldBeCalled();
     $existingPayment->setState('cancelled')->shouldBeCalled();
     $paymentManager->flush()->shouldBeCalled();
     $order->getCurrency()->willReturn('EUR')->shouldBeCalled();
     $order->getTotal()->willReturn(100)->shouldBeCalled();
     $paymentFactory->createNew()->willReturn($payment)->shouldBeCalled();
     $payment->setCurrency('EUR')->shouldBeCalled();
     $payment->setAmount(100)->shouldBeCalled();
     $order->addPayment($payment)->shouldBeCalled();
     $this->createPayment($order)->shouldReturn($payment);
 }
开发者ID:bendavies,项目名称:Sylius,代码行数:14,代码来源:PaymentProcessorSpec.php

示例6: ArrayCollection

 function it_marks_order_as_partially_paid_if_one_of_the_payment_is_processing(FactoryInterface $stateMachineFactory, StateMachineInterface $stateMachine, OrderInterface $order, PaymentInterface $payment1, PaymentInterface $payment2)
 {
     $payment1->getAmount()->willReturn(6000);
     $payment1->getState()->willReturn(PaymentInterface::STATE_PROCESSING);
     $payment2->getAmount()->willReturn(4000);
     $payment2->getState()->willReturn(PaymentInterface::STATE_COMPLETED);
     $payments = new ArrayCollection([$payment1->getWrappedObject(), $payment2->getWrappedObject()]);
     $order->hasPayments()->willReturn(true);
     $order->getPayments()->willReturn($payments);
     $order->getPaymentState()->willReturn(OrderPaymentStates::STATE_AWAITING_PAYMENT);
     $order->getTotal()->willReturn(10000);
     $stateMachineFactory->get($order, OrderPaymentTransitions::GRAPH)->willReturn($stateMachine);
     $stateMachine->can(OrderPaymentTransitions::TRANSITION_PARTIALLY_PAY)->willReturn(true);
     $stateMachine->apply(OrderPaymentTransitions::TRANSITION_PARTIALLY_PAY)->shouldBeCalled();
     $this->resolve($order);
 }
开发者ID:starspire,项目名称:Sylius,代码行数:16,代码来源:OrderPaymentStateResolverSpec.php

示例7: use

 function it_must_dispatch_pre_and_post_payment_state_changed_if_state_changed($factory, SecuredNotifyRequest $request, OrderInterface $order, PaymentModelInterface $paymentModel, PaymentInterface $payment, ObjectManager $objectManager, StateMachineInterface $sm, Collection $payments)
 {
     $request->getModel()->willReturn($paymentModel);
     $order->getPayments()->willReturn($payments);
     $payments->last()->willReturn($payment);
     $paymentModel->getState()->willReturn(Payment::STATE_PENDING);
     $factory->get($paymentModel, PaymentTransitions::GRAPH)->willReturn($sm);
     $sm->getTransitionToState('cancelled')->willReturn(PaymentTransitions::SYLIUS_CANCEL);
     $sm->apply(PaymentTransitions::SYLIUS_CANCEL)->shouldBeCalled()->will(function ($args) use($paymentModel) {
         $paymentModel->getState()->willReturn(Payment::STATE_CANCELLED);
     });
     $payment->execute(Argument::type('Payum\\Core\\Request\\SyncRequest'))->willReturn(null);
     $payment->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Payum\\Request\\StatusRequest'))->will(function ($args) {
         $args[0]->markCanceled();
     });
     $objectManager->flush()->shouldBeCalled();
     $this->execute($request);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:18,代码来源:NotifyOrderActionSpec.php

示例8: Payment

 function it_marks_order_as_new_if_no_payment_is_in_process(OrderInterface $order)
 {
     $payment1 = new Payment();
     $payment1->setAmount(6000);
     $payment1->setState(PaymentInterface::STATE_NEW);
     $payment2 = new Payment();
     $payment2->setAmount(4000);
     $payment2->setState(PaymentInterface::STATE_NEW);
     $payments = new ArrayCollection(array($payment1, $payment2));
     $order->hasPayments()->willReturn(true);
     $order->getPayments()->willReturn($payments);
     $order->getTotal()->willReturn(10000);
     $order->setPaymentState(PaymentInterface::STATE_NEW)->shouldBeCalled();
     $this->resolvePaymentState($order);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:15,代码来源:StateResolverSpec.php

示例9: selectPayment

 /**
  * @param OrderInterface $order
  */
 private function selectPayment(OrderInterface $order)
 {
     $paymentMethod = $this->faker->randomElement($order->getChannel()->getPaymentMethods()->toArray());
     Assert::notNull($paymentMethod);
     foreach ($order->getPayments() as $payment) {
         $payment->setMethod($paymentMethod);
     }
     $this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:OrderFixture.php

示例10: applyPaymentTransitionOnOrder

 /**
  * @param OrderInterface $order
  * @param string $transition
  */
 private function applyPaymentTransitionOnOrder(OrderInterface $order, $transition)
 {
     foreach ($order->getPayments() as $payment) {
         $this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->apply($transition);
     }
 }
开发者ID:nakashu,项目名称:Sylius,代码行数:10,代码来源:OrderContext.php

示例11: ArrayCollection

 function it_sets_orders_total_on_payment_amount_when_payment_is_new(OrderInterface $order, PaymentInterface $payment)
 {
     $payments = new ArrayCollection();
     $order->getPayments()->willReturn($payments);
     $order->getState()->willReturn(OrderInterface::STATE_NEW);
     $order->getTotal()->willReturn(123);
     $order->getCurrencyCode()->willReturn('EUR');
     $payment->getState()->willReturn(PaymentInterface::STATE_NEW);
     $order->getLastNewPayment()->willReturn($payment);
     $payment->setAmount(123)->shouldBeCalled();
     $payment->setCurrencyCode('EUR')->shouldBeCalled();
     $this->process($order);
 }
开发者ID:starspire,项目名称:Sylius,代码行数:13,代码来源:OrderPaymentProcessorSpec.php

示例12: getLastOrderPaymentElement

 /**
  * @param OrderInterface $order
  *
  * @return NodeElement|null
  */
 private function getLastOrderPaymentElement(OrderInterface $order)
 {
     $payment = $order->getPayments()->last();
     $paymentStateElements = $this->getElement('payments')->findAll('css', sprintf('span.ui.label:contains(\'%s\')', ucfirst($payment->getState())));
     $paymentStateElement = end($paymentStateElements);
     return $paymentStateElement->getParent()->getParent();
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:ShowPage.php

示例13: selectPayment

 /**
  * @param OrderInterface $order
  */
 private function selectPayment(OrderInterface $order)
 {
     $paymentMethod = $this->faker->randomElement($this->paymentMethodRepository->findEnabledForChannel($order->getChannel()));
     Assert::notNull($paymentMethod, 'Payment method should not be null.');
     foreach ($order->getPayments() as $payment) {
         $payment->setMethod($paymentMethod);
     }
     $this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
 }
开发者ID:sylius,项目名称:sylius,代码行数:12,代码来源:OrderFixture.php

示例14: getLastPaymentWithState

 /**
  * @param OrderInterface $order
  * @param string $state
  *
  * @return null|PaymentInterface
  */
 private function getLastPaymentWithState(OrderInterface $order, $state)
 {
     $lastPayment = $order->getPayments()->filter(function (PaymentInterface $payment) use($state) {
         return $payment->getState() === $state;
     })->last();
     return $lastPayment !== false ? $lastPayment : null;
 }
开发者ID:loic425,项目名称:Sylius,代码行数:13,代码来源:OrderPaymentProcessor.php


注:本文中的Sylius\Component\Core\Model\OrderInterface::getPayments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。