Skip to content

Commit

Permalink
Merge pull request #1220 from PrestaShopCorp/release/v6.3.6.2
Browse files Browse the repository at this point in the history
Release v6.3.6.2
  • Loading branch information
Matt75 committed Apr 2, 2024
2 parents 775184e + 8c25ba5 commit 360aaa0
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,11 @@ export class ExpressButtonProductComponent extends BaseComponent {

buttonContainer.append(this.checkoutExpressButton);

const {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
} = this.prestashopService.getProductDetails();

this.children.expressCheckoutButton = new ExpressCheckoutButtonComponent(
this.app,
{
fundingSource: 'paypal',
querySelector: '#ps-checkout-express-button',
data: {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
}
querySelector: '#ps-checkout-express-button'
}
).render();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,11 @@ export class PayLaterButtonProductComponent extends BaseComponent {
buttonContainer.append(this.checkoutExpressButton);
}

const {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
} = this.prestashopService.getProductDetails();

this.children.expressCheckoutButton = new ExpressCheckoutButtonComponent(
this.app,
{
fundingSource: 'paylater',
querySelector: '#ps-checkout-express-button',
data: {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
}
querySelector: '#ps-checkout-express-button'
}
).render();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,11 @@ export class ExpressButtonProductComponent extends BaseComponent {
this.updateButtonContainerVisibility();
});

const {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
} = this.prestashopService.getProductDetails();

this.children.expressCheckoutButton = new ExpressCheckoutButtonComponent(
this.app,
{
fundingSource: 'paypal',
querySelector: `#${BUTTON_CONTAINER_SELECTOR}`,
data: {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
}
querySelector: `#${BUTTON_CONTAINER_SELECTOR}`
}
).render();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,11 @@ export class PayLaterButtonProductComponent extends BaseComponent {
this.updateButtonContainerVisibility();
});

const {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
} = this.prestashopService.getProductDetails();

