Skip to content

Commit

Permalink
PISHPS-362: billie is now hidden for none business accounts (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muxfeld-diw authored Sep 30, 2024
1 parent c4fd0a4 commit 0d01ac0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Service/Payment/Remover/RegularPaymentRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Kiener\MolliePayments\Struct\PaymentMethod\PaymentMethodAttributes;
use Mollie\Api\Types\PaymentMethod;
use Psr\Log\LoggerInterface;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -50,8 +51,29 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S
if ($attributes->getMollieIdentifier() === PaymentMethod::INGHOMEPAY) {
$originalData->getPaymentMethods()->remove($key);
}

# hiding billie for none business customers
if ($attributes->getMollieIdentifier() === PaymentMethod::BILLIE && $this->isBusinessAccount($context) === false) {
$originalData->getPaymentMethods()->remove($key);
}
}

return $originalData;
}

private function isBusinessAccount(SalesChannelContext $context): bool
{
$customer = $context->getCustomer();

if ($customer === null) {
return false;
}

if (method_exists($customer, 'getAccountType') === false) {
$billingAddress = $customer->getDefaultBillingAddress();
return $billingAddress && !empty($billingAddress->getCompany());
}

return $customer->getAccountType() === CustomerEntity::ACCOUNT_TYPE_BUSINESS;
}
}

0 comments on commit 0d01ac0

Please sign in to comment.