WooCommerce PayPal Powered by Braintree Payment Gateway - Version 2.1.2

Version Description

  • Tweak - Add payment details to the customer data export and remove it for erasure requests
  • Tweak - Remove payment tokens for customer data erasure requests
  • Misc - Add support for WooCommerce 3.4
Download this release

Release Info

Developer bor0
Plugin Icon 128x128 WooCommerce PayPal Powered by Braintree Payment Gateway
Version 2.1.2
Comparing to
See all releases

Code changes from version 2.1.1 to 2.1.2

class-wc-braintree.php CHANGED
@@ -88,7 +88,7 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
88
 
89
 
90
  /** plugin version number */
91
- const VERSION = '2.1.1';
92
 
93
  /** @var WC_Braintree single instance of this plugin */
94
  protected static $instance;
@@ -431,7 +431,7 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
431
  if ( isset( $paypal_settings['enabled'] ) && 'yes' == $paypal_settings['enabled'] ) {
432
  if ( isset( $paypal_settings['environment'] ) && 'production' == $paypal_settings['environment'] ) {
433
 
434
- if ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! $this->get_admin_notice_handler()->is_notice_dismissed( 'ssl-recommended-notice' ) ) {
435
 
436
  $this->get_admin_notice_handler()->add_admin_notice( __( 'WooCommerce is not being forced over SSL -- Using PayPal with Braintree requires that checkout to be forced over SSL.', 'woocommerce-gateway-paypal-powered-by-braintree' ), 'ssl-recommended-notice' );
437
  }
88
 
89
 
90
  /** plugin version number */
91
+ const VERSION = '2.1.2';
92
 
93
  /** @var WC_Braintree single instance of this plugin */
94
  protected static $instance;
431
  if ( isset( $paypal_settings['enabled'] ) && 'yes' == $paypal_settings['enabled'] ) {
432
  if ( isset( $paypal_settings['environment'] ) && 'production' == $paypal_settings['environment'] ) {
433
 
434
+ if ( ! WC_Braintree_Framework\SV_WC_Plugin_Compatibility::wc_checkout_is_https() && ! $this->get_admin_notice_handler()->is_notice_dismissed( 'ssl-recommended-notice' ) ) {
435
 
436
  $this->get_admin_notice_handler()->add_admin_notice( __( 'WooCommerce is not being forced over SSL -- Using PayPal with Braintree requires that checkout to be forced over SSL.', 'woocommerce-gateway-paypal-powered-by-braintree' ), 'ssl-recommended-notice' );
437
  }
i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.1.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-gateway-paypal-powered-by-"
8
  "braintree/\n"
@@ -629,11 +629,14 @@ msgid "Default"
629
  msgstr ""
630
 
631
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:484
 
632
  msgid "Card Type"
633
  msgstr ""
634
 
635
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:489
636
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:525
 
 
637
  msgid "Last Four"
638
  msgstr ""
639
 
@@ -644,6 +647,7 @@ msgstr ""
644
 
645
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:517
646
  #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php:419
 
647
  #. translators: e-check account type, HTML form field label
648
  msgid "Account Type"
649
  msgstr ""
@@ -673,6 +677,7 @@ msgid "Remove"
673
  msgstr ""
674
 
675
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-user-handler.php:211
 
676
  msgid "%s Payment Tokens"
677
  msgstr ""
678
 
@@ -1173,14 +1178,14 @@ msgstr ""
1173
  msgid "Securely Save to Account"
1174
  msgstr ""
1175
 
1176
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:423
1177
  #. translators: Placeholders: %s - plugin name
1178
  msgid ""
1179
  "%s: WooCommerce is not being forced over SSL; your customer's payment data "
1180
  "may be at risk."
1181
  msgstr ""
1182
 
1183
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:480
1184
  #. translators: Placeholders: %1$s - plugin name, %2$s - a
1185
  #. currency/comma-separated list of currencies, %3$s - <a> tag, %4$s - </a> tag
1186
  msgid ""
@@ -1192,7 +1197,7 @@ msgid_plural ""
1192
  msgstr[0] ""
1193
  msgstr[1] ""
1194
 
1195
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:524
1196
  #. translators: Placeholders: %1$s - payment gateway title (such as
1197
  #. Authorize.net, Braintree, etc), %2$s - <a> tag, %3$s - </a> tag
1198
  msgid ""
@@ -1200,7 +1205,7 @@ msgid ""
1200
  "tokenization%3$s to activate %1$s for Subscriptions."
1201
  msgstr ""
1202
 
1203
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:542
1204
  #. translators: Placeholders: %1$s - payment gateway title (such as
1205
  #. Authorize.net, Braintree, etc), %2$s - <a> tag, %3$s - </a> tag
1206
  msgid ""
@@ -1208,18 +1213,18 @@ msgid ""
1208
  "tokenization%3$s to activate %1$s for Pre-Orders."
1209
  msgstr ""
1210
 
1211
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:578
1212
  msgid ""
1213
  "You must enable tokenization for this gateway in order to support automatic "
1214
  "renewal payments with the WooCommerce Subscriptions extension."
1215
  msgstr ""
1216
 
1217
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:579
1218
  msgid "Inactive"
1219
  msgstr ""
1220
 
1221
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:723
1222
- #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:792
1223
  #. translators: verb, as in "Capture credit card charge". Used when an
1224
  #. amount has been pre-authorized before, but funds have not yet been captured
1225
  #. (taken) from the card. Capturing the charge will take the money from the
@@ -1227,6 +1232,26 @@ msgstr ""
1227
  msgid "Capture Charge"
1228
  msgstr ""
1229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1230
  #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php:414
1231
  msgid "Check Number is missing"
1232
  msgstr ""
2
  # This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.1.2\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-gateway-paypal-powered-by-"
8
  "braintree/\n"
629
  msgstr ""
630
 
631
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:484
632
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:291
633
  msgid "Card Type"
634
  msgstr ""
635
 
636
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:489
637
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:525
638
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:191
639
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:289
640
  msgid "Last Four"
641
  msgstr ""
642
 
647
 
648
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php:517
649
  #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php:419
650
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:290
651
  #. translators: e-check account type, HTML form field label
652
  msgid "Account Type"
653
  msgstr ""
677
  msgstr ""
678
 
679
  #: lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-user-handler.php:211
680
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:200
681
  msgid "%s Payment Tokens"
682
  msgstr ""
683
 
1178
  msgid "Securely Save to Account"
1179
  msgstr ""
1180
 
1181
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:432
1182
  #. translators: Placeholders: %s - plugin name
1183
  msgid ""
1184
  "%s: WooCommerce is not being forced over SSL; your customer's payment data "
1185
  "may be at risk."
1186
  msgstr ""
1187
 
1188
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:489
1189
  #. translators: Placeholders: %1$s - plugin name, %2$s - a
1190
  #. currency/comma-separated list of currencies, %3$s - <a> tag, %4$s - </a> tag
1191
  msgid ""
1197
  msgstr[0] ""
1198
  msgstr[1] ""
1199
 
1200
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:533
1201
  #. translators: Placeholders: %1$s - payment gateway title (such as
1202
  #. Authorize.net, Braintree, etc), %2$s - <a> tag, %3$s - </a> tag
1203
  msgid ""
1205
  "tokenization%3$s to activate %1$s for Subscriptions."
1206
  msgstr ""
1207
 
1208
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:551
1209
  #. translators: Placeholders: %1$s - payment gateway title (such as
1210
  #. Authorize.net, Braintree, etc), %2$s - <a> tag, %3$s - </a> tag
1211
  msgid ""
1213
  "tokenization%3$s to activate %1$s for Pre-Orders."
1214
  msgstr ""
1215
 
1216
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:587
1217
  msgid ""
1218
  "You must enable tokenization for this gateway in order to support automatic "
1219
  "renewal payments with the WooCommerce Subscriptions extension."
1220
  msgstr ""
1221
 
1222
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:588
1223
  msgid "Inactive"
1224
  msgstr ""
1225
 
1226
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:732
1227
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php:801
1228
  #. translators: verb, as in "Capture credit card charge". Used when an
1229
  #. amount has been pre-authorized before, but funds have not yet been captured
1230
  #. (taken) from the card. Capturing the charge will take the money from the
1232
  msgid "Capture Charge"
1233
  msgstr ""
1234
 
1235
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:114
1236
+ msgid "%s Customer ID"
1237
+ msgstr ""
1238
+
1239
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:183
1240
+ msgid "Type"
1241
+ msgstr ""
1242
+
1243
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:245
1244
+ msgid "Removed payment token \"%d\""
1245
+ msgstr ""
1246
+
1247
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:292
1248
+ msgid "Expiry Date"
1249
+ msgstr ""
1250
+
1251
+ #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php:293
1252
+ msgid "Payer Email"
1253
+ msgstr ""
1254
+
1255
  #: lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php:414
1256
  msgid "Check Number is missing"
1257
  msgstr ""
lib/skyverge/woocommerce/class-sv-wc-plugin-compatibility.php CHANGED
@@ -279,6 +279,20 @@ class SV_WC_Plugin_Compatibility {
279
  }
280
 
281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  /** WordPress core ******************************************************/
283
 
284
 
279
  }
280
 
281
 
282
+ /**
283
+ * Determines if the installed version of WooCommerce meets or exceeds the
284
+ * passed version.
285
+ *
286
+ * @since 2.1.2
287
+ *
288
+ * @param string $version version number to compare
289
+ * @return bool
290
+ */
291
+ public static function is_wc_version_gte( $version ) {
292
+ return self::get_wc_version() && version_compare( self::get_wc_version(), $version, '>=' );
293
+ }
294
+
295
+
296
  /** WordPress core ******************************************************/
297
 
298
 
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php CHANGED
@@ -84,6 +84,9 @@ abstract class SV_WC_Payment_Gateway_Plugin extends SV_WC_Plugin {
84
  /** @var boolean true if this gateway requires SSL for processing transactions, false otherwise */
85
  private $require_ssl;
86
 
 
 
 
87
  /** @var SV_WC_Payment_Gateway_Admin_User_Edit_Handler adds admin user edit payment gateway functionality */
88
  private $admin_user_edit_handler;
89
 
@@ -259,6 +262,12 @@ abstract class SV_WC_Payment_Gateway_Plugin extends SV_WC_Plugin {
259
  require_once( $payment_gateway_framework_path . '/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php' );
260
  }
261
 
 
 
 
 
 
 
262
  // Admin user handler
263
  if ( is_admin() ) {
264
  require_once( $payment_gateway_framework_path . '/admin/class-sv-wc-payment-gateway-admin-user-handler.php' );
@@ -847,6 +856,19 @@ abstract class SV_WC_Payment_Gateway_Plugin extends SV_WC_Plugin {
847
  /** Getter methods ******************************************************/
848
 
849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
850
  /**
851
  * Get the admin user handler instance.
852
  *
84
  /** @var boolean true if this gateway requires SSL for processing transactions, false otherwise */
85
  private $require_ssl;
86
 
87
+ /** @var SV_WC_Payment_Gateway_Privacy payment gateway privacy handler instance */
88
+ protected $privacy_handler;
89
+
90
  /** @var SV_WC_Payment_Gateway_Admin_User_Edit_Handler adds admin user edit payment gateway functionality */
91
  private $admin_user_edit_handler;
92
 
262
  require_once( $payment_gateway_framework_path . '/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php' );
263
  }
264
 
265
+ // privacy
266
+ if ( SV_WC_Plugin_Compatibility::is_wc_version_gte( '3.4' ) && class_exists( 'WC_Abstract_Privacy' ) ) {
267
+ require_once( "{$payment_gateway_framework_path}/class-sv-wc-payment-gateway-privacy.php" );
268
+ $this->privacy_handler = new SV_WC_Payment_Gateway_Privacy( $this );
269
+ }
270
+
271
  // Admin user handler
272
  if ( is_admin() ) {
273
  require_once( $payment_gateway_framework_path . '/admin/class-sv-wc-payment-gateway-admin-user-handler.php' );
856
  /** Getter methods ******************************************************/
857
 
858
 
859
+ /**
860
+ * Gets the privacy handler instance.
861
+ *
862
+ * @since 2.1.2
863
+ *
864
+ * @return SV_WC_Payment_Gateway_Privacy
865
+ */
866
+ public function get_privacy_instance() {
867
+
868
+ return $this->privacy_handler;
869
+ }
870
+
871
+
872
  /**
873
  * Get the admin user handler instance.
874
  *
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Payment Gateway Framework
4
+ *
5
+ * This source file is subject to the GNU General Public License v3.0
6
+ * that is bundled with this package in the file license.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.html
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@skyverge.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
16
+ * versions in the future. If you wish to customize the plugin for your
17
+ * needs please refer to http://www.skyverge.com
18
+ *
19
+ * @package SkyVerge/WooCommerce/Payment-Gateway/Classes
20
+ * @author SkyVerge
21
+ * @copyright Copyright (c) 2013-2016, SkyVerge, Inc.
22
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
23
+ */
24
+
25
+ namespace SkyVerge\Plugin_Framework;
26
+
27
+ defined( 'ABSPATH' ) or exit;
28
+
29
+ if ( ! class_exists( '\SkyVerge\Plugin_Framework\SV_WC_Payment_Gateway_Privacy' ) ) :
30
+
31
+ /**
32
+ * The payment gateway privacy handler class.
33
+ *
34
+ * @since 2.1.2
35
+ */
36
+ class SV_WC_Payment_Gateway_Privacy extends \WC_Abstract_Privacy {
37
+
38
+
39
+ /** @var SV_WC_Payment_Gateway_Plugin payment gateway plugin instance */
40
+ private $plugin;
41
+
42
+
43
+ /**
44
+ * Constructs the class.
45
+ *
46
+ * @since 2.1.2
47
+ *
48
+ * @param SV_WC_Payment_Gateway_Plugin payment gateway plugin instance
49
+ */
50
+ public function __construct( SV_WC_Payment_Gateway_Plugin $plugin ) {
51
+
52
+ $this->plugin = $plugin;
53
+
54
+ parent::__construct( $plugin->get_plugin_name() );
55
+
56
+ // add the action & filter hooks
57
+ $this->add_hooks();
58
+
59
+ // add the token exporters & erasers
60
+ $this->add_exporter( "wc-{$plugin->get_id_dasherized()}-customer-tokens", __( "{$plugin->get_plugin_name()} Payment Tokens", 'woocommerce-gateway-paypal-powered-by-braintree' ), array( $this, 'customer_tokens_exporter' ) );
61
+ $this->add_eraser( "wc-{$plugin->get_id_dasherized()}-customer-tokens", __( "{$plugin->get_plugin_name()} Payment Tokens", 'woocommerce-gateway-paypal-powered-by-braintree' ), array( $this, 'customer_tokens_eraser' ) );
62
+ }
63
+
64
+
65
+ /**
66
+ * Adds the action & filter hooks.
67
+ *
68
+ * @since 2.1.2
69
+ */
70
+ protected function add_hooks() {
71
+
72
+ // add the gateway data to customer data exports
73
+ add_filter( 'woocommerce_privacy_export_customer_personal_data', array( $this, 'add_export_customer_data' ), 10, 2 );
74
+
75
+ // removes the gateway data during a customer data erasure
76
+ add_action( 'woocommerce_privacy_erase_personal_data_customer', array( $this, 'remove_customer_personal_data' ), 10, 2 );
77
+
78
+ // add the gateway data to order data exports
79
+ add_filter( 'woocommerce_privacy_export_order_personal_data', array( $this, 'add_export_order_data' ), 10, 2 );
80
+
81
+ // removes the gateway data during an order data erasure
82
+ add_action( 'woocommerce_privacy_remove_order_personal_data', array( $this, 'remove_order_personal_data' ) );
83
+ }
84
+
85
+
86
+ /** Customer methods ******************************************************/
87
+
88
+
89
+ /**
90
+ * Adds the gateway data to customer data exports.
91
+ *
92
+ * @internal
93
+ *
94
+ * @since 2.1.2
95
+ *
96
+ * @param array $data customer personal data to export
97
+ * @param \WC_Customer $customer customer object
98
+ * @return array
99
+ */
100
+ public function add_export_customer_data( $data, $customer ) {
101
+
102
+ if ( $customer instanceof \WC_Customer ) {
103
+
104
+ foreach ( $this->get_plugin()->get_gateways() as $gateway ) {
105
+
106
+ // skip gateways that don't support customer ID
107
+ if ( ! $gateway->supports_customer_id() ) {
108
+ continue;
109
+ }
110
+
111
+ if ( $customer_id = $gateway->get_customer_id( $customer->get_id(), array( 'autocreate' => false ) ) ) {
112
+
113
+ $data[] = array(
114
+ 'name' => sprintf( __( '%s Customer ID', 'woocommerce-gateway-paypal-powered-by-braintree' ), $gateway->get_method_title() ),
115
+ 'value' => $customer_id,
116
+ );
117
+ }
118
+ }
119
+ }
120
+
121
+ return $data;
122
+ }
123
+
124
+
125
+ /**
126
+ * Removes the gateway data during an order data erasure.
127
+ *
128
+ * @since 2.1.2
129
+ *
130
+ * @param array $response customer data erasure response
131
+ * @param \WC_Customer $customer customer object
132
+ * @return array
133
+ */
134
+ public function remove_customer_personal_data( $response, $customer ) {
135
+
136
+ if ( $customer instanceof \WC_Customer ) {
137
+
138
+ foreach ( $this->get_plugin()->get_gateways() as $gateway ) {
139
+
140
+ // skip gateways that don't support customer ID
141
+ if ( ! $gateway->supports_customer_id() ) {
142
+ continue;
143
+ }
144
+
145
+ $gateway->remove_customer_id( $customer->get_id() );
146
+ }
147
+ }
148
+
149
+ return $response;
150
+ }
151
+
152
+
153
+ /**
154
+ * Handles the customer token exporter.
155
+ *
156
+ * @internal
157
+ *
158
+ * @param string $email_address email address for the user to export
159
+ * @param int $page page offset - unused as we don't page tokens
160
+ * @return array token export data
161
+ */
162
+ public function customer_tokens_exporter( $email_address, $page ) {
163
+
164
+ $data = array();
165
+ $user = get_user_by( 'email', $email_address );
166
+
167
+ if ( $user instanceof \WP_User ) {
168
+
169
+ foreach ( $this->get_plugin()->get_gateways() as $gateway ) {
170
+
171
+ // skip gateways that don't support tokenization
172
+ if ( ! $gateway->supports_tokenization() ) {
173
+ continue;
174
+ }
175
+
176
+ foreach ( $gateway->get_payment_tokens_handler()->get_tokens( $user->ID ) as $token ) {
177
+
178
+ $token_data = array();
179
+
180
+ if ( $token->get_type_full() ) {
181
+
182
+ $token_data[] = array(
183
+ 'name' => __( 'Type', 'woocommerce-gateway-paypal-powered-by-braintree' ),
184
+ 'value' => $token->get_type_full(),
185
+ );
186
+ }
187
+
188
+ if ( $token->get_last_four() ) {
189
+
190
+ $token_data[] = array(
191
+ 'name' => __( 'Last Four', 'woocommerce-gateway-paypal-powered-by-braintree' ),
192
+ 'value' => $token->get_last_four(),
193
+ );
194
+ }
195
+
196
+ if ( ! empty( $token_data ) ) {
197
+
198
+ $data[] = array(
199
+ 'group_id' => 'wc_' . $gateway->get_id() . '_tokens',
200
+ 'group_label' => sprintf( __( '%s Payment Tokens', 'woocommerce-gateway-paypal-powered-by-braintree' ), $gateway->get_method_title() ),
201
+ 'item_id' => 'token-' . $token->get_id(),
202
+ 'data' => $token_data,
203
+ );
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ return array(
210
+ 'data' => $data,
211
+ 'done' => true,
212
+ );
213
+ }
214
+
215
+
216
+ /**
217
+ * Handles the customer token eraser.
218
+ *
219
+ * @internal
220
+ *
221
+ * @param string $email_address email address for the user to erase
222
+ * @param int $page page offset - unused as we don't page tokens
223
+ * @return array token eraser data
224
+ */
225
+ public function customer_tokens_eraser( $email_address, $page ) {
226
+
227
+ $removed = false;
228
+ $messages = array();
229
+
230
+ $user = get_user_by( 'email', $email_address );
231
+
232
+ if ( $user instanceof \WP_User ) {
233
+
234
+ foreach ( $this->get_plugin()->get_gateways() as $gateway ) {
235
+
236
+ // skip gateways that don't support tokenization
237
+ if ( ! $gateway->supports_tokenization() ) {
238
+ continue;
239
+ }
240
+
241
+ foreach ( $gateway->get_payment_tokens_handler()->get_tokens( $user->ID ) as $token ) {
242
+
243
+ $gateway->get_payment_tokens_handler()->remove_token( $user->ID, $token );
244
+
245
+ $messages[] = sprintf( __( 'Removed payment token "%d"', 'woocommerce-gateway-paypal-powered-by-braintree' ), $token->get_id() );
246
+ $removed = true;
247
+ }
248
+
249
+ // completely remove the user meta in case there is an API failure
250
+ delete_user_meta( $user->ID, $gateway->get_payment_tokens_handler()->get_user_meta_name() );
251
+
252
+ $gateway->get_payment_tokens_handler()->clear_transient( $user->ID );
253
+ }
254
+ }
255
+
256
+ return array(
257
+ 'items_removed' => $removed,
258
+ 'items_retained' => false,
259
+ 'messages' => $messages,
260
+ 'done' => true,
261
+ );
262
+ }
263
+
264
+
265
+ /** Order methods *********************************************************/
266
+
267
+
268
+ /**
269
+ * Adds the gateway data to order data exports.
270
+ *
271
+ * @internal
272
+ *
273
+ * @since 2.1.2
274
+ *
275
+ * @param array $data order personal data to export
276
+ * @param \WC_Order $order order object
277
+ * @return array
278
+ */
279
+ public function add_export_order_data( $data, $order ) {
280
+
281
+ $order = wc_get_order( $order );
282
+
283
+ // ensure we have a full order object and it belongs to the plugin's gateway
284
+ if ( $order && $this->get_plugin()->has_gateway( $order->get_payment_method() ) ) {
285
+
286
+ $gateway = $this->get_plugin()->get_gateway( $order->get_payment_method() );
287
+
288
+ $meta_to_export = array(
289
+ 'account_four' => __( 'Last Four', 'woocommerce-gateway-paypal-powered-by-braintree' ),
290
+ 'account_type' => __( 'Account Type', 'woocommerce-gateway-paypal-powered-by-braintree' ),
291
+ 'card_type' => __( 'Card Type', 'woocommerce-gateway-paypal-powered-by-braintree' ),
292
+ 'card_expiry_date' => __( 'Expiry Date', 'woocommerce-gateway-paypal-powered-by-braintree' ),
293
+ 'payer_email' => __( 'Payer Email', 'woocommerce-gateway-paypal-powered-by-braintree' ),
294
+ );
295
+
296
+ foreach ( $meta_to_export as $key => $label ) {
297
+
298
+ if ( $value = $gateway->get_order_meta( $order, $key ) ) {
299
+
300
+ $data[] = array(
301
+ 'name' => $label,
302
+ 'value' => $value,
303
+ );
304
+ }
305
+ }
306
+ }
307
+
308
+ return $data;
309
+ }
310
+
311
+
312
+ /**
313
+ * Removes the gateway data during an order data erasure.
314
+ *
315
+ * @since 2.1.2
316
+ *
317
+ * @param \WC_Order $order order object
318
+ */
319
+ public function remove_order_personal_data( $order ) {
320
+
321
+ $order = wc_get_order( $order );
322
+
323
+ // ensure we have a full order object and it belongs to the plugin's gateway
324
+ if ( $order && $this->get_plugin()->has_gateway( $order->get_payment_method() ) ) {
325
+
326
+ $gateway = $this->get_plugin()->get_gateway( $order->get_payment_method() );
327
+
328
+ $meta_to_remove = array(
329
+ 'account_four' => 'XXXX',
330
+ 'account_type' => '',
331
+ 'card_type' => '',
332
+ 'card_expiry_date' => 'XXXX',
333
+ 'payer_email' => '',
334
+ );
335
+
336
+ /**
337
+ * Filters the personal order meta data to remove during a customer erasure request.
338
+ *
339
+ * @since 2.1.2
340
+ *
341
+ * @param array $meta_keys personal order meta data to remove during a customer erasure request, in the form of $meta_key => $anonymized_value
342
+ * @param \WC_Order $order order object
343
+ */
344
+ $meta_to_remove = apply_filters( 'wc_' . $gateway->get_id() . '_order_personal_data_to_remove', $meta_to_remove, $order );
345
+
346
+ foreach ( $meta_to_remove as $key => $anonymized_value ) {
347
+
348
+ // if the meta value already exists (don't add new meta to orders)
349
+ if ( $value = $gateway->get_order_meta( $order, $key ) ) {
350
+
351
+ // if no anon value was specified, let WP use its default
352
+ if ( empty( $anonymized_value ) && function_exists( 'wp_privacy_anonymize_data' ) ) {
353
+ $anonymized_value = wp_privacy_anonymize_data( 'text', $value );
354
+ }
355
+
356
+ $gateway->update_order_meta( $order, $key, $anonymized_value );
357
+ }
358
+ }
359
+
360
+ // clear the payment token (we don't want any "[deleted]" value stored)
361
+ if ( $gateway->get_order_meta( $order, 'payment_token' ) ) {
362
+ $gateway->update_order_meta( $order, 'payment_token', '' );
363
+ }
364
+ }
365
+ }
366
+
367
+
368
+ /**
369
+ * Gets the payment gateway plugin instance.
370
+ *
371
+ * @since 2.1.2
372
+ *
373
+ * @return SV_WC_Payment_Gateway_Plugin
374
+ */
375
+ protected function get_plugin() {
376
+
377
+ return $this->plugin;
378
+ }
379
+
380
+
381
+ }
382
+
383
+ endif;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr, zandyring, skyverge
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
4
  Requires at least: 4.4
5
- Tested up to: 4.9.2
6
- Stable tag: 2.1.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -122,6 +122,11 @@ New feature requests and bugs reports can be made in the plugin forum.
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
125
  = 2.1.1 =
126
  * Fix - Fix the payment form JavaScript compatibility with IE 11
127
 
2
  Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr, zandyring, skyverge
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
4
  Requires at least: 4.4
5
+ Tested up to: 4.9.6
6
+ Stable tag: 2.1.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
122
 
123
  == Changelog ==
124
 
125
+ = 2.1.2 =
126
+ * Tweak - Add payment details to the customer data export and remove it for erasure requests
127
+ * Tweak - Remove payment tokens for customer data erasure requests
128
+ * Misc - Add support for WooCommerce 3.4
129
+
130
  = 2.1.1 =
131
  * Fix - Fix the payment form JavaScript compatibility with IE 11
132
 
woocommerce-gateway-paypal-powered-by-braintree.php CHANGED
@@ -5,10 +5,10 @@
5
  * Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
6
  * Author: WooCommerce
7
  * Author URI: http://woocommerce.com/
8
- * Version: 2.1.1
9
  *
10
  * WC requires at least: 2.5.5
11
- * WC tested up to: 3.3.0
12
  *
13
  * Copyright (c) 2016-2018, Automattic, Inc.
14
  *
5
  * Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
6
  * Author: WooCommerce
7
  * Author URI: http://woocommerce.com/
8
+ * Version: 2.1.2
9
  *
10
  * WC requires at least: 2.5.5
11
+ * WC tested up to: 3.4.0
12
  *
13
  * Copyright (c) 2016-2018, Automattic, Inc.
14
  *