Skip to content

Commit 986d5b1

Browse files
committed
get customer id from cart not context
1 parent afaede9 commit 986d5b1

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

app/code/Magento/PaypalGraphQl/Model/Plugin/Cart/HostedPro/SetPaymentMethodOnCart.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\PaypalGraphQl\Model\Plugin\Cart\HostedPro;
99

1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
11-
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1211
use Magento\Paypal\Model\Config;
1312
use Magento\Quote\Model\Quote;
1413
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool;
@@ -48,7 +47,6 @@ public function __construct(
4847
* @param mixed $result
4948
* @param Quote $cart
5049
* @param array $paymentData
51-
* @param ContextInterface $context
5250
* @return void
5351
* @throws GraphQlInputException
5452
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -57,8 +55,7 @@ public function afterExecute(
5755
\Magento\QuoteGraphQl\Model\Cart\SetPaymentMethodOnCart $subject,
5856
$result,
5957
Quote $cart,
60-
array $paymentData,
61-
ContextInterface $context
58+
array $paymentData
6259
): void {
6360
$paymentData = $this->additionalDataProviderPool->getData(Config::METHOD_HOSTEDPRO, $paymentData);
6461

app/code/Magento/PaypalGraphQl/Model/Plugin/Cart/PayflowPro/SetPaymentMethodOnCart.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\PaypalGraphQl\Model\Plugin\Cart\PayflowPro;
99

1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
11-
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1211
use Magento\Paypal\Model\Config;
1312
use Magento\Quote\Model\Quote;
1413
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool;
@@ -49,7 +48,6 @@ public function __construct(
4948
* @param mixed $result
5049
* @param Quote $cart
5150
* @param array $paymentData
52-
* @param ContextInterface $context
5351
* @return void
5452
* @throws GraphQlInputException
5553
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -58,13 +56,11 @@ public function afterExecute(
5856
\Magento\QuoteGraphQl\Model\Cart\SetPaymentMethodOnCart $subject,
5957
$result,
6058
Quote $cart,
61-
array $paymentData,
62-
ContextInterface $context
59+
array $paymentData
6360
): void {
6461
$paymentData = $this->additionalDataProviderPool->getData(Config::METHOD_PAYFLOWPRO, $paymentData);
65-
66-
if (!$context->getExtensionAttributes()->getIsCustomer()
67-
&& array_key_exists(PayflowProSetCcData::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, $paymentData)) {
62+
$cartCustomerId = (int)$cart->getCustomerId();
63+
if ($cartCustomerId === 0 && array_key_exists(PayflowProSetCcData::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, $paymentData)) {
6864
$payment = $cart->getPayment();
6965
$payment->unsAdditionalInformation(PayflowProSetCcData::IS_ACTIVE_PAYMENT_TOKEN_ENABLER);
7066
$payment->save();

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
use Magento\Framework\Exception\NoSuchEntityException;
1212
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
14-
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1514
use Magento\Quote\Api\Data\PaymentInterface;
1615
use Magento\Quote\Api\Data\PaymentInterfaceFactory;
1716
use Magento\Quote\Api\PaymentMethodManagementInterface;
1817
use Magento\Quote\Model\Quote;
1918
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool;
2019

2120
/**
22-
* Set payment method for cart
21+
* Set payment method on cart
2322
*/
2423
class SetPaymentMethodOnCart
2524
{
@@ -58,12 +57,11 @@ public function __construct(
5857
*
5958
* @param Quote $cart
6059
* @param array $paymentData
61-
* @param ContextInterface $context
6260
* @throws GraphQlInputException
6361
* @throws GraphQlNoSuchEntityException
6462
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6563
*/
66-
public function execute(Quote $cart, array $paymentData, ContextInterface $context): void
64+
public function execute(Quote $cart, array $paymentData): void
6765
{
6866
if (!isset($paymentData['code']) || empty($paymentData['code'])) {
6967
throw new GraphQlInputException(__('Required parameter "code" for "payment_method" is missing.'));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
6868
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
6969
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
7070
$this->checkCartCheckoutAllowance->execute($cart);
71-
$this->setPaymentMethodOnCart->execute($cart, $paymentData, $context);
71+
$this->setPaymentMethodOnCart->execute($cart, $paymentData);
7272

7373
return [
7474
'cart' => [

0 commit comments

Comments
 (0)