WP eCommerce - Version 3.13.1

Version Description

[2017-10-25] =

  • Fix: Fatal errors in Braintree gateway below PHP 7.0.
Download this release

Release Info

Developer JustinSainton
Plugin Icon 128x128 WP eCommerce
Version 3.13.1
Comparing to
See all releases

Code changes from version 3.13.0 to 3.13.1

readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpecommerce.org
4
  Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 4.5
6
  Tested up to: 4.9
7
- Stable tag: 3.13.0
8
 
9
  WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
@@ -36,6 +36,10 @@ After upgrading from earlier versions look for link "Update Store". This will up
36
 
37
  == Changelog ==
38
 
 
 
 
 
39
  = 3.13.0 [2017-10-25] =
40
 
41
  * New: Now including PayPal's Braintree payment gateway by default.
4
  Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 4.5
6
  Tested up to: 4.9
7
+ Stable tag: 3.13.1
8
 
9
  WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
36
 
37
  == Changelog ==
38
 
39
+ = 3.13.1 [2017-10-25] =
40
+
41
+ * Fix: Fatal errors in Braintree gateway below PHP 7.0.
42
+
43
  = 3.13.0 [2017-10-25] =
44
 
45
  * New: Now including PayPal's Braintree payment gateway by default.
wp-shopping-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP eCommerce
4
  * Plugin URI: http://wpecommerce.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
- * Version: 3.13.0
7
  * Author: WP eCommerce
8
  * Author URI: http://wpecommerce.org/
9
  * Text Domain: wp-e-commerce
3
  * Plugin Name: WP eCommerce
4
  * Plugin URI: http://wpecommerce.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
+ * Version: 3.13.1
7
  * Author: WP eCommerce
8
  * Author URI: http://wpecommerce.org/
9
  * Text Domain: wp-e-commerce
wpsc-components/merchant-core-v3/gateways/braintree-credit-cards.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
3
-
4
  public function __construct() {
5
  require_once( WPSC_MERCHANT_V3_SDKS_PATH . '/pp-braintree/pp-braintree.php' );
6
  parent::__construct();
@@ -14,14 +14,18 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
14
  // Define user set variables
15
  }
16
 
 
 
 
 
17
  public function init() {
18
  parent::init();
19
 
20
  // Disable if not setup using BT Auth
21
- if ( ! $this->helpers::is_gateway_setup( 'braintree-credit-cards' ) ) {
22
  // Remove gateway if its not setup properly
23
  add_filter( 'wpsc_get_active_gateways', array( $this, 'remove_gateways' ) );
24
- add_filter( 'wpsc_payment_method_form_fields', array( $this, 'remove_gateways_v2' ), 999 );
25
  }
26
 
27
  // Tev1 fields
@@ -82,7 +86,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
82
 
83
  return $fields;
84
  }
85
-
86
  public function tev1_checkout_fields_extra( $name ) {
87
  $output = '';
88
 
@@ -98,7 +102,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
98
  </div>
99
  </div>';
100
 
101
- echo $output;
102
  }
103
 
104
  public function process() {
@@ -132,7 +136,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
132
  $error = __( '3D Secure verification failed.', 'wp-e-commerce' );
133
  $order->set( 'processed', WPSC_Purchase_Log::INCOMPLETE_SALE )->save();
134
  $order->add_note( $error );
135
- $this->helpers::set_payment_error_message( $error );
136
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
137
  }
138
 
@@ -183,14 +187,14 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
183
  'deviceData' => $kount_fraud,
184
  );
185
 
186
- if ( $this->helpers::bt_auth_is_connected() ) {
187
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
188
  $gateway = new Braintree_Gateway( array(
189
  'accessToken' => $acc_token,
190
  ));
191
  $result = $gateway->transaction()->sale( $params );
192
  } else {
193
- $this->helpers::setBraintreeConfiguration();
194
  $result = Braintree_Transaction::sale( $params );
195
  }
196
 
@@ -210,13 +214,13 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
210
  } else {
211
  if ( $result->transaction ) {
212
  $order->set( 'processed', WPSC_Purchase_Log::INCOMPLETE_SALE )->save();
213
- $error = $this->helpers::get_failure_status_info( $result, 'message' );
214
- $this->helpers::set_payment_error_message( $error );
215
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
216
  } else {
217
  $error = "Payment Error: " . $result->message;
218
 
219
- $this->helpers::set_payment_error_message( $error );
220
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
221
  }
222
  }
@@ -227,7 +231,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
227
  $pp_3ds_risk = $this->setting->get( 'three_d_secure_risk' ) != false ? $this->setting->get( 'three_d_secure_risk' ) : 'standard' ;
228
  $auth_3ds = false;
229
 