this.children.expressCheckoutButton = new ExpressCheckoutButtonComponent(
this.app,
{
fundingSource: 'paylater',
querySelector: `#${BUTTON_CONTAINER_SELECTOR}`,
data: {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
}
querySelector: `#${BUTTON_CONTAINER_SELECTOR}`
}
).render();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class ExpressCheckoutButtonComponent extends BaseComponent {
static Inject = {
payPalService: 'PayPalService',
psCheckoutApi: 'PsCheckoutApi',
prestashopService: 'PrestashopService',
$: '$'
};

Expand Down Expand Up @@ -88,7 +89,22 @@ export class ExpressCheckoutButtonComponent extends BaseComponent {
}

createOrder(data) {
const extraData = this.props?.data ? this.props.data : {};
let extraData = {};

if (this.prestashopService.isProductPage()) {
let {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
} = this.prestashopService.getProductDetails();
extraData = {
id_product,
id_product_attribute,
id_customization,
quantity_wanted
};
}

return this.psCheckoutApi
.postCreateOrder({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class PrestashopPs1_6Service {
static getProductDetails() {
const id_product = document.getElementById('product_page_product_id');
const id_product_attribute = document.getElementById('idCombination');
const id_customization = window.customizationId;
const id_customization = window?.customizationId;
const quantity_wanted = document.getElementById('quantity_wanted');

return {
id_product: id_product.value || '',
id_product_attribute: id_product_attribute.value || '',
id_product: id_product?.value || '',
id_product_attribute: id_product_attribute?.value || '',
id_customization: id_customization || '',
quantity_wanted: quantity_wanted.value || ''
quantity_wanted: quantity_wanted?.value || ''
};
}

Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[6.3.6.1]]></version>
<version><![CDATA[6.3.6.2]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
4 changes: 2 additions & 2 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '6.3.6.1';
const VERSION = '6.3.6.2';

const INTEGRATION_DATE = '2022-14-06';

Expand All @@ -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 = '6.3.6.1';
$this->version = '6.3.6.2';
$this->author = 'PrestaShop';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
Expand Down
8 changes: 4 additions & 4 deletions src/Builder/Payload/OrderPayloadBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,14 @@ private function getAddressPortable($addressType)
$address = $this->cart['addresses'][$addressType];
$payerCountryIsoCode = $this->getCountryIsoCodeById($address->id_country);

return [
return array_filter([
'address_line_1' => $address->address1,
'address_line_2' => $address->address2,
'admin_area_1' => (string) $this->getStateNameById($address->id_state),
'admin_area_1' => $this->getStateNameById($address->id_state),
'admin_area_2' => $address->city,
'country_code' => (string) $countryCodeMatrice->getPaypalIsoCode($payerCountryIsoCode),
'country_code' => $countryCodeMatrice->getPaypalIsoCode($payerCountryIsoCode),
'postal_code' => $address->postcode,
];
]);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/PayPal/AdvancedCheckoutEligibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function getSupportedCardBrandsByCountryAndCurrency($country, $currency)
*/
public function getSupportedCardBrands()
{
return array_unique(array_merge(...array_values(self::SUPPORTED_CARD_BRANDS_BY_COUNTRY)));
return array_values(array_unique(array_merge(...array_values(self::SUPPORTED_CARD_BRANDS_BY_COUNTRY))));
}

/**
Expand All @@ -271,16 +271,16 @@ public function getSupportedCardBrands()
public function getSupportedCardBrandsByContext($country, $currency)
{
if ($this->hasSupportedCardBrandsByCountryAndCurrency($country)) {
return array_intersect(
return array_values(array_intersect(
$this->getSupportedCardBrandsByCountry($country),
$this->getSupportedCardBrandsByCurrency($currency),
$this->getSupportedCardBrandsByCountryAndCurrency($country, $currency)
);
));
}

return array_intersect(
return array_values(array_intersect(
$this->getSupportedCardBrandsByCountry($country),
$this->getSupportedCardBrandsByCurrency($currency)
);
));
}
}
24 changes: 16 additions & 8 deletions tests/Unit/PayPal/AdvancedCheckoutEligibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ public function setUp()
public function testGetSupportedCountries()
{
$this->assertEquals(
[0 => 'AU', 1 => 'AT', 2 => 'BE', 3 => 'BG', 4 => 'CA', 5 => 'CY', 6 => 'CZ', 7 => 'DK', 8 => 'EE', 9 => 'FI', 10 => 'FR', 11 => 'DE', 12 => 'GR', 13 => 'HU', 14 => 'IE', 15 => 'IT', 16 => 'JP', 17 => 'LV', 18 => 'LI', 19 => 'LT', 20 => 'LU', 21 => 'MT', 22 => 'MX', 23 => 'NL', 24 => 'NO', 25 => 'PL', 26 => 'PT', 27 => 'RO', 28 => 'SK', 29 => 'SI', 30 => 'ES', 31 => 'SE', 32 => 'GB', 33 => 'US'],
['AU', 'AT', 'BE', 'BG', 'CA', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'JP', 'LV', 'LI', 'LT', 'LU', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB', 'US'],
$this->advancedCheckoutEligibility->getSupportedCountries()
);
}

public function testGetSupportedCurrenciesByCountry()
{
$this->assertEquals(
[0 => 'AUD', 1 => 'CAD', 2 => 'EUR', 3 => 'GBP', 4 => 'JPY', 5 => 'USD'],
['AUD', 'CAD', 'EUR', 'GBP', 'JPY', 'USD'],
$this->advancedCheckoutEligibility->getSupportedCurrenciesByCountry('US')
);
$this->assertEquals(
[0 => 'AUD', 1 => 'BRL', 2 => 'CAD', 3 => 'CHF', 4 => 'CZK', 5 => 'DKK', 6 => 'EUR', 7 => 'GBP', 8 => 'HKD', 9 => 'HUF', 10 => 'ILS', 11 => 'JPY', 12 => 'MXN', 13 => 'NOK', 14 => 'NZD', 15 => 'PHP', 16 => 'PLN', 17 => 'SEK', 18 => 'SGD', 19 => 'THB', 20 => 'TWD', 21 => 'USD'],
['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
$this->advancedCheckoutEligibility->getSupportedCurrenciesByCountry('AU')
);
$this->assertEquals(
[0 => 'AUD', 1 => 'BRL', 2 => 'CAD', 3 => 'CHF', 4 => 'CZK', 5 => 'DKK', 6 => 'EUR', 7 => 'GBP', 8 => 'HKD', 9 => 'HUF', 10 => 'ILS', 11 => 'JPY', 12 => 'MXN', 13 => 'NOK', 14 => 'NZD', 15 => 'PHP', 16 => 'PLN', 17 => 'SEK', 18 => 'SGD', 19 => 'THB', 20 => 'TWD', 21 => 'USD'],
['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
$this->advancedCheckoutEligibility->getSupportedCurrenciesByCountry('CA')
);
$this->assertEquals(
[0 => 'AUD', 1 => 'BRL', 2 => 'CAD', 3 => 'CHF', 4 => 'CZK', 5 => 'DKK', 6 => 'EUR', 7 => 'GBP', 8 => 'HKD', 9 => 'HUF', 10 => 'ILS', 11 => 'JPY', 12 => 'MXN', 13 => 'NOK', 14 => 'NZD', 15 => 'PHP', 16 => 'PLN', 17 => 'SEK', 18 => 'SGD', 19 => 'THB', 20 => 'TWD', 21 => 'USD'],
['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
$this->advancedCheckoutEligibility->getSupportedCurrenciesByCountry('FR')
);
$this->assertEquals(
[0 => 'AUD', 1 => 'BRL', 2 => 'CAD', 3 => 'CHF', 4 => 'CZK', 5 => 'DKK', 6 => 'EUR', 7 => 'GBP', 8 => 'HKD', 9 => 'HUF', 10 => 'ILS', 11 => 'JPY', 12 => 'MXN', 13 => 'NOK', 14 => 'NZD', 15 => 'PHP', 16 => 'PLN', 17 => 'SEK', 18 => 'SGD', 19 => 'THB', 20 => 'TWD', 21 => 'USD'],
['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
$this->advancedCheckoutEligibility->getSupportedCurrenciesByCountry('DE')
);
$this->assertEquals(
[0 => 'AUD', 1 => 'BRL', 2 => 'CAD', 3 => 'CHF', 4 => 'CZK', 5 => 'DKK', 6 => 'EUR', 7 => 'GBP', 8 => 'HKD', 9 => 'HUF', 10 => 'ILS', 11 => 'JPY', 12 => 'MXN', 13 => 'NOK', 14 => 'NZD', 15 => 'PHP', 16 => 'PLN', 17 => 'SEK', 18 => 'SGD', 19 => 'THB', 20 => 'TWD', 21 => 'USD'],
['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
$this->advancedCheckoutEligibility->getSupportedCurrenciesByCountry('IT')
);
$this->assertEquals(
Expand Down Expand Up @@ -224,7 +224,11 @@ public function testGetSupportedCardBrands()
{
$this->assertEquals(
['MASTERCARD', 'VISA', 'AMEX', 'JCB', 'CB_NATIONALE', 'DISCOVER'],
array_values($this->advancedCheckoutEligibility->getSupportedCardBrands())
$this->advancedCheckoutEligibility->getSupportedCardBrands()
);
$this->assertEquals(
'["MASTERCARD","VISA","AMEX","JCB","CB_NATIONALE","DISCOVER"]',
json_encode($this->advancedCheckoutEligibility->getSupportedCardBrands())
);
}

Expand Down Expand Up @@ -305,5 +309,9 @@ public function testGetSupportedCardBrandsByContext()
[],
$this->advancedCheckoutEligibility->getSupportedCardBrandsByContext('BO', 'JPY')
);
$this->assertEquals(
'["MASTERCARD","VISA","AMEX","JCB"]',
json_encode($this->advancedCheckoutEligibility->getSupportedCardBrandsByContext('JP', 'JPY'))
);
}
}

0 comments on commit 360aaa0

Please sign in to comment.