Skip to content

Commit

Permalink
get customer id from cart not context
Browse files Browse the repository at this point in the history
  • Loading branch information
Usik2203 committed Jul 28, 2020
1 parent afaede9 commit 986d5b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Magento\PaypalGraphQl\Model\Plugin\Cart\HostedPro;

use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Paypal\Model\Config;
use Magento\Quote\Model\Quote;
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool;
Expand Down Expand Up @@ -48,7 +47,6 @@ public function __construct(
* @param mixed $result
* @param Quote $cart
* @param array $paymentData
* @param ContextInterface $context
* @return void
* @throws GraphQlInputException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Expand All @@ -57,8 +55,7 @@ public function afterExecute(
\Magento\QuoteGraphQl\Model\Cart\SetPaymentMethodOnCart $subject,
$result,
Quote $cart,
array $paymentData,
ContextInterface $context
array $paymentData
): void {
$paymentData = $this->additionalDataProviderPool->getData(Config::METHOD_HOSTEDPRO, $paymentData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Magento\PaypalGraphQl\Model\Plugin\Cart\PayflowPro;

use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Paypal\Model\Config;
use Magento\Quote\Model\Quote;
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool;
Expand Down Expand Up @@ -49,7 +48,6 @@ public function __construct(
* @param mixed $result
* @param Quote $cart
* @param array $paymentData
* @param ContextInterface $context
* @return void
* @throws GraphQlInputException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Expand All @@ -58,13 +56,11 @@ public function afterExecute(
\Magento\QuoteGraphQl\Model\Cart\SetPaymentMethodOnCart $subject,
$result,
Quote $cart,
array $paymentData,
ContextInterface $context
array $paymentData
): void {
$paymentData = $this->additionalDataProviderPool->getData(Config::METHOD_PAYFLOWPRO, $paymentData);

if (!$context->getExtensionAttributes()->getIsCustomer()
&& array_key_exists(PayflowProSetCcData::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, $paymentData)) {
$cartCustomerId = (int)$cart->getCustomerId();
if ($cartCustomerId === 0 && array_key_exists(PayflowProSetCcData::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, $paymentData)) {
$payment = $cart->getPayment();
$payment->unsAdditionalInformation(PayflowProSetCcData::IS_ACTIVE_PAYMENT_TOKEN_ENABLER);
$payment->save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Quote\Api\Data\PaymentInterface;
use Magento\Quote\Api\Data\PaymentInterfaceFactory;
use Magento\Quote\Api\PaymentMethodManagementInterface;
use Magento\Quote\Model\Quote;
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool;

/**
* Set payment method for cart
* Set payment method on cart
*/
class SetPaymentMethodOnCart
{
Expand Down Expand Up @@ -58,12 +57,11 @@ public function __construct(
*
* @param Quote $cart
* @param array $paymentData
* @param ContextInterface $context
* @throws GraphQlInputException
* @throws GraphQlNoSuchEntityException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(Quote $cart, array $paymentData, ContextInterface $context): void
public function execute(Quote $cart, array $paymentData): void
{
if (!isset($paymentData['code']) || empty($paymentData['code'])) {
throw new GraphQlInputException(__('Required parameter "code" for "payment_method" is missing.'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
$this->checkCartCheckoutAllowance->execute($cart);
$this->setPaymentMethodOnCart->execute($cart, $paymentData, $context);
$this->setPaymentMethodOnCart->execute($cart, $paymentData);

return [
'cart' => [
Expand Down

0 comments on commit 986d5b1

Please sign in to comment.