Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan202 committed Nov 26, 2020
2 parents fbdad0e + 37d562b commit 6e950d0
Show file tree
Hide file tree
Showing 96 changed files with 5,012 additions and 296 deletions.
2 changes: 1 addition & 1 deletion 202/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<property name="src-dir" value="${basedir}" />
<property name="TARGETNAME" value="paypal" />
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}" />
<property name="TARGETVERSION" value="5.2.1" />
<property name="TARGETVERSION" value="5.3.0" />
<property name="PHPVERSION" value="5.6" />
<property name="PSVERSION" value="1.7.5.x" />

Expand Down
17 changes: 10 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
# PayPal Officiel
# PayPal Official Module for PrestaShop

## About

Let customer pay with one of this payment methods :
Let customer pay with one of the payment methods :

On PrestaShop 1.7 :
- PayPal Express Checkout
- PayPal Express Checkout Cards
- PayPal Plus Germany, Mexique and Brazil
- PayPal Plus Germany, Mexico and Brazil

On PrestaShop 1.6 :
- PayPal Express Checkout
- PayPal Integral Evolution
- Braintree cards
- PayPal Plus
- PayPal Plus Germany

#### Product page on PrestaShop Addons:

https://addons.prestashop.com/en/payment-card-wallet/1748-paypal-official.html

#### Support on PrestaShop Addons:

https://addons.prestashop.com/en/contact-us?id_product=1748

## Module version guide

| PrestaShop version | Module version | Repo | Doc | PHP Version |
|---------|------------|---------------------|---------------------|-------------|
| 1.5.x - 1.6.x | 3.14.x | [release/3.14.0][paypal-3.12] | | 5.3 or greater |
| 1.7.x | 5.x | [master][paypal-4] | [module documentation][6]| 5.4 or greater |
| 1.5.x - 1.6.x | 3.x | [release/3.14.0][paypal-3.12] | | 5.3 or greater |
| 1.7.x | 5.x | [master][paypal-4] | [User Guide][6]| 5.4 or greater |

## Requirements

Expand Down
12 changes: 0 additions & 12 deletions _dev/js/Onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,4 @@ export const Onboarding = {
}
});
},

test (authCode, sharedId) {

},

addPaypalLib () {
if (typeof(paypalOnboardingLib) != 'undefined') {
let script = document.createElement('script');
script.src = paypalOnboardingLib;
document.body.appendChild(script);
}
}
};
248 changes: 247 additions & 1 deletion _dev/js/adminCheckout.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// Import functions for scrolling effect to necessary block on click
import {hoverConfig, hoverTabConfig} from './functions.js';
import { SetupAdmin } from './adminSetup.js';
import {Tools} from './tools.js';

var CustomizeCheckout = {
init() {
Expand All @@ -45,7 +46,23 @@ var CustomizeCheckout = {
});

CustomizeCheckout.checkConfigurations();
CustomizeCheckout.updateHookPreview();
$('input').change(CustomizeCheckout.checkConfigurations);
$('select').change(CustomizeCheckout.checkConfigurations);
$(document).on('click', '[toggle-style-configuration]', function (e) {
CustomizeCheckout.toggleStyleConfiguration(e);
CustomizeCheckout.updatePreviewButton(e);
CustomizeCheckout.updateColorDescription(e);
});
$(document).on('change', '[customize-style-shortcut-container]', CustomizeCheckout.updatePreviewButton);
$(document).on('change', '[data-type="color"]', CustomizeCheckout.updateColorDescription);
$(document).on('change', '.pp-select-preview-container', CustomizeCheckout.updateHookPreview);
$(document).on('change', '[data-type="height"]', CustomizeCheckout.checkHeight);
$(document).on('change', '[data-type="width"]', CustomizeCheckout.checkWidth);

if (typeof sectionSelector !== 'undefined') {
CustomizeCheckout.scrollTo(sectionSelector);
}
},

