Skip to content

Commit

Permalink
Release 2.0.32
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrowanwallee committed Jan 10, 2023
1 parent d51ae2b commit 05fc17d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 74 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ This repository contains the plentymarkets extension that enables to process pay

## Documentation

* [Documentation](https://plugin-documentation.wallee.com/wallee-payment/plentymarkets/2.0.31/docs/en/documentation.html)
* [Documentation](https://plugin-documentation.wallee.com/wallee-payment/plentymarkets/2.0.32/docs/en/documentation.html)

## License

Please see the [license file](https://github.com/wallee-payment/plentymarkets/blob/2.0.31/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/plentymarkets/blob/2.0.32/LICENSE) for more information.
2 changes: 1 addition & 1 deletion docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/plentymarkets/releases/tag/2.0.31/">
<a href="https://github.com/wallee-payment/plentymarkets/releases/tag/2.0.32/">
Source
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"namespace": "Wallee",
"type": "payment",
"version": "2.0.31",
"version": "2.0.32",
"license": " Apache License Version 2",
"isClosedSource": false,
"pluginIcon": "icon_plugin_md.png",
Expand Down
8 changes: 1 addition & 7 deletions resources/lib/getTransaction.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
<?php
use Wallee\Sdk\Service\TransactionService;
use Wallee\Sdk\ApiClient;

require_once __DIR__ . '/WalleeSdkHelper.php';

$gatewayBasePath = SdkRestApi::getParam('gatewayBasePath');
$userId = SdkRestApi::getParam('apiUserId');
$userKey = SdkRestApi::getParam('apiUserKey');

$client = new ApiClient($userId, $userKey);
$client->setBasePath($gatewayBasePath . '/api');
$client = WalleeSdkHelper::getApiClient(SdkRestApi::getParam('gatewayBasePath'), SdkRestApi::getParam('apiUserId'), SdkRestApi::getParam('apiUserKey'));

$spaceId = SdkRestApi::getParam('spaceId');

Expand Down
32 changes: 5 additions & 27 deletions src/Controllers/PaymentNotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,12 @@ public function updateTransaction()
'transactioninvoice',
'refund'
])) {
$this->processWebhook($webhookRequest);
}
return "OK";
}

