99namespace CM \Payments \Config ;
1010
1111use CM \Payments \Api \Config \ConfigInterface ;
12+ use CM \Payments \Model \Adminhtml \Source \Mode ;
1213use CM \Payments \Model \ConfigProvider ;
1314use Magento \Framework \App \Config \ScopeConfigInterface ;
1415use Magento \Store \Model \ScopeInterface ;
@@ -68,10 +69,17 @@ public function getCurrentVersion(): ?string
6869 /**
6970 * @inheritDoc
7071 */
71- public function getMerchantKey (): ?string
72+ public function getMerchantName (): ?string
7273 {
74+ $ mode = $ this ->getMode ();
75+ $ configPath = self ::XML_PATH_GENERAL_TEST_MERCHANT_NAME ;
76+
77+ if ($ mode == Mode::LIVE ) {
78+ $ configPath = self ::XML_PATH_GENERAL_LIVE_MERCHANT_NAME ;
79+ }
80+
7381 return $ this ->getConfig (
74- self :: XML_PATH_GENERAL_MERCHANT_KEY ,
82+ $ configPath ,
7583 ScopeInterface::SCOPE_STORES ,
7684 (string )$ this ->storeManager ->getStore ()->getId ()
7785 );
@@ -80,10 +88,17 @@ public function getMerchantKey(): ?string
8088 /**
8189 * @inheritDoc
8290 */
83- public function getMerchantName (): ?string
91+ public function getMerchantPassword (): ?string
8492 {
93+ $ mode = $ this ->getMode ();
94+ $ configPath = self ::XML_PATH_GENERAL_TEST_MERCHANT_PASSWORD ;
95+
96+ if ($ mode == Mode::LIVE ) {
97+ $ configPath = self ::XML_PATH_GENERAL_LIVE_MERCHANT_PASSWORD ;
98+ }
99+
85100 return $ this ->getConfig (
86- self :: XML_PATH_GENERAL_MERCHANT_NAME ,
101+ $ configPath ,
87102 ScopeInterface::SCOPE_STORES ,
88103 (string )$ this ->storeManager ->getStore ()->getId ()
89104 );
@@ -92,10 +107,29 @@ public function getMerchantName(): ?string
92107 /**
93108 * @inheritDoc
94109 */
95- public function getMerchantPassword (): ?string
110+ public function getMerchantKey (): ?string
96111 {
112+ $ mode = $ this ->getMode ();
113+ $ configPath = self ::XML_PATH_GENERAL_TEST_MERCHANT_KEY ;
114+
115+ if ($ mode == Mode::LIVE ) {
116+ $ configPath = self ::XML_PATH_GENERAL_LIVE_MERCHANT_KEY ;
117+ }
118+
97119 return $ this ->getConfig (
98- self ::XML_PATH_GENERAL_MERCHANT_PASSWORD ,
120+ $ configPath ,
121+ ScopeInterface::SCOPE_STORES ,
122+ (string )$ this ->storeManager ->getStore ()->getId ()
123+ );
124+ }
125+
126+ /**
127+ * @inheritDoc
128+ */
129+ public function getMode (): ?string
130+ {
131+ return $ this ->getConfig (
132+ self ::XML_PATH_GENERAL_MODE ,
99133 ScopeInterface::SCOPE_STORES ,
100134 (string )$ this ->storeManager ->getStore ()->getId ()
101135 );
@@ -123,18 +157,6 @@ public function getPaymentProfile(string $paymentMethod): ?string
123157 return $ defaultPaymentMethod ;
124158 }
125159
126- /**
127- * @inheritDoc
128- */
129- public function getMode (): ?string
130- {
131- return $ this ->getConfig (
132- self ::XML_PATH_GENERAL_MODE ,
133- ScopeInterface::SCOPE_STORES ,
134- (string )$ this ->storeManager ->getStore ()->getId ()
135- );
136- }
137-
138160 /**
139161 * @inheritDoc
140162 */
0 commit comments