Skip to content

Commit

Permalink
Release 1.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
vttn committed Jul 6, 2020
1 parent db7a20e commit 2270f20
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 1.1.9
- Put try catch on webhook install

# 1.1.8
- Remove unhelpful tickets info in release comments

# 1.1.7
- [WAL-8566] Promotions
- Implement promotions
- Code refactoring

# 1.1.6
Expand All @@ -10,12 +16,12 @@
- Fix settings bug

# 1.1.4
- [WAL-8526] Disable changing credentials on the showcases
- Disable changing credentials on the showcases

# 1.1.3
- [WAL-8526] Make line item consistency default
- [WAL-8526] Confirm transaction right away
- [WAL-8526] Update settings descriptions
- Make line item consistency default
- Confirm transaction right away
- Update settings descriptions

# 1.1.2
- Prepare internal server side install for showcases and demos
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
"wallee/sdk": "2.1.*"
},
"type": "shopware-platform-plugin",
"version": "1.1.7"
"version": "1.1.9"
}
63 changes: 32 additions & 31 deletions src/Core/Api/WebHooks/Service/WebHooksService.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,38 +243,39 @@ public function setSalesChannelId(?string $salesChannelId = null): WebHooksServi
* Install Listeners
*
* @return array
* @throws \Wallee\Sdk\ApiException
* @throws \Wallee\Sdk\Http\ConnectionException
* @throws \Wallee\Sdk\VersioningException
*/
protected function installListeners(): array
{
$webHookUrlId = $this->getOrCreateWebHookUrl()->getId();
$installedWebHooks = $this->getInstalledWebHookListeners($webHookUrlId);
$webHookEntityIds = array_map(function (WebhookListener $webHook) {
return $webHook->getEntity();
}, $installedWebHooks);
$returnValue = [];

/**
* @var $data Entity
*/
foreach ($this->webHookEntitiesConfig as $data) {

if (in_array($data->getId(), $webHookEntityIds)) {
continue;
$returnValue = [];
try {
$webHookUrlId = $this->getOrCreateWebHookUrl()->getId();
$installedWebHooks = $this->getInstalledWebHookListeners($webHookUrlId);
$webHookEntityIds = array_map(function (WebhookListener $webHook) {
return $webHook->getEntity();
}, $installedWebHooks);


/**
* @var \WalleePayment\Core\Api\WebHooks\Struct\Entity $data
*/
foreach ($this->webHookEntitiesConfig as $data) {

if (in_array($data->getId(), $webHookEntityIds)) {
continue;
}

$entity = (new WebhookListenerCreate())
->setName($data->getName())
->setEntity($data->getId())
->setNotifyEveryChange($data->isNotifyEveryChange())
->setState(CreationEntityState::CREATE)
->setEntityStates($data->getStates())
->setUrl($webHookUrlId);

$returnValue[] = $this->apiClient->getWebhookListenerService()->create($this->spaceId, $entity);
}

/** @noinspection PhpParamsInspection */
$entity = (new WebhookListenerCreate())
->setName($data->getName())
->setEntity($data->getId())
->setNotifyEveryChange($data->isNotifyEveryChange())
->setState(CreationEntityState::CREATE)
->setEntityStates($data->getStates())
->setUrl($webHookUrlId);

$returnValue[] = $this->apiClient->getWebhookListenerService()->create($this->spaceId, $entity);
} catch (\Exception $exception) {
$this->logger->critical($exception->getTraceAsString());
}

return $returnValue;
Expand All @@ -290,13 +291,13 @@ protected function installListeners(): array
*/
protected function getOrCreateWebHookUrl(): WebhookUrl
{

$url = $this->getWebHookCallBackUrl();
/** @noinspection PhpParamsInspection */
$entityQueryFilter = (new EntityQueryFilter())
->setType(EntityQueryFilterType::_AND)
->setChildren([
$this->getEntityFilter('state', CreationEntityState::ACTIVE),
$this->getEntityFilter('url', $this->getWebHookCallBackUrl()),
$this->getEntityFilter('url', $url),
]);

$query = (new EntityQuery())->setFilter($entityQueryFilter)->setNumberOfEntities(1);
Expand All @@ -310,7 +311,7 @@ protected function getOrCreateWebHookUrl(): WebhookUrl
/** @noinspection PhpParamsInspection */
$entity = (new WebhookUrlCreate())
->setName('Shopware6::WebHookURL')
->setUrl($this->getWebHookCallBackUrl())
->setUrl($url)
->setState(CreationEntityState::ACTIVE);

return $this->apiClient->getWebhookUrlService()->create($this->spaceId, $entity);
Expand Down

0 comments on commit 2270f20

Please sign in to comment.