-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [PW-2473]: Shopware review fixes and remove 3DS2 image size (#7) * Shopware review fixes and remove 3DS2 image size * Indentation fixes * Hardcode 3DS image size * Revert hardcode 3DS image size * [PW-2562] Adjustments for phpcs (#9) * Fixes and removing phpcs exclude patterns in favor of specific rules suppression * New phpcs version and ignore/disable sniffs * Adjusting copyright comment * Update composer.json (#31) To correctly install the plugin via composer, the module directory needs to be renamed to 'AdyenPayment'. * Fix #19 PW-2601 Update completed state (#34) * Fix #22 PW-2743 Show error on 404 (#35) Shows error message when 404 is returned from Test button. This means the plugin is not active. * PW-2603 remove customer id from shopperinfo payload (#33) Co-authored-by: Wanne Van Camp <[email protected]> * Fixing Yandex logo (#40) * Improve exception logging (#37) Fix #23 PW-2747 * Fixes #15 Handle offer_closed notification (#39) * Fixes #15 Handle offer_closed notification * PW-2748 Tabs -> spaces * Fixes #18 PW-2600 Catch exception during backend Test (#38) * Fixes #18 PW-2600 Catch exception during backend Test * PW-2600 Tabs to spaces * PW-2804 Save form before test (#36) Saves the config before the test is ran. Fix #24 * PW-2565 Make paymentsmethod cache configurable (#43) Adds configuration option to make caching of /paymentmethods call configurable. Co-authored-by: Ángel Campos <[email protected]> Fixes #26 * PW-2505 Distinquish fields of test and live (#44) * PW-2505 Distinquish fields of test and live * PW-2505 Remove debug lines * Improve labels Co-authored-by: Ángel Campos <[email protected]> Co-authored-by: Marcos Garcia <[email protected]> Co-authored-by: Ángel Campos <[email protected]> * Fixes #13 PW-2748 Add event to order restore (#42) * Localizing changelog (#49) * Feature/change refund function (#48) * Save successful psp reference to PaymentInfo * Fixes #17 Use succesfull notification for refunds * Changing API test error code from 500 to 400 (#52) * Fixing changelog * 1.5.0 version bump * Adding N/A to houseNumberOrName in Components/Payload/Providers/ShopperInfoProvider.php * Only send mail after succesful payment (#46) * Only send mail after succesful payment * Fixes #12 Tabs to spaces * Fix indentation * Fix indentation Co-authored-by: Marcos Garcia <[email protected]> Co-authored-by: Ángel Campos <[email protected]> * #54 cronjobs not running (#55) Add missing service registration * add redirect data to payments request (#56) Co-authored-by: Wanne Van Camp <[email protected]> * 1.5.1 changelog Co-authored-by: maxwellpowers <[email protected]> Co-authored-by: Rune Laenen <[email protected]> Co-authored-by: Wanne Van Camp <[email protected]> Co-authored-by: Wanne Van Camp <[email protected]> Co-authored-by: Rune Laenen <[email protected]> Co-authored-by: Marcos Garcia <[email protected]>
- Loading branch information
1 parent
4371f95
commit 85530d1
Showing
11 changed files
with
241 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace AdyenPayment\Components; | ||
|
||
use Shopware\Components\Model\ModelManager; | ||
|
||
class OrderMailService | ||
{ | ||
/** | ||
* @var ModelManager | ||
*/ | ||
private $modelManager; | ||
/** | ||
* @var BasketService | ||
*/ | ||
private $basketService; | ||
|
||
public function __construct( | ||
ModelManager $modelManager, | ||
BasketService $basketService | ||
) { | ||
$this->modelManager = $modelManager; | ||
$this->basketService = $basketService; | ||
} | ||
|
||
/** | ||
* Sends the mail after a payment is confirmed | ||
* | ||
* @param \Shopware\Models\Order\Order $order | ||
*/ | ||
public function sendOrderConfirmationMail($orderNumber) | ||
{ | ||
$order = $this->basketService->getOrderByOrderNumber($orderNumber); | ||
if (!$order) { | ||
return; | ||
} | ||
|
||
$paymentInfoRepository = $this->modelManager->getRepository(\AdyenPayment\Models\PaymentInfo::class); | ||
/** @var \AdyenPayment\Models\PaymentInfo $paymentInfo */ | ||
$paymentInfo = $paymentInfoRepository->findOneBy([ | ||
'orderId' => $order->getId() | ||
]); | ||
|
||
if (!$paymentInfo) { | ||
return; | ||
} | ||
|
||
$variables = json_decode($paymentInfo->getOrdermailVariables(), true); | ||
|
||
if (is_array($variables)) { | ||
$sOrder = Shopware()->Modules()->Order(); | ||
$sOrder->sUserData = $variables; | ||
$sOrder->sendMail($variables); | ||
} | ||
|
||
$paymentInfo->setOrdermailVariables(null); | ||
$this->modelManager->persist($paymentInfo); | ||
$this->modelManager->flush($paymentInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace AdyenPayment\Subscriber; | ||
|
||
use AdyenPayment\AdyenPayment; | ||
use AdyenPayment\Components\NotificationManager; | ||
use AdyenPayment\Components\OrderMailService; | ||
use AdyenPayment\Models\PaymentInfo; | ||
use Doctrine\Common\Persistence\ObjectRepository; | ||
use Doctrine\ORM\EntityRepository; | ||
use Enlight\Event\SubscriberInterface; | ||
use Enlight_Event_EventArgs; | ||
use MollieShopware\Models\Transaction; | ||
use Shopware\Components\HttpClient\Response; | ||
use Shopware\Components\Model\ModelManager; | ||
use Shopware_Controllers_Frontend_Checkout; | ||
|
||
class OrderEmailSubscriber implements SubscriberInterface | ||
{ | ||
/** | ||
* @var ModelManager | ||
*/ | ||
private $modelManager; | ||
|
||
/** | ||
* @var ObjectRepository|EntityRepository | ||
*/ | ||
private $paymentInfoRepository; | ||
/** | ||
* @var OrderMailService | ||
*/ | ||
private $orderMailService; | ||
|
||
public function __construct( | ||
ModelManager $modelManager, | ||
OrderMailService $orderMailService | ||
) { | ||
$this->modelManager = $modelManager; | ||
$this->paymentInfoRepository = $this->modelManager->getRepository(PaymentInfo::class); | ||
$this->orderMailService = $orderMailService; | ||
} | ||
|
||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
'Shopware_Modules_Order_SendMail_Send' => 'shouldStopEmailSending', | ||
'Enlight_Controller_Action_PostDispatch_Frontend_Checkout' => 'onCheckoutDispatch' | ||
]; | ||
} | ||
|
||
public function shouldStopEmailSending(Enlight_Event_EventArgs $args) | ||
{ | ||
$orderId = $args->get('orderId'); | ||
$variables = $args->get('variables'); | ||
|
||
if ($variables['additional']['payment']['name'] === AdyenPayment::ADYEN_GENERAL_PAYMENT_METHOD && | ||
Shopware()->Session()->get(AdyenPayment::SESSION_ADYEN_RESTRICT_EMAILS, true) === false) { | ||
Shopware()->Session()->offsetSet(AdyenPayment::SESSION_ADYEN_RESTRICT_EMAILS, true); | ||
|
||
/** @var PaymentInfo $paymentInfo */ | ||
$paymentInfo = $this->paymentInfoRepository->findOneBy([ | ||
'orderId' => $orderId | ||
]); | ||
|
||
if ($paymentInfo && empty($paymentInfo->getOrdermailVariables())) { | ||
$paymentInfo->setOrdermailVariables(json_encode($variables)); | ||
|
||
$this->modelManager->persist($paymentInfo); | ||
$this->modelManager->flush($paymentInfo); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function onCheckoutDispatch(Enlight_Event_EventArgs $args) | ||
{ | ||
|
||
/** @var Shopware_Controllers_Frontend_Checkout $subject */ | ||
$subject = $args->getSubject(); | ||
|
||
if ($subject->Request()->getActionName() !== 'finish') { | ||
return; | ||
} | ||
|
||
$data = $subject->View()->getAssign(); | ||
|
||
if (!$data['sOrderNumber']) { | ||
return; | ||
} | ||
|
||
$this->orderMailService->sendOrderConfirmationMail($data['sOrderNumber']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters