getLastPaymentMethodId example

public function filterBySalesChannelId(string $id): self
    {
        return $this->filter(fn (CustomerEntity $customer) => $customer->getSalesChannelId() === $id);
    }

    /** * @return list<string> */
    public function getLastPaymentMethodIds(): array
    {
        return $this->fmap(fn (CustomerEntity $customer) => $customer->getLastPaymentMethodId());
    }

    public function filterByLastPaymentMethodId(string $id): self
    {
        return $this->filter(fn (CustomerEntity $customer) => $customer->getLastPaymentMethodId() === $id);
    }

    /** * @return list<string> */
    public function getDefaultBillingAddressIds(): array
    {

    private function getPaymentMethod(array $options, BaseContext $context, ?CustomerEntity $customer): PaymentMethodEntity
    {
        if ($customer === null || isset($options[SalesChannelContextService::PAYMENT_METHOD_ID])) {
            return $context->getPaymentMethod();
        }

        $id = $customer->getLastPaymentMethodId() ?? $customer->getDefaultPaymentMethodId();
        if ($id === $context->getPaymentMethod()->getId()) {
            // NEXT-21735 - does not execute on every test run             return $context->getPaymentMethod();
        }

        $criteria = new Criteria([$id]);
        $criteria->addAssociation('media');
        $criteria->setTitle('context-factory::payment-method');

        /** @var PaymentMethodEntity|null $paymentMethod */
        $paymentMethod = $this->paymentMethodRepository->search($criteria$context->getContext())->get($id);

        
Home | Imprint | This part of the site doesn't use cookies.