Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAGE-526: Fix Klarna issues with B2B and shipping address #482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -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();
Expand All @@ -53,6 +57,15 @@ public function isDobRequired()
return false;
}

/**
* @return bool
*/
public function isB2B()
{
$billingCompany = $this->getQuote()->getBillingAddress()->getCompany();
return !empty($billingCompany);
}

/**
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<?php echo !empty($this->getQuote()->getShippingAddress()->getEmail()) ? $this->getQuote()->getShippingAddress()->getEmail() : $this->getQuote()->getBillingAddress()->getEmail() ?>";

if (!formKlarnaPaymentMethod.checked || formKlarnaPaymentMethod.value == klarnaBaseCode || paymentMethodCategoryIdentifier == '') {
return payone.exec(origMethod);
Expand Down Expand Up @@ -261,7 +262,7 @@ $quoteLocale = str_replace('_', '-' , Mage::app()->getLocale()->getLocaleCode())
shipping_address: {
given_name: "<?php echo $this->getQuote()->getShippingAddress()->getFirstname() ?>",
family_name: "<?php echo $this->getQuote()->getShippingAddress()->getLastname() ?>",
email: "<?php echo $this->getQuote()->getShippingAddress()->getEmail() ?>",
email: shippingEmail,
street_address: "<?php echo $this->getQuote()->getShippingAddress()->getStreet1() ?>",
street_address2: "<?php echo $this->getQuote()->getShippingAddress()->getStreet2() ?>",
postal_code: "<?php echo $this->getQuote()->getShippingAddress()->getPostcode() ?>",
Expand Down