protected function processWebhook($webhook)
{
$transactionId = $webhook->entityId;
try {
// this makes a call to whatever the listenerEntityTechnicalName is e.g. getTransaction
$transaction = $this->sdkService->call('get' . ucfirst($webhook->listenerEntityTechnicalName), [
'id' => $transactionId,
'spaceId' => $webhook->spaceId
$this->webhookRepository->registerWebhook([
'listenerEntityTechnicalName' => $webhookRequest->listenerEntityTechnicalName,
'entityId' => $webhookRequest->entityId,
'spaceId' => $webhookRequest->spaceId
]);

} catch (Exception $e) {
$this->getLogger(__METHOD__)->error('Error calling SDK service' . $e->getMessage());
}

if (empty($transaction)) {
$this->getLogger(__METHOD__)->error('The ' . $webhook->listenerEntityTechnicalName . ' was not found.', $transactionId);
return true;
}

if (is_array($transaction) && isset($transaction['error'])) {
throw new \Exception($transaction['error_msg']);
}

return $this->paymentHelper->updatePlentyPayment($transaction);
return "OK";
}
}
36 changes: 1 addition & 35 deletions src/Helper/WalleeServiceProviderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
use Plenty\Modules\Payment\Method\Contracts\PaymentMethodRepositoryContract;
use Plenty\Modules\Payment\Events\Checkout\GetPaymentMethodContent;
use Plenty\Modules\Payment\Events\Checkout\ExecutePayment;
use Plenty\Plugin\ConfigRepository;
use Plenty\Plugin\Events\Dispatcher;
use Wallee\Helper\PaymentHelper;
use Wallee\Services\PaymentService;
use Wallee\Services\WalleeSdkService;

class WalleeServiceProviderHelper
{
Expand Down Expand Up @@ -45,16 +43,6 @@ class WalleeServiceProviderHelper
*/
private $paymentMethodService;

/**
* @var $sdkService
*/
private $sdkService;

/**
*
* @var ConfigRepository
*/
private $config;

/**
* Construct the helper
Expand All @@ -65,27 +53,21 @@ class WalleeServiceProviderHelper
* @param OrderRepositoryContract $orderRepository
* @param PaymentService $paymentService
* @param PaymentMethodRepositoryContract $paymentMethodService
* @param WalleeSdkService $sdkService
* @param ConfigRepository $config
*/
public function __construct(
Dispatcher $eventDispatcher,
PaymentHelper $paymentHelper,
BasketRepositoryContract $basketRepository,
OrderRepositoryContract $orderRepository,
PaymentService $paymentService,
PaymentMethodRepositoryContract $paymentMethodService,
WalleeSdkService $sdkService,
ConfigRepository $config
PaymentMethodRepositoryContract $paymentMethodService
) {
$this->eventDispatcher = $eventDispatcher;
$this->paymentHelper = $paymentHelper;
$this->basketRepository = $basketRepository;
$this->orderRepository = $orderRepository;
$this->paymentService = $paymentService;
$this->paymentMethodService = $paymentMethodService;
$this->sdkService = $sdkService;
$this->config = $config;
}

/**
Expand Down Expand Up @@ -122,20 +104,4 @@ public function addExecutePaymentContentEventListener() {
}
});
}

/**
* Creates the webhook
* @return never
*/
public function createWebhook()
{
/** @var \Plenty\Modules\Helper\Services\WebstoreHelper $webstoreHelper */
$webstoreHelper = pluginApp(\Plenty\Modules\Helper\Services\WebstoreHelper::class);
/** @var \Plenty\Modules\System\Models\WebstoreConfiguration $webstoreConfig */
$webstoreConfig = $webstoreHelper->getCurrentWebstoreConfiguration();
$this->sdkService->call('createWebhook', [
'storeId' => $webstoreConfig->webstoreId,
'notificationUrl' => $webstoreConfig->domainSsl . '/wallee/update-transaction' . ($this->config->get('plenty.system.info.urlTrailingSlash', 0) == 2 ? '/' : '')
]);
}
}
1 change: 0 additions & 1 deletion src/Providers/WalleeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public function boot(

$walleeServiceProviderHelper->addPaymentMethodContentEventListener();
$walleeServiceProviderHelper->addExecutePaymentContentEventListener();
$walleeServiceProviderHelper->createWebhook();

$cronContainer->add(CronContainer::EVERY_FIFTEEN_MINUTES, WebhookCronHandler::class);
}
Expand Down
14 changes: 14 additions & 0 deletions src/Services/PaymentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public function __construct(WalleeSdkService $sdkService, ConfigRepository $conf
*/
public function getPaymentContent(Basket $basket, array $basketForTemplate, PaymentMethod $paymentMethod): array
{
$this->createWebhook();

$parameters = [
'transactionId' => $this->session->getPlugin()->getValue('walleeTransactionId'),
'basket' => $basket,
Expand Down Expand Up @@ -209,6 +211,18 @@ public function getPaymentContent(Basket $basket, array $basketForTemplate, Paym
];
}

private function createWebhook()
{
/** @var \Plenty\Modules\Helper\Services\WebstoreHelper $webstoreHelper */
$webstoreHelper = pluginApp(\Plenty\Modules\Helper\Services\WebstoreHelper::class);
/** @var \Plenty\Modules\System\Models\WebstoreConfiguration $webstoreConfig */
$webstoreConfig = $webstoreHelper->getCurrentWebstoreConfiguration();
$this->sdkService->call('createWebhook', [
'storeId' => $webstoreConfig->webstoreId,
'notificationUrl' => $webstoreConfig->domainSsl . '/wallee/update-transaction' . ($this->config->get('plenty.system.info.urlTrailingSlash', 0) == 2 ? '/' : '')
]);
}

/**
* Creates the payment in plentymarkets.
*
Expand Down

0 comments on commit 05fc17d

Please sign in to comment.