checkConfigurations() {
Expand All @@ -54,6 +71,8 @@ var CustomizeCheckout = {
const EcOptions = [
'paypal_express_checkout_in_context',
'paypal_express_checkout_shortcut_cart',
'paypal_express_checkout_shortcut',
'paypal_express_checkout_shortcut_signup',
'paypal_api_advantages',
'paypal_config_brand',
'paypal_config_logo'
Expand All @@ -74,6 +93,80 @@ var CustomizeCheckout = {
'paypal_os_validation_error',
'paypal_os_refunded_paypal'
];
const customShortcutStyle = document.querySelector('[name="PAYPAL_EXPRESS_CHECKOUT_CUSTOMIZE_SHORTCUT_STYLE"]');
const shortcutLocationProduct = $('[name="paypal_express_checkout_shortcut"]');
const shortcutLocationCart = $('[name="paypal_express_checkout_shortcut_cart"]');
const shortcutLocationSignup = $('[name="paypal_express_checkout_shortcut_signup"]');
const showShortcutOnProductPage = document.querySelector('[name="paypal_express_checkout_shortcut"]');
const displayModeProductPage = document.querySelector('[name="PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_PRODUCT"]');
const showShortcutOnCartPage = document.querySelector('[name="paypal_express_checkout_shortcut_cart"]');
const displayModeCartPage = document.querySelector('[name="PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_CART"]');
const showShortcutOnSignupPage = document.querySelector('[name="paypal_express_checkout_shortcut_signup"]');
const displayModeSignupPage = document.querySelector('[name="PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_SIGNUP"]');


// Show the product page display configurations of a shortcut if need
if (showShortcutOnProductPage.checked && customShortcutStyle.checked) {
$('[data-section-customize-mode-product]').closest('.form-group').show();
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_PRODUCT');
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_PRODUCT');

if (displayModeProductPage.value === '1') {
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_PRODUCT');
CustomizeCheckout.hideConfiguration('productPageWidgetCode');
} else if (displayModeProductPage.value === '2') {
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_PRODUCT');
CustomizeCheckout.showConfiguration('productPageWidgetCode');
}
} else {
$('[data-section-customize-mode-product]').closest('.form-group').hide();
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_PRODUCT');
CustomizeCheckout.hideConfiguration('productPageWidgetCode');
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_PRODUCT');
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_PRODUCT');
}

// Show the cart page display configurations of a shortcut if need
if (showShortcutOnCartPage.checked && customShortcutStyle.checked) {
$('[data-section-customize-mode-cart]').closest('.form-group').show();
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_CART');
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_CART');

if (displayModeCartPage.value === '1') {
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_CART');
CustomizeCheckout.hideConfiguration('cartPageWidgetCode');
} else if (displayModeCartPage.value === '2') {
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_CART');
CustomizeCheckout.showConfiguration('cartPageWidgetCode');
}
} else {
$('[data-section-customize-mode-cart]').closest('.form-group').hide();
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_CART');
CustomizeCheckout.hideConfiguration('cartPageWidgetCode');
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_CART');
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_CART');
}

// Show the signup page display configurations of a shortcut if need
if (showShortcutOnSignupPage.checked && customShortcutStyle.checked) {
$('[data-section-customize-mode-signup]').closest('.form-group').show();
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_SIGNUP');
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_SIGNUP');

if (displayModeSignupPage.value === '1') {
CustomizeCheckout.showConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_SIGNUP');
CustomizeCheckout.hideConfiguration('signupPageWidgetCode');
} else if (displayModeSignupPage.value === '2') {
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_SIGNUP');
CustomizeCheckout.showConfiguration('signupPageWidgetCode');
}
} else {
$('[data-section-customize-mode-signup]').closest('.form-group').hide();
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_SIGNUP');
CustomizeCheckout.hideConfiguration('signupPageWidgetCode');
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_SIGNUP');
CustomizeCheckout.hideConfiguration('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_SIGNUP');
}

if (paypalEcEnabled.length > 0 ) {
if (paypalEcEnabled.prop('checked') == true) {
Expand Down Expand Up @@ -102,6 +195,22 @@ var CustomizeCheckout = {
$('.advanced-help-message').hide();
}
}

// Show the alert if the customize shortcut style is active and any shortcut location is not active
if (customShortcutStyle !== null) {
if (
customShortcutStyle.checked === true
&& shortcutLocationProduct.prop('checked') === false
&& shortcutLocationCart.prop('checked') === false
&& shortcutLocationSignup.prop('checked') === false
) {
$('.shortcut-customize-style-alert').closest('.form-group').show();
$('.shortcut-customize-style-alert').removeClass('hidden');
} else {
$('.shortcut-customize-style-alert').closest('.form-group').hide();
$('.shortcut-customize-style-alert').addClass('hidden');
}
}
},

// Hide block while switch inactive
Expand All @@ -122,7 +231,144 @@ var CustomizeCheckout = {
formGroup.show();
},

}
toggleStyleConfiguration(e) {
var button = $(e.target);
var configurations = button.closest('[customize-style-shortcut-container]').find('[configuration-section]');
var preview = button.closest('[customize-style-shortcut-container]').find('[preview-section]');

if (configurations.hasClass('hidden')) {
button.find('i').addClass('icon-remove');
button.find('i').removeClass('icon-edit');
configurations.removeClass('hidden');
preview.removeClass('invisible');
} else {
button.find('i').removeClass('icon-remove');
button.find('i').addClass('icon-edit');
configurations.addClass('hidden');
preview.addClass('invisible');
}
},

updatePreviewButton(e) {
var container = $(e.target).closest('[customize-style-shortcut-container]');
var preview = container.find('[preview-section]').find('[button-container]');
var configurations = container.find('[configuration-section]');
var color = configurations.find('[data-type="color"]').val();
var shape = configurations.find('[data-type="shape"]').val();
var label = configurations.find('[data-type="label"]').val();
var width = configurations.find('[data-type="width"]').val();
var height = configurations.find('[data-type="height"]').val();

$.ajax({
url: controllerUrl,
type: 'POST',
dataType: 'JSON',
data: {
ajax: true,
action: 'getShortcut',
color: color,
shape: shape,
label: label,
height: height,
width: width
},
success(response) {
if ('content' in response) {
preview.html(response.content);
}
},
})
},

updateColorDescription(e) {
var container = $(e.target).closest('[customize-style-shortcut-container]');
var color = container.find('[data-type="color"]').val();

container.find('[after-select-content] [data-color]').hide();

if (color === 'gold') {
container.find('[after-select-content] [data-color="gold"]').show();
} else if(color === 'blue') {
container.find('[after-select-content] [data-color="blue"]').show();
} else if (['silver', 'white', 'black'].includes(color)) {
container.find('[after-select-content] [data-color="other"]').show();
}

},

updateHookPreview() {
const containers = $('.pp-select-preview-container');

containers.each((index, container) => {
container = $(container);
let option = container.find('option:selected');
let previewPath = option.attr('data-preview-image');
let previewContainter = container.find('.pp-preview');
previewContainter.css('background-image', `url(${previewPath})`);
});
},

checkHeight(e) {
const containerSize = $(e.target).closest('[chain-input-container]');
const msgContainer = containerSize.closest('[field]').find('[msg-container]');
const inputHeight = containerSize.find('[data-type="height"]');
let height = inputHeight.val();
let msg = null;

if (height == 'undefined') {
return true;
}

height = parseInt(height);

if (height > 55 || height < 25) {
msg = Tools.getAlert(inputHeight.attr('data-msg-error'), 'danger');
}

if (msg == null) {
msgContainer.html('');
return true;
}

msgContainer.html(msg);
return true;
},

checkWidth(e) {
const containerSize = $(e.target).closest('[chain-input-container]');
const msgContainer = containerSize.closest('[field]').find('[msg-container]');
const inputWidth = containerSize.find('[data-type="width"]');
let width = inputWidth.val();
let msg = null;

if (width == 'undefined') {
return true;
}

width = parseInt(width);

if (width < 150) {
msg = Tools.getAlert(inputWidth.attr('data-msg-error'), 'danger');
}

if (msg == null) {
msgContainer.html('');
return true;
}

msgContainer.html(msg);
return true;
},

scrollTo(selector) {
const el = $(sectionSelector);
// Scroll to current block
$('html, body').animate({
scrollTop: el.offset().top - 200 + "px"
}, 900);
}

};

$(document).ready(() => {
CustomizeCheckout.init();
Expand Down
Loading

0 comments on commit 6e950d0

Please sign in to comment.