diff --git a/library/checkout/billinkcheckout.php b/library/checkout/billinkcheckout.php index ffb8c261..1d7abece 100644 --- a/library/checkout/billinkcheckout.php +++ b/library/checkout/billinkcheckout.php @@ -75,15 +75,9 @@ public function getBillingAddress() } $country = new Country($this->invoice_address->id_country); - $category = self::CUSTOMER_TYPE_B2C; - if ($this->customerType == self::CUSTOMER_TYPE_B2B - || $this->companyExists($this->invoice_address->company)) { - $category = self::CUSTOMER_TYPE_B2B; - } - $payload = [ 'recipient' => [ - 'category' => $category, + 'category' => $this->getRecipientCategory(), 'careOf' => $this->invoice_address->firstname . ' ' . $this->invoice_address->lastname, 'firstName' => $this->invoice_address->firstname, 'lastName' => $this->invoice_address->lastname, @@ -134,6 +128,14 @@ public function getArticles() return $mergedProducts; } + public function getRecipientCategory() + { + if ($this->customerType == self::CUSTOMER_TYPE_BOTH && $this->companyExists($this->invoice_address->company)) { + return self::CUSTOMER_TYPE_B2B; + } + return $this->customerType; + } + protected function prepareProductArticles() { $articles = []; @@ -252,7 +254,7 @@ public function getShippingAddress() $payload = [ 'recipient' => [ - 'category' => RecipientCategory::PERSON, + 'category' => $this->getRecipientCategory(), 'careOf' => $this->shipping_address->firstname . ' ' . $this->shipping_address->lastname, 'firstName' => $this->shipping_address->firstname, 'lastName' => $this->shipping_address->lastname,