WooCommerce PayPal Express Checkout Payment Gateway - Version 1.6.17

Version Description

  • 2019-08-08 =
  • Update - WooCommerce 3.7 compatibility
  • Add - Filter to require display of billing agreement during checkout
  • Add - Add CURRENCYCODE to capture_payment
  • Add - Add filter for buttons on products
  • Fix - Skip wasteful render on initial Checkout page load
  • Fix - Appearance tweaks on Checkout screen
Download this release

Release Info

Developer woothemes
Plugin Icon 128x128 WooCommerce PayPal Express Checkout Payment Gateway
Version 1.6.17
Comparing to
See all releases

Code changes from version 1.6.16 to 1.6.17

assets/css/wc-gateway-ppec-frontend-checkout.css DELETED
@@ -1,13 +0,0 @@
1
- .woocommerce-billing-fields .ppec-bypass.hidden {
2
- display: none !important;
3
- }
4
-
5
- .payment_method_ppec_paypal img {
6
- max-height: 68px !important;
7
- }
8
-
9
- .wc-gateway-ppec-cancel {
10
- display: block;
11
- text-align: center;
12
- padding: 10px;
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/{wc-gateway-ppec-frontend-cart.css → wc-gateway-ppec-frontend.css} RENAMED
@@ -37,3 +37,22 @@
37
  .site-header .widget_shopping_cart .woocommerce-mini-cart__empty-message + p.buttons.wcppec-cart-widget-spb {
38
  display: none;
39
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  .site-header .widget_shopping_cart .woocommerce-mini-cart__empty-message + p.buttons.wcppec-cart-widget-spb {
38
  display: none;
39
  }
40
+
41
+ .payment_method_ppec_paypal img {
42
+ max-height: 68px !important;
43
+ border-radius: 0;
44
+ }
45
+
46
+ .wc-gateway-ppec-cancel {
47
+ display: block;
48
+ text-align: center;
49
+ padding: 10px;
50
+ }
51
+
52
+ #woo_pp_ec_button_checkout {
53
+ display: none;
54
+ }
55
+
56
+ #payment .place-order .button {
57
+ display: block;
58
+ }
assets/js/wc-gateway-ppec-order-review.js CHANGED
@@ -7,8 +7,11 @@
7
  return;
8
  }
9
 
10
- var isPPEC = $( this ).is( '#payment_method_ppec_paypal' );
11
- $( '#place_order' ).toggle( ! isPPEC );
12
- $( '#woo_pp_ec_button_checkout' ).toggle( isPPEC );
 
 
 
13
  } );
14
  })( jQuery, window, document );
7
  return;
8
  }
9
 
10
+ var isPPEC = $( this ).is( '#payment_method_ppec_paypal' );
11
+ var togglePPEC = isPPEC ? 'show' : 'hide';
12
+ var toggleSubmit = isPPEC ? 'hide' : 'show';
13
+
14
+ $( '#woo_pp_ec_button_checkout' ).animate( { opacity: togglePPEC, height: togglePPEC, padding: togglePPEC }, 230 );
15
+ $( '#place_order' ).animate( { opacity: toggleSubmit, height: toggleSubmit, padding: toggleSubmit }, 230 );
16
  } );
17
  })( jQuery, window, document );
assets/js/wc-gateway-ppec-smart-payment-buttons.js CHANGED
@@ -59,12 +59,18 @@
59
  var allowed = wc_ppec_context[ prefix + 'allowed_methods' ];
60
  var disallowed = wc_ppec_context[ prefix + 'disallowed_methods' ];
61
 
62
- var selector = isMiniCart ? '#woo_pp_ec_button_mini_cart' : '#woo_pp_ec_button_' + wc_ppec_context.page;
 
 
 
 
 
 
63
 
