Skip to content

Commit 6152fd0

Browse files
committed
AC2093:Added payment funding source on review page for paypal
1 parent 44a86cb commit 6152fd0

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,12 @@ protected function _beforeToHtml()
306306

307307
return parent::_beforeToHtml();
308308
}
309+
310+
public function getPaypalFundingSource()
311+
{
312+
if ($this->_quote->getPayment()->getPaypalFundingSource()) {
313+
return ucfirst($this->_quote->getPayment()->getPaypalFundingSource());
314+
}
315+
return null;
316+
}
309317
}

app/code/Magento/Paypal/Controller/Express/OnAuthorization.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public function execute(): ResultInterface
116116
$controllerResult = $this->resultFactory->create(ResultFactory::TYPE_JSON);
117117
$payerId = $this->getRequest()->getParam('payerId');
118118
$tokenId = $this->getRequest()->getParam('paymentToken');
119+
$fundingSource = $this->getRequest()->getParam('paypalFundingSource');
119120

120121
try {
121122
$quote = $this->_getQuote();
@@ -128,7 +129,7 @@ public function execute(): ResultInterface
128129
/** Populate checkout object with new data */
129130
$this->_initCheckout($quote);
130131
/** Populate quote with information about billing and shipping addresses*/
131-
$this->_checkout->returnFromPaypal($tokenId, $payerId);
132+
$this->_checkout->returnFromPaypal($tokenId, $payerId, $fundingSource);
132133
if ($this->_checkout->canSkipOrderReviewStep()) {
133134
$this->_checkout->place($tokenId);
134135
$order = $this->_checkout->getOrder();

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public function canSkipOrderReviewStep()
614614
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
615615
* @SuppressWarnings(PHPMD.NPathComplexity)
616616
*/
617-
public function returnFromPaypal($token, string $payerIdentifier = null)
617+
public function returnFromPaypal($token, string $payerIdentifier = null, $fundingSource = null)
618618
{
619619
$this->_getApi()
620620
->setToken($token)
@@ -689,6 +689,9 @@ public function returnFromPaypal($token, string $payerIdentifier = null)
689689
$payment = $quote->getPayment();
690690
$payment->setMethod($this->_methodType);
691691
$this->_paypalInfo->importToPayment($this->_getApi(), $payment);
692+
if ($fundingSource) {
693+
$payment->setPaypalFundingSource($fundingSource);
694+
}
692695
$payerId = $payerIdentifier ? : $this->_getApi()->getPayerId();
693696
$payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $payerId)
694697
->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use Magento\Paypal\Block\Express\Review;
101101
<div class="box box-order-billing-address">
102102
<strong class="box-title"><span><?= $escaper->escapeHtml(__('Payment Method')) ?></span></strong>
103103
<div class="box-content">
104-
<?= $escaper->escapeHtml($block->getPaymentMethodTitle()) ?><br>
104+
<?= $escaper->escapeHtml($block->getPaypalFundingSource() ?? $block->getPaymentMethodTitle()) ?><br>
105105
<?= $escaper->escapeHtml($block->getEmail()) ?> <br>
106106
<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png"
107107
alt="<?= $block->escapeHtml(__('Buy now with PayPal')) ?>"/>

app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout-smart-buttons.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ define([
77
'underscore',
88
'jquery',
99
'Magento_Paypal/js/in-context/paypal-sdk',
10+
'Magento_Customer/js/customer-data',
1011
'domReady!'
11-
], function (_, $, paypalSdk) {
12+
], function (_, $, paypalSdk, customerData) {
1213
'use strict';
1314

1415
/**
@@ -47,6 +48,7 @@ define([
4748
var params = {
4849
paymentToken: data.orderID,
4950
payerId: data.payerID,
51+
paypalFundingSource: customerData.get('paypal-funding-source'),
5052
'form_key': clientConfig.formKey
5153
};
5254

@@ -56,8 +58,10 @@ define([
5658
$.post(clientConfig.onAuthorizeUrl, params).done(function (res) {
5759
clientConfig.rendererComponent
5860
.afterOnAuthorize(res, deferred.resolve, deferred.reject, actions);
61+
customerData.set('paypal-funding-source', '');
5962
}).fail(function (jqXHR, textStatus, err) {
6063
clientConfig.rendererComponent.catchOnAuthorize(err, deferred.resolve, deferred.reject);
64+
customerData.set('paypal-funding-source', '');
6165
});
6266
});
6367
}).promise();
@@ -97,7 +101,8 @@ define([
97101
/**
98102
* Execute logic on Paypal button click
99103
*/
100-
onClick: function () {
104+
onClick: function (data) {
105+
customerData.set('paypal-funding-source', data.fundingSource);
101106
clientConfig.rendererComponent.validate();
102107
clientConfig.rendererComponent.onClick();
103108
},

app/code/Magento/Quote/etc/db_schema.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@
456456
<column xsi:type="text" name="additional_data" nullable="true" comment="Additional Data"/>
457457
<column xsi:type="varchar" name="cc_ss_issue" nullable="true" length="255" comment="Cc Ss Issue"/>
458458
<column xsi:type="text" name="additional_information" nullable="true" comment="Additional Information"/>
459+
<column xsi:type="varchar" name="paypal_funding_source" nullable="true" length="255" comment="Funding source"/>
459460
<constraint xsi:type="primary" referenceId="PRIMARY">
460461
<column name="payment_id"/>
461462
</constraint>

0 commit comments

Comments
 (0)