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);