WooCommerce PayPal Powered by Braintree Payment Gateway - Version 1.2.5

Version Description

  • Fix - Prevent void on unsettled transaction when refunding partially.
  • Tweak - Add filter wc_gateway_paypal_braintree_sale_args to filter arguments passed to sale call.
Download this release

Release Info

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

Code changes from version 1.2.4 to 1.2.5

classes/class-wc-gateway-paypal-braintree-subscription.php CHANGED
@@ -266,7 +266,7 @@ abstract class WC_Gateway_Paypal_Braintree_Subscription extends WC_Gateway_Paypa
266
  ),
267
  );
268
 
269
- return $sale_args;
270
  }
271
 
272
  /**
@@ -303,18 +303,18 @@ abstract class WC_Gateway_Paypal_Braintree_Subscription extends WC_Gateway_Paypa
303
  ) );
304
 
305
  // Process the sale with the stored token and customer
306
- $sale_args = array(
307
- 'amount' => $amount_to_charge,
308
  'paymentMethodToken' => $payment_method_token,
309
- 'recurring' => true,
310
- 'customerId' => $braintree_customer_id,
311
- 'channel' => 'WooThemes_BT', // aka BN tracking code
312
- 'orderId' => $order->id,
313
- 'options' => array(
314
- 'submitForSettlement' => true,
315
- 'storeInVaultOnSuccess' => true
316
- )
317
- );
318
 
319
  try {
320
  $result = $gateway->transaction()->sale( $sale_args );
266
  ),
267
  );
268
 
269
+ return apply_filters( 'wc_gateway_paypal_braintree_sale_args', $sale_args );
270
  }
271
 
272
  /**
303
  ) );
304
 
305
  // Process the sale with the stored token and customer
306
+ $sale_args = apply_filters( 'wc_gateway_paypal_braintree_sale_args', array(
307
+ 'amount' => $amount_to_charge,
308
  'paymentMethodToken' => $payment_method_token,
309
+ 'recurring' => true,
310
+ 'customerId' => $braintree_customer_id,
311
+ 'channel' => 'WooThemes_BT', // aka BN tracking code
312
+ 'orderId' => $order->id,
313
+ 'options' => array(
314
+ 'submitForSettlement' => true,
315
+ 'storeInVaultOnSuccess' => true,
316
+ ),
317
+ ) );
318
 
319
  try {
320
  $result = $gateway->transaction()->sale( $sale_args );
classes/class-wc-gateway-paypal-braintree.php CHANGED
@@ -824,7 +824,7 @@ abstract class WC_Gateway_Paypal_Braintree extends WC_Payment_Gateway {
824
  'countryCodeAlpha2' => $order->shipping_country
825
  );
826
 
827
- $sale_args = array(
828
  'amount' => $order->order_total,
829
  'billing' => $billing,
830
  'shipping' => $shipping,
@@ -832,9 +832,9 @@ abstract class WC_Gateway_Paypal_Braintree extends WC_Payment_Gateway {
832
  'channel' => 'WooThemes_BT', // aka BN tracking code
833
  'orderId' => $order_id,
834
  'options' => array(
835
- 'submitForSettlement' => $this->capture ? 'true' : 'false'
836
- )
837
- );
838
 
839
  require_once( dirname( __FILE__ ) . '/../braintree_sdk/lib/Braintree.php' );
840
  $gateway = new Braintree_Gateway( array(
@@ -1002,6 +1002,11 @@ abstract class WC_Gateway_Paypal_Braintree extends WC_Payment_Gateway {
1002
  return false;
1003
  }
1004
 
 
 
 
 
 
1005
  try {
1006
  if ( "void" === $action_to_take ) {
1007
  $result = $gateway->transaction()->void( $transaction_id );
824
  'countryCodeAlpha2' => $order->shipping_country
825
  );
826
 
827
+ $sale_args = apply_filters( 'wc_gateway_paypal_braintree_sale_args', array(
828
  'amount' => $order->order_total,
829
  'billing' => $billing,
830
  'shipping' => $shipping,
832
  'channel' => 'WooThemes_BT', // aka BN tracking code
833
  'orderId' => $order_id,
834
  'options' => array(
835
+ 'submitForSettlement' => $this->capture ? 'true' : 'false',
836
+ ),
837
+ ) );
838
 
839
  require_once( dirname( __FILE__ ) . '/../braintree_sdk/lib/Braintree.php' );
840
  $gateway = new Braintree_Gateway( array(
1002
  return false;
1003
  }
1004
 
1005
+ // Only void transaction when refund amount equals to order's total.
1006
+ if ( 'void' === $action_to_take && $refund_amount != $order->get_total() ) {
1007
+ return new WP_Error( 'unable_to_void', __( 'Unable to void unsettled transaction when refunding partially.', 'woocommerce-gateway-paypal-braintree' ) );
1008
+ }
1009
+
1010
  try {
1011
  if ( "void" === $action_to_take ) {
1012
  $result = $gateway->transaction()->void( $transaction_id );
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === WooCommerce PayPal Powered by Braintree Payment Gateway ===
2
- Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb
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.6.1
6
- Stable tag: 1.2.4
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -110,6 +110,10 @@ New feature requests and bugs reports can be made in the plugin forum.
110
 
111
  == Changelog ==
112
 
 
 
 
 
113
  = 1.2.4 =
114
  * Fix - Free subscription trails not allowed.
115
  * Fix - Subscription recurring billing after free trial not working.
1
  === WooCommerce PayPal Powered by Braintree Payment Gateway ===
2
+ Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr
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.6.1
6
+ Stable tag: 1.2.5
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
110
 
111
  == Changelog ==
112
 
113
+ = 1.2.5 =
114
+ * Fix - Prevent void on unsettled transaction when refunding partially.
115
+ * Tweak - Add filter wc_gateway_paypal_braintree_sale_args to filter arguments passed to sale call.
116
+
117
  = 1.2.4 =
118
  * Fix - Free subscription trails not allowed.
119
  * Fix - Subscription recurring billing after free trial not working.
woocommerce-gateway-paypal-powered-by-braintree.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Receive 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: WooThemes
7
  * Author URI: http://woothemes.com/
8
- * Version: 1.2.4
9
  *
10
  * Copyright (c) 2016 WooThemes
11
  *
5
  * Description: Receive 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: WooThemes
7
  * Author URI: http://woothemes.com/
8
+ * Version: 1.2.5
9
  *
10
  * Copyright (c) 2016 WooThemes
11
  *