Skip to content

Commit 0f6e869

Browse files
committed
MC-42830: Saved Cards in BrainTree Vault not available in the admin when placing an order for the customer
1 parent 70d1517 commit 0f6e869

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function getComponentProvider($vaultProviderCode)
228228
*/
229229
private function getVaultPayment($vaultPaymentCode)
230230
{
231-
$storeId = $this->storeManager->getStore()->getId();
231+
$storeId = $this->session->getStoreId() ?? $this->storeManager->getStore()->getId();
232232
$vaultPayment = $this->getPaymentDataHelper()->getMethodInstance($vaultPaymentCode);
233233
return $vaultPayment->isActive($storeId) ? $vaultPayment : null;
234234
}

app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function setUp(): void
134134
->getMock();
135135
$this->session = $this->getMockBuilder(Quote::class)
136136
->disableOriginalConstructor()
137-
->setMethods(['getCustomerId', 'getReordered'])
137+
->setMethods(['getCustomerId', 'getReordered', 'getStoreId'])
138138
->getMock();
139139
$this->dateTimeFactory = $this->getMockBuilder(DateTimeFactory::class)
140140
->disableOriginalConstructor()
@@ -191,11 +191,19 @@ protected function setUp(): void
191191
public function testGetTokensComponentsRegisteredCustomer()
192192
{
193193
$customerId = 1;
194+
$storeId = 1;
194195

195196
$this->session->expects(static::once())
196197
->method('getCustomerId')
197198
->willReturn($customerId);
198199

200+
$this->session->expects(static::once())
201+
->method('getStoreId')
202+
->willReturn($storeId);
203+
204+
$this->storeManager->expects(static::never())
205+
->method('getStore');
206+
199207
$this->paymentDataHelper->expects(static::once())
200208
->method('getMethodInstance')
201209
->with(self::VAULT_PAYMENT_CODE)
@@ -250,7 +258,12 @@ public function testGetTokensComponentsGuestCustomer()
250258
{
251259
$customerId = null;
252260

253-
$this->initStoreMock();
261+
$this->session->expects(static::once())
262+
->method('getStoreId')
263+
->willReturn(null);
264+
265+
$this->storeManager->expects(static::once())
266+
->method('getStore');
254267

255268
$this->session->expects(static::once())
256269
->method('getCustomerId')

0 commit comments

Comments
 (0)