From b68c366eb616c60366baa5b3e755021dd61129ef Mon Sep 17 00:00:00 2001 From: Roel van Hintum Date: Mon, 9 May 2022 11:50:31 +0200 Subject: [PATCH] Added craft 4 support --- CHANGELOG.md | 4 ++++ src/base/Gateway.php | 12 ++++++------ src/gateways/CreditCardGateway.php | 8 ++++---- src/gateways/IdealGateway.php | 8 ++++---- src/gateways/PayPalGateway.php | 2 +- src/gateways/SepaDirectDebitGateway.php | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9307d2..c9f38e8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release notes for Buckaroo Gateway for Craft Commerce +## 2.0.0-beta.1 - 2022-05-09 +### Changed +- Added craft 4 support + ## 1.3.0 - 2022-03-10 ### Change - Update ideal issuers diff --git a/src/base/Gateway.php b/src/base/Gateway.php index 42726ef..889e1fb 100755 --- a/src/base/Gateway.php +++ b/src/base/Gateway.php @@ -9,7 +9,7 @@ use craft\commerce\omnipay\base\OffsiteGateway; use Omnipay\Common\AbstractGateway; -use Omnipay\Buckaroo\Gateway as OmnipayGateway; +use Omnipay\Buckaroo\BuckarooGateway as OmnipayBuckarooGateway; abstract class Gateway extends OffsiteGateway { @@ -37,7 +37,7 @@ abstract class Gateway extends OffsiteGateway /** * @inheritdoc */ - public function getSettingsHtml() + public function getSettingsHtml(): ?string { return Craft::$app->getView()->renderTemplate('commerce-buckaroo/gatewaySettings', ['gateway' => $this]); } @@ -45,7 +45,7 @@ public function getSettingsHtml() /** * @inheritdoc */ - public function populateRequest(array &$request, BasePaymentForm $paymentForm = null) + public function populateRequest(array &$request, BasePaymentForm $paymentForm = null): void { $request['culture'] = Craft::$app->language; } @@ -71,9 +71,9 @@ public function getPaymentTypeOptions(): array /** * @inheritdoc */ - public function rules() + public function defineRules(): array { - $rules = parent::rules(); + $rules = parent::defineRules(); $rules[] = ['paymentType', 'compare', 'compareValue' => 'purchase']; return $rules; @@ -87,7 +87,7 @@ public function rules() */ protected function createGateway(): AbstractGateway { - /** @var OmnipayGateway $gateway */ + /** @var OmnipayBuckarooGateway $gateway */ $gateway = static::createOmnipayGateway($this->getGatewayClassName()); $settings = BuckarooPlugin::$plugin->getSettings(); diff --git a/src/gateways/CreditCardGateway.php b/src/gateways/CreditCardGateway.php index 678c095..9788dee 100644 --- a/src/gateways/CreditCardGateway.php +++ b/src/gateways/CreditCardGateway.php @@ -52,7 +52,7 @@ public function getPaymentFormModel(): BasePaymentForm /** * @inheritdoc */ - public function getPaymentFormHtml(array $params) + public function getPaymentFormHtml(array $params): null|string { try { $defaults = [ @@ -81,7 +81,7 @@ public function getPaymentFormHtml(array $params) /** * @inheritdoc */ - public function populateRequest(array &$request, BasePaymentForm $paymentForm = null) + public function populateRequest(array &$request, BasePaymentForm $paymentForm = null): void { parent::populateRequest($request, $paymentForm); @@ -96,7 +96,7 @@ public function populateRequest(array &$request, BasePaymentForm $paymentForm = /** * @return mixed */ - public function fetchPaymentMethods() + public function fetchPaymentMethods(): array { // Source: https://dev.buckaroo.nl/PaymentMethods/Description/creditcards return [ @@ -122,7 +122,7 @@ public function fetchPaymentMethods() /** * @inheritdoc */ - protected function getGatewayClassName() + protected function getGatewayClassName(): null|string { return '\\' . OmniPayCreditCardGateway::class; } diff --git a/src/gateways/IdealGateway.php b/src/gateways/IdealGateway.php index 374886d..4b53e78 100644 --- a/src/gateways/IdealGateway.php +++ b/src/gateways/IdealGateway.php @@ -52,7 +52,7 @@ public function getPaymentFormModel(): BasePaymentForm /** * @inheritdoc */ - public function getPaymentFormHtml(array $params) + public function getPaymentFormHtml(array $params): null|string { try { $defaults = [ @@ -81,7 +81,7 @@ public function getPaymentFormHtml(array $params) /** * @inheritdoc */ - public function populateRequest(array &$request, BasePaymentForm $paymentForm = null) + public function populateRequest(array &$request, BasePaymentForm $paymentForm = null): void { parent::populateRequest($request, $paymentForm); @@ -96,7 +96,7 @@ public function populateRequest(array &$request, BasePaymentForm $paymentForm = /** * @return mixed */ - public function fetchIssuers() + public function fetchIssuers(): array { // Source: https://dev.buckaroo.nl/PaymentMethods/Description/ideal return [ @@ -121,7 +121,7 @@ public function fetchIssuers() /** * @inheritdoc */ - protected function getGatewayClassName() + protected function getGatewayClassName(): null|string { return '\\' . OmniPayIdealGateway::class; } diff --git a/src/gateways/PayPalGateway.php b/src/gateways/PayPalGateway.php index da1d09d..436e0c8 100644 --- a/src/gateways/PayPalGateway.php +++ b/src/gateways/PayPalGateway.php @@ -44,7 +44,7 @@ public static function displayName(): string /** * @inheritdoc */ - protected function getGatewayClassName() + protected function getGatewayClassName(): null|string { return '\\' . OmniPayPayPalGateway::class; } diff --git a/src/gateways/SepaDirectDebitGateway.php b/src/gateways/SepaDirectDebitGateway.php index cdbfbac..7ec75e7 100644 --- a/src/gateways/SepaDirectDebitGateway.php +++ b/src/gateways/SepaDirectDebitGateway.php @@ -44,7 +44,7 @@ public static function displayName(): string /** * @inheritdoc */ - protected function getGatewayClassName() + protected function getGatewayClassName(): null|string { return '\\' . OmniPaySepaDirectDebitGateway::class; }