Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 17, 2019
1 parent 8e34132 commit d41a7b2
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 55 deletions.
37 changes: 25 additions & 12 deletions OL.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@
use Magento\Quote\Model\Quote\Address\Total as T;
/**
* 2019-09-17
* @see \Dfe\KlarnaC\OL\AheadWorks\CustomerBalance
* @see \Dfe\KlarnaC\OL\AheadWorks\GiftCard
* @see \Dfe\KlarnaC\OL\AheadWorks\Reward
* @final Unable to use the PHP «final» keyword here because of the M2 code generation.
* @used-by etc/klarna.xml
*/
abstract class OL implements IOL {
class OL implements IOL {
/**
* 2019-09-17
* @used-by fetch()
* @see \Dfe\KlarnaC\OL\AheadWorks\CustomerBalance::id()
* @see \Dfe\KlarnaC\OL\AheadWorks\GiftCard::id()
* @see \Dfe\KlarnaC\OL\AheadWorks\Reward::id()
* @return string
* @param string $id
* @param string $type
*/
abstract protected function id();
final function __construct($id, $type) {$this->_id = $id; $this->_type = $type;}

/**
* 2019-09-17
Expand All @@ -46,6 +42,7 @@ function isIsTotalCollector() {return true;}

/**
* 2019-09-17
* @final Unable to use the PHP «final» keyword here because of the M2 code generation.
* @override
* @see AL::collect()
* @see IOL::collect()
Expand All @@ -54,7 +51,7 @@ function isIsTotalCollector() {return true;}
*/
function fetch(IB $b) {
$h = df_o(H::class); /** @var H $h */
if (($t = dfa($b->getObject()->getTotals(), $this->id())) && ($a = $h->toApiFloat($t->getValue()))) {
if (($t = dfa($b->getObject()->getTotals(), $this->_id)) && ($a = $h->toApiFloat($t->getValue()))) {
/** @var T|null $t *//** @var int $a */
$b->addOrderLine([
'name' => $t->getTitle()
Expand All @@ -63,7 +60,7 @@ function fetch(IB $b) {
,'tax_rate' => 0
,'total_amount' => $a
,'total_tax_amount' => 0
,'type' => $t->getCode()
,'type' => $this->_type
,'unit_price' => $a
]);
}
Expand Down Expand Up @@ -98,4 +95,20 @@ function setCode($v) {$this->_code = $v; return $this;}
* @var string
*/
private $_code;

/**
* 2019-09-17
* @used-by __construct()
* @used-by fetch()
* @var string
*/
private $_id;

/**
* 2019-09-17
* @used-by __construct()
* @used-by fetch()
* @var string
*/
private $_type;
}
14 changes: 0 additions & 14 deletions OL/AheadWorks/CustomerBalance.php

This file was deleted.

14 changes: 0 additions & 14 deletions OL/AheadWorks/GiftCard.php

This file was deleted.

14 changes: 0 additions & 14 deletions OL/AheadWorks/Reward.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/klarna-compatibility"
,"version": "0.0.1"
,"version": "1.0.0"
,"description": "The module makes the official Klarna payment module for Magento 2 compatible with third-party modules"
,"type": "magento2-module"
,"homepage": "https://mage2.pro/c/extensions/klarna-compatibility"
Expand Down
27 changes: 27 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version='1.0'?>
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='urn:magento:framework:ObjectManager/etc/config.xsd'
>
<virtualType name='Dfe\KlarnaC\OL\AheadWorks\CustomerBalance' type='Dfe\KlarnaC\OL'>
<arguments>
<argument name='id' xsi:type='string'>aw_store_credit</argument>
<argument name='type' xsi:type='const'
>Klarna\Core\Model\Checkout\Orderline\Customerbalance::ITEM_TYPE_CUSTOMERBALANCE</argument>
</arguments>
</virtualType>
<virtualType name='Dfe\KlarnaC\OL\AheadWorks\GiftCard' type='Dfe\KlarnaC\OL'>
<arguments>
<argument name='id' xsi:type='string'>aw_giftcard</argument>
<argument name='type' xsi:type='const'
>Klarna\Core\Model\Checkout\Orderline\Giftcard::ITEM_TYPE_GIFTCARD</argument>
</arguments>
</virtualType>
<virtualType name='Dfe\KlarnaC\OL\AheadWorks\Reward' type='Dfe\KlarnaC\OL'>
<arguments>
<argument name='id' xsi:type='string'>aw_reward_points</argument>
<argument name='type' xsi:type='const'
>Klarna\Core\Model\Checkout\Orderline\Reward::ITEM_TYPE_REWARD</argument>
</arguments>
</virtualType>
</config>

0 comments on commit d41a7b2

Please sign in to comment.