Data.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Authorizenet\Helper\Backend;
  8. use Magento\Authorizenet\Helper\Data as FrontendDataHelper;
  9. use Magento\Framework\App\Helper\Context;
  10. use Magento\Store\Model\StoreManagerInterface;
  11. use Magento\Sales\Model\OrderFactory;
  12. use Magento\Backend\Model\UrlInterface;
  13. /**
  14. * Authorize.net Backend Data Helper
  15. *
  16. * @api
  17. * @since 100.0.2
  18. * @deprecated 100.3.1 Authorize.net is removing all support for this payment method
  19. */
  20. class Data extends FrontendDataHelper
  21. {
  22. /**
  23. * @param \Magento\Framework\App\Helper\Context $context
  24. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  25. * @param \Magento\Sales\Model\OrderFactory $orderFactory
  26. * @param \Magento\Backend\Model\UrlInterface $backendUrl
  27. */
  28. public function __construct(
  29. Context $context,
  30. StoreManagerInterface $storeManager,
  31. OrderFactory $orderFactory,
  32. UrlInterface $backendUrl
  33. ) {
  34. parent::__construct($context, $storeManager, $orderFactory);
  35. $this->_urlBuilder = $backendUrl;
  36. }
  37. /**
  38. * Return URL for admin area
  39. *
  40. * @param string $route
  41. * @param array $params
  42. * @return string
  43. */
  44. protected function _getUrl($route, $params = [])
  45. {
  46. return $this->_urlBuilder->getUrl($route, $params);
  47. }
  48. /**
  49. * Retrieve place order url in admin
  50. *
  51. * @return string
  52. */
  53. public function getPlaceOrderAdminUrl()
  54. {
  55. return $this->_getUrl('adminhtml/authorizenet_directpost_payment/place', []);
  56. }
  57. /**
  58. * Retrieve place order url
  59. *
  60. * @param array $params
  61. * @return string
  62. */
  63. public function getSuccessOrderUrl($params)
  64. {
  65. $param = [];
  66. $route = 'sales/order/view';
  67. $order = $this->orderFactory->create()->loadByIncrementId($params['x_invoice_num']);
  68. $param['order_id'] = $order->getId();
  69. return $this->_getUrl($route, $param);
  70. }
  71. /**
  72. * Retrieve redirect iframe url
  73. *
  74. * @param array $params
  75. * @return string
  76. */
  77. public function getRedirectIframeUrl($params)
  78. {
  79. return $this->_getUrl('adminhtml/authorizenet_directpost_payment/redirect', $params);
  80. }
  81. /**
  82. * Get direct post relay url
  83. *
  84. * @param null|int|string $storeId
  85. * @return string
  86. *
  87. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  88. */
  89. public function getRelayUrl($storeId = null)
  90. {
  91. $defaultStore = $this->storeManager->getDefaultStoreView();
  92. if (!$defaultStore) {
  93. $allStores = $this->storeManager->getStores();
  94. if (isset($allStores[0])) {
  95. $defaultStore = $allStores[0];
  96. }
  97. }
  98. $baseUrl = $defaultStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK);
  99. return $baseUrl . 'authorizenet/directpost_payment/backendResponse';
  100. }
  101. }