Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions os2forms_payment.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ package: OS2Forms
core_version_requirement: ^9 || ^10
dependencies:
- webform:webform
- advancedqueue:advancedqueue

configure: os2forms_payment.admin.settings
4 changes: 2 additions & 2 deletions src/Element/NetsEasyPaymentElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
12 changes: 6 additions & 6 deletions src/Helper/PaymentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<mixed>|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 {
Expand Down Expand Up @@ -153,7 +153,7 @@ private function findPaymentElementKey(WebformSubmissionInterface $submission):
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
*
* @return array
* @return array<string, mixed>
* An array containing the payment element and its machine name.
*/
private function getWebformElementNames(WebformSubmissionInterface $submission): array {
Expand Down Expand Up @@ -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, [
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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<mixed> $params
* Optional. An associative array of parameters
* to be sent in the request body.
*
Expand Down
38 changes: 30 additions & 8 deletions src/Plugin/AdvancedQueue/JobType/NetsEasyPaymentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ final class NetsEasyPaymentHandler extends JobTypeBase implements ContainerFacto

/**
* {@inheritdoc}
*
* @param array<mixed> $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,
Expand All @@ -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<mixed> $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(
Expand All @@ -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 = [
Expand Down Expand Up @@ -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<mixed> $logger_context
* Context for logging.
*
* @throws \Drupal\os2forms_payment\Exception\RuntimeException
Expand Down Expand Up @@ -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<mixed> $logger_context
* Context for logging.
*
* @throws \Drupal\os2forms_payment\Exception\RuntimeException
Expand Down Expand Up @@ -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<mixed> $logger_context
* Context for logging.
*
* @throws \Exception
Expand Down Expand Up @@ -259,7 +281,7 @@ private function chargePayment(Job $job, WebformSubmissionInterface $webformSubm
/**
* Validates the reservation and charge amounts.
*
* @param array $payload
* @param array<mixed> $payload
* The payload data containing reserved and charged amounts.
*
* @throws \Exception
Expand Down
Loading