230
- if ( $this->helpers::bt_auth_can_connect() && $this->helpers::bt_auth_is_connected() ) {
231
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
232
 
233
  $gateway = new Braintree_Gateway( array(
@@ -292,7 +296,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
292
  $transaction_id = $log->get( 'transactid' );
293
  $log->get( 'totalprice' );
294
 
295
- if ( $this->helpers::bt_auth_can_connect() && $this->helpers::bt_auth_is_connected() ) {
296
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
297
 
298
  $gateway = new Braintree_Gateway( array(
@@ -300,7 +304,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
300
  ));
301
  $result = $gateway->transaction()->submitForSettlement( $transaction_id );
302
  } else {
303
- $this->helpers::setBraintreeConfiguration();
304
  $result = Braintree_Transaction::submitForSettlement( $transaction_id );
305
  }
306
 
@@ -324,7 +328,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
324
  // Process a Void on the Authorization
325
  $transaction_id = $log->get( 'transactid' );
326
 
327
- if ( $this->helpers::bt_auth_can_connect() && $this->helpers::bt_auth_is_connected() ) {
328
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
329
 
330
  $gateway = new Braintree_Gateway( array(
@@ -332,7 +336,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
332
  ));
333
  $result = $gateway->transaction()->void( $transaction_id );
334
  } else {
335
- $this->helpers::setBraintreeConfiguration();
336
  $result = Braintree_Transaction::void( $transaction_id );
337
  }
338
 
@@ -385,7 +389,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
385
 
386
  $transaction_id = $log->get( 'transactid' );
387
 
388
- if ( $this->helpers::bt_auth_can_connect() && $this->helpers::bt_auth_is_connected() ) {
389
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
390
 
391
  $gateway = new Braintree_Gateway( array(
@@ -393,12 +397,12 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
393
  ));
394
  $result = $gateway->transaction()->refund( $transaction_id );
395
  } else {
396
- $this->helpers::setBraintreeConfiguration();
397
  $result = Braintree_Transaction::refund( $transaction_id );
398
  }
399
 
400
  if ( $result->success ) {
401
-
402
  $current_refund = $log->get_total_refunded();
403
 
404
  // Set a log meta entry, and save log before adding refund note.
@@ -411,7 +415,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
411
  }
412
  }
413
 
414
- return false;
415
  }
416
 
417
  public function manual_credentials( $hide = false ) {
@@ -458,11 +462,11 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
458
  </tr>
459
  <?php
460
  }
461
-
462
-
463
  public function setup_form() {
464
- if ( $this->helpers::bt_auth_can_connect() ) {
465
- echo $this->helpers::show_connect_button();
466
  } else {
467
  $this->manual_credentials(true);
468
  }
@@ -487,7 +491,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
487
  <td colspan="2">
488
  <h4><?php _e( '3D Secure Settings', 'wp-e-commerce' ); ?></h4>
489
  </td>
490
- </tr>
491
  <tr>
492
  <td>
493
  <label for="wpsc-worldpay-secure-key"><?php _e( '3D Secure Enabled', 'wp-e-commerce' ); ?></label>
@@ -507,7 +511,7 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
507
  <label><input <?php checked( (bool) $this->setting->get( 'three_d_secure_only' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'three_d_secure_only' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
508
  <p class="description"><?php _e( 'Only transactions that pass 3D Secure verifications are allowed to be processed', 'wpsc' ); ?></p>
509
  </td>
510
- </tr>
511
  <tr>
512
  <td>
513
  <label for="wpsc-worldpay-payment-capture"><?php _e( '3D Secure Risk Settings', 'wp-e-commerce' ); ?></label>
@@ -558,4 +562,4 @@ class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
558
  }
559
  return $fields;
560
  }
561
- }
1
  <?php
2
  class WPSC_Payment_Gateway_Braintree_Credit_Cards extends WPSC_Payment_Gateway {
3
+
4
  public function __construct() {
5
  require_once( WPSC_MERCHANT_V3_SDKS_PATH . '/pp-braintree/pp-braintree.php' );
6
  parent::__construct();
14
  // Define user set variables
15
  }
16
 
17
+ public function load() {
18
+ return version_compare( PHP_VERSION, '5.4.0', '>=' );
19
+ }
20
+
21
  public function init() {
22
  parent::init();
23
 
24
  // Disable if not setup using BT Auth
25
+ if ( ! $this->helpers->is_gateway_setup( 'braintree-credit-cards' ) ) {
26
  // Remove gateway if its not setup properly
27
  add_filter( 'wpsc_get_active_gateways', array( $this, 'remove_gateways' ) );
28
+ add_filter( 'wpsc_payment_method_form_fields', array( $this, 'remove_gateways_v2' ), 999 );
29
  }
30
 
31
  // Tev1 fields
86
 
87
  return $fields;
88
  }
89
+
90
  public function tev1_checkout_fields_extra( $name ) {
91
  $output = '';
92
 
102
  </div>
103
  </div>';
104
 
105
+ echo $output;
106
  }
107
 
108
  public function process() {
136
  $error = __( '3D Secure verification failed.', 'wp-e-commerce' );
137
  $order->set( 'processed', WPSC_Purchase_Log::INCOMPLETE_SALE )->save();
138
  $order->add_note( $error );
139
+ $this->helpers->set_payment_error_message( $error );
140
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
141
  }
142
 
187
  'deviceData' => $kount_fraud,
188
  );
189
 
190
+ if ( $this->helpers->bt_auth_is_connected() ) {
191
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
192
  $gateway = new Braintree_Gateway( array(
193
  'accessToken' => $acc_token,
194
  ));
195
  $result = $gateway->transaction()->sale( $params );
196
  } else {
197
+ $this->helpers->setBraintreeConfiguration();
198
  $result = Braintree_Transaction::sale( $params );
199
  }
200
 
214
  } else {
215
  if ( $result->transaction ) {
216
  $order->set( 'processed', WPSC_Purchase_Log::INCOMPLETE_SALE )->save();
217
+ $error = $this->helpers->get_failure_status_info( $result, 'message' );
218
+ $this->helpers->set_payment_error_message( $error );
219
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
220
  } else {
221
  $error = "Payment Error: " . $result->message;
222
 
223
+ $this->helpers->set_payment_error_message( $error );
224
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
225
  }
226
  }
231
  $pp_3ds_risk = $this->setting->get( 'three_d_secure_risk' ) != false ? $this->setting->get( 'three_d_secure_risk' ) : 'standard' ;
232
  $auth_3ds = false;
233
 
