Skip to content

Commit 87ae5d8

Browse files
committed
MC-32657: Deliver PR
1 parent d026850 commit 87ae5d8

File tree

7 files changed

+66
-50
lines changed

7 files changed

+66
-50
lines changed

app/code/Magento/Paypal/Model/SmartButtonConfig.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public function getConfig(string $page): array
9393
ScopeInterface::SCOPE_STORE
9494
);
9595

96-
9796
return [
9897
'styles' => $this->getButtonStyles($page),
9998
'isVisibleOnProductPage' => (bool)$this->config->getValue('visible_on_product'),
@@ -105,13 +104,15 @@ public function getConfig(string $page): array
105104
/**
106105
* Generate the url to download the Paypal SDK
107106
*
107+
* @param string $page
108+
*
108109
* @return string
109110
*/
110-
private function generatePaypalSdkUrl(string $page) : string
111+
private function generatePaypalSdkUrl(string $page): string
111112
{
112113
$clientId = (int)$this->config->getValue('sandbox_flag') ?
113114
$this->config->getValue('sandbox_client_id') : $this->config->getValue('client_id');
114-
$disallowedFunding = implode(",", $this->getDisallowedFunding());
115+
$disallowedFunding = implode(',', $this->getDisallowedFunding());
115116

116117
$commit = $page === 'checkout' ? 'true' : 'false';
117118

@@ -124,7 +125,7 @@ private function generatePaypalSdkUrl(string $page) : string
124125
'intent' => $this->getIntent(),
125126
];
126127
if ($disallowedFunding) {
127-
$params['disable-funding'] = $disallowedFunding;
128+
$params['disable-funding'] = $disallowedFunding;
128129
}
129130

130131
return self::BASE_URL . http_build_query($params);
@@ -168,7 +169,7 @@ private function getDisallowedFunding(): array
168169
$result);
169170

170171
//disable unsupported payment methods
171-
$result = array_merge($disallowedFundingArray, $this->unsupportedPaymentMethods);
172+
$result = array_merge($result, $this->unsupportedPaymentMethods);
172173

173174
return $result;
174175
}

app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public function testGetConfig(
110110
$isPaypalGuestCheckoutEnabled ? Config::EC_SOLUTION_TYPE_SOLE : Config::EC_SOLUTION_TYPE_MARK
111111
],
112112
['sandbox_flag', null, true],
113+
['paymentAction', null, 'Authorization'],
113114
['disable_funding_options', null, $disallowedFundings],
114115
["{$page}_page_button_customize", null, $isCustomize],
115116
["{$page}_page_button_layout", null, $layout],

app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
'mx',
2121
true,
2222
[
23-
'merchantId' => 'merchant',
24-
'environment' => 'sandbox',
25-
'locale' => 'es_MX',
26-
'allowedFunding' => ['ELV'],
27-
'disallowedFunding' => ['CREDIT'],
2823
'styles' => [
2924
'layout' => 'horizontal',
3025
'size' => 'small',
@@ -34,7 +29,9 @@
3429
'installmentperiod' => 0
3530
],
3631
'isVisibleOnProductPage' => false,
37-
'isGuestCheckoutAllowed' => true
32+
'isGuestCheckoutAllowed' => true,
33+
'sdkUrl' => 'https://www.paypal.com/sdk/js?commit=false&merchant-id=merchant&locale=es_MX&' .
34+
'intent=authorize&disable-funding=CREDIT'
3835
]
3936
],
4037
'checkout' => [
@@ -51,11 +48,6 @@
5148
'br',
5249
true,
5350
[
54-
'merchantId' => 'merchant',
55-
'environment' => 'sandbox',
56-
'locale' => 'en_BR',
57-
'allowedFunding' => ['CREDIT', 'ELV'],
58-
'disallowedFunding' => [],
5951
'styles' => [
6052
'layout' => 'horizontal',
6153
'size' => 'small',
@@ -65,7 +57,8 @@
6557
'installmentperiod' => 0
6658
],
6759
'isVisibleOnProductPage' => false,
68-
'isGuestCheckoutAllowed' => true
60+
'isGuestCheckoutAllowed' => true,
61+
'sdkUrl' => 'https://www.paypal.com/sdk/js?commit=false&merchant-id=merchant&locale=en_BR&intent=authorize'
6962
]
7063
],
7164
'mini_cart' => [
@@ -82,11 +75,6 @@
8275
'br',
8376
true,
8477
[
85-
'merchantId' => 'merchant',
86-
'environment' => 'sandbox',
87-
'locale' => 'en',
88-
'allowedFunding' => ['CREDIT', 'ELV'],
89-
'disallowedFunding' => [],
9078
'styles' => [
9179
'layout' => 'vertical',
9280
'size' => 'responsive',
@@ -95,7 +83,8 @@
9583
'label' => 'paypal'
9684
],
9785
'isVisibleOnProductPage' => false,
98-
'isGuestCheckoutAllowed' => true
86+
'isGuestCheckoutAllowed' => true,
87+
'sdkUrl' => 'https://www.paypal.com/sdk/js?commit=false&merchant-id=merchant&locale=en&intent=authorize'
9988
]
10089
],
10190
'product' => [
@@ -112,11 +101,6 @@
112101
'br',
113102
true,
114103
[
115-
'merchantId' => 'merchant',
116-
'environment' => 'sandbox',
117-
'locale' => 'en',
118-
'allowedFunding' => ['ELV'],
119-
'disallowedFunding' => ['CREDIT'],
120104
'styles' => [
121105
'layout' => 'vertical',
122106
'size' => 'responsive',
@@ -125,7 +109,9 @@
125109
'label' => 'paypal',
126110
],
127111
'isVisibleOnProductPage' => false,
128-
'isGuestCheckoutAllowed' => true
112+
'isGuestCheckoutAllowed' => true,
113+
'sdkUrl' => 'https://www.paypal.com/sdk/js?commit=false&merchant-id=merchant&locale=en&intent=authorize'
114+
. '&disable-funding=CREDIT'
129115
]
130116
],
131117
'checkout_with_paypal_guest_checkout_disabled' => [
@@ -142,11 +128,6 @@
142128
'br',
143129
false,
144130
[
145-
'merchantId' => 'merchant',
146-
'environment' => 'sandbox',
147-
'locale' => 'en_BR',
148-
'allowedFunding' => ['CREDIT', 'ELV'],
149-
'disallowedFunding' => ['CARD'],
150131
'styles' => [
151132
'layout' => 'horizontal',
152133
'size' => 'small',
@@ -156,7 +137,9 @@
156137
'installmentperiod' => 0
157138
],
158139
'isVisibleOnProductPage' => false,
159-
'isGuestCheckoutAllowed' => true
140+
'isGuestCheckoutAllowed' => true,
141+
'sdkUrl' => 'https://www.paypal.com/sdk/js?commit=false&merchant-id=merchant&locale=en_BR'
142+
. '&intent=authorize&disable-funding=CARD'
160143
]
161144
],
162145
];

