Skip to content

Commit

Permalink
Release 1.0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
edgaraswallee committed Sep 12, 2024
1 parent ee134a9 commit bfd5538
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ account dashboard.

## Documentation

[Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/jtl-5/1.0.29/docs/en/documentation.html)
[Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/jtl-5/1.0.30/docs/en/documentation.html)

## License

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Plugin\jtl_postfinancecheckout\Services\PostFinanceCheckoutTransactionService;
use Plugin\jtl_postfinancecheckout\Webhooks\Strategies\Interfaces\PostFinanceCheckoutOrderUpdateStrategyInterface;
use PostFinanceCheckout\Sdk\Model\TransactionState;
use JTL\Catalog\Product\Artikel;
use JTL\Checkout\StockUpdater;
use JTL\Helpers\Product;

class PostFinanceCheckoutNameOrderUpdateRefundStrategy implements PostFinanceCheckoutOrderUpdateStrategyInterface
{
Expand All @@ -25,11 +28,23 @@ class PostFinanceCheckoutNameOrderUpdateRefundStrategy implements PostFinanceChe
*/
private $orderService;

/**
* The StockUpdater's JTL service.
*
* @var JTL\Checkout\StockUpdater
*/
protected $stockUpdater;

public function __construct(PostFinanceCheckoutRefundService $refundService, PostFinanceCheckoutTransactionService $transactionService)
{
$this->refundService = $refundService;
$this->transactionService = $transactionService;
$this->orderService = new PostFinanceCheckoutOrderService();

if (!function_exists('getStockUpdater')) {
require_once \PFAD_ROOT . \PFAD_INCLUDES . 'bestellabschluss_inc.php';
}
$this->stockUpdater = getStockUpdater();
}

/**
Expand All @@ -54,6 +69,31 @@ public function updateOrderStatus(string $entityId): void
$transaction = $refund->getTransaction();
$amountToBeRefunded = round(floatval($transaction->getCompletedAmount()) - $transaction->getRefundedAmount(), 2);

// Restores the stock of the refunded product.
$reductions = $refund->getReductions();
$quantity = 0;
if (count($reductions) > 0) {
foreach ($reductions as $reduction) {
$quantity = $reduction->getQuantityReduction();
$line_item_id = $reduction->getLineItemUniqueId();
if ($quantity > 0) {
foreach ($refund->getReducedLineItems() as $line_item) {
if ($line_item_id == $line_item->getUniqueId()) {
$product_name = $line_item->getName();
$product = Product::getProductByAttribute('cName', $product_name);
if ($product instanceof Artikel) {
$productID = $product->getID();
// Amount is negative because we're filling up the stock.
$this->stockUpdater->updateProductStockLevel($productID, -1, $quantity);
}
}
}
}

$quantity = 0;
}
}

if ($amountToBeRefunded > 0) {
$this->orderService->updateOrderStatus($orderId, \BESTELLUNG_STATUS_BEZAHLT, \BESTELLUNG_STATUS_TEILVERSANDT);
$this->transactionService->updateTransactionStatus($transaction->getId(), 'PARTIALLY REFUNDED');
Expand Down
2 changes: 1 addition & 1 deletion docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/pfpayments/jtl-5/releases/tag/1.0.29/">
<a href="https://github.com/pfpayments/jtl-5/releases/tag/1.0.30/">
Source
</a>
</li>
Expand Down
1 change: 1 addition & 0 deletions frontend/postfinancecheckout_iframe.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php declare(strict_types=1);

use JTL\Shop;
use Plugin\jtl_postfinancecheckout\PostFinanceCheckoutHelper;

/** @global \JTL\Smarty\JTLSmarty $smarty */
Expand Down
1 change: 1 addition & 0 deletions frontend/postfinancecheckout_thank_you_page.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php declare(strict_types=1);

use JTL\Checkout\Bestellung;
use JTL\Shop;
use Plugin\jtl_postfinancecheckout\Services\PostFinanceCheckoutTransactionService;
use Plugin\jtl_postfinancecheckout\PostFinanceCheckoutApiClient;

Expand Down
2 changes: 1 addition & 1 deletion info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Icon>logo.jpg</Icon>
<PluginID>jtl_postfinancecheckout</PluginID>
<CreateDate>2023-05-29</CreateDate>
<Version>1.0.29</Version>
<Version>1.0.30</Version>
<Install>
<Locales>
<Variable>
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '23881441945da62c99ed76e8ccae1abaa8c573cc',
'reference' => '444a0d4db972eeb5f986817906a3c2d5411820ed',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '23881441945da62c99ed76e8ccae1abaa8c573cc',
'reference' => '444a0d4db972eeb5f986817906a3c2d5411820ed',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down

0 comments on commit bfd5538

Please sign in to comment.