234
+ if ( $this->helpers->bt_auth_can_connect() && $this->helpers->bt_auth_is_connected() ) {
235
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
236
 
237
  $gateway = new Braintree_Gateway( array(
296
  $transaction_id = $log->get( 'transactid' );
297
  $log->get( 'totalprice' );
298
 
299
+ if ( $this->helpers->bt_auth_can_connect() && $this->helpers->bt_auth_is_connected() ) {
300
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
301
 
302
  $gateway = new Braintree_Gateway( array(
304
  ));
305
  $result = $gateway->transaction()->submitForSettlement( $transaction_id );
306
  } else {
307
+ $this->helpers->setBraintreeConfiguration();
308
  $result = Braintree_Transaction::submitForSettlement( $transaction_id );
309
  }
310
 
328
  // Process a Void on the Authorization
329
  $transaction_id = $log->get( 'transactid' );
330
 
331
+ if ( $this->helpers->bt_auth_can_connect() && $this->helpers->bt_auth_is_connected() ) {
332
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
333
 
334
  $gateway = new Braintree_Gateway( array(
336
  ));
337
  $result = $gateway->transaction()->void( $transaction_id );
338
  } else {
339
+ $this->helpers->setBraintreeConfiguration();
340
  $result = Braintree_Transaction::void( $transaction_id );
341
  }
342
 
389
 
390
  $transaction_id = $log->get( 'transactid' );
391
 
392
+ if ( $this->helpers->bt_auth_can_connect() && $this->helpers->bt_auth_is_connected() ) {
393
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
394
 
395
  $gateway = new Braintree_Gateway( array(
397
  ));
398
  $result = $gateway->transaction()->refund( $transaction_id );
399
  } else {
400
+ $this->helpers->setBraintreeConfiguration();
401
  $result = Braintree_Transaction::refund( $transaction_id );
402
  }
403
 
404
  if ( $result->success ) {
405
+
406
  $current_refund = $log->get_total_refunded();
407
 
408
  // Set a log meta entry, and save log before adding refund note.
415
  }
416
  }
417
 
418
+ return false;
419
  }
420
 
421
  public function manual_credentials( $hide = false ) {
462
  </tr>
463
  <?php
464
  }
465
+
466
+
467
  public function setup_form() {
468
+ if ( $this->helpers->bt_auth_can_connect() ) {
469
+ echo $this->helpers->show_connect_button();
470
  } else {
471
  $this->manual_credentials(true);
472
  }
491
  <td colspan="2">
492
  <h4><?php _e( '3D Secure Settings', 'wp-e-commerce' ); ?></h4>
493
  </td>
494
+ </tr>
495
  <tr>
496
  <td>
497
  <label for="wpsc-worldpay-secure-key"><?php _e( '3D Secure Enabled', 'wp-e-commerce' ); ?></label>
511
  <label><input <?php checked( (bool) $this->setting->get( 'three_d_secure_only' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'three_d_secure_only' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
512
  <p class="description"><?php _e( 'Only transactions that pass 3D Secure verifications are allowed to be processed', 'wpsc' ); ?></p>
513
  </td>
514
+ </tr>
515
  <tr>
516
  <td>
517
  <label for="wpsc-worldpay-payment-capture"><?php _e( '3D Secure Risk Settings', 'wp-e-commerce' ); ?></label>
562
  }
563
  return $fields;
564
  }
565
+ }
wpsc-components/merchant-core-v3/gateways/braintree-paypal.php CHANGED
@@ -13,15 +13,19 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
13
  $this->but_colour = $this->setting->get( 'but_colour' ) !== null ? $this->setting->get( 'but_colour' ) : $this->setting->set( 'but_colour', 'gold' );
14
  $this->but_shape = $this->setting->get( 'but_shape' ) !== null ? $this->setting->get( 'but_shape' ) : $this->setting->set( 'but_shape', 'pill' );
15
  }
 
 
 
 
16
 
17
  public function init() {
18
  parent::init();
19
 
20
  // Disable if not setup using BT Auth
21
- if ( ! $this->helpers::is_gateway_setup( 'braintree-paypal' ) ) {
22
  // Remove gateway if its not setup properly
23
  add_filter( 'wpsc_get_active_gateways', array( $this, 'remove_gateways' ) );
24
- add_filter( 'wpsc_payment_method_form_fields', array( $this, 'remove_gateways_v2' ), 999 );
25
  }
26
 
27
  // Tev1 fields
@@ -63,7 +67,7 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
63
  public function process() {
64
  global $braintree_settings;
65
 
66
- WPEC_Braintree_Helpers::setBraintreeConfiguration('braintree-paypal');
67
 
68
  $order = $this->purchase_log;
69
  $payment_method_nonce = $_POST['pp_btree_method_nonce'];
@@ -111,7 +115,7 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
111
  ),
112
  );
113
 
