Skip to content

Commit 05632a8

Browse files
committed
Move Method Specific input into PaymentMethodInput
1 parent d57d076 commit 05632a8

File tree

10 files changed

+90
-92
lines changed

10 files changed

+90
-92
lines changed

app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class BraintreeDataProvider implements AdditionalDataProviderInterface
1717
{
18-
private const PATH_ADDITIONAL_DATA = 'input/payment_method/additional_data/braintree';
18+
private const PATH_ADDITIONAL_DATA = 'braintree';
1919

2020
/**
2121
* @var ArrayManager

app/code/Magento/BraintreeGraphQl/Model/BraintreeVaultDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class BraintreeVaultDataProvider implements AdditionalDataProviderInterface
1717
{
18-
private const PATH_ADDITIONAL_DATA = 'input/payment_method/additional_data/braintree_cc_vault';
18+
private const PATH_ADDITIONAL_DATA = 'braintree_cc_vault';
1919

2020
/**
2121
* @var ArrayManager

app/code/Magento/BraintreeGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright © Magento, Inc. All rights reserved.
22
# See COPYING.txt for license details.
33

4-
input PaymentMethodAdditionalDataInput {
4+
input PaymentMethodInput {
55
braintree: BraintreeInput
66
braintree_cc_vault: BraintreeCcVaultInput
77
}

app/code/Magento/QuoteGraphQl/Model/Cart/SetPaymentMethodOnCart.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,15 @@ public function execute(Quote $cart, array $paymentData): void
6868
$paymentMethodCode = $paymentData['code'];
6969

7070
$poNumber = $paymentData['purchase_order_number'] ?? null;
71-
$additionalData = isset($paymentData['additional_data'])
72-
? $this->additionalDataProviderPool->getData($paymentMethodCode, $paymentData['additional_data'])
73-
: [];
71+
$additionalData = $this->additionalDataProviderPool->getData($paymentMethodCode, $paymentData);
7472

7573
$payment = $this->paymentFactory->create(
7674
[
77-
'data' =>
78-
[
79-
PaymentInterface::KEY_METHOD => $paymentMethodCode,
80-
PaymentInterface::KEY_PO_NUMBER => $poNumber,
81-
PaymentInterface::KEY_ADDITIONAL_DATA => $additionalData,
82-
],
75+
'data' => [
76+
PaymentInterface::KEY_METHOD => $paymentMethodCode,
77+
PaymentInterface::KEY_PO_NUMBER => $poNumber,
78+
PaymentInterface::KEY_ADDITIONAL_DATA => $additionalData,
79+
],
8380
]
8481
);
8582

dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function setUp()
8888
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
8989
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
9090
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
91-
* @magentoApiDataFixture Magento/Graphql/Braintree/_files/payments.php
91+
* @magentoApiDataFixture Magento/GraphQl/Braintree/_files/enable_braintree_payment.php
9292
*/
9393
public function testPlaceOrder()
9494
{
@@ -121,7 +121,7 @@ public function testPlaceOrder()
121121
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
122122
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
123123
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
124-
* @magentoApiDataFixture Magento/Graphql/Braintree/_files/payments.php
124+
* @magentoApiDataFixture Magento/GraphQl/Braintree/_files/enable_braintree_payment.php
125125
*/
126126
public function testPlaceOrderSaveInVault()
127127
{
@@ -161,8 +161,8 @@ public function testPlaceOrderSaveInVault()
161161
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
162162
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
163163
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
164-
* @magentoApiDataFixture Magento/Graphql/Braintree/_files/payments.php
165-
* @magentoApiDataFixture Magento/Graphql/Braintree/_files/token.php
164+
* @magentoApiDataFixture Magento/GraphQl/Braintree/_files/enable_braintree_payment.php
165+
* @magentoApiDataFixture Magento/GraphQl/Braintree/_files/token.php
166166
*/
167167
public function testPlaceOrderWithVault()
168168
{
@@ -224,11 +224,9 @@ private function getSetPaymentBraintreeQuery(string $maskedQuoteId, bool $saveIn
224224
cart_id:"{$maskedQuoteId}"
225225
payment_method:{
226226
code:"braintree"
227-
additional_data:{
228-
braintree:{
229-
is_active_payment_token_enabler:{$saveInVault}
230-
payment_method_nonce:"fake-valid-nonce"
231-
}
227+
braintree:{
228+
is_active_payment_token_enabler:{$saveInVault}
229+
payment_method_nonce:"fake-valid-nonce"
232230
}
233231
}
234232
}) {
@@ -262,12 +260,10 @@ private function getSetPaymentBraintreeVaultQuery(
262260
cart_id:"{$maskedQuoteId}"
263261
payment_method:{
264262
code:"braintree_cc_vault"
265-
additional_data:{
266-
braintree_cc_vault:{
267-
is_active_payment_token_enabler:{$saveInVault}
268-
payment_method_nonce:"{$nonce}"
269-
public_hash:"{$publicHash}"
270-
}
263+
braintree_cc_vault:{
264+
is_active_payment_token_enabler:{$saveInVault}
265+
payment_method_nonce:"{$nonce}"
266+
public_hash:"{$publicHash}"
271267
}
272268
}
273269
}) {

dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
*/
2121
class SetPaymentMethodTest extends GraphQlAbstract
2222
{
23-
private const REQUIRED_CONSTS = [
24-
'TESTS_BRAINTREE_MERCHANT_ID',
25-
'TESTS_BRAINTREE_PUBLIC_KEY',
26-
'TESTS_BRAINTREE_PRIVATE_KEY',
27-
];
28-
2923
/**
3024
* @var CustomerTokenServiceInterface
3125
*/
@@ -56,12 +50,6 @@ class SetPaymentMethodTest extends GraphQlAbstract
5650
*/
5751
protected function setUp()
5852
{
59-
foreach (static::REQUIRED_CONSTS as $const) {
60-
if (!defined($const)) {
61-
$this->markTestSkipped('Braintree sandbox credentials must be defined in phpunit_graphql.xml.dist');
62-
}
63-
}
64-
6553
$objectManager = Bootstrap::getObjectManager();
6654
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
6755
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
@@ -79,7 +67,7 @@ protected function setUp()
7967
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
8068
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
8169
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
82-
* @magentoApiDataFixture Magento/Graphql/Braintree/_files/payments.php
70+
* @magentoApiDataFixture Magento/GraphQl/Braintree/_files/enable_braintree_payment.php
8371
*/
8472
public function testPlaceOrder()
8573
{
@@ -126,11 +114,9 @@ private function getSetPaymentBraintreeQuery(string $maskedQuoteId): string
126114
cart_id:"{$maskedQuoteId}"
127115
payment_method:{
128116
code:"braintree"
129-
additional_data:{
130-
braintree:{
131-
is_active_payment_token_enabler:false
132-
payment_method_nonce:"fake-valid-nonce"
133-
}
117+
braintree:{
118+
is_active_payment_token_enabler:false
119+
payment_method_nonce:"fake-valid-nonce"
134120
}
135121
}
136122
}) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\App\Config\Storage\Writer;
9+
use Magento\Framework\App\Config\Storage\WriterInterface;
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
use Magento\Framework\Encryption\EncryptorInterface;
12+
use Magento\Braintree\Model\Ui\ConfigProvider;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
15+
$objectManager = Bootstrap::getObjectManager();
16+
17+
/** @var Writer $configWriter */
18+
$configWriter = $objectManager->get(WriterInterface::class);
19+
/** @var EncryptorInterface $encryptor */
20+
$encryptor = $objectManager->get(EncryptorInterface::class);
21+
22+
/** @var $mutableScopeConfig */
23+
$mutableScopeConfig = $objectManager->get(
24+
\Magento\Framework\App\Config\MutableScopeConfigInterface::class
25+
);
26+
27+
$configWriter->save('payment/' . ConfigProvider::CODE . '/merchant_id', 'def_merchant_id');
28+
$configWriter->save('payment/' . ConfigProvider::CODE . '/public_key', $encryptor->encrypt('def_public_key'));
29+
$configWriter->save('payment/' . ConfigProvider::CODE . '/private_key', $encryptor->encrypt('def_private_key'));
30+
$configWriter->save('payment/' . ConfigProvider::CODE . '/active', '1');
31+
$configWriter->save('payment/' . ConfigProvider::CODE . '/environment', 'sandbox');
32+
$configWriter->save('payment/' . ConfigProvider::CC_VAULT_CODE . '/active', '1');
33+
34+
$scopeConfig = $objectManager->get(ScopeConfigInterface::class);
35+
$scopeConfig->clean();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\App\Config\Storage\Writer;
9+
use Magento\Framework\App\Config\Storage\WriterInterface;
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
use Magento\Framework\Encryption\EncryptorInterface;
12+
use Magento\Braintree\Model\Ui\ConfigProvider;
13+
14+
$objectManager = Bootstrap::getObjectManager();
15+
16+
/** @var Writer $configWriter */
17+
$configWriter = $objectManager->get(WriterInterface::class);
18+
/** @var EncryptorInterface $encryptor */
19+
$encryptor = $objectManager->get(EncryptorInterface::class);
20+
21+
/** @var $mutableScopeConfig */
22+
$mutableScopeConfig = $objectManager->get(
23+
\Magento\Framework\App\Config\MutableScopeConfigInterface::class
24+
);
25+
26+
$configWriter->delete('payment/' . ConfigProvider::CODE . '/merchant_id');
27+
$configWriter->delete('payment/' . ConfigProvider::CODE . '/public_key');
28+
$configWriter->delete('payment/' . ConfigProvider::CODE . '/private_key');
29+
$configWriter->delete('payment/' . ConfigProvider::CODE . '/active');
30+
$configWriter->delete('payment/' . ConfigProvider::CODE . '/environment');
31+
$configWriter->delete('payment/' . ConfigProvider::CC_VAULT_CODE . '/active');

dev/tests/integration/testsuite/Magento/GraphQl/Braintree/_files/payments.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/GraphQl/Braintree/_files/token.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@
88
use Magento\Vault\Model\PaymentToken;
99
use Magento\Vault\Model\PaymentTokenRepository;
1010

11-
$requiredConst = [
12-
'TESTS_BRAINTREE_MERCHANT_ID',
13-
'TESTS_BRAINTREE_PUBLIC_KEY',
14-
'TESTS_BRAINTREE_PRIVATE_KEY',
15-
];
16-
foreach ($requiredConst as $const) {
17-
if (!defined($const)) {
18-
return;
19-
}
20-
}
21-
2211
$objectManager = Bootstrap::getObjectManager();
2312

2413
$adapterFactory = $objectManager->get(\Magento\Braintree\Model\Adapter\BraintreeAdapterFactory::class);

0 commit comments

Comments
 (0)