Skip to content

Commit

Permalink
Never refund a payment when changing an order status, just deal with …
Browse files Browse the repository at this point in the history
…pre-authorized payments (#901)

* Fix - Changing an order status to "Cancelled" will no longer refund the payment.

* Prepare a release with this fix

* Using a boolean would have been too easy...

* Never refund a payment when changing an order status, just deal with pre-authorized payments
  • Loading branch information
Daniel Rey López authored Jun 26, 2019
1 parent 6e32571 commit 9bcd635
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** Changelog ***

= 4.2.2 - 2019-06-26 =
* Fix - Changing an order status to "Cancelled" or "Refunded" will no longer refund the payment, will only void the payment if it was just authorized.

= 4.2.1 - 2019-06-17 =
* Update - Add UGX (Ugandan Shilling) to zero decimal currency list.
* Fix - CSRF verification error upon creating account on checkout.
Expand Down
9 changes: 7 additions & 2 deletions includes/class-wc-stripe-order-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,19 @@ public function capture_payment( $order_id ) {
* Cancel pre-auth on refund/cancellation.
*
* @since 3.1.0
* @version 4.0.0
* @version 4.2.2
* @param int $order_id
*/
public function cancel_payment( $order_id ) {
$order = wc_get_order( $order_id );

if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
$this->process_refund( $order_id );
$captured = WC_Stripe_Helper::is_wc_lt( '3.0' )
? get_post_meta( $order_id, '_stripe_charge_captured', true )
: $order->get_meta( '_stripe_charge_captured', true );
if ( 'no' === $captured ) {
$this->process_refund( $order_id );
}

// This hook fires when admin manually changes order status to cancel.
do_action( 'woocommerce_stripe_process_manual_cancel', $order );
Expand Down
12 changes: 5 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: credit card, stripe, apple pay, payment request, google pay, sepa, sofort,
Requires at least: 4.4
Tested up to: 5.2.1
Requires PHP: 5.6
Stable tag: 4.2.1
Stable tag: 4.2.2
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Attributions: thorsten-stripe
Expand Down Expand Up @@ -113,14 +113,12 @@ If you get stuck, you can ask for help in the Plugin Forum.

== Changelog ==

= 4.2.1 - 2019-06-17 =
* Update - Add UGX (Ugandan Shilling) to zero decimal currency list.
* Fix - CSRF verification error upon creating account on checkout.
* Fix - Duplicate emails and order notes after successful transactions.
= 4.2.2 - 2019-06-26 =
* Fix - Changing an order status to "Cancelled" or "Refunded" will no longer refund the payment, will only void the payment if it was just authorized.

[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/master/changelog.txt).

== Upgrade Notice ==

= 4.1 =
4.1 is a minor release. Please do a full site backup and test on a staging site before deploying to a live/production server.
= 4.2 =
4.2 is a minor release. Please do a full site backup and test on a staging site before deploying to a live/production server.
4 changes: 2 additions & 2 deletions woocommerce-gateway-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Take credit card payments on your store using Stripe.
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* Version: 4.2.1
* Version: 4.2.2
* Requires at least: 4.4
* Tested up to: 5.2.1
* WC requires at least: 2.6
Expand Down Expand Up @@ -46,7 +46,7 @@ function woocommerce_gateway_stripe_init() {
/**
* Required minimums and constants
*/
define( 'WC_STRIPE_VERSION', '4.2.1' );
define( 'WC_STRIPE_VERSION', '4.2.2' );
define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
Expand Down

0 comments on commit 9bcd635

Please sign in to comment.