-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [GraphQL] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #28821: [GraphQL] Paypal PayFlowPro store the payment details in myaccount for future (by @Usik2203) Fixed GitHub Issues: - #28520: Implement the schema for PayPal PayFloPro (reported by @nrkapoor) has been fixed in #28821 by @Usik2203 in 2.4-develop branch Related commits: 1. d29468d 2. e798f75 3. 934db87 4. aef0f96 5. dee5009 6. 2e6e63e 7. f714e12 8. 009a3ba 9. c28747d 10. 6596e65 11. d6a2fb7 12. 57b733f 13. 1422df6 14. dbb3427 15. 6b3da47 16. 1baeb21 17. 7bd8e06 18. afaede9 19. 986d5b1 20. 6925546 21. d723f24 22. 065c780 23. d47baa8 24. a37e651 25. fd8e270 26. af7ece4 27. 47d7be2 28. 3c9406d 29. e4d71d1 30. 05e9e4e 31. db47d6c - #28558: Implement the schema for PayPal PayFloPro (reported by @magento-engcom-team) has been fixed in #28821 by @Usik2203 in 2.4-develop branch Related commits: 1. d29468d 2. e798f75 3. 934db87 4. aef0f96 5. dee5009 6. 2e6e63e 7. f714e12 8. 009a3ba 9. c28747d 10. 6596e65 11. d6a2fb7 12. 57b733f 13. 1422df6 14. dbb3427 15. 6b3da47 16. 1baeb21 17. 7bd8e06 18. afaede9 19. 986d5b1 20. 6925546 21. d723f24 22. 065c780 23. d47baa8 24. a37e651 25. fd8e270 26. af7ece4 27. 47d7be2 28. 3c9406d 29. e4d71d1 30. 05e9e4e 31. db47d6c
- Loading branch information
Showing
8 changed files
with
438 additions
and
4 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
app/code/Magento/PaypalGraphQl/Model/Plugin/Cart/PayflowPro/SetPaymentMethodOnCart.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\PaypalGraphQl\Model\Plugin\Cart\PayflowPro; | ||
|
||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Paypal\Model\Config; | ||
use Magento\Quote\Model\Quote; | ||
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool; | ||
use Magento\Sales\Model\Order\Payment\Repository as PaymentRepository; | ||
use Magento\PaypalGraphQl\Observer\PayflowProSetCcData; | ||
|
||
/** | ||
* Set additionalInformation on payment for PayflowPro method | ||
*/ | ||
class SetPaymentMethodOnCart | ||
{ | ||
/** | ||
* @var PaymentRepository | ||
*/ | ||
private $paymentRepository; | ||
|
||
/** | ||
* @var AdditionalDataProviderPool | ||
*/ | ||
private $additionalDataProviderPool; | ||
|
||
/** | ||
* @param PaymentRepository $paymentRepository | ||
* @param AdditionalDataProviderPool $additionalDataProviderPool | ||
*/ | ||
public function __construct( | ||
PaymentRepository $paymentRepository, | ||
AdditionalDataProviderPool $additionalDataProviderPool | ||
) { | ||
$this->paymentRepository = $paymentRepository; | ||
$this->additionalDataProviderPool = $additionalDataProviderPool; | ||
} | ||
|
||
/** | ||
* Set redirect URL paths on payment additionalInformation | ||
* | ||
* @param \Magento\QuoteGraphQl\Model\Cart\SetPaymentMethodOnCart $subject | ||
* @param mixed $result | ||
* @param Quote $cart | ||
* @param array $paymentData | ||
* @return void | ||
* @throws GraphQlInputException | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterExecute( | ||
\Magento\QuoteGraphQl\Model\Cart\SetPaymentMethodOnCart $subject, | ||
$result, | ||
Quote $cart, | ||
array $paymentData | ||
): void { | ||
$paymentData = $this->additionalDataProviderPool->getData(Config::METHOD_PAYFLOWPRO, $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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/code/Magento/PaypalGraphQl/Observer/PayflowProSetCcData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\PaypalGraphQl\Observer; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Payment\Observer\AbstractDataAssignObserver; | ||
use Magento\Quote\Api\Data\PaymentInterface; | ||
|
||
/** | ||
* Class PayflowProSetCcData set CcData to quote payment | ||
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse) | ||
*/ | ||
class PayflowProSetCcData extends AbstractDataAssignObserver | ||
{ | ||
const XML_PATH_PAYMENT_PAYFLOWPRO_CC_VAULT_ACTIVE = "payment/payflowpro_cc_vault/active"; | ||
const IS_ACTIVE_PAYMENT_TOKEN_ENABLER = "is_active_payment_token_enabler"; | ||
|
||
/** | ||
* Core store config | ||
* | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
/** | ||
* @param ScopeConfigInterface $scopeConfig | ||
*/ | ||
public function __construct( | ||
ScopeConfigInterface $scopeConfig | ||
) { | ||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
/** | ||
* Set CcData | ||
* | ||
* @param Observer $observer | ||
* | ||
* @throws GraphQlInputException | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
$dataObject = $this->readDataArgument($observer); | ||
$additionalData = $dataObject->getData(PaymentInterface::KEY_ADDITIONAL_DATA); | ||
$paymentModel = $this->readPaymentModelArgument($observer); | ||
|
||
if (!isset($additionalData['cc_details'])) { | ||
return; | ||
} | ||
|
||
if ($this->isPayflowProVaultEnable()) { | ||
if (!isset($additionalData[self::IS_ACTIVE_PAYMENT_TOKEN_ENABLER])) { | ||
$paymentModel->setData(self::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, false); | ||
} | ||
|
||
$paymentModel->setData( | ||
self::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, | ||
$additionalData[self::IS_ACTIVE_PAYMENT_TOKEN_ENABLER] | ||
); | ||
} else { | ||
$paymentModel->setData(self::IS_ACTIVE_PAYMENT_TOKEN_ENABLER, false); | ||
} | ||
|
||
$ccData = $additionalData['cc_details']; | ||
$paymentModel->setCcType($ccData['cc_type']); | ||
$paymentModel->setCcExpYear($ccData['cc_exp_year']); | ||
$paymentModel->setCcExpMonth($ccData['cc_exp_month']); | ||
$paymentModel->setCcLast4($ccData['cc_last_4']); | ||
} | ||
|
||
/** | ||
* Check if payflowpro vault is enable | ||
* | ||
* @return bool | ||
*/ | ||
private function isPayflowProVaultEnable() | ||
{ | ||
return (bool)$this->scopeConfig->getValue(self::XML_PATH_PAYMENT_PAYFLOWPRO_CC_VAULT_ACTIVE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.