114
- if ( $this->helpers::bt_auth_is_connected() ) {
115
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
116
  $gateway = new Braintree_Gateway( array(
117
  'accessToken' => $acc_token,
@@ -119,10 +123,10 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
119
 
120
  $result = $gateway->transaction()->sale( $params );
121
  } else {
122
- $this->helpers::setBraintreeConfiguration('braintree-paypal');
123
  $result = Braintree_Transaction::sale( $params );
124
  }
125
-
126
  // In theory all error handling should be done on the client side...?
127
  if ( $result->success ) {
128
  // Payment complete
@@ -132,13 +136,13 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
132
  } else {
133
  if ( $result->transaction ) {
134
  $order->set( 'processed', WPSC_Purchase_Log::INCOMPLETE_SALE )->save();
135
- $error = $this->helpers::get_failure_status_info( $result, 'message' );
136
- $this->helpers::set_payment_error_message( $error );
137
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
138
  } else {
139
  $error = "Payment Error: " . $result->message;
140
 
141
- $this->helpers::set_payment_error_message( $error );
142
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
143
  }
144
  }
@@ -195,8 +199,8 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
195
  * @return string
196
  */
197
  public function setup_form() {
198
- if ( $this->helpers::bt_auth_can_connect() ) {
199
- echo $this->helpers::show_connect_button();
200
  } else {
201
  $this->manual_credentials(true);
202
  }
@@ -205,7 +209,7 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
205
  <td colspan="2">
206
  <h4><?php _e( 'Gateway Settings', 'wp-e-commerce' ); ?></h4>
207
  </td>
208
- </tr>
209
  <tr>
210
  <td>
211
  <label for="wpsc-worldpay-secure-key"><?php _e( 'Button Size', 'wp-e-commerce' ); ?></label>
@@ -217,7 +221,7 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
217
  <option value='responsive' <?php selected( 'responsive', $this->setting->get( 'but_size' ) ); ?>><?php _e( 'Responsive', 'wp-e-commerce' )?></option>
218
  </select>
219
  </td>
220
- </tr>
221
  <tr>
222
  <td>
223
  <label for="wpsc-worldpay-secure-key"><?php _e( 'Button Colour', 'wp-e-commerce' ); ?></label>
@@ -229,7 +233,7 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
229
  <option value='silver' <?php selected( 'silver', $this->setting->get( 'but_colour' ) ); ?>><?php _e( 'Silver', 'wp-e-commerce' )?></option>
230
  </select>
231
  </td>
232
- </tr>
233
  <tr>
234
  <td>
235
  <label for="wpsc-worldpay-secure-key"><?php _e( 'Button Shape', 'wp-e-commerce' ); ?></label>
@@ -255,7 +259,7 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
255
  <label><input <?php checked( $this->setting->get( 'debugging' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wp-e-commerce' ); ?></label>&nbsp;&nbsp;&nbsp;
256
  <label><input <?php checked( (bool) $this->setting->get( 'debugging' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
257
  </td>
258
- </tr>
259
  <?php
260
  }
261
 
@@ -288,4 +292,4 @@ class WPSC_Payment_Gateway_Braintree_PayPal extends WPSC_Payment_Gateway {
288
  }
289
  return $fields;
290
  }
291
- }
13
  $this->but_colour = $this->setting->get( 'but_colour' ) !== null ? $this->setting->get( 'but_colour' ) : $this->setting->set( 'but_colour', 'gold' );
14
  $this->but_shape = $this->setting->get( 'but_shape' ) !== null ? $this->setting->get( 'but_shape' ) : $this->setting->set( 'but_shape', 'pill' );
15
  }
16
+
17
+ public function load() {
18
+ return version_compare( PHP_VERSION, '5.4.0', '>=' );
19
+ }
20
 
21
  public function init() {
22
  parent::init();
23
 
24
  // Disable if not setup using BT Auth
25
+ if ( ! $this->helpers->is_gateway_setup( 'braintree-paypal' ) ) {
26
  // Remove gateway if its not setup properly
27
  add_filter( 'wpsc_get_active_gateways', array( $this, 'remove_gateways' ) );
28
+ add_filter( 'wpsc_payment_method_form_fields', array( $this, 'remove_gateways_v2' ), 999 );
29
  }
30
 
31
  // Tev1 fields
67
  public function process() {
68
  global $braintree_settings;
69
 
70
+ $this->helpers->setBraintreeConfiguration('braintree-paypal');
71
 
72
  $order = $this->purchase_log;
73
  $payment_method_nonce = $_POST['pp_btree_method_nonce'];
115
  ),
116
  );
117
 
118
+ if ( $this->helpers->bt_auth_is_connected() ) {
119
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
120
  $gateway = new Braintree_Gateway( array(
121
  'accessToken' => $acc_token,
123
 
124
  $result = $gateway->transaction()->sale( $params );
125
  } else {
126
+ $this->helpers->setBraintreeConfiguration('braintree-paypal');
127
  $result = Braintree_Transaction::sale( $params );
128
  }
129
+
130
  // In theory all error handling should be done on the client side...?
131
  if ( $result->success ) {
132
  // Payment complete
136
  } else {
137
  if ( $result->transaction ) {
138
  $order->set( 'processed', WPSC_Purchase_Log::INCOMPLETE_SALE )->save();
139
+ $error = $this->helpers->get_failure_status_info( $result, 'message' );
140
+ $this->helpers->set_payment_error_message( $error );
141
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
142
  } else {
143
  $error = "Payment Error: " . $result->message;
144
 
145
+ $this->helpers->set_payment_error_message( $error );
146
  wp_safe_redirect( $this->get_shopping_cart_payment_url() );
147
  }
148
  }
199
  * @return string
200
  */
201
  public function setup_form() {
202
+ if ( $this->helpers->bt_auth_can_connect() ) {
203
+ echo $this->helpers->show_connect_button();
204
  } else {
205
  $this->manual_credentials(true);
206
  }
209
  <td colspan="2">
210
  <h4><?php _e( 'Gateway Settings', 'wp-e-commerce' ); ?></h4>
211
  </td>
212
+ </tr>
213
  <tr>
214
  <td>
215
  <label for="wpsc-worldpay-secure-key"><?php _e( 'Button Size', 'wp-e-commerce' ); ?></label>
221
  <option value='responsive' <?php selected( 'responsive', $this->setting->get( 'but_size' ) ); ?>><?php _e( 'Responsive', 'wp-e-commerce' )?></option>
222
  </select>
223
  </td>
224
+ </tr>
225
  <tr>
226
  <td>
227
  <label for="wpsc-worldpay-secure-key"><?php _e( 'Button Colour', 'wp-e-commerce' ); ?></label>
233
  <option value='silver' <?php selected( 'silver', $this->setting->get( 'but_colour' ) ); ?>><?php _e( 'Silver', 'wp-e-commerce' )?></option>
234
  </select>
235
  </td>
236
+ </tr>
237
  <tr>
238
  <td>
239
  <label for="wpsc-worldpay-secure-key"><?php _e( 'Button Shape', 'wp-e-commerce' ); ?></label>
259
  <label><input <?php checked( $this->setting->get( 'debugging' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wp-e-commerce' ); ?></label>&nbsp;&nbsp;&nbsp;
260
  <label><input <?php checked( (bool) $this->setting->get( 'debugging' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
261
  </td>
262
+ </tr>
263
  <?php
264
  }
265
 
292
  }
293
  return $fields;
294
  }
295
+ }
wpsc-components/merchant-core-v3/libraries/pp-braintree/pp-braintree.php CHANGED
@@ -11,12 +11,16 @@ class WPEC_Braintree_Helpers {
11
 
12
  public static function get_instance() {
13
  if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPEC_Braintree_Helpers ) ) {
14
- self::$instance = new WPEC_Braintree_Helpers;
 
 
 
15
 
16
- self::deactivate_plugins();
17
- self::includes();
18
- self::add_actions();
19
- self::add_filters();
 
20
  }
21
  return self::$instance;
22
  }
@@ -63,7 +67,7 @@ class WPEC_Braintree_Helpers {
63
  if ( $gateway['internalname'] == 'braintree-credit-cards' ) {
64
  $name = __( 'Cards', 'wp-e-commerce' );
65
  }
66
-
67
  if ( $gateway['internalname'] == 'braintree-paypal' ) {
68
  $name = __( 'PayPal', 'wp-e-commerce' );
69
  }
@@ -96,11 +100,11 @@ class WPEC_Braintree_Helpers {
96
  }
97
 
98
  public static function pp_braintree_enqueue_js() {
99
- if ( ! self::is_gateway_active( 'braintree-credit-cards' ) && ! self::is_gateway_active( 'braintree-paypal' ) ) {
100
  return;
101
  }
102
 
103
- if ( ! self::is_gateway_setup( 'braintree-credit-cards' ) && ! self::is_gateway_setup( 'braintree-paypal' ) ) {
104
  return;
105
  }
106
 
@@ -112,7 +116,7 @@ class WPEC_Braintree_Helpers {
112
  $bt_pp = new WPSC_Payment_Gateway_Setting( 'braintree-paypal' );
113
 
114
  // Check if we are using Auth and connected
115
- if ( self::bt_auth_can_connect() && self::bt_auth_is_connected() ) {
116
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
117
  $gateway = new Braintree_Gateway( array(
118
  'accessToken' => $acc_token
@@ -121,7 +125,7 @@ class WPEC_Braintree_Helpers {
121
  $clientToken = $gateway->clientToken()->generate();
122
  $pp_sandbox = self::get_auth_environment();
123
  } else {
124
- self::setBraintreeConfiguration();
125
  $clientToken = Braintree_ClientToken::generate();
126
 
127
  $bt_pp_sandbox = $bt_pp->get('sandbox');
@@ -146,13 +150,13 @@ class WPEC_Braintree_Helpers {
146
  'cart_total' => wpsc_cart_total(false),
147
  'currency' => wpsc_get_currency_code(),
148
  'is_shipping' => wpsc_uses_shipping(),
149
- 'is_cc_active' => self::is_gateway_active( 'braintree-credit-cards' ),
150
- 'is_pp_active' => self::is_gateway_active( 'braintree-paypal' ),
151
  )
152
  );
153
-
154
  wp_enqueue_style( 'pp-braintree-css', WPSC_MERCHANT_V3_SDKS_URL . '/pp-braintree/assets/css/style.css' );
155
-
156
  wp_enqueue_script( 'pp-braintree' );
157
  wp_enqueue_script( 'ppbtclient', 'https://js.braintreegateway.com/web/3.20.0/js/client.min.js', array(), null, true );
158
  wp_enqueue_script( 'ppbthosted', 'https://js.braintreegateway.com/web/3.20.0/js/hosted-fields.min.js', array(), null, true );
@@ -163,17 +167,16 @@ class WPEC_Braintree_Helpers {
163
  }
164
  }
165
 
166
- public static function is_gateway_active( $gateway ) {
167
- $selected_gateways = get_option( 'custom_gateway_options', array() );
168
-
169
- return in_array( $gateway, $selected_gateways );
170
  }
171
-
172
- public static function is_gateway_setup( $gateway ) {
173
  $settings = new WPSC_Payment_Gateway_Setting( $gateway );
174
 
175
- if ( self::bt_auth_can_connect() ) {
176
- if ( self::bt_auth_is_connected() && self::is_client_token( $gateway ) ) {
177
  return true;
178
  } else {
179
  //Disconnect BT auth
@@ -196,14 +199,14 @@ class WPEC_Braintree_Helpers {
196
  return false;
197
  }
198
 
199
- public static function show_connect_button() {
200
  $output = '';
201
- if ( self::bt_auth_can_connect() ) {
202
- $connect_url = ! self::bt_auth_is_connected() ? self::wpec_bt_auth_get_connect_url() : self::wpec_bt_auth_get_disconnect_url();
203
  $button_image_url = WPSC_MERCHANT_V3_SDKS_URL . '/pp-braintree/sdk/images/connect-braintree.png';
204
  $output .= '<tr class="btpp-braintree-auth">
205
  <td>Connect/Disconnect</td>';
206
- if ( self::bt_auth_is_connected() ) {
207
  $output .= "<td><a href='". esc_url( $connect_url ) . "' class='button-primary'>" . esc_html__( 'Disconnect from PayPal Powered by Braintree', 'wp-e-commerce' ) . "</a>
208
  <p class='small description'>" . __( 'Merchant account: ', 'wp-e-commerce' ) . esc_attr( get_option( 'wpec_braintree_auth_merchant_id' ) ) ."</p></td>";
209
  } else {
@@ -237,7 +240,7 @@ class WPEC_Braintree_Helpers {
237
  * @return string
238
  */
239
  public static function wpec_bt_auth_get_connect_url() {
240
-
241
  $connect_url = 'https://wpecommerce.org/wp-json/wpec/v1/braintree';
242
 
243
  $redirect_url = wp_nonce_url( admin_url( esc_url_raw( 'options-general.php?page=wpsc-settings&tab=gateway' ) ), 'connect_paypal_braintree', 'wpec_paypal_braintree_admin_nonce' );
@@ -267,16 +270,16 @@ class WPEC_Braintree_Helpers {
267
 
268
  // Let's go ahead and assume the user and business are in the same region and country,
269
  // because they probably are. If not, they can edit these anyways
270
- $base_country = new WPSC_Country( wpsc_get_base_country() );
271
  $region = new WPSC_Region( get_option( 'base_country' ), get_option( 'base_region' ) );
272
 
273
  $location = in_array( $base_country->get_isocode(), array( 'US', 'UK', 'FR' ) ) ? $base_country->get_isocode() : 'US';
274
 
275
- if ( ! empty( wpsc_get_base_country() ) ) {
276
- $query_args['business_country'] = $query_args['user_country'] = wpsc_get_base_country();
277
  }
278
 
279
- if ( ! empty( $region->get_name() ) ) {
280
  $query_args['business_region'] = $query_args['user_region'] = $region->get_code();
281
  }
282
 
@@ -291,18 +294,18 @@ class WPEC_Braintree_Helpers {
291
  return add_query_arg( $query_args, $connect_url );
292
  }
293
 
294
- public static function bt_auth_can_connect() {
295
  $base_country = new WPSC_Country( wpsc_get_base_country() );
296
 
297
  return in_array( $base_country->get_isocode(), array( 'US', 'UK', 'FR', 'GB' ) );
298
  }
299
 
300
- public static function bt_auth_is_connected() {
301
  $token = get_option( 'wpec_braintree_auth_access_token', '' );
302
 
303
  return ! empty( $token );
304
  }
305
-
306
  /**
307
  * Returns a list of merchant currencies
308
  */
@@ -491,9 +494,9 @@ class WPEC_Braintree_Helpers {
491
  /**
492
  * Setup the Braintree configuration
493
  */
494
- public static function setBraintreeConfiguration( $gateway = 'braintree-credit-cards' ) {
495
  global $merchant_currency, $braintree_settings;
496
-
497
  if ( $gateway == 'paypal' ) {
498
  //Get PayPal Gateway settings
499
  $settings = new WPSC_Payment_Gateway_Setting( 'braintree-paypal' );
@@ -502,13 +505,13 @@ class WPEC_Braintree_Helpers {
502
  }
503
 
504
  $sandbox = $settings->get('sandbox') == '1' ? 'sandbox' : 'production';
505
-
506
  Braintree_Configuration::environment( $sandbox );
507
  Braintree_Configuration::merchantId( $settings->get('merchant_id') );
508
  Braintree_Configuration::publicKey( $settings->get('public_key') );
509
- Braintree_Configuration::privateKey( $settings->get('private_key') );
510
  }
511
-
512
  /**
513
  * Handles the Braintree Auth connection response.
514
  *
@@ -526,14 +529,14 @@ class WPEC_Braintree_Helpers {
526
  if ( ! wp_verify_nonce( $nonce, 'connect_paypal_braintree' ) ) {
527
  wp_die( __( 'Invalid connection request', 'wp-e-commerce' ) );
528
  }
529
- $access_token = isset( $_REQUEST[ 'access_token' ] ) ? sanitize_text_field( base64_decode( $_REQUEST[ 'access_token' ] ) ) : false;
530
  if ( $access_token ) {
531
  update_option( 'wpec_braintree_auth_access_token', $access_token );
532
  list( $token_key, $environment, $merchant_id, $raw_token ) = explode( '$', $access_token );
533
  update_option( 'wpec_braintree_auth_environment', $environment );
534
  update_option( 'wpec_braintree_auth_merchant_id', $merchant_id );
535
  $connected = true;
536
-
537
  // BT Authentication successful.
538
  // Set 3D Secure setting here
539
  self::is_client_token();
@@ -584,7 +587,7 @@ class WPEC_Braintree_Helpers {
584
  public static function is_client_token( $gateway= '' ) {
585
  $valid = true;
586
 
587
- if ( self::bt_auth_is_connected() ) {
588
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
589
 
590
  try {
@@ -596,7 +599,7 @@ class WPEC_Braintree_Helpers {
596
  }
597
  } else {
598
  try {
599
- self::setBraintreeConfiguration( $gateway );
600
  $clientToken = Braintree_ClientToken::generate();
601
  }
602
  catch ( Exception $e ) {
@@ -629,9 +632,9 @@ class WPEC_Braintree_Helpers {
629
  if ( $gateway[0] == 'braintree-credit-cards' ) {
630
  $token = self::is_client_token( 'braintree-credit-cards' );
631
  } else {
632
- $token = self::is_client_token('braintree-paypal');
633
  }
634
-
635
  if ( ! $token ) {
636
  // Show some error message
637
  }
@@ -639,7 +642,7 @@ class WPEC_Braintree_Helpers {
639
  }
640
  }
641
 
642
- public static function set_payment_error_message( $error ) {
643
  if ( wpsc_is_theme_engine( '1.0' ) ) {
644
  $messages = wpsc_get_customer_meta( 'checkout_misc_error_messages' );
645
  if ( ! is_array( $messages ) ) {
@@ -651,7 +654,7 @@ class WPEC_Braintree_Helpers {
651
  WPSC_Message_Collection::get_instance()->add( $error, 'error', 'main', 'flash' );
652
  }
653
  }
654
-
655
  /**
656
  * Gets configured environment.
657
  *
@@ -664,7 +667,7 @@ class WPEC_Braintree_Helpers {
664
  public static function get_auth_environment() {
665
  $environment = false;
666
 
667
- if ( self::bt_auth_is_connected() ) {
668
  $environment = get_option( 'wpec_braintree_auth_environment', 'production' );
669
  }
670
 
@@ -677,7 +680,7 @@ class WPEC_Braintree_Helpers {
677
  * @param string $type status info type, either `code` or `message`
678
  * @return string
679
  */
680
- public static function get_failure_status_info( $result, $type ) {
681
 
682
  // see https://developers.braintreepayments.com/reference/response/transaction/php#unsuccessful-result
683
  // As per recommendation show a generic response message
@@ -723,11 +726,11 @@ class WPEC_Braintree_Helpers {
723
  }
724
 
725
  public function admin_notices() {
726
- if ( ! self::is_gateway_active( 'braintree-credit-cards' ) && ! self::is_gateway_active( 'braintree-paypal' ) ) {
727
  return;
728
  }
729
-
730
- if ( self::is_gateway_setup( 'braintree-credit-cards' ) || self::is_gateway_setup( 'braintree-paypal' ) ) {
731
  return;
732
  }
733
  ?>
@@ -736,4 +739,4 @@ class WPEC_Braintree_Helpers {
736
  </div>
737
  <?php
738
  }
739
- }
11
 
12
  public static function get_instance() {
13
  if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPEC_Braintree_Helpers ) ) {
14
+ if( version_compare( phpversion(), '5.4', '<' ) ) {
15
+ return;
16
+ } else {
17
+ self::$instance = new WPEC_Braintree_Helpers;
18
 
19
+ self::deactivate_plugins();
20
+ self::includes();
21
+ self::add_actions();
22
+ self::add_filters();
23
+ }
24
  }
25
  return self::$instance;
26
  }
67
  if ( $gateway['internalname'] == 'braintree-credit-cards' ) {
68
  $name = __( 'Cards', 'wp-e-commerce' );
69
  }
70
+
71
  if ( $gateway['internalname'] == 'braintree-paypal' ) {
72
  $name = __( 'PayPal', 'wp-e-commerce' );
73
  }
100
  }
101
 
102
  public static function pp_braintree_enqueue_js() {
103
+ if ( ! self::get_instance()->is_gateway_active( 'braintree-credit-cards' ) && ! self::get_instance()->is_gateway_active( 'braintree-paypal' ) ) {
104
  return;
105
  }
106
 
107
+ if ( ! self::get_instance()->is_gateway_setup( 'braintree-credit-cards' ) && ! self::get_instance()->is_gateway_setup( 'braintree-paypal' ) ) {
108
  return;
109
  }
110
 
116
  $bt_pp = new WPSC_Payment_Gateway_Setting( 'braintree-paypal' );
117
 
118
  // Check if we are using Auth and connected
119
+ if ( self::get_instance()->bt_auth_is_connected() && self::get_instance()->bt_auth_is_connected() ) {
120
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
121
  $gateway = new Braintree_Gateway( array(
122
  'accessToken' => $acc_token
125
  $clientToken = $gateway->clientToken()->generate();
126
  $pp_sandbox = self::get_auth_environment();
127
  } else {
128
+ self::get_instance()->setBraintreeConfiguration();
129
  $clientToken = Braintree_ClientToken::generate();
130
 
131
  $bt_pp_sandbox = $bt_pp->get('sandbox');
150
  'cart_total' => wpsc_cart_total(false),
151
  'currency' => wpsc_get_currency_code(),
152
  'is_shipping' => wpsc_uses_shipping(),
153
+ 'is_cc_active' => self::get_instance()->is_gateway_active( 'braintree-credit-cards' ),
154
+ 'is_pp_active' => self::get_instance()->is_gateway_active( 'braintree-paypal' ),
155
  )
156
  );
157
+
158
  wp_enqueue_style( 'pp-braintree-css', WPSC_MERCHANT_V3_SDKS_URL . '/pp-braintree/assets/css/style.css' );
159
+
160
  wp_enqueue_script( 'pp-braintree' );
161
  wp_enqueue_script( 'ppbtclient', 'https://js.braintreegateway.com/web/3.20.0/js/client.min.js', array(), null, true );
162
  wp_enqueue_script( 'ppbthosted', 'https://js.braintreegateway.com/web/3.20.0/js/hosted-fields.min.js', array(), null, true );
167
  }
168
  }
169
 
170
+ public function is_gateway_active( $gateway ) {
171
+
172
+ return wpsc_is_gateway_active( $gateway );
 
173
  }
174
+
175
+ public function is_gateway_setup( $gateway ) {
176
  $settings = new WPSC_Payment_Gateway_Setting( $gateway );
177
 
178
+ if ( self::get_instance()->bt_auth_is_connected() ) {
179
+ if ( self::get_instance()->bt_auth_is_connected() && self::is_client_token( $gateway ) ) {
180
  return true;
181
  } else {
182
  //Disconnect BT auth
199
  return false;
200
  }
201
 
202
+ public function show_connect_button() {
203
  $output = '';
204
+ if ( self::get_instance()->bt_auth_can_connect() ) {
205
+ $connect_url = ! self::get_instance()->bt_auth_is_connected() ? self::wpec_bt_auth_get_connect_url() : self::wpec_bt_auth_get_disconnect_url();
206
  $button_image_url = WPSC_MERCHANT_V3_SDKS_URL . '/pp-braintree/sdk/images/connect-braintree.png';
207
  $output .= '<tr class="btpp-braintree-auth">
208
  <td>Connect/Disconnect</td>';
209
+ if ( self::get_instance()->bt_auth_is_connected() ) {
210
  $output .= "<td><a href='". esc_url( $connect_url ) . "' class='button-primary'>" . esc_html__( 'Disconnect from PayPal Powered by Braintree', 'wp-e-commerce' ) . "</a>
211
  <p class='small description'>" . __( 'Merchant account: ', 'wp-e-commerce' ) . esc_attr( get_option( 'wpec_braintree_auth_merchant_id' ) ) ."</p></td>";
212
  } else {
240
  * @return string
241
  */
242
  public static function wpec_bt_auth_get_connect_url() {
243
+ $base = wpsc_get_base_country();
244
  $connect_url = 'https://wpecommerce.org/wp-json/wpec/v1/braintree';
245
 
246
  $redirect_url = wp_nonce_url( admin_url( esc_url_raw( 'options-general.php?page=wpsc-settings&tab=gateway' ) ), 'connect_paypal_braintree', 'wpec_paypal_braintree_admin_nonce' );
270
 
271
  // Let's go ahead and assume the user and business are in the same region and country,
272
  // because they probably are. If not, they can edit these anyways
273
+ $base_country = new WPSC_Country( $base );
274
  $region = new WPSC_Region( get_option( 'base_country' ), get_option( 'base_region' ) );
275
 
276
  $location = in_array( $base_country->get_isocode(), array( 'US', 'UK', 'FR' ) ) ? $base_country->get_isocode() : 'US';
277
 
278
+ if ( ! empty( $base ) ) {
279
+ $query_args['business_country'] = $query_args['user_country'] = $base;
280
  }
281
 
282
+ if ( ! empty( $region ) ) {
283
  $query_args['business_region'] = $query_args['user_region'] = $region->get_code();
284
  }
285
 
294
  return add_query_arg( $query_args, $connect_url );
295
  }
296
 
297
+ public function bt_auth_can_connect() {
298
  $base_country = new WPSC_Country( wpsc_get_base_country() );
299
 
300
  return in_array( $base_country->get_isocode(), array( 'US', 'UK', 'FR', 'GB' ) );
301
  }
302
 
303
+ public function bt_auth_is_connected() {
304
  $token = get_option( 'wpec_braintree_auth_access_token', '' );
305
 
306
  return ! empty( $token );
307
  }
308
+
309
  /**
310
  * Returns a list of merchant currencies
311
  */
494
  /**
495
  * Setup the Braintree configuration
496
  */
497
+ public function setBraintreeConfiguration( $gateway = 'braintree-credit-cards' ) {
498
  global $merchant_currency, $braintree_settings;
499
+
500
  if ( $gateway == 'paypal' ) {
501
  //Get PayPal Gateway settings
502
  $settings = new WPSC_Payment_Gateway_Setting( 'braintree-paypal' );
505
  }
506
 
507
  $sandbox = $settings->get('sandbox') == '1' ? 'sandbox' : 'production';
508
+
509
  Braintree_Configuration::environment( $sandbox );
510
  Braintree_Configuration::merchantId( $settings->get('merchant_id') );
511
  Braintree_Configuration::publicKey( $settings->get('public_key') );
512
+ Braintree_Configuration::privateKey( $settings->get('private_key') );
513
  }
514
+
515
  /**
516
  * Handles the Braintree Auth connection response.
517
  *
529
  if ( ! wp_verify_nonce( $nonce, 'connect_paypal_braintree' ) ) {
530
  wp_die( __( 'Invalid connection request', 'wp-e-commerce' ) );
531
  }
532
+ $access_token = isset( $_REQUEST[ 'access_token' ] ) ? sanitize_text_field( base64_decode( $_REQUEST[ 'access_token' ] ) ) : false;
533
  if ( $access_token ) {
534
  update_option( 'wpec_braintree_auth_access_token', $access_token );
535
  list( $token_key, $environment, $merchant_id, $raw_token ) = explode( '$', $access_token );
536
  update_option( 'wpec_braintree_auth_environment', $environment );
537
  update_option( 'wpec_braintree_auth_merchant_id', $merchant_id );
538
  $connected = true;
539
+
540
  // BT Authentication successful.
541
  // Set 3D Secure setting here
542
  self::is_client_token();
587
  public static function is_client_token( $gateway= '' ) {
588
  $valid = true;
589
 
590
+ if ( self::get_instance()->bt_auth_is_connected() ) {
591
  $acc_token = get_option( 'wpec_braintree_auth_access_token' );
592
 
593
  try {
599
  }
600
  } else {
601
  try {
602
+ self::get_instance()->setBraintreeConfiguration( $gateway );
603
  $clientToken = Braintree_ClientToken::generate();
604
  }
605
  catch ( Exception $e ) {
632
  if ( $gateway[0] == 'braintree-credit-cards' ) {
633
  $token = self::is_client_token( 'braintree-credit-cards' );
634
  } else {
635
+ $token = self::is_client_token('braintree-paypal');
636
  }
637
+
638
  if ( ! $token ) {
639
  // Show some error message
640
  }
642
  }
643
  }
644
 
645
+ public function set_payment_error_message( $error ) {
646
  if ( wpsc_is_theme_engine( '1.0' ) ) {
647
  $messages = wpsc_get_customer_meta( 'checkout_misc_error_messages' );
648
  if ( ! is_array( $messages ) ) {
654
  WPSC_Message_Collection::get_instance()->add( $error, 'error', 'main', 'flash' );
655
  }
656
  }
657
+
658
  /**
659
  * Gets configured environment.
660
  *
667
  public static function get_auth_environment() {
668
  $environment = false;
669
 
670
+ if ( self::get_instance()->bt_auth_is_connected() ) {
671
  $environment = get_option( 'wpec_braintree_auth_environment', 'production' );
672
  }
673
 
680
  * @param string $type status info type, either `code` or `message`
681
  * @return string
682
  */
683
+ public function get_failure_status_info( $result, $type ) {
684
 
685
  // see https://developers.braintreepayments.com/reference/response/transaction/php#unsuccessful-result
686
  // As per recommendation show a generic response message
726
  }
727
 
728
  public function admin_notices() {
729
+ if ( ! self::get_instance()->is_gateway_active( 'braintree-credit-cards' ) && ! self::get_instance()->is_gateway_active( 'braintree-paypal' ) ) {
730
  return;
731
  }
732
+
733
+ if ( self::get_instance()->is_gateway_setup( 'braintree-credit-cards' ) || self::get_instance()->is_gateway_setup( 'braintree-paypal' ) ) {
734
  return;
735
  }
736
  ?>
739
  </div>
740
  <?php
741
  }
742
+ }
wpsc-core/wpsc-constants.php CHANGED
@@ -55,7 +55,7 @@ function wpsc_core_constants() {
55
 
56
  // Define Plugin version
57
  if ( ! defined( 'WPSC_VERSION' ) ) {
58
- define( 'WPSC_VERSION' , '3.13.0' );
59
  }
60
 
61
  if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
@@ -63,7 +63,7 @@ function wpsc_core_constants() {
63
  }
64
 
65
  if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
66
- define( 'WPSC_PRESENTABLE_VERSION', '3.13.0' );
67
  }
68
 
69
  // Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first
55
 
56
  // Define Plugin version
57
  if ( ! defined( 'WPSC_VERSION' ) ) {
58
+ define( 'WPSC_VERSION' , '3.13.1' );
59
  }
60
 
61
  if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
63
  }
64
 
65
  if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
66
+ define( 'WPSC_PRESENTABLE_VERSION', '3.13.1' );
67
  }
68
 
69
  // Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first