mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge branch 'trunk' into PCP-75-validate-form-before-sending-paypal-request
This commit is contained in:
commit
6b61205474
7 changed files with 60 additions and 9 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 ==
|
||||
|
||||
|
|
|
@ -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/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue