Skip to content

Commit

Permalink
Release/1.2.16 (#42)
Browse files Browse the repository at this point in the history
* Merged in SC-101 (pull request #6)

SC-101 error CartItemInterface not found

* SC-101 error CartItemInterface not found

* Merged in feature/SC-104 (pull request #4)

Release 1.2.4 Fixed the partial payment widget cheapest option price

* Release 1.2.4 Fixed the partial payment widget cheapest option price

* Merged in UDC-16 (pull request #7)

UDC-16 fix update svea blcoks on ajax request

* UDC-16 fix update svea blcoks on ajax request

* Merged in SC-113 (pull request #12)

SC-113

* [SC-113] Fixed issue where CheckoutException could receive constructor parameter of incorrect type (string instead of Phrase). Refactored exception throwing functions for better consistency. Fixed some coding standard violations

Approved-by: Alexandru-Georgian Mazalu

* v1.2.8

* [SC-118] Improved and expanded logic for how Invoice Fee rows are detected

* bump composer version

* Merged in SC-118 (pull request #13)

SC-118

* [SC-118] Invoice fee detection is now done using Article Number. Also sets invoice fee on quote addresses before submitting, so the fee gets copied to order

* v1.2.10

* Merged in SC-118-2 (pull request #14)

[SC-118] Adds missing Invoice Fee Article Number definition

* [SC-118] Adds missing Invoice Fee Article Number definition


Approved-by: Alexandru-Georgian Mazalu

* Version bumped 1.2.10 => 1.2.11

* Merged in SC-121 (pull request #15)

SC-121

* [SC-121] Fixes definition of svea_invoice_fee column in various tables to be able to store decimals


Approved-by: Alexandru-Georgian Mazalu

* Version bumped 1.2.11 => 1.2.12

* Merged in SC-123 (pull request #16)

[SC-123]

* [SC-123] Changes sequence separator to a bind, since using an underscore causes payment issues with certain payment methods (Vipps)


Approved-by: Alexandru-Georgian Mazalu

* Merged in SC-124 (pull request #17)

SC-124

* [SC-124] Saves transaction ID on invoice during capture so that refund online can be performed


Approved-by: Alexandru-Georgian Mazalu

* 1.2.13

* Merged in SC-128 (pull request #19)

SC-128

* Version bumped 1.2.13 => 1.2.14

* [SC-128] Changed method of saving payment method in Push controller to a more efficient and less error-prone version


Approved-by: Alexandru-Georgian Mazalu

* Merged in SC-130 (pull request #20)

[SC-130]

* [SC-130] Fixes issue where Svea Checkout woudln't work with fixed discounts on whole cart amount, with discounts applied on prices excluding tax.
This was caused by excessive calls to collectTotals() functions, so they are now reduced to just one call.


Approved-by: Alexandru-Georgian Mazalu

* Merged in SC-130 (pull request #21)

SC-130 Version bumped 1.2.14 => 1.2.15

* [SC-130] Fixes issue where Svea Checkout woudln't work with fixed discounts on whole cart amount, with discounts applied on prices excluding tax.
This was caused by excessive calls to collectTotals() functions, so they are now reduced to just one call.

* [SC-130] Version bumped 1.2.14 => 1.2.15

* Merge branch 'develop' into SC-130


Approved-by: Benjamin Ramnek

* Merged in SC-133 (pull request #23)

SC-133

* [SC-133] Fixes issue where config for allowed customer types would only be retrieved from default config scope

* [SC-133] Version bumped 1.2.15 => 1.2.16


Approved-by: Alexandru-Georgian Mazalu

* Merged in SC-134 (pull request #24)

[SC-134] Adding customer reference

* [SC-134] Sets customer reference on order payment additional info when order is placed. Reference be shown on order view page in admin.


Approved-by: Alexandru-Georgian Mazalu

Co-authored-by: Sergiu Moscalu <[email protected]>
Co-authored-by: martin.sternelius <[email protected]>
Co-authored-by: Alex Mazalu <[email protected]>
  • Loading branch information
4 people authored Apr 4, 2022
1 parent c8e5819 commit 1404cad
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 53 deletions.
9 changes: 9 additions & 0 deletions Block/Payment/Checkout/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ public function getSveaCheckoutId()
return "";
}
}

public function getSveaCustomerReference()
{
try {
return $this->getInfo()->getAdditionalInformation('svea_customer_reference');
} catch (\Exception $e) {
return "";
}
}
}
10 changes: 1 addition & 9 deletions Controller/Order/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,13 @@ protected function createMagentoOrder(GetOrderResponse $sveaOrder, $sveaHash)


// here we create the magento order
$quote->getPayment()->setAdditionalInformation('svea_payment_method', $sveaOrder->getPaymentType());
try {
// we try to create the order now ;)
$order = $this->placeOrder($sveaOrder, $quote);
} catch (\Exception $e) {
throw $e;
}

// save svea payment info
try {
$order->getPayment()->setAdditionalInformation("svea_payment_method", $sveaOrder->getPaymentType());
$this->sveaCheckoutContext->getOrderRepository()->save($order);
} catch (\Exception $e) {
// ignore
$this->getSveaCheckout()->getLogger()->error("Svea Push: Could not set svea payment method to order");
}

return $order;
}
Expand Down
23 changes: 6 additions & 17 deletions Model/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,12 @@ public function initCheckout($reloadIfCurrencyChanged = true, $reloadIfCountryCh
$selectedShippingMethod = $this->checkAndChangeShippingMethod();

try {
$quote->setTotalsCollectedFlag(false)->collectTotals()->save(); //REQUIRED (maybe shipping amount was changed)
$quote->setTotalsCollectedFlag(false)->collectTotals(); //REQUIRED (maybe shipping amount was changed)
$this->quoteRepository->save($quote);
} catch (\Exception $e) {
// do nothing
}

$billingAddress->save();
$shippingAddress->save();

$this->totalsCollector->collectAddressTotals($quote, $shippingAddress);
$this->totalsCollector->collectQuoteTotals($quote);

/**
* We need to reset shipping assignments before saving quote
* since they were changes
*/
$repositoryLoadHandler = $this->getRepositoryLoadHandler();
$repositoryLoadHandler->load($quote);

$quote->collectTotals();
$this->quoteRepository->save($quote);

if (($reloadIfCurrencyChanged && $currencyChanged) || ($reloadIfCountryChanged && $countryChanged)) {
//not needed
$this->throwReloadException('Checkout was reloaded.');
Expand Down Expand Up @@ -612,6 +597,10 @@ public function placeOrder(GetOrderResponse $sveaOrder, Quote $quote)

//set payment
$payment = $quote->getPayment();
$customerReference = $sveaOrder->getCustomerReference();
if ($customerReference) {
$payment->setAdditionalInformation('svea_customer_reference', $customerReference);
}

//force payment method
if (!$payment->getMethod() || $payment->getMethod() != $this->_paymentMethod) {
Expand Down
20 changes: 9 additions & 11 deletions Model/Svea/Data/PresetValues/CustomerDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace Svea\Checkout\Model\Svea\Data\PresetValues;

use Magento\Customer\Model\Session;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\DataObject;
use Svea\Checkout\Model\Client\DTO\Order\PresetValue;
use Svea\Checkout\Helper\Data as Helper;

class CustomerDataProvider implements PresetValuesProviderInterface
{
/**
* @var ScopeConfigInterface
* @var Helper
*/
private $scopeConfig;
private $helper;

/**
* @var Session
Expand All @@ -35,18 +35,18 @@ class CustomerDataProvider implements PresetValuesProviderInterface
* @param Session $customer
* @param DataObject $dataContainer
* @param PresetValueFactory $presetValueFactory
* @param ScopeConfigInterface $scopeConfig
* @param Helper $helper
*/
public function __construct(
Session $customer,
DataObject $dataContainer,
PresetValueFactory $presetValueFactory,
ScopeConfigInterface $scopeConfig
Helper $helper
) {
$this->customer = $customer;
$this->dataContainer = $dataContainer;
$this->presetValueFactory = $presetValueFactory;
$this->scopeConfig = $scopeConfig;
$this->helper = $helper;
}

/**
Expand Down Expand Up @@ -113,19 +113,17 @@ public function getPostalCode() : PresetValue
*/
public function getIsCompany() : PresetValue
{
$customerType = $this->scopeConfig->getValue('svea_checkout/settings/default_customer_type');
$customerTypes = $this->scopeConfig->getValue('svea_checkout/settings/customer_types');
$customerTypes = explode(',', $customerTypes);
$customerType = $this->helper->getDefaultConsumerType();
$customerTypes = $this->helper->getConsumerTypes();

$isB2B = $customerType == 'B2B';
$isB2C = in_array('B2C', $customerTypes);

$presetValue = new PresetValue();
$presetValue->setIsCompany($isB2B);
$presetValue->setValue($isB2B);

$isReadOnly = true;
if (count($customerTypes) > 1) {
if (is_array($customerTypes) && count($customerTypes) > 1) {
$isReadOnly = false;
}

Expand Down
18 changes: 9 additions & 9 deletions Model/Svea/Data/PresetValues/TestValuesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
namespace Svea\Checkout\Model\Svea\Data\PresetValues;

use Svea\Checkout\Model\Client\DTO\Order\PresetValue;
use Svea\Checkout\Helper\Data as Helper;

class TestValuesProvider implements PresetValuesProviderInterface
{

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
* @var Helper
*/
private $scopeConfig;
private $helper;

/**
* TestValuesProvider constructor.
*/
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
public function __construct(Helper $helper)
{
$this->scopeConfig = $scopeConfig;
$this->helper = $helper;
}

/**
Expand Down Expand Up @@ -46,19 +48,17 @@ public function getPhoneNumber() : PresetValue
*/
public function getIsCompany() : PresetValue
{
$customerType = $this->scopeConfig->getValue('svea_checkout/settings/default_customer_type');
$customerTypes = $this->scopeConfig->getValue('svea_checkout/settings/customer_types');
$customerTypes = explode(',', $customerTypes);
$customerType = $this->helper->getDefaultConsumerType();
$customerTypes = $this->helper->getConsumerTypes();

$isB2B = $customerType == 'B2B';
$isB2C = in_array('B2C', $customerTypes);

$presetValue = new PresetValue();
$presetValue->setIsCompany($isB2B);
$presetValue->setValue($isB2B);

$isReadOnly = true;
if (count($customerTypes) > 1) {
if (is_array($customerTypes) && count($customerTypes) > 1) {
$isReadOnly = false;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sveawebpay/nwt-magento2-checkout",
"description": "Svea Checkout",
"type": "magento2-module",
"version": "1.2.13",
"version": "1.2.16",
"autoload": {
"files": [
"registration.php"
Expand Down
23 changes: 17 additions & 6 deletions view/adminhtml/templates/payment/checkout/info.phtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<?php
use Svea\Checkout\Block\Payment\Checkout\Info;
use Magento\Framework\Escaper;

/**
* @var $block \Svea\Checkout\Block\Payment\Checkout\Info
* @var Info $block
* @var Escaper $escaper
*/

?>
<div class="order-payment-method-name"><?php echo $block->escapeHtml($block->getMethod()->getTitle()); ?></div>
<div class="order-payment-method-name"><?= $escaper->escapeHtml($block->getMethod()->getTitle()); ?></div>
<table class="data-table admin__table-secondary">
<tr>
<th><?php echo $block->escapeHtml(__('Svea Checkout Order ID')); ?>:</th>
<td><?php echo $block->escapeHtml($block->getSveaCheckoutId()); ?></td>
<th><?= $escaper->escapeHtml(__('Svea Checkout Order ID')); ?>:</th>
<td><?= $escaper->escapeHtml($block->getSveaCheckoutId()); ?></td>
</tr>
<tr>
<th><?php echo $block->escapeHtml(__('Svea Payment Method')); ?>:</th>
<td><?php echo $block->escapeHtml($block->getSveaPaymentMethod()); ?></td>
<th><?= $escaper->escapeHtml(__('Svea Payment Method')); ?>:</th>
<td><?= $escaper->escapeHtml($block->getSveaPaymentMethod()); ?></td>
</tr>
<?php if ($block->getSveaCustomerReference()): ?>
<tr>
<th><?= $escaper->escapeHtml(__('Svea Customer Payment Reference')) ?>:</th>
<td><?= $escaper->escapeHtml($block->getSveaCustomerReference()) ?>
</tr>
<?php endif ?>
</table>

0 comments on commit 1404cad

Please sign in to comment.