From 3774b0321b838a575f1112abc5457e616c9607d6 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Fri, 7 Feb 2025 14:32:14 +0100 Subject: [PATCH 1/3] 3782: Update terms_and_conditions_url settings key --- CHANGELOG.md | 2 ++ src/Helper/PaymentHelper.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d59609c..ae573e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Update `terms_and_conditions_url` settings key. + ## [1.1.0] - 2024-12-17 ### Added diff --git a/src/Helper/PaymentHelper.php b/src/Helper/PaymentHelper.php index 73d8468..b50c754 100644 --- a/src/Helper/PaymentHelper.php +++ b/src/Helper/PaymentHelper.php @@ -325,7 +325,7 @@ public function getSecretKey(): ?string { * The terms and conditions url. */ public function getTermsUrl(): ?string { - return $this->getPaymentSettings()['terms_url'] ?? NULL; + return $this->getPaymentSettings()['terms_and_conditions_url'] ?? NULL; } /** From 06ce6ee7a9ba063dde13c523b8a24eeaccf82cf4 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Fri, 7 Feb 2025 14:40:15 +0100 Subject: [PATCH 2/3] 3782: Added advancedqueue dependency --- composer.json | 1 + os2forms_payment.info.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/composer.json b/composer.json index 26c442a..1d347b0 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ ], "require": { "php": "^8.1", + "drupal/advancedqueue": "^1.0", "drupal/webform": "^6.1", "drush/drush": "^11 || ^12", "symfony/options-resolver": "^5.4 || ^6.0" diff --git a/os2forms_payment.info.yml b/os2forms_payment.info.yml index d043ceb..d245414 100644 --- a/os2forms_payment.info.yml +++ b/os2forms_payment.info.yml @@ -5,5 +5,6 @@ package: OS2Forms core_version_requirement: ^9 || ^10 dependencies: - webform:webform + - advancedqueue:advancedqueue configure: os2forms_payment.admin.settings From 0ef787bfaa367f457c6d9af4de98d9cbdee2baa7 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Fri, 7 Feb 2025 15:03:32 +0100 Subject: [PATCH 3/3] 3782: Clean up --- src/Element/NetsEasyPaymentElement.php | 4 +- src/Helper/PaymentHelper.php | 10 ++--- .../JobType/NetsEasyPaymentHandler.php | 38 +++++++++++++++---- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/Element/NetsEasyPaymentElement.php b/src/Element/NetsEasyPaymentElement.php index 036d7bc..4b411e9 100644 --- a/src/Element/NetsEasyPaymentElement.php +++ b/src/Element/NetsEasyPaymentElement.php @@ -2,14 +2,14 @@ namespace Drupal\os2forms_payment\Element; -use Drupal\Core\Render\Element\FormElement; +use Drupal\Core\Render\Element\FormElementBase; /** * Provides an OS2forms payment element'. * * @FormElement("os2forms_payment_nets_easy_payment") */ -class NetsEasyPaymentElement extends FormElement { +class NetsEasyPaymentElement extends FormElementBase { /** * {@inheritdoc} diff --git a/src/Helper/PaymentHelper.php b/src/Helper/PaymentHelper.php index b50c754..7e94727 100644 --- a/src/Helper/PaymentHelper.php +++ b/src/Helper/PaymentHelper.php @@ -106,7 +106,7 @@ public function webformSubmissionPresave(WebFormSubmissionInterface $submission) * The key of the payment object to update. * @param mixed|null $value * The value to set for the payment object key. - * @param array|null $paymentObject + * @param array|null $paymentObject * The payment object to replace the existing with. */ public function updateWebformSubmissionPaymentObject(WebformSubmissionInterface $webformSubmission, ?string $key = NULL, mixed $value = NULL, ?array $paymentObject = NULL): WebformSubmissionInterface { @@ -153,7 +153,7 @@ private function findPaymentElementKey(WebformSubmissionInterface $submission): * @param \Drupal\webform\WebformSubmissionInterface $submission * The webform submission. * - * @return array + * @return array * An array containing the payment element and its machine name. */ private function getWebformElementNames(WebformSubmissionInterface $submission): array { @@ -208,9 +208,9 @@ public function webformSubmissionInsert(WebFormSubmissionInterface $submission): $request = $this->requestStack->getCurrentRequest(); $paymentId = $request->request->get('os2forms_payment_reference_field'); - /** @var \Drupal\advancedqueue\Entity\Queue $queue */ + /** @var \Drupal\advancedqueue\Entity\Queue|NULL $queue */ $queue = $this->getQueue(); - if (!$queue) { + if (is_null($queue)) { throw new Exception(sprintf('Queue with ID %s does not exist.', $this->queueId)); } $job = Job::create(NetsEasyPaymentHandler::class, [ @@ -450,7 +450,7 @@ public function getAmountToPayTemp(): float { * The HTTP method for the request. * @param string $endpoint * The endpoint URL. - * @param array $params + * @param array $params * Optional. An associative array of parameters * to be sent in the request body. * diff --git a/src/Plugin/AdvancedQueue/JobType/NetsEasyPaymentHandler.php b/src/Plugin/AdvancedQueue/JobType/NetsEasyPaymentHandler.php index 4366530..3a679c3 100644 --- a/src/Plugin/AdvancedQueue/JobType/NetsEasyPaymentHandler.php +++ b/src/Plugin/AdvancedQueue/JobType/NetsEasyPaymentHandler.php @@ -27,6 +27,19 @@ final class NetsEasyPaymentHandler extends JobTypeBase implements ContainerFacto /** * {@inheritdoc} + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin ID for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Logger\LoggerChannel $logger + * The logger. + * @param \GuzzleHttp\Client $httpClient + * The client. + * @param \Drupal\os2forms_payment\Helper\PaymentHelper $paymentHelper + * The payment helper. */ public function __construct( array $configuration, @@ -41,6 +54,15 @@ public function __construct( /** * {@inheritdoc} + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container to pull out services used in the plugin. + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin ID for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new NetsEasyPaymentHandler( @@ -67,7 +89,7 @@ public function process(Job $job): JobResult { $payload = $job->getPayload(); $stage = $payload['processing_stage'] ?? 0; - /** @var \Drupal\webform\Entity\WebformSubmissionInterface $webformSubmission */ + /** @var \Drupal\webform\WebformSubmissionInterface $webformSubmission */ $webformSubmission = WebformSubmission::load($payload['submissionId']); $logger_context = [ @@ -107,9 +129,9 @@ public function process(Job $job): JobResult { * * @param \Drupal\advancedqueue\Job $job * The job object containing payload information. - * @param \Drupal\webform\Entity\WebformSubmissionInterface $webformSubmission + * @param \Drupal\webform\WebformSubmissionInterface $webformSubmission * The webform submission related to the payment. - * @param array $logger_context + * @param array $logger_context * Context for logging. * * @throws \Drupal\os2forms_payment\Exception\RuntimeException @@ -161,9 +183,9 @@ private function getPaymentAndSetRelevantValues(Job $job, WebformSubmissionInter * * @param \Drupal\advancedqueue\Job $job * The job object containing payload information. - * @param \Drupal\webform\Entity\WebformSubmissionInterface $webformSubmission + * @param \Drupal\webform\WebformSubmissionInterface $webformSubmission * The webform submission related to the payment. - * @param array $logger_context + * @param array $logger_context * Context for logging. * * @throws \Drupal\os2forms_payment\Exception\RuntimeException @@ -199,9 +221,9 @@ private function updatePaymentReference(Job $job, WebformSubmissionInterface $we * * @param \Drupal\advancedqueue\Job $job * The job object containing payload information. - * @param \Drupal\webform\Entity\WebformSubmissionInterface $webformSubmission + * @param \Drupal\webform\WebformSubmissionInterface $webformSubmission * The webform submission related to the payment. - * @param array $logger_context + * @param array $logger_context * Context for logging. * * @throws \Exception @@ -259,7 +281,7 @@ private function chargePayment(Job $job, WebformSubmissionInterface $webformSubm /** * Validates the reservation and charge amounts. * - * @param array $payload + * @param array $payload * The payload data containing reserved and charged amounts. * * @throws \Exception