Skip to content

Commit

Permalink
Merge pull request #185 in PLUG_OPEN/swagpaymentpaypalunified from pt…
Browse files Browse the repository at this point in the history
…-10562/5.2/remove-mail-handling to master

* commit '042def2aac4dab6e25a2188055ee83df1533d87a':
  PT-10562 - Do not interfere mail sending in error case
  • Loading branch information
mitelg committed Jun 25, 2019
2 parents 143612c + 042def2 commit ca6395b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 109 deletions.
36 changes: 20 additions & 16 deletions Controllers/Backend/PaypalUnified.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
*/

use Doctrine\DBAL\Connection;
use Doctrine\ORM\Query\Expr\Join;
use Shopware\Components\Model\QueryBuilder;
use Shopware\Models\Order\Order;
use Shopware\Models\Order\Status;
use Shopware\Models\Shop\Repository as ShopRepository;
use Shopware\Models\Shop\Shop;
use SwagPaymentPayPalUnified\Components\ExceptionHandlerServiceInterface;
use SwagPaymentPayPalUnified\Components\PaymentMethodProvider;
Expand Down Expand Up @@ -463,7 +465,7 @@ protected function getList($offset, $limit, $sort = [], $filter = [], array $who
$orderStatusNamespace = $this->container->get('snippets')->getNamespace('backend/static/order_status');
$paymentStatusNamespace = $this->container->get('snippets')->getNamespace('backend/static/payment_status');

$orderList['data'] = array_map(function ($order) use ($orderStatusNamespace, $paymentStatusNamespace) {
$orderList['data'] = array_map(static function ($order) use ($orderStatusNamespace, $paymentStatusNamespace) {
if (!isset($order['orderStatus']['description'])) {
$order['orderStatus']['description'] = $orderStatusNamespace->get($order['orderStatus']['name']);
}
Expand Down Expand Up @@ -543,22 +545,22 @@ private function prepareOrderQueryBuilder(QueryBuilder $builder)
$builder->innerJoin(
'sOrder.payment',
'payment',
\Doctrine\ORM\Query\Expr\Join::WITH,
Join::WITH,
'payment.id IN (:paymentIds)'
)->setParameter('paymentIds', $paymentIds, Connection::PARAM_INT_ARRAY);

$builder->leftJoin('sOrder.languageSubShop', 'languageSubShop')
->leftJoin('sOrder.customer', 'customer')
->leftJoin('sOrder.orderStatus', 'orderStatus')
->leftJoin('sOrder.paymentStatus', 'paymentStatus')
->leftJoin('sOrder.attribute', 'attribute')

->addSelect('languageSubShop')
->addSelect('payment')
->addSelect('customer')
->addSelect('orderStatus')
->addSelect('paymentStatus')
->addSelect('attribute');
->leftJoin('sOrder.customer', 'customer')
->leftJoin('sOrder.orderStatus', 'orderStatus')
->leftJoin('sOrder.paymentStatus', 'paymentStatus')
->leftJoin('sOrder.attribute', 'attribute')
->addSelect('languageSubShop')
->addSelect('payment')
->addSelect('customer')
->addSelect('orderStatus')
->addSelect('paymentStatus')
->addSelect('attribute')
->andWhere("sOrder.transactionId != ''");

return $builder;
}
Expand All @@ -568,7 +570,7 @@ private function prepareOrderQueryBuilder(QueryBuilder $builder)
*/
private function registerShopResource($shopId = null)
{
/** @var \Shopware\Models\Shop\Repository $shopRepository */
/** @var ShopRepository $shopRepository */
$shopRepository = $this->get('models')->getRepository(Shop::class);

if ($shopId === null) {
Expand Down Expand Up @@ -632,14 +634,16 @@ private function prepareUnifiedDetails($paymentId)
private function updatePaymentStatus(array $refundData)
{
/** @var Order $orderModel */
$orderModel = $this->getModelManager()->getRepository(Order::class)->findOneBy(['temporaryId' => $refundData['parent_payment']]);
$orderModel = $this->getModelManager()->getRepository(Order::class)
->findOneBy(['temporaryId' => $refundData['parent_payment']]);

if (!($orderModel instanceof Order)) {
return;
}

/** @var Status $orderStatusModel */
$orderStatusModel = $this->getModelManager()->getRepository(Status::class)->find(PaymentStatus::PAYMENT_STATUS_REFUNDED);
$orderStatusModel = $this->getModelManager()->getRepository(Status::class)
->find(PaymentStatus::PAYMENT_STATUS_REFUNDED);

$orderModel->setPaymentStatus($orderStatusModel);

Expand Down
18 changes: 0 additions & 18 deletions Controllers/Frontend/PaypalUnified.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ public function returnAction()
} catch (RequestException $exception) {
$errorCode = ErrorCodes::COMMUNICATION_FAILURE;
if ($sendOrderNumber) {
$session->offsetUnset('paypalUnifiedFinishOrderSendMailVariables');
$orderDataService->setOrderState($orderNumber, PaymentStatus::ORDER_STATUS_CLARIFICATION_REQUIRED);
$orderDataService->removeTransactionId($orderNumber);
$errorCode = ErrorCodes::COMMUNICATION_FAILURE_FINISH;
Expand Down Expand Up @@ -319,8 +318,6 @@ public function returnAction()

$orderDataService->applyPaymentTypeAttribute($orderNumber, $response, $isExpressCheckout);

$this->sendOrderMail($session);

$redirectParameter = [
'module' => 'frontend',
'controller' => 'checkout',
Expand Down Expand Up @@ -507,19 +504,4 @@ private function noDispatchForOrder()

return !empty($this->shopwareConfig->get('premiumShippingNoOrder')) && (empty($session['sDispatch']) || empty($session['sCountry']));
}

private function sendOrderMail(Enlight_Components_Session_Namespace $session)
{
if (!$session->offsetExists('paypalUnifiedFinishOrderSendMailVariables')) {
return;
}

$sendMailOrderVariables = $session->get('paypalUnifiedFinishOrderSendMailVariables');
$sendMailOrderVariables['paypalUnifiedSendMail'] = true;
/** @var sOrder $sOrder */
$sOrder = $this->get('paypal_unified.dependency_provider')->getModule('order');
$sOrder->sendMail($sendMailOrderVariables);

$session->offsetUnset('paypalUnifiedFinishOrderSendMailVariables');
}
}
7 changes: 0 additions & 7 deletions Resources/services/subscribers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@
<tag name="shopware.event_subscriber"/>
</service>

<service id="swag_payment_pay_pal_unified.subscriber.order"
class="SwagPaymentPayPalUnified\Subscriber\Order">
<argument type="service" id="dbal_connection"/>
<argument type="service" id="paypal_unified.dependency_provider"/>
<tag name="shopware.event_subscriber"/>
</service>

<service id="paypal_unified.subscriber.payment_means"
class="SwagPaymentPayPalUnified\Subscriber\PaymentMeans">
<argument type="service" id="dbal_connection"/>
Expand Down
68 changes: 0 additions & 68 deletions Subscriber/Order.php

This file was deleted.

0 comments on commit ca6395b

Please sign in to comment.