本文整理汇总了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);
}
示例2: updateExistingPaymentsStates
/**
* @param OrderInterface $order
*/
private function updateExistingPaymentsStates(OrderInterface $order)
{
foreach ($order->getPayments() as $payment) {
$this->cancelPaymentStateIfNotStarted($payment);
}
$this->paymentManager->flush();
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}