Skip to content

Commit

Permalink
Merge pull request #111 from buckaroo-it/BP-3275-Change-Klarna-paymen…
Browse files Browse the repository at this point in the history
…t-flow

fix street name klarna
  • Loading branch information
Rinor12010 authored Dec 14, 2023
2 parents 2d2f7f2 + 91c6abf commit 4f5fae1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 236 deletions.
2 changes: 1 addition & 1 deletion buckaroo3.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function hookPaymentOptions($params)
'creditcardIssuers' => $buckarooConfigService->getActiveCreditCards(),
'creditCardDisplayMode' => $buckarooConfigService->getConfigValue('creditcard', 'display_type'),
'in3Method' => $this->get('buckaroo.classes.issuers.capayableIn3')->getMethod(),
'showIdealIssuers' => $buckarooConfigService->getConfigValue('ideal', 'show_issuers') ?? true
'showIdealIssuers' => $buckarooConfigService->getConfigValue('ideal', 'show_issuers') ?? true,
]
);
} catch (Exception $e) {
Expand Down
6 changes: 2 additions & 4 deletions library/checkout/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ public function __construct($cart)
$this->cart = $cart;
$this->customer = new Customer($cart->id_customer);
$this->invoice_address = new Address((int) $cart->id_address_invoice);
$this->shipping_address = null;
if ($cart->id_address_invoice != $cart->id_address_delivery) {
$this->shipping_address = new Address((int) $cart->id_address_delivery);
}
$this->shipping_address = $cart->id_address_invoice != $cart->id_address_delivery ?
new Address((int) $cart->id_address_delivery) : $this->invoice_address;
$this->products = $this->cart->getProducts();
$this->buckarooConfigService = $this->module->getBuckarooConfigService();
$this->buckarooFeeService = $this->module->getBuckarooFeeService();
Expand Down
72 changes: 18 additions & 54 deletions library/checkout/klarnacheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,73 +45,37 @@ final public function setCheckout()
*/
public function getBillingAddress()
{
return $this->getAddress((array) $this->invoice_address);
}
protected function getAddress(array $address): array
{
$address_components = $this->getAddressComponents($address['address1']); // phpcs:ignore
$address = array_merge($address,$address_components);

return [
'recipient' => [
'firstName' => $this->invoice_address->firstname,
'lastName' => $this->invoice_address->lastname,
'firstName' => $address['firstname'],
'lastName' => $address['lastname'],
'gender' => Tools::getValue('bpe_klarna_invoice_person_gender') === '1' ? 'male': 'female',
'category' => 'B2C'
],
'address' => [
'street' => $this->invoice_address->address1,
'houseNumber' => $this->invoice_address->address2,
'zipcode' => $this->invoice_address->postcode,
'city' => $this->invoice_address->city,
'country' => Tools::strtoupper(
(new Country($this->invoice_address->id_country))->iso_code
),
],
'phone' => [
'mobile' => $this->getPhone($this->invoice_address) ?: $this->getPhone($this->shipping_address),
'street' => $address['street'],
'houseNumber' => $address['house_number'],
'houseNumberAdditional' => $address['address2'],
'zipcode' => $address['zipcode'] ?? $address['postcode'],
'city' => $address['city'],
'country' => Tools::strtoupper((new Country($address['id_country']))->iso_code),
],
'email' => $this->customer->email,
];
}

public function getShippingAddress()
{
if (!empty($this->shipping_address)) {
$country = new Country($this->invoice_address->id_country);

$address_components = $this->getAddressComponents($this->shipping_address->address1); // phpcs:ignore
$street = $address_components['street'];
if (empty($address_components['house_number'])) {
$houseNumber = $this->invoice_address->address2;
} else {
$houseNumber = $address_components['house_number'];
}
$zipcode = $this->shipping_address->postcode;
$city = $this->shipping_address->city;

$carrierHandler = new CarrierHandler($this->cart);
$sendCloudData = $carrierHandler->handleSendCloud();

if ($sendCloudData) {
$street = $sendCloudData['street'];
$houseNumber = $sendCloudData['houseNumber'];
$zipcode = $sendCloudData['zipcode'];
$city = $sendCloudData['city'];
$country = $sendCloudData['country'];
}
return [
'recipient' => [
'firstName' => $this->shipping_address->firstname,
'lastName' => $this->shipping_address->lastname,
'gender' => Tools::getValue('bpe_klarna_invoice_person_gender') === '1' ? 'male': 'female',
'category' => 'B2C'
],
'address' => [
'street' => $street,
'houseNumber' => $houseNumber,
'zipcode' => $zipcode,
'city' => $city,
'country' => Tools::strtoupper($country->iso_code),
],
'email' => $this->customer->email,
];
}
$carrierHandler = new CarrierHandler($this->cart);
$sendCloudData = $carrierHandler->handleSendCloud() ?? [];

return null;
return $this->getAddress(array_merge((array) $this->shipping_address,$sendCloudData));
}

public function getArticles()
Expand Down
177 changes: 0 additions & 177 deletions views/img/buckaroo/Payment methods/SVG/Apple Pay.svg

This file was deleted.

0 comments on commit 4f5fae1

Please sign in to comment.