diff --git a/payfast/commerce_payfast.info.yml b/payfast/commerce_payfast.info.yml index 876bedd..60e0c28 100644 --- a/payfast/commerce_payfast.info.yml +++ b/payfast/commerce_payfast.info.yml @@ -8,5 +8,5 @@ dependencies: # Information added by Drupal.org packaging script version: '1.5.0' -core_version_requirement: ^9.3 || ^10 +core_version_requirement: ^9.3 || ^10 || ^11 project: 'commerce_payfast' diff --git a/payfast/commerce_payfast.services.yml b/payfast/commerce_payfast.services.yml index f4e0e09..ad189dd 100644 --- a/payfast/commerce_payfast.services.yml +++ b/payfast/commerce_payfast.services.yml @@ -1,4 +1 @@ -services: - your_module.site_url_service: - class: 'Drupal\commerce_payfast\SiteUrlService' - arguments: [ '@request_stack' ] +services: {} diff --git a/payfast/src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php b/payfast/src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php index d485bf3..7bbf773 100644 --- a/payfast/src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php +++ b/payfast/src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php @@ -12,6 +12,8 @@ use Drupal\commerce_payment\PaymentStorage; use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OffsitePaymentGatewayBase; use Drupal\commerce_price\Price; +use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; +use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Form\FormStateInterface; use Payfast\PayfastCommon\Aggregator\Request\PaymentRequest; @@ -131,20 +133,25 @@ protected function getRequestDataArray(string $request_content): array protected function loadPaymentByRemoteId($remote_id): mixed { $message = '@message'; + $storage = NULL; + /** @var PaymentStorage $storage */ try { $storage = $this->entityTypeManager->getStorage('commerce_payment'); - } catch (Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException $e) { - Drupal::logger('your_module')->error( + } catch (InvalidPluginDefinitionException $e) { + Drupal::logger('commerce_payfast')->error( 'Invalid plugin definition exception: @message', [$message => $e->getMessage()] ); - } catch (Drupal\Component\Plugin\Exception\PluginNotFoundException $e) { - Drupal::logger('your_module')->error( + return FALSE; + } catch (PluginNotFoundException $e) { + Drupal::logger('commerce_payfast')->error( 'Plugin not found exception: @message', [$message => $e->getMessage()] ); + return FALSE; } + $payment_by_remote_id = $storage->loadByProperties(['order_id' => $remote_id]); return reset($payment_by_remote_id); @@ -273,7 +280,7 @@ public function processOrder($pfError, $pfData, $pfErrMsg): void // Mark order as completed in state storage \Drupal::state()->set('payfast_order_notified_' . $order_id, true); } catch (EntityStorageException $e) { - Drupal::logger('your_module')->error( + Drupal::logger('commerce_payfast')->error( 'Entity storage exception: @message', [$message => $e->getMessage()] ); diff --git a/payfast/src/PluginForm/OffsiteRedirect/PaymentOffsiteForm.php b/payfast/src/PluginForm/OffsiteRedirect/PaymentOffsiteForm.php index 31c6958..b26e99a 100644 --- a/payfast/src/PluginForm/OffsiteRedirect/PaymentOffsiteForm.php +++ b/payfast/src/PluginForm/OffsiteRedirect/PaymentOffsiteForm.php @@ -53,7 +53,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta try { $payment->save(); } catch (EntityStorageException $e) { - Drupal::logger('your_module')->error( + Drupal::logger('commerce_payfast')->error( 'Entity storage exception: @message', ['@message' => $e->getMessage()] ); @@ -115,7 +115,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $redirect_form = []; $redirect_form = $this->buildRedirectForm($form, $form_state, $url, $data, 'post'); } catch (NeedsRedirectException $e) { - Drupal::logger('your_module')->error( + Drupal::logger('commerce_payfast')->error( 'Needs redirect exception: @message', ['@message' => $e->getMessage()] );