本文整理汇总了PHP中Sylius\Component\Core\Model\OrderInterface::getLastPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderInterface::getLastPayment方法的具体用法?PHP OrderInterface::getLastPayment怎么用?PHP OrderInterface::getLastPayment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\OrderInterface
的用法示例。
在下文中一共展示了OrderInterface::getLastPayment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLastPayment
/**
* @param OrderInterface $order
*
* @return null|PaymentInterface
*/
private function getLastPayment(OrderInterface $order)
{
$lastPayment = $order->getLastPayment(PaymentInterface::STATE_CANCELLED);
if (null === $lastPayment) {
$lastPayment = $order->getLastPayment(PaymentInterface::STATE_FAILED);
}
return $lastPayment;
}
示例2: setPaymentMethodIfNeeded
/**
* {@inheritdoc}
*/
private function setPaymentMethodIfNeeded(OrderInterface $order, PaymentInterface $payment)
{
$lastCancelledPayment = $order->getLastPayment(PaymentInterface::STATE_CANCELLED);
$lastNewPayment = $order->getLastPayment(PaymentInterface::STATE_NEW);
if (!$lastNewPayment && $lastCancelledPayment) {
$payment->setMethod($lastCancelledPayment->getMethod());
}
}
示例3:
function it_does_not_set_payment_method_from_last_cancelled_payment_during_processing_if_new_payment_exists(PaymentFactoryInterface $paymentFactory, PaymentInterface $newPaymentReadyToPay, PaymentInterface $cancelledPayment, PaymentInterface $payment, OrderInterface $order)
{
$order->getTotal()->willReturn(1234);
$order->getCurrency()->willReturn('EUR');
$order->getLastPayment(PaymentInterface::STATE_CANCELLED)->willReturn($cancelledPayment);
$order->getLastPayment(PaymentInterface::STATE_NEW)->willReturn($newPaymentReadyToPay);
$paymentFactory->createWithAmountAndCurrency(1234, 'EUR')->willReturn($payment);
$payment->setMethod($cancelledPayment)->shouldNotBeCalled();
$order->addPayment($payment)->shouldBeCalled();
$this->processOrderPayments($order);
}
示例4: getLastPayment
/**
* @param OrderInterface $order
*
* @return PaymentInterface|null
*/
private function getLastPayment(OrderInterface $order)
{
$lastCancelledPayment = $order->getLastPayment(PaymentInterface::STATE_CANCELLED);
if (null !== $lastCancelledPayment) {
return $lastCancelledPayment;
}
$lastFailedPayment = $order->getLastPayment(PaymentInterface::STATE_FAILED);
if (null !== $lastFailedPayment) {
return $lastFailedPayment;
}
return null;
}
示例5:
function it_does_not_set_order_payment_if_it_cannot_be_provided(OrderInterface $order, OrderPaymentProviderInterface $orderPaymentProvider)
{
$order->getState()->willReturn(OrderInterface::STATE_CART);
$order->getLastPayment(PaymentInterface::STATE_CART)->willReturn(null);
$orderPaymentProvider->provideOrderPayment($order, PaymentInterface::STATE_CART)->willThrow(NotProvidedOrderPaymentException::class);
$order->addPayment(Argument::any())->shouldNotBeCalled();
$this->process($order);
}
示例6:
function it_tries_to_pay_again(SharedStorageInterface $sharedStorage, OrderRepositoryInterface $orderRepository, PaypalApiMocker $paypalApiMocker, OrderPaymentsPageInterface $orderPaymentsPage, OrderInterface $order, CustomerInterface $customer, UserInterface $user, PaymentInterface $payment)
{
$sharedStorage->get('user')->willReturn($user);
$user->getCustomer()->willReturn($customer);
$orderRepository->findByCustomer($customer)->willReturn([$order]);
$order->getLastPayment()->willReturn($payment);
$paypalApiMocker->mockApiPaymentInitializeResponse()->shouldBeCalled();
$orderPaymentsPage->clickPayButtonForGivenPayment($payment)->shouldBeCalled();
$this->iTryToPayAgain();
}
示例7:
function it_sets_orders_total_on_payment_amount_when_payment_is_new(OrderInterface $order, PaymentInterface $payment)
{
$order->getState()->willReturn(OrderInterface::STATE_NEW);
$order->getTotal()->willReturn(123);
$order->getCurrencyCode()->willReturn('EUR');
$payment->getState()->willReturn(PaymentInterface::STATE_NEW);
$order->getLastPayment(PaymentInterface::STATE_NEW)->willReturn($payment);
$payment->setAmount(123)->shouldBeCalled();
$payment->setCurrencyCode('EUR')->shouldBeCalled();
$this->process($order);
}
示例8: thisOrderIsAlreadyPaid
/**
* @Given /^(this order) is already paid$/
*/
public function thisOrderIsAlreadyPaid(OrderInterface $order)
{
$payment = $order->getLastPayment();
$this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->apply(PaymentTransitions::TRANSITION_COMPLETE);
$this->objectManager->flush();
}
示例9:
function it_throws_exception_if_payment_method_cannot_be_resolved_for_provided_payment(OrderInterface $order, PaymentFactoryInterface $paymentFactory, PaymentInterface $lastFailedPayment, PaymentInterface $newPayment)
{
$order->getTotal()->willReturn(1000);
$order->getCurrencyCode()->willReturn('USD');
$order->getLastPayment(PaymentInterface::STATE_CANCELLED)->willReturn(null);
$order->getLastPayment(PaymentInterface::STATE_FAILED)->willReturn($lastFailedPayment);
$lastFailedPayment->getMethod()->willReturn(null);
$paymentFactory->createWithAmountAndCurrencyCode(1000, 'USD')->willReturn($newPayment);
$this->shouldThrow(NotProvidedOrderPaymentException::class)->during('provideOrderPayment', [$order, PaymentInterface::STATE_NEW]);
}
示例10: getLastPayment
/**
* @param OrderInterface $order
*
* @return null|PaymentInterface
*/
private function getLastPayment(OrderInterface $order)
{
return $order->getLastPayment(PaymentInterface::STATE_CANCELLED) ?: $order->getLastPayment(PaymentInterface::STATE_FAILED);
}