Skip to content

Commit 9d4a98d

Browse files
authored
Merge pull request #592 from FatchipRobert/MAG2-356-GooglePay-MerchantId
MAG2-356 - Added MerchantId configuration for GooglePay production mode
2 parents 8080abd + 5a37514 commit 9d4a98d

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

Model/Methods/GooglePay.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public function getFrontendConfig()
149149
return [
150150
'merchantId' => $this->getMerchantId(),
151151
'storeName' => $this->getStoreName(),
152+
'googlePayMerchantId' => $this->shopHelper->getConfigParam('google_pay_merchant_id', PayoneConfig::METHOD_GOOGLE_PAY, 'payment'),
152153
'operationMode' => $this->getOperationMode(),
153154
];
154155
}

Test/Unit/Model/Methods/GooglePayTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function testGetFrontendConfig()
137137
$expected = [
138138
'merchantId' => $expectedConfigParam,
139139
'storeName' => $expectedConfigParam,
140+
'googlePayMerchantId' => $expectedConfigParam,
140141
'operationMode' => $expectedConfigParam,
141142
];
142143

@@ -148,6 +149,7 @@ public function testGetFrontendConfigNoStoreConfig()
148149
{
149150
$expectedConfigParam = "testValue";
150151
$expectedStoreName = "storeFrontendName";
152+
$expectedGooglePayMerchantId = "testValue";
151153

152154
$this->quote->method('getStore')->willReturn($this->store);
153155
$this->store->method('getFrontendName')->willReturn($expectedStoreName);
@@ -157,13 +159,15 @@ public function testGetFrontendConfigNoStoreConfig()
157159
['mid', PayoneConfig::METHOD_GOOGLE_PAY, 'payone_payment', 'test', $expectedConfigParam],
158160
['mid', 'global', 'payone_general', null, $expectedConfigParam],
159161
['store_name', PayoneConfig::METHOD_GOOGLE_PAY, 'payment', 'test', null],
162+
['google_pay_merchant_id', PayoneConfig::METHOD_GOOGLE_PAY, 'payment', null, $expectedGooglePayMerchantId],
160163
['mode', PayoneConfig::METHOD_GOOGLE_PAY, 'payone_payment', 'test', $expectedConfigParam],
161164
]
162165
);
163166

164167
$expected = [
165168
'merchantId' => $expectedConfigParam,
166169
'storeName' => $expectedStoreName,
170+
'googlePayMerchantId' => $expectedGooglePayMerchantId,
167171
'operationMode' => $expectedConfigParam,
168172
];
169173

@@ -174,6 +178,7 @@ public function testGetFrontendConfigNoStoreConfig()
174178
public function testGetFrontendConfigStoreDoubleEmpty()
175179
{
176180
$expectedConfigParam = "testValue";
181+
$expectedGooglePayMerchantId = "testValue";
177182

178183
$this->quote->method('getStore')->willReturn(null);
179184

@@ -182,13 +187,15 @@ public function testGetFrontendConfigStoreDoubleEmpty()
182187
['mid', PayoneConfig::METHOD_GOOGLE_PAY, 'payone_payment', 'test', $expectedConfigParam],
183188
['mid', 'global', 'payone_general', null, $expectedConfigParam],
184189
['store_name', PayoneConfig::METHOD_GOOGLE_PAY, 'payment', 'test', null],
190+
['google_pay_merchant_id', PayoneConfig::METHOD_GOOGLE_PAY, 'payment', null, $expectedGooglePayMerchantId],
185191
['mode', PayoneConfig::METHOD_GOOGLE_PAY, 'payone_payment', 'test', $expectedConfigParam],
186192
]
187193
);
188194

189195
$expected = [
190196
'merchantId' => $expectedConfigParam,
191197
'storeName' => 'Online Store',
198+
'googlePayMerchantId' => $expectedGooglePayMerchantId,
192199
'operationMode' => $expectedConfigParam,
193200
];
194201

etc/adminhtml/system/payone_google_pay.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<label>Instructions</label>
4646
<config_path>payment/payone_google_pay/instructions</config_path>
4747
</field>
48+
<field id="google_pay_merchant_id" translate="label,comment" type="text" sortOrder="65" showInDefault="1" showInWebsite="1" showInStore="1">
49+
<label>GooglePay MerchantId</label>
50+
<config_path>payment/payone_google_pay/google_pay_merchant_id</config_path>
51+
<comment>Needed for Live mode.</comment>
52+
</field>
4853
<field id="store_name" translate="label,comment" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
4954
<label>Store Name</label>
5055
<config_path>payment/payone_google_pay/store_name</config_path>

view/frontend/web/js/view/payment/method-renderer/google_pay-method.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ define(
228228
paymentDataRequest.merchantInfo = {
229229
merchantName: this.getFrontendConfigParam('storeName')
230230
};
231+
232+
if (this.getFrontendConfigParam('operationMode') == "live") {
233+
paymentDataRequest.merchantInfo.merchantId = this.getFrontendConfigParam('googlePayMerchantId');
234+
}
235+
231236
return paymentDataRequest;
232237
},
233238
addGooglePayButton: function () {

0 commit comments

Comments
 (0)