64
  paypal.Button.render( {
65
  env: wc_ppec_context.environment,
66
  locale: wc_ppec_context.locale,
67
- commit: 'checkout' === wc_ppec_context.page && ! isMiniCart,
68
 
69
  funding: {
70
  allowed: getFundingMethods( allowed ),
@@ -106,7 +112,7 @@
106
  .attr( 'value', wc_ppec_context.start_checkout_nonce )
107
  )
108
  .add( $( '<input type="hidden" name="from_checkout" /> ' )
109
- .attr( 'value', 'checkout' === wc_ppec_context.page && ! isMiniCart ? 'yes' : 'no' )
110
  )
111
  .serialize();
112
 
@@ -129,7 +135,7 @@
129
  },
130
 
131
  onAuthorize: function( data, actions ) {
132
- if ( 'checkout' === wc_ppec_context.page && ! isMiniCart ) {
133
  // Pass data necessary for authorizing payment to back-end.
134
  $( 'form.checkout' )
135
  .append( $( '<input type="hidden" name="paymentToken" /> ' ).attr( 'value', data.paymentToken ) )
@@ -146,7 +152,9 @@
146
 
147
  // Render cart, single product, or checkout buttons.
148
  if ( wc_ppec_context.page ) {
149
- render();
 
 
150
  $( document.body ).on( 'updated_cart_totals updated_checkout', render.bind( this, false ) );
151
  }
152
 
59
  var allowed = wc_ppec_context[ prefix + 'allowed_methods' ];
60
  var disallowed = wc_ppec_context[ prefix + 'disallowed_methods' ];
61
 
62
+ var selector = isMiniCart ? '#woo_pp_ec_button_mini_cart' : '#woo_pp_ec_button_' + wc_ppec_context.page;
63
+ var fromCheckout = 'checkout' === wc_ppec_context.page && ! isMiniCart;
64
+
65
+ // Don't render if already rendered in DOM.
66
+ if ( $( selector ).children().length ) {
67
+ return;
68
+ }
69
 
70
  paypal.Button.render( {
71
  env: wc_ppec_context.environment,
72
  locale: wc_ppec_context.locale,
73
+ commit: fromCheckout,
74
 
75
  funding: {
76
  allowed: getFundingMethods( allowed ),
112
  .attr( 'value', wc_ppec_context.start_checkout_nonce )
113
  )
114
  .add( $( '<input type="hidden" name="from_checkout" /> ' )
115
+ .attr( 'value', fromCheckout ? 'yes' : 'no' )
116
  )
117
  .serialize();
118
 
135
  },
136
 
137
  onAuthorize: function( data, actions ) {
138
+ if ( fromCheckout ) {
139
  // Pass data necessary for authorizing payment to back-end.
140
  $( 'form.checkout' )
141
  .append( $( '<input type="hidden" name="paymentToken" /> ' ).attr( 'value', data.paymentToken ) )
152
 
153
  // Render cart, single product, or checkout buttons.
154
  if ( wc_ppec_context.page ) {
155
+ if ( 'checkout' !== wc_ppec_context.page ) {
156
+ render();
157
+ }
158
  $( document.body ).on( 'updated_cart_totals updated_checkout', render.bind( this, false ) );
159
  }
160
 
changelog.txt CHANGED
@@ -1,5 +1,13 @@
1
  *** Changelog ***
2
 
 
 
 
 
 
 
 
 
3
  = 1.6.16 - 2019-07-18 =
4
  * Fix - Don't require address for renewal of virtual subscriptions
5
  * Fix - Avoid broken confirmation screen edge case after 10486 redirect
1
  *** Changelog ***
2
 
3
+ = 1.6.17 - 2019-08-08 =
4
+ * Update - WooCommerce 3.7 compatibility
5
+ * Add - Filter to require display of billing agreement during checkout
6
+ * Add - Add CURRENCYCODE to capture_payment
7
+ * Add - Add filter for buttons on products
8
+ * Fix - Skip wasteful render on initial Checkout page load
9
+ * Fix - Appearance tweaks on Checkout screen
10
+
11
  = 1.6.16 - 2019-07-18 =
12
  * Fix - Don't require address for renewal of virtual subscriptions
13
  * Fix - Avoid broken confirmation screen edge case after 10486 redirect
includes/abstracts/abstract-wc-gateway-ppec.php CHANGED
@@ -18,7 +18,7 @@ abstract class WC_Gateway_PPEC extends WC_Payment_Gateway {
18
  $this->method_title = __( 'PayPal Checkout', 'woocommerce-gateway-paypal-express-checkout' );
19
  $this->method_description = __( 'Allow customers to conveniently checkout directly with PayPal.', 'woocommerce-gateway-paypal-express-checkout' );
20
 
21
- if ( empty( $_GET['woo-paypal-return'] ) ) {
22
  $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-paypal-express-checkout' );
23
  }
24
 
18
  $this->method_title = __( 'PayPal Checkout', 'woocommerce-gateway-paypal-express-checkout' );
19
  $this->method_description = __( 'Allow customers to conveniently checkout directly with PayPal.', 'woocommerce-gateway-paypal-express-checkout' );
20
 
21
+ if ( empty( $_GET['woo-paypal-return'] ) && 'yes' !== $this->get_option( 'use_spb' ) ) {
22
  $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-paypal-express-checkout' );
23
  }
24
 
includes/class-wc-gateway-ppec-admin-handler.php CHANGED
@@ -21,8 +21,8 @@ class WC_Gateway_PPEC_Admin_Handler {
21
 
22
  add_action( 'woocommerce_order_status_processing', array( $this, 'capture_payment' ) );
23
  add_action( 'woocommerce_order_status_completed', array( $this, 'capture_payment' ) );
24
- add_action( 'woocommerce_order_status_cancelled', array( $this, 'cancel_payment' ) );
25
- add_action( 'woocommerce_order_status_refunded', array( $this, 'cancel_payment' ) );
26
 
27
  add_filter( 'woocommerce_order_actions', array( $this, 'add_capture_charge_order_action' ) );
28
  add_action( 'woocommerce_order_action_ppec_capture_charge', array( $this, 'maybe_capture_charge' ) );
@@ -162,6 +162,7 @@ class WC_Gateway_PPEC_Admin_Handler {
162
 
163
  $params['AUTHORIZATIONID'] = $trans_id;
164
  $params['AMT'] = floatval( $order_total );
 
165
  $params['COMPLETETYPE'] = 'Complete';
166
 
167
  $result = wc_gateway_ppec()->client->do_express_checkout_capture( $params );
@@ -197,11 +198,11 @@ class WC_Gateway_PPEC_Admin_Handler {
197
  }
198
 
199
  /**
200
- * Cancel authorization
201
  *
202
  * @param int $order_id
203
  */
204
- public function cancel_payment( $order_id ) {
205
  $order = wc_get_order( $order_id );
206
  $old_wc = version_compare( WC_VERSION, '3.0', '<' );
207
  $payment_method = $old_wc ? $order->payment_method : $order->get_payment_method();
21
 
22
  add_action( 'woocommerce_order_status_processing', array( $this, 'capture_payment' ) );
23
  add_action( 'woocommerce_order_status_completed', array( $this, 'capture_payment' ) );
24
+ add_action( 'woocommerce_order_status_cancelled', array( $this, 'cancel_authorization' ) );
25
+ add_action( 'woocommerce_order_status_refunded', array( $this, 'cancel_authorization' ) );
26
 
27
  add_filter( 'woocommerce_order_actions', array( $this, 'add_capture_charge_order_action' ) );
28
  add_action( 'woocommerce_order_action_ppec_capture_charge', array( $this, 'maybe_capture_charge' ) );
162
 
163
  $params['AUTHORIZATIONID'] = $trans_id;
164
  $params['AMT'] = floatval( $order_total );
165
+ $params['CURRENCYCODE'] = $old_wc ? $order->order_currency : $order->get_currency();
166
  $params['COMPLETETYPE'] = 'Complete';
167
 
168
  $result = wc_gateway_ppec()->client->do_express_checkout_capture( $params );
198
  }
199
 
200
  /**
201
+ * Cancel authorization (if one is present)
202
  *
203
  * @param int $order_id
204
  */
205
+ public function cancel_authorization( $order_id ) {
206
  $order = wc_get_order( $order_id );
207
  $old_wc = version_compare( WC_VERSION, '3.0', '<' );
208
  $payment_method = $old_wc ? $order->payment_method : $order->get_payment_method();
includes/class-wc-gateway-ppec-cart-handler.php CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
7
  }
8
 
9
  /**
10
- * WC_Gateway_PPEC_Cart_Handler handles button display in the cart.
11
  */
12
  class WC_Gateway_PPEC_Cart_Handler {
13
 
@@ -275,6 +275,10 @@ class WC_Gateway_PPEC_Cart_Handler {
275
  return;
276
  }
277
 
 
 
 
 
278
  $settings = wc_gateway_ppec()->settings;
279
 
280
  $express_checkout_img_url = apply_filters( 'woocommerce_paypal_express_checkout_button_img_url', sprintf( 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-%s.png', $settings->button_size ) );
@@ -431,7 +435,7 @@ class WC_Gateway_PPEC_Cart_Handler {
431
  $settings = wc_gateway_ppec()->settings;
432
  $client = wc_gateway_ppec()->client;
433
 
434
- wp_enqueue_style( 'wc-gateway-ppec-frontend-cart', wc_gateway_ppec()->plugin_url . 'assets/css/wc-gateway-ppec-frontend-cart.css' );
435
 
436
  $is_cart = is_cart() && ! WC()->cart->is_empty() && 'yes' === $settings->cart_checkout_enabled;
437
  $is_product = is_product() && 'yes' === $settings->checkout_on_single_product_enabled;
7
  }
8
 
9
  /**
10
+ * WC_Gateway_PPEC_Cart_Handler handles button display in the frontend.
11
  */
12
  class WC_Gateway_PPEC_Cart_Handler {
13
 
275
  return;
276
  }
277
 
278
+ if ( apply_filters( 'woocommerce_paypal_express_checkout_hide_button_on_product_page', false ) ) {
279
+ return;
280
+ }
281
+
282
  $settings = wc_gateway_ppec()->settings;
283
 
284
  $express_checkout_img_url = apply_filters( 'woocommerce_paypal_express_checkout_button_img_url', sprintf( 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-%s.png', $settings->button_size ) );
435
  $settings = wc_gateway_ppec()->settings;
436
  $client = wc_gateway_ppec()->client;
437
 
438
+ wp_enqueue_style( 'wc-gateway-ppec-frontend', wc_gateway_ppec()->plugin_url . 'assets/css/wc-gateway-ppec-frontend.css' );
439
 
440
  $is_cart = is_cart() && ! WC()->cart->is_empty() && 'yes' === $settings->cart_checkout_enabled;
441
  $is_product = is_product() && 'yes' === $settings->checkout_on_single_product_enabled;
includes/class-wc-gateway-ppec-checkout-handler.php CHANGED
@@ -1033,7 +1033,7 @@ class WC_Gateway_PPEC_Checkout_Handler {
1033
  }
1034
  }
1035
 
1036
- return $needs_billing_agreement;
1037
  }
1038
 
1039
  /**
1033
  }
1034
  }
1035
 
1036
+ return apply_filters( 'woocommerce_paypal_express_checkout_needs_billing_agreement', $needs_billing_agreement );
1037
  }
1038
 
1039
  /**
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: automattic, woothemes, akeda, dwainm, royho, allendav, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, mikaey, fullysupportedphil, dsmithweb, corsonr, bor0, zandyring, pauldechov, robobot3000
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal
4
  Requires at least: 4.4
5
- Tested up to: 5.2.0
6
- Stable tag: 1.6.16
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -101,6 +101,14 @@ Please use this to inform us about bugs, or make contributions via PRs.
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
 
 
104
  = 1.6.16 - 2019-07-18 =
105
  * Fix - Don't require address for renewal of virtual subscriptions
106
  * Fix - Avoid broken confirmation screen edge case after 10486 redirect
2
  Contributors: automattic, woothemes, akeda, dwainm, royho, allendav, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, mikaey, fullysupportedphil, dsmithweb, corsonr, bor0, zandyring, pauldechov, robobot3000
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal
4
  Requires at least: 4.4
5
+ Tested up to: 5.2.2
6
+ Stable tag: 1.6.17
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
101
 
102
  == Changelog ==
103
 
104
+ = 1.6.17 - 2019-08-08 =
105
+ * Update - WooCommerce 3.7 compatibility
106
+ * Add - Filter to require display of billing agreement during checkout
107
+ * Add - Add CURRENCYCODE to capture_payment
108
+ * Add - Add filter for buttons on products
109
+ * Fix - Skip wasteful render on initial Checkout page load
110
+ * Fix - Appearance tweaks on Checkout screen
111
+
112
  = 1.6.16 - 2019-07-18 =
113
  * Fix - Don't require address for renewal of virtual subscriptions
114
  * Fix - Avoid broken confirmation screen edge case after 10486 redirect
woocommerce-gateway-paypal-express-checkout.php CHANGED
@@ -3,19 +3,19 @@
3
  * Plugin Name: WooCommerce PayPal Checkout Gateway
4
  * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
5
  * Description: A payment gateway for PayPal Checkout (https://www.paypal.com/us/webapps/mpp/paypal-checkout).
6
- * Version: 1.6.16
7
  * Author: WooCommerce
8
  * Author URI: https://woocommerce.com
9
- * Copyright: © 2018 WooCommerce / PayPal.
10
  * License: GNU General Public License v3.0
11
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
  * Text Domain: woocommerce-gateway-paypal-express-checkout
13
  * Domain Path: /languages
14
- * WC tested up to: 3.6
15
  * WC requires at least: 2.6
16
  */
17
  /**
18
- * Copyright (c) 2018 PayPal, Inc.
19
  *
20
  * The name of the PayPal may not be used to endorse or promote products derived from this
21
  * software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND
@@ -27,7 +27,7 @@ if ( ! defined( 'ABSPATH' ) ) {
27
  exit; // Exit if accessed directly
28
  }
29
 
30
- define( 'WC_GATEWAY_PPEC_VERSION', '1.6.16' );
31
 
32
  /**
33
  * Return instance of WC_Gateway_PPEC_Plugin.
3
  * Plugin Name: WooCommerce PayPal Checkout Gateway
4
  * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
5
  * Description: A payment gateway for PayPal Checkout (https://www.paypal.com/us/webapps/mpp/paypal-checkout).
6
+ * Version: 1.6.17
7
  * Author: WooCommerce
8
  * Author URI: https://woocommerce.com
9
+ * Copyright: © 2019 WooCommerce / PayPal.
10
  * License: GNU General Public License v3.0
11
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
  * Text Domain: woocommerce-gateway-paypal-express-checkout
13
  * Domain Path: /languages
14
+ * WC tested up to: 3.7
15
  * WC requires at least: 2.6
16
  */
17
  /**
18
+ * Copyright (c) 2019 PayPal, Inc.
19
  *
20
  * The name of the PayPal may not be used to endorse or promote products derived from this
21
  * software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND
27
  exit; // Exit if accessed directly
28
  }
29
 
30
+ define( 'WC_GATEWAY_PPEC_VERSION', '1.6.17' );
31
 
32
  /**
33
  * Return instance of WC_Gateway_PPEC_Plugin.