Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #33 from heidelpay/refactor/review-plenty
Browse files Browse the repository at this point in the history
Refactor/review plenty
  • Loading branch information
xBlack-Shadow authored Jul 8, 2020
2 parents bfdc32a + 1ab6823 commit 63eb8ea
Show file tree
Hide file tree
Showing 23 changed files with 329 additions and 40 deletions.
7 changes: 2 additions & 5 deletions src/Controllers/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class TestController extends Controller
{
use Loggable;

public function __construct()
{
}

/**
* Reset model
*
Expand Down Expand Up @@ -98,6 +94,7 @@ public function show(Request $request, Response $response): BaseResponse
{
$model = $request->get('model');

return $response->json(pluginApp(DataBase::class)->query(PluginConfiguration::PLUGIN_NAME.'\\Models\\'.$model)->get());
return $response->json(pluginApp(DataBase::class)
->query(PluginConfiguration::PLUGIN_NAME.'\\Models\\'.$model)->get());
}
}
88 changes: 78 additions & 10 deletions src/Methods/BasePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace HeidelpayMGW\Methods;

use Plenty\Plugin\Application;
use HeidelpayMGW\Configuration\PluginConfiguration;
use HeidelpayMGW\Services\BasketService;
use Plenty\Modules\Payment\Method\Services\PaymentMethodBaseService;
use Plenty\Plugin\Application;
use Plenty\Plugin\Translation\Translator;
use HeidelpayMGW\Configuration\PluginConfiguration;
use Plenty\Modules\Payment\Method\Contracts\PaymentMethodService;

/**
* Base payment method class
Expand All @@ -31,7 +31,7 @@
*
* @package heidelpayMGW/methods
*/
class BasePaymentMethod extends PaymentMethodService
class BasePaymentMethod extends PaymentMethodBaseService
{
const AVAILABLE_COUNTRIES = [];

Expand Down Expand Up @@ -84,9 +84,10 @@ public function isActive(): bool
/**
* Get the name of the payment method
*
* @param string $lang
* @return string Payment method's name in checkout or PDF document
*/
public function getName(): string
public function getName(string $lang = ""): string
{
return $this->settings->displayName;
}
Expand All @@ -96,32 +97,35 @@ public function getName(): string
*
* @return float
*/
public function getFee()
public function getFee(): float
{
return 0.00;
}

/**
* Get the path of the icon
*
* @param string $lang
* @return string Icon path to display in checkout
*/
public function getIcon(): string
public function getIcon(string $lang = ""): string
{
$app = pluginApp(Application::class);

return $this->settings->iconURL ?: $app->getUrlPath(PluginConfiguration::PLUGIN_NAME) . '/images/default_payment_icon.png';
return $this->settings->iconURL ?: $app->getUrlPath(PluginConfiguration::PLUGIN_NAME) .
'/images/default_payment_icon.png';
}

/**
* Get the description of the payment method
* Child class should implement it's own method
*
* @param string $lang
* @return string
*/
public function getDescription(): string
public function getDescription(string $lang = ""): string
{
return'';
return '';
}

/**
Expand All @@ -138,4 +142,68 @@ private function isCountryRestricted(): bool

return true;
}

/**
* @inheritDoc
*/
public function getSourceUrl(string $lang = ""): string
{
return '';
}

/**
* @inheritDoc
*/
public function isSwitchableTo(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function isSwitchableFrom(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function isBackendSearchable(): bool
{
return true;
}

/**
* @inheritDoc
*/
public function isBackendActive(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function getBackendName(string $lang = ""): string
{
return '';
}

/**
* @inheritDoc
*/
public function canHandleSubscriptions(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function getBackendIcon(): string
{
return '';
}
}
9 changes: 9 additions & 0 deletions src/Methods/CardsPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ public function isActive(): bool
{
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW Cards';
}
}
9 changes: 9 additions & 0 deletions src/Methods/FlexiPayDirectPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ public function isActive(): bool
{
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW FlexiPay Direct';
}
}
9 changes: 9 additions & 0 deletions src/Methods/IdealPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public function isActive(): bool
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW iDEAL';
}

/**
* Check if country of the address is in available countries list
*
Expand Down
9 changes: 9 additions & 0 deletions src/Methods/InvoiceGuaranteedPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ public function isActive(): bool

return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW Invoice Guaranteed';
}
}
9 changes: 9 additions & 0 deletions src/Methods/InvoiceGuaranteedPaymentMethodB2b.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ public function isActive(): bool

return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW Invoice Guaranteed B2B';
}
}
10 changes: 10 additions & 0 deletions src/Methods/InvoicePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@ public function isActive(): bool

return parent::isActive();
}


/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW Invoice';
}
}
9 changes: 9 additions & 0 deletions src/Methods/PaypalPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ public function isActive(): bool
{
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW PayPal';
}
}
9 changes: 9 additions & 0 deletions src/Methods/SepaDirectDebitGuaranteedPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ public function isActive(): bool
{
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW SEPA Direct Debit Guaranteed';
}
}
9 changes: 9 additions & 0 deletions src/Methods/SepaDirectDebitPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ public function isActive(): bool
{
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW SEPA Direct Debit';
}
}
9 changes: 9 additions & 0 deletions src/Methods/SofortPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@ public function isActive(): bool
{
return parent::isActive();
}

/**
* @param string $lang
* @return string
*/
public function getBackendName(string $lang = ""): string
{
return 'Heidelpay MGW SOFORT';
}
}
16 changes: 16 additions & 0 deletions src/Migrations/CreateCardsSettingTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace HeidelpayMGW\Migrations;

use HeidelpayMGW\Configuration\PluginConfiguration;
use HeidelpayMGW\Helpers\Loggable;
use HeidelpayMGW\Helpers\PaymentHelper;
use HeidelpayMGW\Models\CardsSetting;
use Plenty\Modules\Plugin\DataBase\Contracts\Migrate;

Expand Down Expand Up @@ -30,6 +33,18 @@
*/
class CreateCardsSettingTable extends BasePluginMigration
{
use Loggable;

/**
* @var PaymentHelper
*/
private $paymentHelper;

public function __construct(PaymentHelper $paymentHelper)
{
$this->paymentHelper = $paymentHelper;
}

/**
* Create CardsSetting model's table
*
Expand All @@ -40,5 +55,6 @@ class CreateCardsSettingTable extends BasePluginMigration
public function run(Migrate $migrate)
{
$this->createTable($migrate, CardsSetting::class);
$this->paymentHelper->createMopIfNotExists(PluginConfiguration::PAYMENT_KEY_CARDS);
}
}
16 changes: 16 additions & 0 deletions src/Migrations/CreateFlexiPayDirectSettingTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace HeidelpayMGW\Migrations;

use HeidelpayMGW\Configuration\PluginConfiguration;
use HeidelpayMGW\Helpers\Loggable;
use HeidelpayMGW\Helpers\PaymentHelper;
use HeidelpayMGW\Models\FlexiPayDirectSetting;
use Plenty\Modules\Plugin\DataBase\Contracts\Migrate;

Expand Down Expand Up @@ -30,6 +33,18 @@
*/
class CreateFlexiPayDirectSettingTable extends BasePluginMigration
{
use Loggable;

/**
* @var PaymentHelper
*/
private $paymentHelper;

public function __construct(PaymentHelper $paymentHelper)
{
$this->paymentHelper = $paymentHelper;
}

/**
* Create FlexiPayDirectSetting model's table
*
Expand All @@ -40,5 +55,6 @@ class CreateFlexiPayDirectSettingTable extends BasePluginMigration
public function run(Migrate $migrate)
{
$this->createTable($migrate, FlexiPayDirectSetting::class);
$this->paymentHelper->createMopIfNotExists(PluginConfiguration::PAYMENT_KEY_FLEXIPAY_DIRECT);
}
}
Loading

0 comments on commit 63eb8ea

Please sign in to comment.