Skip to content

Commit

Permalink
Merge pull request #117 from buckaroo-it/prestashop-validator
Browse files Browse the repository at this point in the history
Prestashop validator
  • Loading branch information
vegimcarkaxhija authored Dec 20, 2023
2 parents 5a2f593 + e848e3b commit 22abb61
Show file tree
Hide file tree
Showing 156 changed files with 828 additions and 106 deletions.
4 changes: 4 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

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

ini_set('memory_limit','256M');

$finder = PhpCsFixer\Finder::create()->in([
Expand Down
8 changes: 8 additions & 0 deletions api/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@
* @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;
}

use Buckaroo\Resources\Constants\ResponseStatus;

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

abstract class BuckarooAbstract extends ResponseStatus
{
public const BUCKAROO_SUCCESS = 'BUCKAROO_SUCCESS';
Expand Down
4 changes: 4 additions & 0 deletions api/corelogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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;
}

class CoreLogger
{
// put your code here
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/afterpay/afterpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 AfterPay extends PaymentMethod
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/alipay/alipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Alipay extends PaymentMethod
Expand Down
3 changes: 3 additions & 0 deletions api/paymentmethods/applepay/applepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* @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';

Expand Down
5 changes: 4 additions & 1 deletion api/paymentmethods/bancontactmrcash/bancontactmrcash.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
require_once dirname(__FILE__) . '/../paymentmethod.php';
if (!defined('_PS_VERSION_')) {
exit;
}

require_once dirname(__FILE__) . '/../paymentmethod.php';
class Bancontactmrcash extends PaymentMethod
{
public function __construct()
Expand Down
3 changes: 3 additions & 0 deletions api/paymentmethods/belfius/belfius.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* @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';

Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/billink/billink.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
* @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 Billink extends PaymentMethod
{
public function __construct()
Expand Down
5 changes: 4 additions & 1 deletion api/paymentmethods/creditcard/creditcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
require_once dirname(__FILE__) . '/../paymentmethod.php';
if (!defined('_PS_VERSION_')) {
exit;
}

require_once dirname(__FILE__) . '/../paymentmethod.php';
class CreditCard extends PaymentMethod
{
public $issuer;
Expand Down
5 changes: 4 additions & 1 deletion api/paymentmethods/eps/eps.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
require_once dirname(__FILE__) . '/../paymentmethod.php';
if (!defined('_PS_VERSION_')) {
exit;
}

require_once dirname(__FILE__) . '/../paymentmethod.php';
class Eps extends PaymentMethod
{
public function __construct()
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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;
}

function autoload($payment_method)
{
require_once _PS_ROOT_DIR_ . '/modules/buckaroo3/vendor/autoload.php';
Expand Down
5 changes: 4 additions & 1 deletion api/paymentmethods/giftcard/giftcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
require_once dirname(__FILE__) . '/../paymentmethod.php';
if (!defined('_PS_VERSION_')) {
exit;
}

require_once dirname(__FILE__) . '/../paymentmethod.php';
class GiftCard extends PaymentMethod
{
public function __construct()
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/giropay/giropay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Giropay extends PaymentMethod
Expand Down
9 changes: 7 additions & 2 deletions api/paymentmethods/ideal/ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 IDeal extends PaymentMethod
{
Expand All @@ -32,11 +36,12 @@ public function __construct()
// @codingStandardsIgnoreStart
public function pay($customVars = [])
{
if($this->issuerIsRequired){
if ($this->issuerIsRequired) {
$this->payload['issuer'] = is_string($this->issuer) ? $this->issuer : '';
}else{
} else {
$this->payload['continueOnIncomplete'] = 1;
}

return parent::pay();
}
}
4 changes: 3 additions & 1 deletion api/paymentmethods/idin/idin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* @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 Idin extends PaymentMethod
{
public $issuer;
Expand Down
4 changes: 3 additions & 1 deletion api/paymentmethods/idin/idinresponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* @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;
}

use Buckaroo\PrestaShop\Src\Service\BuckarooIdinService;

require_once dirname(__FILE__) . '/../response.php';
require_once dirname(__FILE__) . '/../../../library/logger.php';

class IdinResponse extends Response
{
protected $buckarooIdinService;
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/in3/in3.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 In3 extends PaymentMethod
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/in3old/in3old.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 In3Old extends PaymentMethod
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/kbc/kbc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Kbc extends PaymentMethod
Expand Down
5 changes: 5 additions & 0 deletions api/paymentmethods/klarna/klarna.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Klarna extends PaymentMethod
Expand All @@ -28,6 +32,7 @@ public function getPayload($data)
{
return array_merge_recursive($this->payload, $data);
}

public function pay($customVars = [])
{
$this->payload = $this->getPayload($customVars);
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/mbway/mbway.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Mbway extends PaymentMethod
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/multibanco/multibanco.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Multibanco extends PaymentMethod
Expand Down
5 changes: 5 additions & 0 deletions api/paymentmethods/paybybank/paybybank.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* @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 PayByBank extends PaymentMethod
{
public $issuer;
Expand Down
4 changes: 4 additions & 0 deletions api/paymentmethods/payconiq/payconiq.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* @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 Payconiq extends PaymentMethod
Expand Down
44 changes: 25 additions & 19 deletions api/paymentmethods/paymentmethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
use Buckaroo\BuckarooClient;
use Buckaroo\PrestaShop\Classes\Config;

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

abstract class PaymentMethod extends BuckarooAbstract
{
protected $type;
Expand Down Expand Up @@ -80,19 +84,19 @@ public function payGlobal($customPayAction = null)
(!$customPayAction) ? $payAction = 'pay' : $payAction = $customPayAction;

$this->payload = array_merge([
'currency' => $this->currency,
'amountDebit' => $this->amountDebit,
'invoice' => $this->invoiceId,
'description' => $this->description,
'order' => $this->orderId,
'returnURL' => $this->returnUrl,
'pushURL' => $this->pushUrl,
'platformName' => $this->platformName,
'platformVersion' => $this->platformVersion,
'moduleVersion' => $this->moduleVersion,
'moduleSupplier' => $this->moduleSupplier,
'moduleName' => $this->moduleName,
],$this->payload);
'currency' => $this->currency,
'amountDebit' => $this->amountDebit,
'invoice' => $this->invoiceId,
'description' => $this->description,
'order' => $this->orderId,
'returnURL' => $this->returnUrl,
'pushURL' => $this->pushUrl,
'platformName' => $this->platformName,
'platformVersion' => $this->platformVersion,
'moduleVersion' => $this->moduleVersion,
'moduleSupplier' => $this->moduleSupplier,
'moduleName' => $this->moduleName,
], $this->payload);

$buckaroo = $this->getBuckarooClient(Config::getMode($this->type));
// Pay
Expand Down Expand Up @@ -164,17 +168,19 @@ public function verify($customVars = [])

return ResponseFactory::getResponse($response);
}
public function setDescription($cartId){

public function setDescription($cartId)
{
$description = (string) Configuration::get('BUCKAROO_TRANSACTION_LABEL');
preg_match_all('/{\w+}/',$description,$matches);
preg_match_all('/{\w+}/', $description, $matches);

if (!empty($matches[0])) {
$order = \Order::getByCartId($cartId);
$patterns = ['/{order_number}/','/{shop_name}/'];
$replacement = [$order->reference,\Context::getContext()->shop->name];
$patterns = ['/{order_number}/', '/{shop_name}/'];
$replacement = [$order->reference, \Context::getContext()->shop->name];

foreach ($matches[0] as $match){
if(!in_array("/$match/",$patterns)) {
foreach ($matches[0] as $match) {
if (!in_array("/$match/", $patterns)) {
$property = trim($match, '{}');
if (isset($order->$property)) {
$replacement[] = $order->$property;
Expand Down
3 changes: 3 additions & 0 deletions api/paymentmethods/paymentrequestfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
include_once dirname(__FILE__) . '/functions.php';

if (!defined('_PS_VERSION_')) {
exit;
}
class PaymentRequestFactory
{
public const REQUEST_TYPE_PAYPAL = 'paypal';
Expand Down
Loading

0 comments on commit 22abb61

Please sign in to comment.