From 16f4e49bd2f9667410b85b041b2c84b80998638e Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:57:50 +0200 Subject: [PATCH 1/8] Bump version to v8.3.6.3 --- config.xml | 2 +- ps_checkout.php | 4 ++-- upgrade/upgrade-8.3.6.3.php | 43 +++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 upgrade/upgrade-8.3.6.3.php diff --git a/config.xml b/config.xml index 90b451ef7..15dcce3f8 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_checkout - + diff --git a/ps_checkout.php b/ps_checkout.php index 3084b1b90..53efbee6f 100755 --- a/ps_checkout.php +++ b/ps_checkout.php @@ -112,7 +112,7 @@ class Ps_checkout extends PaymentModule // Needed in order to retrieve the module version easier (in api call headers) than instanciate // the module each time to get the version - const VERSION = '8.3.6.2'; + const VERSION = '8.3.6.3'; const INTEGRATION_DATE = '2022-14-06'; @@ -133,7 +133,7 @@ public function __construct() // We cannot use the const VERSION because the const is not computed by addons marketplace // when the zip is uploaded - $this->version = '8.3.6.2'; + $this->version = '8.3.6.3'; $this->author = 'PrestaShop'; $this->currencies = true; $this->currencies_mode = 'checkbox'; diff --git a/upgrade/upgrade-8.3.6.3.php b/upgrade/upgrade-8.3.6.3.php new file mode 100644 index 000000000..549752c4d --- /dev/null +++ b/upgrade/upgrade-8.3.6.3.php @@ -0,0 +1,43 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * Update main function for module version 8.3.6.3 + * + * @param Ps_checkout $module + * + * @return bool + */ +function upgrade_module_8_3_6_3($module) +{ + try { + $db = Db::getInstance(); + $db->update('pscheckout_cart', ['paypal_token' => null, 'paypal_token_expire' => null], 'paypal_token IS NOT NULL', 0, true); + $db->update('pscheckout_cart', ['paypal_status' => 'CANCELED'], 'paypal_status = "CREATED" AND date_add < DATE_SUB(NOW(), INTERVAL 1 HOUR)'); + $db->delete('pscheckout_cart', 'paypal_order IS NULL OR paypal_order = ""'); + } catch (Exception $exception) { + PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id); + } + + return true; +} From e34e3bdea98c24fec6c121222ddf31dc300f9558 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:06:22 +0200 Subject: [PATCH 2/8] Remove comments in javascript --- _dev/js/front/webpack/profile/build.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_dev/js/front/webpack/profile/build.js b/_dev/js/front/webpack/profile/build.js index 794d4870d..5948fc653 100644 --- a/_dev/js/front/webpack/profile/build.js +++ b/_dev/js/front/webpack/profile/build.js @@ -27,6 +27,9 @@ module.exports = merge(common, { minimizer: [ new TerserPlugin({ terserOptions: { + format: { + comments: false + }, parse: { // We want terser to parse ecma 8 code. However, we don't want it // to apply any minification steps that turns valid ecma 5 code @@ -62,7 +65,8 @@ module.exports = merge(common, { // https://github.com/facebook/create-react-app/issues/2488 ascii_only: true } - } + }, + extractComments: false }) ] } From 62402d56f5ad209b8a5101a3db850d8eb9a3c5c9 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:09:44 +0200 Subject: [PATCH 3/8] Remove PayPal Client Token from order payload --- src/Builder/Payload/OrderPayloadBuilder.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Builder/Payload/OrderPayloadBuilder.php b/src/Builder/Payload/OrderPayloadBuilder.php index 55023a5df..cbdcbe431 100644 --- a/src/Builder/Payload/OrderPayloadBuilder.php +++ b/src/Builder/Payload/OrderPayloadBuilder.php @@ -177,16 +177,6 @@ public function buildBaseNode() ], ]; - $psCheckoutCartCollection = new \PrestaShopCollection('PsCheckoutCart'); - $psCheckoutCartCollection->where('id_cart', '=', (int) Context::getContext()->cart->id); - - /** @var \PsCheckoutCart|false $psCheckoutCart */ - $psCheckoutCart = $psCheckoutCartCollection->getFirst(); - - if (false === $this->isPatch && false !== $psCheckoutCart && false === empty($psCheckoutCart->paypal_token)) { - $node['token'] = $psCheckoutCart->paypal_token; - } - if (true === $this->isUpdate) { $node['id'] = $this->paypalOrderId; } else { From 6b9235694f8558c985db28362ba834445a163a76 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:24:38 +0200 Subject: [PATCH 4/8] Fix javascript issues --- .../1_7/conditions-checkbox.component.js | 22 +- _dev/js/front/src/service/paypal.service.js | 188 +----------------- .../query-selector-ps1_6.service.js | 68 +++---- .../query-selector-ps1_7.service.js | 8 +- 4 files changed, 45 insertions(+), 241 deletions(-) diff --git a/_dev/js/front/src/components/1_7/conditions-checkbox.component.js b/_dev/js/front/src/components/1_7/conditions-checkbox.component.js index 590dfdead..365054c08 100644 --- a/_dev/js/front/src/components/1_7/conditions-checkbox.component.js +++ b/_dev/js/front/src/components/1_7/conditions-checkbox.component.js @@ -24,25 +24,25 @@ export class ConditionsCheckboxComponent extends BaseComponent { }; created() { - this.conditionsCheckboxes = this.querySelectorService.getConditionsCheckboxes(); + this.conditionsCheckboxes = + this.querySelectorService.getConditionsCheckboxes(); } isActive() { - return this.conditionsCheckboxes.length > 0; + return this.conditionsCheckboxes?.length > 0; } isChecked() { - return this.isActive() - ? this.conditionsCheckboxes - .map(({ checked }) => checked) - .filter((value) => !value).length === 0 - : true; + if (this.isActive()) { + return this.conditionsCheckboxes?.every(({ checked }) => checked); + } + + return true; } onChange(listener) { - this.isActive() && - this.conditionsCheckboxes.forEach((checkbox) => - checkbox.addEventListener('change', () => listener()) - ); + this.conditionsCheckboxes?.forEach((checkbox) => + checkbox.addEventListener('change', listener) + ); } } diff --git a/_dev/js/front/src/service/paypal.service.js b/_dev/js/front/src/service/paypal.service.js index b488599f5..1133d892c 100644 --- a/_dev/js/front/src/service/paypal.service.js +++ b/_dev/js/front/src/service/paypal.service.js @@ -75,13 +75,6 @@ import { BaseClass } from '../core/dependency-injection/base.class'; -/** - * @typedef PaypalHostedFieldsEvents - * @type {*} - * - * @property {function} createOrder - */ - export class PayPalService extends BaseClass { static Inject = { configPayPal: 'PayPalSdkConfig', @@ -142,162 +135,6 @@ export class PayPalService extends BaseClass { return {}; } - /** - * @param {*} fieldSelectors - * @param {string} fieldSelectors.number - * @param {string} fieldSelectors.cvv - * @param {string} fieldSelectors.expirationDate - * @param {PaypalHostedFieldsEvents} events - * @returns {*} - */ - getHostedFields(fieldSelectors, events) { - const style = { - ...{ - input: { - 'font-size': '17px', - 'font-family': 'helvetica, tahoma, calibri, sans-serif', - color: '#3a3a3a' - }, - ':focus': { - color: 'black' - } - }, - ...(this.configPayPal.hostedFieldsCustomization || {}), - ...(window.ps_checkout.hostedFieldsCustomization || {}) - }; - - return this.sdk.HostedFields.render({ - styles: style, - fields: { - number: { - selector: fieldSelectors.number, - placeholder: this.$('paypal.hosted-fields.placeholder.card-number') - }, - cvv: { - selector: fieldSelectors.cvv, - placeholder: this.$('paypal.hosted-fields.placeholder.cvv') - }, - expirationDate: { - selector: fieldSelectors.expirationDate, - placeholder: this.$( - 'paypal.hosted-fields.placeholder.expiration-date' - ) - } - }, - ...events - }) - .then((hostedFields) => { - const numberField = document.querySelector(fieldSelectors.number); - const cvvField = document.querySelector(fieldSelectors.cvv); - const expirationDateField = document.querySelector( - fieldSelectors.expirationDate - ); - - const numberLabel = document.querySelector( - `label[for="${numberField.id}"]` - ); - const cvvLabel = document.querySelector(`label[for="${cvvField.id}"]`); - const expirationDateLabel = document.querySelector( - `label[for="${expirationDateField.id}"]` - ); - - numberLabel.innerHTML = this.$( - 'paypal.hosted-fields.label.card-number' - ); - cvvLabel.innerHTML = this.$('paypal.hosted-fields.label.cvv'); - expirationDateLabel.innerHTML = this.$( - 'paypal.hosted-fields.label.expiration-date' - ); - - return hostedFields; - }) - .then((hostedFields) => { - hostedFields.on('focus', (event) => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsFocus', { - detail: { ps_checkout: window.ps_checkout, event: event } - }) - ); - }); - hostedFields.on('blur', (event) => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsBlur', { - detail: { ps_checkout: window.ps_checkout, event: event } - }) - ); - }); - hostedFields.on('empty', (event) => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsEmpty', { - detail: { ps_checkout: window.ps_checkout, event: event } - }) - ); - }); - hostedFields.on('notEmpty', (event) => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsNotEmpty', { - detail: { ps_checkout: window.ps_checkout, event: event } - }) - ); - }); - hostedFields.on('validityChange', (event) => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsValidityChange', { - detail: { ps_checkout: window.ps_checkout, event: event } - }) - ); - }); - hostedFields.on('inputSubmitRequest', () => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsInputSubmitRequest', { - detail: { ps_checkout: window.ps_checkout } - }) - ); - }); - hostedFields.on('cardTypeChange', (event) => { - window.ps_checkout.events.dispatchEvent( - new CustomEvent('hostedFieldsCardTypeChange', { - detail: { ps_checkout: window.ps_checkout, event: event } - }) - ); - - // Change card bg depending on card type - if (event.cards.length === 1) { - document.querySelector('.default-credit-card').style.display = - 'none'; - - const cardImage = document.getElementById('card-image'); - cardImage.className = ''; - cardImage.classList.add(event.cards[0].type); - - document.querySelector('header').classList.add('header-slide'); - - // Change the CVV length for AmericanExpress cards - if (event.cards[0].code.size === 4) { - hostedFields.setAttribute({ - field: 'cvv', - attribute: 'placeholder', - value: 'XXXX' - }); - } - } else { - document.querySelector('.default-credit-card').style.display = - 'block'; - const cardImage = document.getElementById('card-image'); - cardImage.className = ''; - - hostedFields.setAttribute({ - field: 'cvv', - attribute: 'placeholder', - value: 'XXX' - }); - } - }); - - return hostedFields; - }); - } - /** * @param {*} fieldSelectors * @param {string} fieldSelectors.name @@ -325,17 +162,6 @@ export class PayPalService extends BaseClass { placeholder: this.$('paypal.hosted-fields.placeholder.cvv') }); - // await Promise.all( - // [ - // cardNameField.render(nameField), - // cardNumberField.render(numberField), - // cardCvvField.render(cvvField), - // cardExpiryField.render(expirationDateField) - // ] - // ).catch(e => { - // return console.error("Failed to render CardFields", e); - // }) ; - try { await numberField.render(fieldSelectors.number); await expiryField.render(fieldSelectors.expiry); @@ -374,9 +200,7 @@ export class PayPalService extends BaseClass { this.eligibleFundingSources = ( this.configPrestaShop.fundingSourcesSorted || paypalFundingSources ) - .filter( - (fundingSource) => paypalFundingSources.indexOf(fundingSource) >= 0 - ) + .filter((fundingSource) => paypalFundingSources.includes(fundingSource)) .map((fundingSource) => ({ name: fundingSource, mark: this.sdk.Marks({ fundingSource }) @@ -384,7 +208,7 @@ export class PayPalService extends BaseClass { .filter((fundingSource) => { if ( fundingSource.name === 'card' && - this.configPrestaShop.hostedFieldsEnabled && + this.isCardFieldsEnabled() && !this.isCardFieldsEligible() ) { console.warn( @@ -404,8 +228,8 @@ export class PayPalService extends BaseClass { return this.getEligibleFundingSources().contains(fundingSource); } - isHostedFieldsEligible() { - return this.sdk.HostedFields && this.sdk.HostedFields.isEligible(); + isCardFieldsEnabled() { + return this.sdk.CardFields && this.configPrestaShop.hostedFieldsEnabled; } isCardFieldsEligible() { @@ -477,9 +301,7 @@ export class PayPalService extends BaseClass { } /** - * @param {string} placement - * @param {string} amount - * @param {PaypalPayLaterOfferEvents} events + * @returns {object} */ getPaymentFieldsCustomizationStyle() { return { diff --git a/_dev/js/front/src/service/query-selector.service/query-selector-ps1_6.service.js b/_dev/js/front/src/service/query-selector.service/query-selector-ps1_6.service.js index d6a544637..1f302587b 100644 --- a/_dev/js/front/src/service/query-selector.service/query-selector-ps1_6.service.js +++ b/_dev/js/front/src/service/query-selector.service/query-selector-ps1_6.service.js @@ -65,9 +65,7 @@ export class QuerySelectorPs1_6Service { } static getExpressCheckoutButtonContainerCart() { - return this.querySelector( - SELECTORS.EXPRESS_CHECKOUT_CONTAINER_CART_PAGE - ); + return this.querySelector(SELECTORS.EXPRESS_CHECKOUT_CONTAINER_CART_PAGE); } static getExpressCheckoutButtonContainerCheckout() { @@ -83,72 +81,56 @@ export class QuerySelectorPs1_6Service { } static getCardFieldsFormContainer() { - return this.querySelector( - SELECTORS.CARD_FIELDS.FORM - ); + return this.querySelector(SELECTORS.CARD_FIELDS.FORM); } static getCardFieldsNameInputContainer() { - return this.querySelector( - SELECTORS.CARD_FIELDS.NAME - ); + return this.querySelector(SELECTORS.CARD_FIELDS.NAME); } static getCardFieldsNameError() { - return this.querySelector( - SELECTORS.CARD_FIELDS.NAME_ERROR - ); + return this.querySelector(SELECTORS.CARD_FIELDS.NAME_ERROR); } static getCardFieldsNumberInputContainer() { - return this.querySelector( - SELECTORS.CARD_FIELDS.NUMBER - ); + return this.querySelector(SELECTORS.CARD_FIELDS.NUMBER); } static getCardFieldsNumberError() { - return this.querySelector( - SELECTORS.CARD_FIELDS.NUMBER_ERROR - ); + return this.querySelector(SELECTORS.CARD_FIELDS.NUMBER_ERROR); } static getCardFieldsVendorError() { - return this.querySelector( - SELECTORS.CARD_FIELDS.VENDOR_ERROR - ); + return this.querySelector(SELECTORS.CARD_FIELDS.VENDOR_ERROR); } static getCardFieldsExpiryInputContainer() { - return this.querySelector( - SELECTORS.CARD_FIELDS.EXPIRY - ); + return this.querySelector(SELECTORS.CARD_FIELDS.EXPIRY); } static getCardFieldsExpiryError() { - return this.querySelector( - SELECTORS.CARD_FIELDS.EXPIRY_ERROR - ); + return this.querySelector(SELECTORS.CARD_FIELDS.EXPIRY_ERROR); } static getCardFieldsCvvInputContainer() { - return this.querySelector( - SELECTORS.CARD_FIELDS.CVV - ); + return this.querySelector(SELECTORS.CARD_FIELDS.CVV); } static getCardFieldsCvvError() { - return this.querySelector( - SELECTORS.CARD_FIELDS.CVV_ERROR - ); + return this.querySelector(SELECTORS.CARD_FIELDS.CVV_ERROR); } static getPayLaterOfferMessageContainerSelector(placement) { switch (placement) { case 'product': - return this.querySelector(SELECTORS.PAY_LATER_OFFER_MESSAGE_CONTAINER_PRODUCT); + return this.querySelector( + SELECTORS.PAY_LATER_OFFER_MESSAGE_CONTAINER_PRODUCT + ); case 'cart': case 'payment': - return this.querySelector(SELECTORS.PAY_LATER_OFFER_MESSAGE_CONTAINER_CART_SUMMARY); + return this.querySelector( + SELECTORS.PAY_LATER_OFFER_MESSAGE_CONTAINER_CART_SUMMARY + ); default: return; } @@ -178,12 +160,10 @@ export class QuerySelectorPs1_6Service { } static querySelectorAll(selector) { - let elements = Array.prototype.slice.call( - document.querySelectorAll(selector) - ); + const elements = [...document.querySelectorAll(selector)]; - if (!elements || elements.length === 0) { - console.error('HTMLElement selector ' + selector + ' not found.'); + if (elements.length === 0) { + console.error(`HTMLElement selector ${selector} not found.`); } return elements; @@ -192,9 +172,13 @@ export class QuerySelectorPs1_6Service { static getPaymentMethodLogoContainer(placement) { switch (placement) { case 'product': - return document.querySelector(SELECTORS.PAYMENT_METHOD_LOGO_PRODUCT_CONTAINER); + return document.querySelector( + SELECTORS.PAYMENT_METHOD_LOGO_PRODUCT_CONTAINER + ); case 'cart': - return document.querySelector(SELECTORS.PAYMENT_METHOD_LOGO_CART_CONTAINER); + return document.querySelector( + SELECTORS.PAYMENT_METHOD_LOGO_CART_CONTAINER + ); default: return; } diff --git a/_dev/js/front/src/service/query-selector.service/query-selector-ps1_7.service.js b/_dev/js/front/src/service/query-selector.service/query-selector-ps1_7.service.js index c9ed7c437..5fb7a1bab 100644 --- a/_dev/js/front/src/service/query-selector.service/query-selector-ps1_7.service.js +++ b/_dev/js/front/src/service/query-selector.service/query-selector-ps1_7.service.js @@ -180,12 +180,10 @@ export class QuerySelectorPs1_7Service { } static querySelectorAll(selector) { - let elements = Array.prototype.slice.call( - document.querySelectorAll(selector) - ); + const elements = [...document.querySelectorAll(selector)]; - if (!elements || elements.length === 0) { - console.error('HTMLElement selector ' + selector + ' not found.'); + if (elements.length === 0) { + console.error(`HTMLElement selector ${selector} not found.`); } return elements; From 59f078bcc6b01ae7df79b78acd07aafe3e915256 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:53:52 +0200 Subject: [PATCH 5/8] Fix issue when PayPal Order data not available --- src/PayPal/Order/PayPalOrderSummaryViewBuilder.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php b/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php index faad6437e..a78527f61 100644 --- a/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php +++ b/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php @@ -103,6 +103,10 @@ public function build(Order $order) $orderPayPal = []; } + if ($orderPayPal === false) { + throw new PsCheckoutException('Unable to retrieve PayPal order data'); + } + $orderPayPalDataProvider = new PaypalOrderDataProvider($orderPayPal); $checkoutDataProvider = new PsCheckoutDataProvider($psCheckoutCart); From 5582f6c86c5fc230571622e7d0f06c5c3d38a420 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:46:21 +0200 Subject: [PATCH 6/8] Check PayPal Order before display express checkout --- ps_checkout.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ps_checkout.php b/ps_checkout.php index 53efbee6f..052fe691c 100755 --- a/ps_checkout.php +++ b/ps_checkout.php @@ -497,7 +497,7 @@ public function hookActionCartUpdateQuantityBefore() return; } - if ($psCheckoutCart->isExpressCheckout || !$this->context->cart->nbProducts()) { + if ($psCheckoutCart->isExpressCheckout || !$psCheckoutCart->isOrderAvailable() || !$this->context->cart->nbProducts()) { $this->context->cookie->__unset('paypalEmail'); } } @@ -554,7 +554,7 @@ public function hookDisplayPayment() /** @var PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration $configurationPayPal */ $configurationPayPal = $this->getService('ps_checkout.paypal.configuration'); - $isExpressCheckout = false !== $psCheckoutCart && $psCheckoutCart->isExpressCheckout; + $isExpressCheckout = false !== $psCheckoutCart && $psCheckoutCart->isExpressCheckout && $psCheckoutCart->isOrderAvailable(); $this->context->smarty->assign([ 'cancelTranslatedText' => $this->l('Choose another payment method'), @@ -1374,7 +1374,7 @@ public function hookDisplayPaymentTop() /** @var PsCheckoutCart|false $psCheckoutCart */ $psCheckoutCart = $psCheckoutCartRepository->findOneByCartId((int) $this->context->cart->id); - $isExpressCheckout = false !== $psCheckoutCart && $psCheckoutCart->isExpressCheckout; + $isExpressCheckout = false !== $psCheckoutCart && $psCheckoutCart->isExpressCheckout && $psCheckoutCart->isOrderAvailable(); $this->context->smarty->assign([ 'cancelTranslatedText' => $this->l('Choose another payment method'), From 0f240328a880ceddd5d63eb156492b2a6c82d004 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:28:20 +0200 Subject: [PATCH 7/8] Do not send invalid email address --- src/Builder/Payload/OrderPayloadBuilder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Builder/Payload/OrderPayloadBuilder.php b/src/Builder/Payload/OrderPayloadBuilder.php index cbdcbe431..d886b8cb8 100644 --- a/src/Builder/Payload/OrderPayloadBuilder.php +++ b/src/Builder/Payload/OrderPayloadBuilder.php @@ -222,10 +222,13 @@ public function buildPayerNode() 'given_name' => (string) $this->cart['addresses']['invoice']->firstname, 'surname' => (string) $this->cart['addresses']['invoice']->lastname, ], - 'email_address' => (string) $this->cart['customer']->email, 'address' => $this->getAddressPortable('invoice'), ]; + if (\Validate::isEmail($this->cart['customer']->email)) { + $node['payer']['email_address'] = (string) $this->cart['customer']->email; + } + // Add optional birthdate if provided if (!empty($this->cart['customer']->birthday) && $this->cart['customer']->birthday !== '0000-00-00') { $node['payer']['birth_date'] = (string) $this->cart['customer']->birthday; From 3147cdf1d41df71cfd4f333419c4073323d5b608 Mon Sep 17 00:00:00 2001 From: Matt75 <5262628+Matt75@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:33:44 +0200 Subject: [PATCH 8/8] Set card payment source only for card-fields --- .../Order/CommandHandler/CreatePayPalOrderCommandHandler.php | 2 +- .../Order/CommandHandler/UpdatePayPalOrderCommandHandler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php b/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php index d3a9f4233..4cf0cddfb 100644 --- a/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php +++ b/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php @@ -70,7 +70,7 @@ public function handle(CreatePayPalOrderCommand $command) { $cartPresenter = (new CartPresenter())->present(); $builder = new OrderPayloadBuilder($cartPresenter); - $builder->setIsCard($command->getFundingSource() === 'card'); + $builder->setIsCard($command->getFundingSource() === 'card' && $command->isHostedFields()); $builder->setExpressCheckout($command->isExpressCheckout()); if ($this->shopContext->isShop17()) { diff --git a/src/PayPal/Order/CommandHandler/UpdatePayPalOrderCommandHandler.php b/src/PayPal/Order/CommandHandler/UpdatePayPalOrderCommandHandler.php index 57eb02a1c..e59ad0d5c 100644 --- a/src/PayPal/Order/CommandHandler/UpdatePayPalOrderCommandHandler.php +++ b/src/PayPal/Order/CommandHandler/UpdatePayPalOrderCommandHandler.php @@ -78,7 +78,7 @@ public function handle(UpdatePayPalOrderCommand $command) $builder = new OrderPayloadBuilder($cartPresenter, true); $builder->setIsUpdate(true); $builder->setPaypalOrderId($command->getPayPalOrderId()->getValue()); - $builder->setIsCard($command->getFundingSource() === 'card'); + $builder->setIsCard($command->getFundingSource() === 'card' && $command->isHostedFields()); $builder->setExpressCheckout($command->isExpressCheckout()); if ($this->shopContext->isShop17()) {