Config.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Signifyd\Model;
  7. use Magento\Framework\App\Config\ScopeConfigInterface;
  8. use Magento\Store\Model\ScopeInterface;
  9. /**
  10. * Signifyd integration configuration.
  11. *
  12. * Class is a proxy service for retrieving configuration settings.
  13. */
  14. class Config
  15. {
  16. /**
  17. * @var ScopeConfigInterface
  18. */
  19. private $scopeConfig;
  20. /**
  21. * Config constructor.
  22. *
  23. * @param ScopeConfigInterface $scopeConfig
  24. */
  25. public function __construct(ScopeConfigInterface $scopeConfig)
  26. {
  27. $this->scopeConfig = $scopeConfig;
  28. }
  29. /**
  30. * If this config option set to false no Signifyd integration should be available
  31. * (only possibility to configure Signifyd setting in admin)
  32. *
  33. * @param int|null $storeId
  34. * @return bool
  35. */
  36. public function isActive($storeId = null): bool
  37. {
  38. $enabled = $this->scopeConfig->isSetFlag(
  39. 'fraud_protection/signifyd/active',
  40. ScopeInterface::SCOPE_STORE,
  41. $storeId
  42. );
  43. return $enabled;
  44. }
  45. /**
  46. * Signifyd API Key used for authentication.
  47. *
  48. * @see https://www.signifyd.com/docs/api/#/introduction/authentication
  49. * @see https://app.signifyd.com/settings
  50. *
  51. * @param int|null $storeId
  52. * @return string
  53. */
  54. public function getApiKey($storeId = null): string
  55. {
  56. $apiKey = $this->scopeConfig->getValue(
  57. 'fraud_protection/signifyd/api_key',
  58. ScopeInterface::SCOPE_STORE,
  59. $storeId
  60. );
  61. return $apiKey;
  62. }
  63. /**
  64. * Base URL to Signifyd REST API.
  65. * Usually equals to https://api.signifyd.com/v2 and should not be changed
  66. *
  67. * @param int|null $storeId
  68. * @return string
  69. */
  70. public function getApiUrl($storeId = null): string
  71. {
  72. $apiUrl = $this->scopeConfig->getValue(
  73. 'fraud_protection/signifyd/api_url',
  74. ScopeInterface::SCOPE_STORE,
  75. $storeId
  76. );
  77. return $apiUrl;
  78. }
  79. /**
  80. * If is "true" extra information about interaction with Signifyd API are written to debug.log file
  81. *
  82. * @param int|null $storeId
  83. * @return bool
  84. */
  85. public function isDebugModeEnabled($storeId = null): bool
  86. {
  87. $debugModeEnabled = $this->scopeConfig->isSetFlag(
  88. 'fraud_protection/signifyd/debug',
  89. ScopeInterface::SCOPE_STORE,
  90. $storeId
  91. );
  92. return $debugModeEnabled;
  93. }
  94. }