Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #149

Merged
merged 54 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
1eddc6a
Refactor SQL query for enhanced security
vegimcarkaxhija Jan 12, 2024
b6527ba
Merge pull request #121 from buckaroo-it/BP-3351-Prestashop-SQL-fix
vegimcarkaxhija Jan 15, 2024
9536f11
fix category in shipping
vegimcarkaxhija Jan 16, 2024
23767ad
create function for getRecipientCategory
vegimcarkaxhija Jan 16, 2024
1e72dc5
fix
vegimcarkaxhija Jan 16, 2024
e17ee8c
fix
vegimcarkaxhija Jan 16, 2024
7a444ec
Merge pull request #123 from buckaroo-it/BP-3355-Fix-error-No-recipie…
vegimcarkaxhija Jan 16, 2024
91a00f6
fix
vegimcarkaxhija Jan 16, 2024
d3e4218
Merge pull request #124 from buckaroo-it/BP-3355-Fix-error-No-recipie…
vegimcarkaxhija Jan 16, 2024
c8f56d0
change version name
vegimcarkaxhija Jan 16, 2024
27ced70
Merge pull request #125 from buckaroo-it/BP-3352-Update-test-release-…
vegimcarkaxhija Jan 16, 2024
c1c2f04
update packages and remove unused packages
vegimcarkaxhija Jan 22, 2024
d9ed8ea
upload logo
vegimcarkaxhija Jan 22, 2024
0a86e24
Merge pull request #126 from buckaroo-it/BP-3359-Fix-vite-dev-server-…
vegimcarkaxhija Jan 23, 2024
4a48a7f
BP-3326 Change new required fields for Riverty DE (#127)
harli91 Jan 23, 2024
afa29aa
changed DATETIME to TIMESTAMP,removed updated_at, and put buckaroo.re…
vegimcarkaxhija Feb 27, 2024
2ca1b3c
Merge pull request #129 from buckaroo-it/BP-3429-New-installation-is-…
vegimcarkaxhija Feb 27, 2024
710518a
validate required issuers from dropdown or radio inputs, for paybyban…
gentiprenaj Mar 1, 2024
f00f643
BP-3439 Add product image URL's for Riverty/Afterpay invoices (#131)
harli91 Mar 1, 2024
d293822
fixed validation in two seperates functions for radio and dropdown
gentiprenaj Mar 4, 2024
18311f9
Merge pull request #130 from buckaroo-it/BP-3431-Prevent-transaction-…
gentiprenaj Mar 4, 2024
d77ec77
BP-3459 Remove old "Mister Cash" name for Bancontact
Mar 8, 2024
921c867
update images
vegimcarkaxhija Mar 8, 2024
2351aec
Merge pull request #132 from buckaroo-it/BP-3459-remove-old-mister-ca…
vegimcarkaxhija Mar 8, 2024
23f711f
Merge pull request #133 from buckaroo-it/BP-3456-Update-payment-metho…
vegimcarkaxhija Mar 8, 2024
2b61fb8
update in3
vegimcarkaxhija Mar 8, 2024
f060c55
fix ideal
vegimcarkaxhija Mar 11, 2024
a14060b
remove unneeded constructor
vegimcarkaxhija Mar 11, 2024
3699452
Merge pull request #134 from buckaroo-it/BP-3460-iDeal-doesn-t-work-w…
vegimcarkaxhija Mar 11, 2024
6b20d69
Merge pull request #135 from buckaroo-it/BP-3461-Bank-Transfer-has-is…
vegimcarkaxhija Mar 11, 2024
987b7a4
update version for release
vegimcarkaxhija Mar 11, 2024
94b0304
Merge pull request #136 from buckaroo-it/BP-3312-Update-test-release-…
vegimcarkaxhija Mar 11, 2024
9af0e72
add Knaken payment method and update php sdk
vegimcarkaxhija Mar 11, 2024
097e1bb
BP-3455 Show cards as individual payment methods (#137)
harli91 Mar 12, 2024
5a5ac54
Merge branch 'develop' into BP-3464-Add-Knaken-Settle-PrestaShop
vegimcarkaxhija Mar 12, 2024
4ad7484
Merge pull request #138 from buckaroo-it/BP-3464-Add-Knaken-Settle-Pr…
vegimcarkaxhija Mar 12, 2024
be67b14
fix merge
vegimcarkaxhija Mar 12, 2024
03f21be
change name in translations from Knaken to Knaken Settle
vegimcarkaxhija Mar 12, 2024
d0186c8
Merge pull request #139 from buckaroo-it/BP-3464-Add-Knaken-Settle-Pr…
vegimcarkaxhija Mar 12, 2024
04afec9
Fix knaken signature error (#140)
harli91 Mar 14, 2024
412c9b0
fix payment_fee to accept .
vegimcarkaxhija Mar 14, 2024
bb83a3c
fix payment_fee to accept .
vegimcarkaxhija Mar 14, 2024
e9a2236
Merge pull request #144 from buckaroo-it/BP-3472-Not-able-to-use-deci…
vegimcarkaxhija Mar 14, 2024
55856f1
fix status code
vegimcarkaxhija Mar 15, 2024
628bb8b
fix status code
vegimcarkaxhija Mar 15, 2024
193ea08
fix status code
vegimcarkaxhija Mar 15, 2024
4f972cb
log order
vegimcarkaxhija Mar 15, 2024
230e1aa
remove log
vegimcarkaxhija Mar 15, 2024
5f5e189
check if order is backOrder
vegimcarkaxhija Mar 15, 2024
6f98cba
Merge pull request #147 from buckaroo-it/BP-3473-Status-changed-from-…
vegimcarkaxhija Mar 18, 2024
3ab4b6b
fix billink afterpay klarna to work with fee, also update billink fee…
vegimcarkaxhija Mar 19, 2024
c7745d9
remove wrapping vat from vue and get from prestashop
vegimcarkaxhija Mar 19, 2024
6fa2410
fix
vegimcarkaxhija Mar 19, 2024
0c463eb
Merge pull request #148 from buckaroo-it/BP-3478-Payment-fee-is-not-w…
vegimcarkaxhija Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The Buckaroo PrestaShop Payments Plugin ([Dutch](https://support.buckaroo.nl/cat

To use the Buckaroo plugin, please be aware of the following minimum requirements:
- A Buckaroo account ([Dutch](https://www.buckaroo.nl/start) or [English](https://www.buckaroo.eu/solutions/request-form))
- PrestaShop 1.7.x or 8.1.2
- PrestaShop 1.7.x or 8.1.4
- PHP 7.4 or higher

### Installation
Expand Down
2 changes: 1 addition & 1 deletion vendor/index.php → api/paymentmethods/knaken/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../../../../../');
header('Location: ../');
exit;
30 changes: 30 additions & 0 deletions api/paymentmethods/knaken/knaken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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 <[email protected]>
* @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 Knaken extends PaymentMethod
{
public function __construct()
{
$this->type = 'knaken';
$this->version = 1;
}
}
2 changes: 2 additions & 0 deletions api/paymentmethods/paymentrequestfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class PaymentRequestFactory
public const REQUEST_TYPE_ALIPAY = 'alipay';
public const REQUEST_TYPE_MULTIBANCO = 'multibanco';
public const REQUEST_TYPE_MBWAY = 'mbway';
public const REQUEST_TYPE_KNAKEN = 'knaken';

// Request types (Payment Methods).
public static $valid_request_types = [
Expand Down Expand Up @@ -82,6 +83,7 @@ class PaymentRequestFactory
PaymentRequestFactory::REQUEST_TYPE_ALIPAY => 'Alipay',
PaymentRequestFactory::REQUEST_TYPE_MULTIBANCO => 'Multibanco',
PaymentRequestFactory::REQUEST_TYPE_MBWAY => 'Mbway',
PaymentRequestFactory::REQUEST_TYPE_KNAKEN => 'Knaken',
];

final public static function create($request_type_id, $data = [])
Expand Down
61 changes: 49 additions & 12 deletions buckaroo3.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct()
{
$this->name = 'buckaroo3';
$this->tab = 'payments_gateways';
$this->version = '4.1.0';
$this->version = '4.2.0';
$this->author = 'Buckaroo';
$this->need_instance = 1;
$this->bootstrap = true;
Expand All @@ -56,7 +56,7 @@ public function __construct()
parent::__construct();

$this->displayName = $this->l('Buckaroo Payments') . ' (v ' . $this->version . ')';
$this->description = $this->l('Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.2');
$this->description = $this->l('Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.4');

$this->confirmUninstall = $this->l('Are you sure you want to delete Buckaroo Payments module?');
$this->tpl_folder = 'buckaroo3';
Expand All @@ -72,7 +72,7 @@ public function __construct()
$this->displayName =
(new RawPaymentMethodRepository())->getPaymentMethodsLabel($response->payment_method);
} else {
$this->displayName = $this->l('Buckaroo Payments (v 4.1.0)');
$this->displayName = $this->l('Buckaroo Payments (v 4.2.0)');
}
}

Expand Down Expand Up @@ -234,9 +234,13 @@ public function uninstall()
return false;
}

$refundSettingsService = $this->get('buckaroo.refund.settings');
if ($refundSettingsService) {
$refundSettingsService->uninstall();
try {
$refundSettingsService = $this->get('buckaroo.refund.settings');
if ($refundSettingsService) {
$refundSettingsService->uninstall();
}
} catch (\Exception $e) {
$this->_errors[] = 'Failed to uninstall buckaroo.refund.settings: ' . $e->getMessage();
}

return parent::uninstall();
Expand Down Expand Up @@ -382,6 +386,8 @@ public function hookPaymentOptions($params)
'creditCardDisplayMode' => $buckarooConfigService->getConfigValue('creditcard', 'display_type'),
'in3Method' => $this->get('buckaroo.classes.issuers.capayableIn3')->getMethod(),
'showIdealIssuers' => $buckarooConfigService->getConfigValue('ideal', 'show_issuers') ?? true,
'buckaroo_idin_test' => $buckarooConfigService->getConfigValue('idin', 'mode'),
'houseNumbersAreValid' => $buckarooPaymentService->areHouseNumberValidForCountryDE($cart)
]
);
} catch (Exception $e) {
Expand Down Expand Up @@ -442,6 +448,7 @@ public function hookDisplayHeader()
'validation' => [
'date' => $this->l('Please enter correct birthdate date'),
'required' => $this->l('Field is required'),
'bank' => $this->l('Please select your bank'),
'agreement' => $this->l('Please accept licence agreements'),
'iban' => $this->l('A valid IBAN is required'),
'age' => $this->l('You must be at least 18 years old'),
Expand All @@ -453,12 +460,13 @@ public function hookDisplayHeader()
$this->context->controller->addJS($this->_path . 'views/js/buckaroo.js', 'all');
}

public static function resolveStatusCode($status_code)
public static function resolveStatusCode($status_code, $id_order = null)
{
switch ($status_code) {
case BuckarooAbstract::BUCKAROO_SUCCESS:
return Configuration::get('BUCKAROO_ORDER_STATE_SUCCESS') ?
Configuration::get('BUCKAROO_ORDER_STATE_SUCCESS') : Configuration::get('PS_OS_PAYMENT');
return self::isOrderBackOrder($id_order) ?
Configuration::get('PS_OS_OUTOFSTOCK_PAID') :
(Configuration::get('BUCKAROO_ORDER_STATE_SUCCESS') ?: Configuration::get('PS_OS_PAYMENT'));
case BuckarooAbstract::BUCKAROO_PENDING_PAYMENT:
return Configuration::get('BUCKAROO_ORDER_STATE_DEFAULT');
case BuckarooAbstract::BUCKAROO_CANCELED:
Expand All @@ -472,9 +480,33 @@ public static function resolveStatusCode($status_code)
}
}

private static function isOrderBackOrder($orderId)
{
$order = new Order($orderId);
$orderDetails = $order->getOrderDetailList();
/** @var OrderDetail $detail */
foreach ($orderDetails as $detail) {
$orderDetail = new OrderDetail($detail['id_order_detail']);
if (
Configuration::get('PS_STOCK_MANAGEMENT') &&
($orderDetail->getStockState() || $orderDetail->product_quantity_in_stock < 0)
) {
return true;
}
}

return false;
}

public function getBuckarooFeeByCartId($id_cart)
{
$sql = 'SELECT buckaroo_fee FROM ' . _DB_PREFIX_ . 'buckaroo_fee where id_cart = ' . (int) $id_cart;
$id_cart = (int) $id_cart;

$sql = new DbQuery();

$sql->select('buckaroo_fee');
$sql->from('buckaroo_fee');
$sql->where('id_cart = ' . pSQL($id_cart));

return Db::getInstance()->getValue($sql);
}
Expand Down Expand Up @@ -585,9 +617,14 @@ public function isIdinProductBoxShow($params)
}
}

private function isProductBuckarooIdinEnabled($productId)
private function isProductBuckarooIdinEnabled(int $productId)
{
$sql = 'SELECT buckaroo_idin FROM ' . _DB_PREFIX_ . 'bk_product_idin WHERE product_id = ' . (int) $productId;
$sql = new DbQuery();

$sql->select('buckaroo_idin');
$sql->from('bk_product_idin');
$sql->where('product_id = ' . pSQL($productId));

$buckarooIdin = Db::getInstance()->getValue($sql);

return $buckarooIdin == 1;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"require": {
"php": ">=7.4",
"buckaroo/sdk": "^1.9.1"
"buckaroo/sdk": "^1.11.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>buckaroo3</name>
<displayName><![CDATA[Buckaroo Payments (v 4.1.0)]]></displayName>
<version><![CDATA[4.1.0]]></version>
<description><![CDATA[Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.2]]></description>
<displayName><![CDATA[Buckaroo Payments (v 4.2.0)]]></displayName>
<version><![CDATA[4.2.0]]></version>
<description><![CDATA[Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.4]]></description>
<author><![CDATA[Buckaroo]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to delete Buckaroo Payments module?]]></confirmUninstall>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buckaroo_refund:
path: buckaroo3/refund
methods: [POST]
defaults:
_controller: 'buckaroo.refund_controller::refund'
_controller: 'Buckaroo\PrestaShop\Controllers\admin\AdminRefundController::refund'

buckaroo_config_paymentMethod:
path: buckaroo3/config/payment/methods
Expand Down
2 changes: 1 addition & 1 deletion config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- "@buckaroo.refund.request.response.handler"
public: true

buckaroo.refund_controller:
Buckaroo\PrestaShop\Controllers\admin\AdminRefundController:
class: Buckaroo\PrestaShop\Controllers\admin\AdminRefundController
arguments:
- "@buckaroo.refund.request.quantity_based_builder"
Expand Down
28 changes: 18 additions & 10 deletions controllers/front/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,21 @@ public function postProcess()
$debug = 'Currency: ' . $currency->name . "\nTotal Amount: " . $total . "\nPayment Method: " . $payment_method;
$logger->logInfo('Checkout info', $debug);

$this->checkout = Checkout::getInstance($payment_method, $cart);
$this->checkout->platformName = 'PrestaShop';
$this->checkout->platformVersion = _PS_VERSION_;
$this->checkout->moduleSupplier = $this->module->author;
$this->checkout->moduleName = $this->module->name;
$this->checkout->moduleVersion = $this->module->version;
$this->checkout->returnUrl = 'http' . ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . __PS_BASE_URI__ . 'index.php?fc=module&module=buckaroo3&controller=userreturn'; // phpcs:ignore
$this->checkout->pushUrl = 'http' . ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . __PS_BASE_URI__ . 'index.php?fc=module&module=buckaroo3&controller=return';
try{
$this->checkout = Checkout::getInstance($payment_method, $cart, $this->context);
$this->checkout->platformName = 'PrestaShop';
$this->checkout->platformVersion = _PS_VERSION_;
$this->checkout->moduleSupplier = $this->module->author;
$this->checkout->moduleName = $this->module->name;
$this->checkout->moduleVersion = $this->module->version;
$this->checkout->returnUrl = 'http' . ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . __PS_BASE_URI__ . 'index.php?fc=module&module=buckaroo3&controller=userreturn'; // phpcs:ignore
$this->checkout->pushUrl = 'http' . ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . __PS_BASE_URI__ . 'index.php?fc=module&module=buckaroo3&controller=return';
} catch (Exception $e) {
$logger->logError('Set checkout info: ', $e->getMessage());
$this->displayError(null, $e->getMessage());

return;
}
$logger->logDebug('Get checkout class: ');
$pending = Configuration::get('BUCKAROO_ORDER_STATE_DEFAULT');

Expand All @@ -151,10 +158,11 @@ public function postProcess()
$id_order_cart = Order::getIdByCartId($cart->id);
$order = new Order($id_order_cart);
$this->checkout->setReference($order->reference);
$this->checkout->setCheckout();
$logger->logDebug('Set checkout info: ');


try {
$this->checkout->setCheckout();
$logger->logDebug('Set checkout info: ');
if ($this->checkout->isVerifyRequired()) {
$logger->logInfo('Start verify process');
$this->checkout->startVerify(['cid' => $cart->id_customer]);
Expand Down
10 changes: 7 additions & 3 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public function initContent()
} else {
$logger->logInfo('Update the order', 'Order ID: ' . $id_order);

$new_status_code = Buckaroo3::resolveStatusCode($response->status);
$new_status_code = Buckaroo3::resolveStatusCode($response->status, $id_order);

$order = new Order($id_order);

if (!in_array($order->reference, $references)) {
Expand Down Expand Up @@ -198,8 +199,11 @@ public function initContent()
exit;
}

$sql = 'SELECT buckaroo_fee FROM ' . _DB_PREFIX_ . 'buckaroo_fee where id_cart = ' .
(int) $response->getCartId();
$cartId = (int) $response->getCartId();
$sql = new DbQuery();
$sql->select('buckaroo_fee');
$sql->from('buckaroo_fee');
$sql->where('id_cart = ' . pSQL($cartId));
$buckarooFee = Db::getInstance()->getValue($sql);

if ($buckarooFee && (isset($payment) && $payment->payment_method != 'Group transaction')) {
Expand Down
5 changes: 4 additions & 1 deletion dev/lang/php_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,8 @@
"payment_methods.transfer": "Überweisen",
"payment_methods.trustly": "Vertrauenswürdig",
"payment_methods.wechatpay": "WeChatPay",
"verification_methods.idin": "iDIN"
"payment_methods.knaken": "Knaken Settle",
"verification_methods.idin": "iDIN",
"dashboard.pages.payments.displayInCheckout": "Group Credit-debitcards",
"dashboard.pages.payments.displayInCheckoutDesc": "Cards option on how to show the brands in the checkout. <br/> <b>Separate</b>: Card issuers are showed seperately in the checkout.</br><b>Grouped</b>: Card issuers are showed within one group."
}
5 changes: 4 additions & 1 deletion dev/lang/php_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,8 @@
"payment_methods.transfer": "Transfer",
"payment_methods.trustly": "Trustly",
"payment_methods.wechatpay": "WeChatPay",
"verification_methods.idin": "iDIN"
"payment_methods.knaken": "Knaken Settle",
"verification_methods.idin": "iDIN",
"dashboard.pages.payments.displayInCheckout": "Group Credit-debitcards",
"dashboard.pages.payments.displayInCheckoutDesc": "Cards option on how to show the brands in the checkout. <br/> <b>Separate</b>: Card issuers are showed seperately in the checkout.</br><b>Grouped</b>: Card issuers are showed within one group."
}
5 changes: 4 additions & 1 deletion dev/lang/php_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,8 @@
"payment_methods.transfer": "Transfert",
"payment_methods.trustly": "En toute confiance",
"payment_methods.wechatpay": "WeChatPay",
"verification_methods.idin": "IDIN"
"payment_methods.knaken": "Knaken Settle",
"verification_methods.idin": "IDIN",
"dashboard.pages.payments.displayInCheckout": "Group Credit-debitcards",
"dashboard.pages.payments.displayInCheckoutDesc": "Cards option on how to show the brands in the checkout. <br/> <b>Separate</b>: Card issuers are showed seperately in the checkout.</br><b>Grouped</b>: Card issuers are showed within one group."
}
5 changes: 4 additions & 1 deletion dev/lang/php_nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,5 +425,8 @@
"payment_methods.transfer": "Transfer",
"payment_methods.trustly": "Trustly",
"payment_methods.wechatpay": "WeChatPay",
"verification_methods.idin": "iDIN"
"payment_methods.knaken": "Knaken Settle",
"verification_methods.idin": "iDIN",
"dashboard.pages.payments.displayInCheckout": "Group Credit-debitcards",
"dashboard.pages.payments.displayInCheckoutDesc": "Cards option on how to show the brands in the checkout. <br/> <b>Separate</b>: Card issuers are showed seperately in the checkout.</br><b>Grouped</b>: Card issuers are showed within one group."
}
Loading
Loading