diff --git a/app/code/community/Payone/Core/Block/Payment/Method/Form/KlarnaBase.php b/app/code/community/Payone/Core/Block/Payment/Method/Form/KlarnaBase.php index a16ffa53..2c1c8bd8 100644 --- a/app/code/community/Payone/Core/Block/Payment/Method/Form/KlarnaBase.php +++ b/app/code/community/Payone/Core/Block/Payment/Method/Form/KlarnaBase.php @@ -43,6 +43,10 @@ protected function _construct() */ public function isDobRequired() { + if ($this->isB2B()) { + return false; + } + // required for all countries // required only if customer didn't enter Dob in previous checkout step $customerDob = $this->getQuote()->getCustomerDob(); @@ -53,6 +57,15 @@ public function isDobRequired() return false; } + /** + * @return bool + */ + public function isB2B() + { + $billingCompany = $this->getQuote()->getBillingAddress()->getCompany(); + return !empty($billingCompany); + } + /** * @return bool */ diff --git a/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php b/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php index 0841160b..fd2896a9 100644 --- a/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php +++ b/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php @@ -614,8 +614,12 @@ public function requestKlarnaStartSession($data = array()) $request->setCity($billingAddress->getCity()); $request->setCountry($billingAddress->getCountry()); $request->setTelephonenumber($billingAddress->getTelephone()); - if (isset($data['dob'])) { - $request->setBirthday($data['dob']); + if (!empty($billingAddress->getCompany())) { + $request->setCompany($billingAddress->getCompany()); + } else { + if (isset($data['dob'])) { + $request->setBirthday($data['dob']); + } } $shippingAddress = $quote->getShippingAddress(); diff --git a/app/design/frontend/base/default/template/payone/core/payment/method/form/klarna_base.phtml b/app/design/frontend/base/default/template/payone/core/payment/method/form/klarna_base.phtml index bf71d30b..09427e26 100644 --- a/app/design/frontend/base/default/template/payone/core/payment/method/form/klarna_base.phtml +++ b/app/design/frontend/base/default/template/payone/core/payment/method/form/klarna_base.phtml @@ -232,6 +232,7 @@ $quoteLocale = str_replace('_', '-' , Mage::app()->getLocale()->getLocaleCode()) var customerDoB = $('payone_klarna_base_additional_fields_customer_dob_full').value; var customerBillingPhone = $('payone_klarna_base_additional_fields_customer_billing_telephone').value; var customerShippingPhone = $('payone_klarna_base_additional_fields_customer_shipping_telephone').value; + var shippingEmail = "getQuote()->getShippingAddress()->getEmail()) ? $this->getQuote()->getShippingAddress()->getEmail() : $this->getQuote()->getBillingAddress()->getEmail() ?>"; if (!formKlarnaPaymentMethod.checked || formKlarnaPaymentMethod.value == klarnaBaseCode || paymentMethodCategoryIdentifier == '') { return payone.exec(origMethod); @@ -261,7 +262,7 @@ $quoteLocale = str_replace('_', '-' , Mage::app()->getLocale()->getLocaleCode()) shipping_address: { given_name: "getQuote()->getShippingAddress()->getFirstname() ?>", family_name: "getQuote()->getShippingAddress()->getLastname() ?>", - email: "getQuote()->getShippingAddress()->getEmail() ?>", + email: shippingEmail, street_address: "getQuote()->getShippingAddress()->getStreet1() ?>", street_address2: "getQuote()->getShippingAddress()->getStreet2() ?>", postal_code: "getQuote()->getShippingAddress()->getPostcode() ?>",