Skip to content
Open
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: 1 addition & 1 deletion payfast/commerce_payfast.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
5 changes: 1 addition & 4 deletions payfast/commerce_payfast.services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
services:
your_module.site_url_service:
class: 'Drupal\commerce_payfast\SiteUrlService'
arguments: [ '@request_stack' ]
services: {}
17 changes: 12 additions & 5 deletions payfast/src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()]
);
Expand Down
4 changes: 2 additions & 2 deletions payfast/src/PluginForm/OffsiteRedirect/PaymentOffsiteForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
);
Expand Down Expand Up @@ -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()]
);
Expand Down