app/code/Magento/Paypal/i18n/en_US.csv

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,3 @@ User,User
740740
"Please enter at least 0 and at most 65535","Please enter at least 0 and at most 65535"
741741
"Order is suspended as an account verification transaction is suspected to be fraudulent.","Order is suspended as an account verification transaction is suspected to be fraudulent."
742742
"Payment can't be accepted since transaction was rejected by merchant.","Payment can't be accepted since transaction was rejected by merchant."
743-
"Venmo","Venmo"
744-
"BanContact","BanContact"
745-
"eps","eps"
746-
"giropay","giropay"
747-
"iDEAL","iDEAL"
748-
"MyBank","MyBank"
749-
"Przelewy24","Przelewy24"
750-
"Sofort","Sofort"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<body>
10+
<referenceContainer name="after.body.start">
11+
<block class="Magento\Paypal\Block\Express\InContext\Component"
12+
name="paypal.express-in-context.component">
13+
<arguments>
14+
<argument name="is_button_context" xsi:type="boolean">true</argument>
15+
</arguments>
16+
</block>
17+
</referenceContainer>
18+
</body>
19+
</page>

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
/* eslint-disable max-nested-callbacks */
56
define([
67
'underscore',
78
'jquery',
@@ -10,6 +11,12 @@ define([
1011
], function (_, $, paypalSdk) {
1112
'use strict';
1213

14+
/**
15+
* Triggers beforePayment action on PayPal buttons
16+
*
17+
* @param {Object} clientConfig
18+
* @returns {Object} jQuery promise
19+
*/
1320
function performCreateOrder(clientConfig)
1421
{
1522
var params = {
@@ -30,6 +37,13 @@ define([
3037
}).promise();
3138
}
3239

40+
/**
41+
* Triggers beforeOnAuthorize action on PayPal buttons
42+
* @param {Object} clientConfig
43+
* @param {Object} data
44+
* @param {Object} actions
45+
* @returns {Object} jQuery promise
46+
*/
3347
function performOnApprove(clientConfig, data, actions)
3448
{
3549
var params = {
@@ -41,15 +55,18 @@ define([
4155
};
4256

4357
return $.Deferred(function (deferred) {
44-
clientConfig.rendererComponent.beforeOnAuthorize(deferred.resolve, deferred.reject, actions).then(function () {
45-
$.post(clientConfig.onAuthorizeUrl, params).done(function (res) {
46-
clientConfig.rendererComponent.afterOnAuthorize(res, deferred.resolve, deferred.reject, actions);
47-
}).fail(function (jqXHR, textStatus, err) {
48-
clientConfig.rendererComponent.catchOnAuthorize(err, deferred.resolve, deferred.reject);
58+
clientConfig.rendererComponent.beforeOnAuthorize(deferred.resolve, deferred.reject, actions)
59+
.then(function () {
60+
$.post(clientConfig.onAuthorizeUrl, params).done(function (res) {
61+
clientConfig.rendererComponent
62+
.afterOnAuthorize(res, deferred.resolve, deferred.reject, actions);
63+
}).fail(function (jqXHR, textStatus, err) {
64+
clientConfig.rendererComponent.catchOnAuthorize(err, deferred.resolve, deferred.reject);
65+
});
4966
});
50-
});
5167
}).promise();
5268
}
69+
5370
return function (clientConfig, element) {
5471
paypalSdk(clientConfig.sdkUrl).done(function (paypal) {
5572
paypal.Buttons({

app/code/Magento/Paypal/view/frontend/web/js/in-context/paypal-sdk.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
15
define([
26
'jquery'
37
], function ($) {
@@ -8,7 +12,6 @@ define([
812
/**
913
* Loads the PayPal SDK object
1014
* @param {String} paypalUrl - the url of the PayPal SDK
11-
* @param {Object} actions
1215
*/
1316
return function loadPaypalScript(paypalUrl)
1417
{

0 commit comments

Comments
 (0)