Merge branch 'trunk' into PCP-75-validate-form-before-sending-paypal-request

This commit is contained in:
Kirill Braslavsky 2021-03-17 12:21:28 +02:00
commit 6b61205474
7 changed files with 60 additions and 9 deletions

View file

@ -1,6 +1,6 @@
# WooCommerce PayPal Payments
PayPal's latest complete payments processing solution. Accept PayPal, PayPal Credit, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
## Requirements

View file

@ -36,7 +36,18 @@ class CheckoutActionHandler {
}).then(function (data) {
if (!data.success) {
spinner.unblock();
errorHandler.message(data.data.message, true);
//handle both messages sent from Woocommerce (data.messages) and this plugin (data.data.message)
if (typeof(data.messages) !== 'undefined' )
{
const domParser = new DOMParser();
errorHandler.appendPreparedErrorMessageElement(
domParser.parseFromString(data.messages, 'text/html')
.querySelector('ul')
);
} else {
errorHandler.message(data.data.message, true);
}
return;
}
const input = document.createElement('input');

View file

@ -4,6 +4,7 @@ class ErrorHandler {
{
this.genericErrorText = genericErrorText;
this.wrapper = document.querySelector('.woocommerce-notices-wrapper');
this.messagesList = document.querySelector('ul.woocommerce-error');
}
genericError() {
@ -14,18 +15,55 @@ class ErrorHandler {
this.message(this.genericErrorText)
}
appendPreparedErrorMessageElement(errorMessageElement)
{
if(this.messagesList === null) {
this.prepareMessagesList();
}
this.messagesList.replaceWith(errorMessageElement);
}
message(text, persist = false)
{
this.wrapper.classList.add('woocommerce-error');
if(! typeof String || text.length === 0){
throw new Error('A new message text must be a non-empty string.');
}
if(this.messagesList === null){
this.prepareMessagesList();
}
if (persist) {
this.wrapper.classList.add('ppcp-persist');
} else {
this.wrapper.classList.remove('ppcp-persist');
}
this.wrapper.innerHTML = this.sanitize(text);
let messageNode = this.prepareMessagesListItem(text);
this.messagesList.appendChild(messageNode);
jQuery.scroll_to_notices(jQuery('.woocommerce-notices-wrapper'))
}
prepareMessagesList()
{
if(this.messagesList === null){
this.messagesList = document.createElement('ul');
this.messagesList.setAttribute('class', 'woocommerce-error');
this.messagesList.setAttribute('role', 'alert');
this.wrapper.appendChild(this.messagesList);
}
}
prepareMessagesListItem(message)
{
const li = document.createElement('li');
li.innerHTML = message;
return li;
}
sanitize(text)
{
const textarea = document.createElement('textarea');

View file

@ -724,14 +724,15 @@ class SmartButton implements SmartButtonInterface {
if ( $payee->merchant_id() ) {
$params['merchant-id'] = $payee->merchant_id();
}
$disable_funding = $this->settings->has( 'disable_funding' ) ?
$disable_funding = $this->settings->has( 'disable_funding' ) ?
$this->settings->get( 'disable_funding' ) : array();
$disable_funding[] = 'venmo';
if ( ! is_checkout() ) {
$disable_funding[] = 'card';
}
$params['disable-funding'] = implode( ',', array_unique( $disable_funding ) );
if ( count( $disable_funding ) > 0 ) {
$params['disable-funding'] = implode( ',', array_unique( $disable_funding ) );
}
$smart_button_url = add_query_arg( $params, 'https://www.paypal.com/sdk/js' );
return $smart_button_url;

View file

@ -618,6 +618,7 @@ return array(
'mybank' => _x( 'MyBank', 'Name of payment method', 'woocommerce-paypal-payments' ),
'p24' => _x( 'Przelewy24', 'Name of payment method', 'woocommerce-paypal-payments' ),
'sofort' => _x( 'Sofort', 'Name of payment method', 'woocommerce-paypal-payments' ),
'venmo' => _x( 'Venmo', 'Name of payment method', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,

View file

@ -8,7 +8,7 @@ Stable tag: 1.2.1
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
PayPal's latest payments processing solution. Accept PayPal, PayPal Credit, credit/debit cards, alternative digital wallets and bank accounts.
PayPal's latest payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets and bank accounts.
== Description ==

View file

@ -2,7 +2,7 @@
/**
* Plugin Name: WooCommerce PayPal Payments
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
* Description: PayPal's latest complete payments processing solution. Accept PayPal, PayPal Credit, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
* Version: 1.2.1
* Author: WooCommerce
* Author URI: https://woocommerce.com/