Skip to content

Commit 4659f2d

Browse files
committed
Added paypal funding source on order review page
1 parent caf390a commit 4659f2d

File tree

5 files changed

+60
-15
lines changed

5 files changed

+60
-15
lines changed

app/code/Magento/Paypal/Block/Express/Review.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace Magento\Paypal\Block\Express;
88

99
use Magento\Framework\Pricing\PriceCurrencyInterface;
10-
use Magento\Paypal\Model\Express\Checkout;
1110
use Magento\Quote\Model\Quote\Address\Rate;
1211

1312
/**
@@ -307,17 +306,4 @@ protected function _beforeToHtml()
307306

308307
return parent::_beforeToHtml();
309308
}
310-
311-
/**
312-
* Return paypal funding source
313-
*
314-
* @return string|null
315-
*/
316-
public function getPaypalFundingSource()
317-
{
318-
if ($this->_quote->getPayment()->getAdditionalInformation(Checkout::PAYMENT_INFO_FUNDING_SOURCE)) {
319-
return ucfirst($this->_quote->getPayment()->getAdditionalInformation(Checkout::PAYMENT_INFO_FUNDING_SOURCE));
320-
}
321-
return null;
322-
}
323309
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
namespace Magento\Paypal\ViewModel;
9+
10+
use Magento\Checkout\Model\Session;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
use Magento\Paypal\Model\Express\Checkout;
13+
14+
/**
15+
* Provides Paypal funding source data
16+
*
17+
*/
18+
class PaypalFundingSourceDataProvider implements ArgumentInterface
19+
{
20+
/**
21+
* @var Session
22+
*/
23+
private $checkoutSession;
24+
25+
/**
26+
* @param Session $checkoutSession
27+
*/
28+
public function __construct(
29+
Session $checkoutSession
30+
) {
31+
$this->checkoutSession = $checkoutSession;
32+
}
33+
34+
/**
35+
* Return paypal funding source
36+
*
37+
* @return string|null
38+
*/
39+
public function getPaypalFundingSource()
40+
{
41+
$quote = $this->checkoutSession->getQuote();
42+
if ($quote->getPayment()->getAdditionalInformation(Checkout::PAYMENT_INFO_FUNDING_SOURCE)) {
43+
return ucfirst($quote->getPayment()->getAdditionalInformation(
44+
Checkout::PAYMENT_INFO_FUNDING_SOURCE
45+
));
46+
}
47+
return null;
48+
}
49+
}

app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
</referenceContainer>
2121
<referenceContainer name="content">
2222
<block class="Magento\Paypal\Block\Express\Review" name="paypal.express.review" template="Magento_Paypal::express/review.phtml">
23+
<arguments>
24+
<argument name="PaypalFundingSourceDataProvider" xsi:type="object">Magento\Paypal\ViewModel\PaypalFundingSourceDataProvider</argument>
25+
</arguments>
2326
<block class="Magento\Paypal\Block\Express\Review" name="express.review.shipping.method" as="shipping_method" template="Magento_Paypal::express/review/shipping/method.phtml"/>
2427
<block class="Magento\Framework\View\Element\Text\ListText" name="paypal.additional.actions">
2528
<block class="Magento\Checkout\Block\Cart\Coupon" name="paypal.cart.coupon" as="coupon" template="Magento_Checkout::cart/coupon.phtml"/>

app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
</referenceContainer>
2121
<referenceContainer name="content">
2222
<block class="Magento\Paypal\Block\Express\Review" name="paypal.express.review" template="Magento_Paypal::express/review.phtml">
23+
<arguments>
24+
<argument name="PaypalFundingSourceDataProvider" xsi:type="object">Magento\Paypal\ViewModel\PaypalFundingSourceDataProvider</argument>
25+
</arguments>
2326
<action method="setControllerPath">
2427
<argument name="prefix" xsi:type="string">paypal/payflowexpress</argument>
2528
</action>

app/code/Magento/Paypal/view/frontend/templates/express/review.phtml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ use Magento\Paypal\Block\Express\Review;
1313
* @var Escaper $escaper
1414
* @var SecureHtmlRenderer $secureRenderer
1515
*/
16+
17+
/** @var \Magento\Paypal\ViewModel\PaypalFundingSourceDataProvider $paypalFundingSourceDataProvider */
18+
$paypalFundingSourceDataProvider = $block->getData('PaypalFundingSourceDataProvider');
1619
?>
1720
<div class="paypal-review view">
1821
<div class="block block-order-details-view">
@@ -101,7 +104,8 @@ use Magento\Paypal\Block\Express\Review;
101104
<div class="box box-order-billing-address">
102105
<strong class="box-title"><span><?= $escaper->escapeHtml(__('Payment Method')) ?></span></strong>
103106
<div class="box-content">
104-
<?= $escaper->escapeHtml($block->getPaypalFundingSource() ?? $block->getPaymentMethodTitle()) ?><br>
107+
<?= $escaper->escapeHtml($paypalFundingSourceDataProvider->getPaypalFundingSource()
108+
?? $block->getPaymentMethodTitle()) ?><br>
105109
<?= $escaper->escapeHtml($block->getEmail()) ?> <br>
106110
<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png"
107111
alt="<?= $block->escapeHtml(__('Buy now with PayPal')) ?>"/>

0 commit comments

Comments
 (0)