Skip to content

Commit

Permalink
Release 1.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
vttn committed Jul 9, 2020
1 parent 2270f20 commit 2c74e0e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.1.10
- Stop responding with server errors when orders are not found

# 1.1.9
- Put try catch on webhook install

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.9"
"version": "1.1.10"
}
18 changes: 10 additions & 8 deletions src/Core/Api/Transaction/Service/TransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function upsert(
];

$data = array_filter($data);
$this->container->get(TransactionEntityDefinition::ENTITY_NAME .'.repository')->upsert([$data], $context);
$this->container->get(TransactionEntityDefinition::ENTITY_NAME . '.repository')->upsert([$data], $context);

} catch (\Exception $exception) {
$this->logger->critical(__CLASS__ . ' : ' . __FUNCTION__ . ' : ' . $exception->getMessage());
Expand Down Expand Up @@ -244,14 +244,16 @@ private function holdDelivery(string $orderId, Context $context)
*/
private function getOrderEntity(string $orderId, Context $context): OrderEntity
{

$criteria = (new Criteria([$orderId]))->addAssociations(['deliveries']);

try {
return $this->container->get('order.repository')->search(
$criteria = (new Criteria([$orderId]))->addAssociations(['deliveries']);
$order = $this->container->get('order.repository')->search(
$criteria,
$context
)->first();
if (is_null($order)) {
throw new OrderNotFoundException($orderId);
}
return $order;
} catch (\Exception $e) {
throw new OrderNotFoundException($orderId);
}
Expand All @@ -267,7 +269,7 @@ private function getOrderEntity(string $orderId, Context $context): OrderEntity
*/
public function getByOrderId(string $orderId, Context $context): TransactionEntity
{
return $this->container->get(TransactionEntityDefinition::ENTITY_NAME .'.repository')
return $this->container->get(TransactionEntityDefinition::ENTITY_NAME . '.repository')
->search(new Criteria([$orderId]), $context)
->get($orderId);
}
Expand Down Expand Up @@ -297,7 +299,7 @@ public function read(int $transactionId, string $salesChannelId): Transaction
*/
public function getByTransactionId(int $transactionId, Context $context): ?TransactionEntity
{
return $this->container->get(TransactionEntityDefinition::ENTITY_NAME .'.repository')
return $this->container->get(TransactionEntityDefinition::ENTITY_NAME . '.repository')
->search((new Criteria())->addAssociations(['refunds']), $context)
->getEntities()
->getByTransactionId($transactionId);
Expand All @@ -312,7 +314,7 @@ public function getByTransactionId(int $transactionId, Context $context): ?Trans
*/
public function getRefundEntityCollectionByTransactionId(int $transactionId, Context $context): ?RefundEntityCollection
{
return $this->container->get(RefundEntityDefinition::ENTITY_NAME .'.repository')
return $this->container->get(RefundEntityDefinition::ENTITY_NAME . '.repository')
->search(new Criteria(), $context)
->getEntities()
->filterByTransactionId($transactionId);
Expand Down
13 changes: 8 additions & 5 deletions src/Core/Api/WebHooks/Controller/WebHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function setLogger(LoggerInterface $logger): void
*/
public function callback(Request $request, Context $context, string $salesChannelId): Response
{
$status = Response::HTTP_INTERNAL_SERVER_ERROR;
$status = Response::HTTP_UNPROCESSABLE_ENTITY;
$callBackData = new WebHookRequest();
try {
// Configuration
Expand Down Expand Up @@ -223,7 +223,7 @@ private function updatePaymentMethodConfiguration(Context $context, string $sale
*/
public function updateRefund(WebHookRequest $callBackData, Context $context): Response
{
$status = Response::HTTP_INTERNAL_SERVER_ERROR;
$status = Response::HTTP_UNPROCESSABLE_ENTITY;

try {
/**
Expand Down Expand Up @@ -323,6 +323,9 @@ private function getOrderEntity(string $orderId, Context $context): OrderEntity
$criteria,
$context
)->first();
if (is_null($this->orderEntity)) {
throw new OrderNotFoundException($orderId);
}
} catch (\Exception $e) {
throw new OrderNotFoundException($orderId);
}
Expand All @@ -340,7 +343,7 @@ private function getOrderEntity(string $orderId, Context $context): OrderEntity
*/
private function updateTransaction(WebHookRequest $callBackData, Context $context): Response
{
$status = Response::HTTP_INTERNAL_SERVER_ERROR;
$status = Response::HTTP_UNPROCESSABLE_ENTITY;

try {
/**
Expand Down Expand Up @@ -390,7 +393,7 @@ private function updateTransaction(WebHookRequest $callBackData, Context $contex
*/
public function updateTransactionInvoice(WebHookRequest $callBackData, Context $context): Response
{
$status = Response::HTTP_INTERNAL_SERVER_ERROR;
$status = Response::HTTP_UNPROCESSABLE_ENTITY;

try {
/**
Expand Down Expand Up @@ -451,7 +454,7 @@ private function unholdDelivery(string $orderId, Context $context)
/**
* @var OrderDeliveryStateHandler $orderDeliveryStateHandler
*/
$order = $this->getOrderEntity($orderId, $context);
$order = $this->getOrderEntity($orderId, $context);
$orderDeliveryStateHandler = $this->container->get(OrderDeliveryStateHandler::class);
$orderDeliveryStateHandler->unhold($order->getDeliveries()->last()->getId(), $context);
} catch (\Exception $exception) {
Expand Down

0 comments on commit 2c74e0e

Please sign in to comment.