VoidHandler.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Amazon\Payment\Gateway\Response;
  17. use Magento\Payment\Gateway\Response\HandlerInterface;
  18. use Amazon\Core\Helper\Data;
  19. use Magento\Payment\Model\Method\Logger;
  20. use Amazon\Payment\Gateway\Helper\SubjectReader;
  21. use Magento\Framework\Message\ManagerInterface;
  22. class VoidHandler implements HandlerInterface
  23. {
  24. /**
  25. * @var ManagerInterface
  26. */
  27. private $messageManager;
  28. /**
  29. * @var Logger
  30. */
  31. private $logger;
  32. /**
  33. * @var SubjectReader
  34. */
  35. private $subjectReader;
  36. /**
  37. * @var Data
  38. */
  39. private $coreHelper;
  40. /**
  41. * RefundHandler constructor.
  42. *
  43. * @param Logger $logger
  44. * @param SubjectReader $subjectReader
  45. * @param Data $coreHelper
  46. * @param $messageManager
  47. */
  48. public function __construct(
  49. Logger $logger,
  50. SubjectReader $subjectReader,
  51. Data $coreHelper,
  52. ManagerInterface $messageManager
  53. ) {
  54. $this->logger = $logger;
  55. $this->subjectReader = $subjectReader;
  56. $this->coreHelper = $coreHelper;
  57. $this->messageManager = $messageManager;
  58. }
  59. /**
  60. * @param array $handlingSubject
  61. * @param array $response
  62. */
  63. public function handle(array $handlingSubject, array $response)
  64. {
  65. if (isset($response['status']) && !$response['status']) {
  66. $this->messageManager->addErrorMessage(
  67. __('Unable to cancel the order or the Amazon Order ID is incorrect.')
  68. );
  69. } else {
  70. $this->messageManager->addSuccessMessage(__('Successfully cancelled Amazon Pay.'));
  71. }
  72. }
  73. }