Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ public function isValid(MolPaymentMethod $paymentMethod): bool
return false;
}

if (!$this->isIdentificationNumberValid()) {
return false;
}

if (!$this->isVatNumberValid()) {
return false;
}

return true;
}

Expand All @@ -79,39 +71,6 @@ public function supports(MolPaymentMethod $paymentMethod): bool
return $paymentMethod->getPaymentMethodName() === PaymentMethod::BILLIE;
}

private function isIdentificationNumberValid(): bool
{
$customerId = $this->context->getCustomerId();

/** @var \Customer $customer */
$customer = $this->customerRepository->findOneBy([
'id_customer' => $customerId,
]);

return !empty($customer->siret);
}

private function isVatNumberValid(): bool
{
$billingAddressId = $this->context->getInvoiceAddressId();

/** @var \Address $billingAddress */
$billingAddress = $this->addressRepository->findOneBy([
'id_address' => (int) $billingAddressId,
]);

/** @var \AddressFormat $addressFormat */
$addressFormat = $this->addressFormatRepository->findOneBy([
'id_country' => $billingAddress->id_country,
]);

if (!str_contains($addressFormat->getFormat($billingAddress->id_country), 'vat_number')) {
return true;
}

return !empty($billingAddress->vat_number);
}

private function isB2bEnabled(): bool
{
return (bool) (int) $this->configuration->get('PS_B2B_ENABLE');
Expand Down
Loading