Skip to content

Commit

Permalink
Merge pull request #184 from buckaroo-it/develop
Browse files Browse the repository at this point in the history
Update, Test & Release (4.4.0)
  • Loading branch information
vegimcarkaxhija authored Sep 11, 2024
2 parents a7d894d + 802a461 commit e5d742e
Show file tree
Hide file tree
Showing 33 changed files with 682 additions and 263 deletions.
29 changes: 29 additions & 0 deletions api/paymentmethods/blik/blik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* It is available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this file
*
* @author Buckaroo.nl <plugins@buckaroo.nl>
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}

require_once dirname(__FILE__) . '/../paymentmethod.php';
class Blik extends PaymentMethod
{
public function __construct()
{
$this->type = 'blik';
$this->version = 1;
}
}
25 changes: 25 additions & 0 deletions api/paymentmethods/blik/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* It is available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this file
*
* @author Buckaroo.nl <plugins@buckaroo.nl>
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
2 changes: 2 additions & 0 deletions api/paymentmethods/paymentrequestfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PaymentRequestFactory
public const REQUEST_TYPE_KBCPAYMENTBUTTON = 'kbcpaymentbutton';
public const REQUEST_TYPE_SEPADIRECTDEBIT = 'sepadirectdebit';
public const REQUEST_TYPE_BANCONTACTMRCASH = 'bancontactmrcash';
public const REQUEST_TYPE_BLIK = 'blik';
public const REQUEST_TYPE_SOFORTBANKING = 'sofortueberweisung';
public const REQUEST_TYPE_GIFTCARD = 'giftcard';
public const REQUEST_TYPE_CREDITCARD = 'creditcard';
Expand Down Expand Up @@ -60,6 +61,7 @@ class PaymentRequestFactory
PaymentRequestFactory::REQUEST_TYPE_GIROPAY => 'Giropay',
PaymentRequestFactory::REQUEST_TYPE_KBCPAYMENTBUTTON => 'Kbcpaymentbutton',
PaymentRequestFactory::REQUEST_TYPE_BANCONTACTMRCASH => 'Bancontactmrcash',
PaymentRequestFactory::REQUEST_TYPE_BLIK => 'Blik',
PaymentRequestFactory::REQUEST_TYPE_SOFORTBANKING => 'Sofortbanking',
PaymentRequestFactory::REQUEST_TYPE_GIFTCARD => 'GiftCard',
PaymentRequestFactory::REQUEST_TYPE_CREDITCARD => 'CreditCard',
Expand Down
4 changes: 2 additions & 2 deletions buckaroo3.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private function initializeModuleInfo()
{
$this->name = 'buckaroo3';
$this->tab = 'payments_gateways';
$this->version = '4.3.0';
$this->version = '4.4.0';
$this->author = 'Buckaroo';
$this->need_instance = 1;
$this->bootstrap = true;
Expand Down Expand Up @@ -84,7 +84,7 @@ private function initializeDisplayName()
} elseif (isset($response->status) && $response->status > 0) {
$this->displayName = (new RawPaymentMethodRepository())->getPaymentMethodsLabel($response->payment_method);
} else {
$this->displayName = $this->l('Buckaroo Payments (v 4.3.0)');
$this->displayName = $this->l('Buckaroo Payments (v 4.4.0)');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>buckaroo3</name>
<displayName><![CDATA[Buckaroo Payments (v 4.3.0)]]></displayName>
<version><![CDATA[4.3.0]]></version>
<displayName><![CDATA[Buckaroo Payments (v 4.4.0)]]></displayName>
<version><![CDATA[4.4.0]]></version>
<description><![CDATA[Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.6]]></description>
<author><![CDATA[Buckaroo]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
19 changes: 12 additions & 7 deletions controllers/admin/AdminRefundController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Buckaroo\PrestaShop\Src\Refund\Request\Handler as RefundRequestHandler;
use Buckaroo\PrestaShop\Src\Refund\Request\QuantityBasedBuilder;
use Buckaroo\PrestaShop\Src\Refund\Request\Response\Handler as RefundResponseHandler;
use Buckaroo\PrestaShop\Src\Refund\Settings;
use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down Expand Up @@ -140,14 +141,18 @@ private function sentRefundRequest(\Order $order, \OrderPayment $payment, float
}

$body = $this->refundBuilder->create($order, $payment, $refundAmount);
$this->responseHandler->parse(
$this->refundHandler->refund(


if (\Configuration::get(Settings::LABEL_REFUND_CONF)){
$this->responseHandler->parse(
$this->refundHandler->refund(
$body,
$payment->payment_method
),
$body,
$payment->payment_method
),
$body,
$order->id
);
$order->id
);
}

return $maxRefundAmount;
}
Expand Down
4 changes: 4 additions & 0 deletions dev/lang/php_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dashboard.pages.payments.max_order_amount_b2c": "Maximaler B2B-Bestellbetrag",
"dashboard.pages.payments.maximum_order_amount": "Maximaler Bestellwert",
"dashboard.pages.payments.min_order_amount_b2b": "Mindestbestellwert für B2B",
"dashboard.pages.payments.max_order_amount_b2b": "Maximaler B2B Bestellwert",
"dashboard.pages.payments.minimum_order_amount": "Mindestbestellmenge",
"dashboard.pages.payments.mode": "Modus",
"dashboard.pages.payments.mode_label": "Bei der Einstellung „Live“ können Sie tatsächliche Zahlungen durchführen. ",
Expand Down Expand Up @@ -136,6 +137,8 @@
"dashboard.pages.settings.no_im_testing": "Nein, ich teste",
"dashboard.pages.settings.order_number": "Bestellnummer",
"dashboard.pages.settings.order_number2": "Bestellnummer",
"dashboard.pages.settings.refund_conf": "Automatische Rückerstattungen über Buckaroo",
"dashboard.pages.settings.refund_conf_label": "Aktivieren/deaktivieren Sie automatische Rückerstattungen über Buckaroo, wenn eine Rückerstattung in PrestaShop initiiert wird.",
"dashboard.pages.settings.re_stock_products": "Produkte wieder auffüllen",
"dashboard.pages.settings.re_stock_products_label": "Ob erstattete Produkte wieder in den Lagerbestand aufgenommen werden sollen (Erhöhung der Lagermenge).",
"dashboard.pages.settings.refunds": "Rückerstattungen",
Expand Down Expand Up @@ -182,6 +185,7 @@
"payment_methods.bancontactmrcash": "Bancontact",
"payment_methods.belfius": "Belfius",
"payment_methods.billink": "Billink",
"payment_methods.blik": "Blik",
"payment_methods.creditcard": "Karten",
"payment_methods.eps": "EPS",
"payment_methods.giftcard": "Geschenkkarte",
Expand Down
4 changes: 4 additions & 0 deletions dev/lang/php_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dashboard.pages.payments.max_order_amount_b2c": "Maximum B2B order amount",
"dashboard.pages.payments.maximum_order_amount": "Maximum order amount",
"dashboard.pages.payments.min_order_amount_b2b": "Minimum B2B order amount",
"dashboard.pages.payments.max_order_amount_b2b": "Maximum B2B order amount",
"dashboard.pages.payments.minimum_order_amount": "Minimum order amount",
"dashboard.pages.payments.mode": "Mode",
"dashboard.pages.payments.mode_label": "When set to \"Live\" you can do actual payments. When set to \"Testing\" you can do test transactions. This payment method will not appear when it is set to \"Off\".",
Expand Down Expand Up @@ -136,6 +137,8 @@
"dashboard.pages.settings.no_im_testing": "No, I'm Testing",
"dashboard.pages.settings.order_number": "Order number",
"dashboard.pages.settings.order_number2": "order_number",
"dashboard.pages.settings.refund_conf": "Automatic refunds via Buckaroo",
"dashboard.pages.settings.refund_conf_label": "Enable/disable automatic refunds via Buckaroo when a refund from PrestaShop is inititated.",
"dashboard.pages.settings.re_stock_products": "Re-stock Products",
"dashboard.pages.settings.re_stock_products_label": "Whether refunded products should be returned to inventory (increasing the quantity in stock).",
"dashboard.pages.settings.refunds": "Refunds",
Expand Down Expand Up @@ -183,6 +186,7 @@
"payment_methods.bancontactmrcash": "Bancontact",
"payment_methods.belfius": "Belfius",
"payment_methods.billink": "Billink",
"payment_methods.blik": "Blik",
"payment_methods.creditcard": "Cards",
"payment_methods.eps": "EPS",
"payment_methods.giftcard": "Giftcard",
Expand Down
4 changes: 4 additions & 0 deletions dev/lang/php_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dashboard.pages.payments.max_order_amount_b2c": "Montant maximum de la commande B2B",
"dashboard.pages.payments.maximum_order_amount": "Montant maximum de la commande",
"dashboard.pages.payments.min_order_amount_b2b": "Montant minimum de la commande B2B",
"dashboard.pages.payments.max_order_amount_b2b": "Montant maximum de la commande B2B",
"dashboard.pages.payments.minimum_order_amount": "Montant minimum de commande",
"dashboard.pages.payments.mode": "Mode",
"dashboard.pages.payments.mode_label": "Lorsqu'il est réglé sur « Live », vous pouvez effectuer des paiements réels. ",
Expand Down Expand Up @@ -136,6 +137,8 @@
"dashboard.pages.settings.no_im_testing": "Non, je teste",
"dashboard.pages.settings.order_number": "Numéro de commande",
"dashboard.pages.settings.order_number2": "numéro de commande",
"dashboard.pages.settings.refund_conf": "Remboursements automatiques via Buckaroo",
"dashboard.pages.settings.refund_conf_label": "Activer/désactiver les remboursements automatiques via Buckaroo lorsqu'un remboursement est initié depuis PrestaShop.",
"dashboard.pages.settings.re_stock_products": "Réapprovisionner les produits",
"dashboard.pages.settings.re_stock_products_label": "Si les produits remboursés doivent être retournés en stock (augmentant la quantité en stock).",
"dashboard.pages.settings.refunds": "Remboursements",
Expand Down Expand Up @@ -182,6 +185,7 @@
"payment_methods.bancontactmrcash": "Bancontact",
"payment_methods.belfius": "Belfius",
"payment_methods.billink": "Lien de facturation",
"payment_methods.blik": "Blik",
"payment_methods.creditcard": "Cartes",
"payment_methods.eps": "PSE",
"payment_methods.giftcard": "Carte cadeau",
Expand Down
4 changes: 4 additions & 0 deletions dev/lang/php_nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dashboard.pages.payments.max_order_amount_b2c": "Maximale B2B bestelbedrag",
"dashboard.pages.payments.maximum_order_amount": "Maximaal toegestane bestelbedrag",
"dashboard.pages.payments.min_order_amount_b2b": "Minimale B2B bestelbedrag",
"dashboard.pages.payments.max_order_amount_b2b": "Maximaal B2B toegestane bestelbedrag",
"dashboard.pages.payments.minimum_order_amount": "Minimaal toegestane bestelbedrag",
"dashboard.pages.payments.mode": "Modus",
"dashboard.pages.payments.mode_label": "Indien ingesteld op \"Live\", dan kunt u daadwerkelijke betalingen doen. Indien ingesteld op \"Test\", dan kun je testtransacties doen. De betaalmethode verschijnt niet als deze op \"Uit\" staat.",
Expand Down Expand Up @@ -134,6 +135,8 @@
"dashboard.pages.settings.no_im_testing": "Nee, ik wil testen",
"dashboard.pages.settings.order_number": "Bestellingsnummer",
"dashboard.pages.settings.order_number2": "bestellingsnummer",
"dashboard.pages.settings.refund_conf": "Automatische terugbetalingen via Buckaroo",
"dashboard.pages.settings.refund_conf_label": "Automatische terugbetalingen via Buckaroo in- of uitschakelen wanneer een terugbetaling vanuit PrestaShop wordt gestart.",
"dashboard.pages.settings.re_stock_products": "De voorraad aanvullen bij retourproducten",
"dashboard.pages.settings.re_stock_products_label": "Of terugbetaalde producten moeten worden teruggeplaatst in de voorraad (waardoor de voorraadhoeveelheid wordt verhoogd).",
"dashboard.pages.settings.refunds": "Terugbetalingen",
Expand Down Expand Up @@ -178,6 +181,7 @@
"payment_methods.bancontactmrcash": "Bancontact",
"payment_methods.belfius": "Belfius",
"payment_methods.billink": "Billink",
"payment_methods.blik": "Blik",
"payment_methods.creditcard": "Cards",
"payment_methods.eps": "EPS",
"payment_methods.giftcard": "Giftcard",
Expand Down
2 changes: 1 addition & 1 deletion dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vueuse/core": "^10.7.2",
"autoprefixer": "^10.4.17",
"axios": "1.6.8",
"axios": ">=1.7.4",
"lodash": "^4.17.21",
"postcss": "^8.4.33",
"sass": "^1.70.0",
Expand Down
8 changes: 8 additions & 0 deletions dev/src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@
</div>
</div>
</div>
<ToggleField class="p-5 space-y-5" v-model="settings.refundconf">
<div>
<label for="client-side-mode" class="font-semibold text-sm">
{{ $t('dashboard.pages.settings.refund_conf') }}
</label>
<div class="text-gray-400 text-xs">{{ $t('dashboard.pages.settings.refund_conf_label') }}</div>
</div>
</ToggleField>
<ToggleField class="p-5 space-y-5" v-model="settings.restock">
<div>
<label for="client-side-mode" class="font-semibold text-sm">
Expand Down
51 changes: 51 additions & 0 deletions library/checkout/blikcheckout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* It is available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this file
*
* @author Buckaroo.nl <plugins@buckaroo.nl>
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
include_once _PS_MODULE_DIR_ . 'buckaroo3/library/checkout/checkout.php';

if (!defined('_PS_VERSION_')) {
exit;
}

class BlikCheckout extends Checkout
{
protected $customVars = [];

final public function setCheckout()
{
parent::setCheckout();
}

public function startPayment()
{
$this->payment_response = $this->payment_request->pay($this->customVars);
}

public function isRedirectRequired()
{
return true;
}

public function isVerifyRequired()
{
return false;
}

protected function initialize()
{
$this->payment_request = PaymentRequestFactory::create(PaymentRequestFactory::REQUEST_TYPE_BLIK);
}
}
2 changes: 2 additions & 0 deletions library/checkout/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ abstract class Checkout
public const CHECKOUT_TYPE_MBWAY = 'mbway';
public const CHECKOUT_TYPE_MULTIBANCO = 'multibanco';
public const CHECKOUT_TYPE_KNAKEN = 'knaken';
public const CHECKOUT_TYPE_BLIK = 'blik';

public static $payment_method_type = [
self::CHECKOUT_TYPE_PAYPAL => 'PayPal',
Expand Down Expand Up @@ -90,6 +91,7 @@ abstract class Checkout
self::CHECKOUT_TYPE_MBWAY => 'Mbway',
self::CHECKOUT_TYPE_MULTIBANCO => 'Multibanco',
self::CHECKOUT_TYPE_KNAKEN => 'Knaken',
self::CHECKOUT_TYPE_BLIK => 'Blik'
];

protected $payment_request;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Config
public const BUCKAROO_SECRET_KEY = 'BUCKAROO_SECRET_KEY';
public const BUCKAROO_TRANSACTION_LABEL = 'BUCKAROO_TRANSACTION_LABEL';
public const BUCKAROO_TRANSACTION_FEE = 'BUCKAROO_TRANSACTION_FEE';

public const LABEL_REFUND_CONF = 'BUCKAROO_REFUND_CONF';
public const LABEL_REFUND_RESTOCK = 'BUCKAROO_REFUND_RESTOCK';
public const LABEL_REFUND_CREDIT_SLIP = 'BUCKAROO_REFUND_CREDIT_SLIP';
public const LABEL_REFUND_VOUCHER = 'BUCKAROO_REFUND_VOUCHER';
Expand Down
1 change: 1 addition & 0 deletions src/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ protected function initConfig()
\Configuration::updateValue(Config::BUCKAROO_TRANSACTION_LABEL, '');
\Configuration::updateValue(Config::BUCKAROO_TRANSACTION_FEE, '');

\Configuration::updateValue(Config::LABEL_REFUND_CONF, true);
\Configuration::updateValue(Config::LABEL_REFUND_RESTOCK, false);
\Configuration::updateValue(Config::LABEL_REFUND_CREDIT_SLIP, true);
\Configuration::updateValue(Config::LABEL_REFUND_VOUCHER, false);
Expand Down
1 change: 1 addition & 0 deletions src/Install/Uninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private function deleteConfig()
Config::BUCKAROO_SECRET_KEY,
Config::BUCKAROO_TRANSACTION_LABEL,
Config::BUCKAROO_TRANSACTION_FEE,
Config::LABEL_REFUND_CONF,
Config::LABEL_REFUND_RESTOCK,
Config::LABEL_REFUND_CREDIT_SLIP,
Config::LABEL_REFUND_VOUCHER,
Expand Down
17 changes: 10 additions & 7 deletions src/Refund/Decorators/IssuePartialRefundHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace Buckaroo\PrestaShop\Src\Refund\Decorators;

use Buckaroo\PrestaShop\Src\Refund\Handler;
use Buckaroo\PrestaShop\Src\Refund\Settings;
use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssuePartialRefundCommand;
use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\IssuePartialRefundHandlerInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
Expand Down Expand Up @@ -59,13 +60,15 @@ public function __construct(
*/
public function handle(IssuePartialRefundCommand $command): void
{
$refundSummary = $this->refundHandler->getRefundSummary($command);
$this->handler->handle($command);
if (
!$this->session->has(self::KEY_SKIP_REFUND_REQUEST)
) {
$this->refundHandler->execute($command, $refundSummary);
$this->session->remove(self::KEY_SKIP_REFUND_REQUEST);
if (\Configuration::get(Settings::LABEL_REFUND_CONF)){
$refundSummary = $this->refundHandler->getRefundSummary($command);
$this->handler->handle($command);
if (
!$this->session->has(self::KEY_SKIP_REFUND_REQUEST)
) {
$this->refundHandler->execute($command, $refundSummary);
$this->session->remove(self::KEY_SKIP_REFUND_REQUEST);
}
}
}
}
Loading

0 comments on commit e5d742e

Please sign in to comment.