Skip to content

Commit

Permalink
Merge pull request #8 from itk-dev/feature/only-generate-payment-job-…
Browse files Browse the repository at this point in the history
…if-payment-element-exists

Added payment element check
  • Loading branch information
jekuaitk authored Dec 6, 2024
2 parents 0a880a4 + aac53a6 commit 6d1d9d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added payment element check in implementation of hook_webform_submission_insert.

## [1.0.0] - 2024-12-06

### Updated
Expand Down
14 changes: 13 additions & 1 deletion src/Helper/PaymentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ public function __construct(
* Return
*/
public function webformSubmissionPresave(WebFormSubmissionInterface $submission): void {

// Only modify submission if payment element exists.
['paymentElement' => $paymentElement, 'paymentElementMachineName' => $paymentElementMachineName] = $this->getWebformElementNames($submission);
$submissionData = $submission->getData();

if (!isset($paymentElement) && !isset($paymentElementMachineName)) {
return;
}

$submissionData = $submission->getData();

/*
* The paymentReferenceField is not a part of the form submission,
* so we get it from the POST payload.
Expand Down Expand Up @@ -182,6 +186,14 @@ private function getWebformElementNames(WebformSubmissionInterface $submission):
* Throws exception.
*/
public function webformSubmissionInsert(WebFormSubmissionInterface $submission): void {

// Only modify submission if payment element exists.
['paymentElement' => $paymentElement, 'paymentElementMachineName' => $paymentElementMachineName] = $this->getWebformElementNames($submission);

if (!isset($paymentElement) && !isset($paymentElementMachineName)) {
return;
}

$logger_context = [
'handler_id' => 'os2forms_payment',
'channel' => 'webform_submission',
Expand Down

0 comments on commit 6d1d9d8

Please sign in to comment.