Payment Plugins for Stripe WooCommerce - Version 3.0.3

Version Description

  • Fixed - Check added to wc_stripe_order_status_completed function to ensure capture charge is only called when Stripe is the payment gateway for the order.
  • Updated - Stripe API version to 2019-11-05
Download this release

Release Info

Developer mr.clayton
Plugin Icon wp plugin Payment Plugins for Stripe WooCommerce
Version 3.0.3
Comparing to
See all releases

Code changes from version 3.0.2 to 3.0.3

i18n/languages/woo-stripe-payment.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: woo-stripe-payment\n"
5
- "POT-Creation-Date: 2019-10-22 13:13-0700\n"
6
  "PO-Revision-Date: 2019-08-16 14:27-0700\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
@@ -10,7 +10,7 @@ msgstr ""
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 2.1.1\n"
14
  "X-Poedit-Basepath: ../..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-KeywordsList: __;_e;_x\n"
@@ -46,13 +46,13 @@ msgid "Error capturing charge in Stripe. Reason: %s"
46
  msgstr ""
47
 
48
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:136
49
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:206
50
  #, php-format
51
  msgid "Error voiding charge. Reason: %s"
52
  msgstr ""
53
 
54
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:138
55
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:208
56
  msgid "Charge voided in Stripe."
57
  msgstr ""
58
 
@@ -63,21 +63,21 @@ msgid ""
63
  msgstr ""
64
 
65
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:169
66
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:243
67
  #, php-format
68
  msgid "Recurring payment captured in Stripe. Payment method: %s"
69
  msgstr ""
70
 
71
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:171
72
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:209
73
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:245
74
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:311
75
  #, php-format
76
  msgid "Recurring payment authorized in Stripe. Payment method: %s"
77
  msgstr ""
78
 
79
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:183
80
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:277
81
  #, php-format
82
  msgid "Error deleting Stripe card. Token Id: %s"
83
  msgstr ""
@@ -89,7 +89,7 @@ msgid ""
89
  msgstr ""
90
 
91
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:207
92
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:309
93
  #, php-format
94
  msgid "Pre-order payment captured in Stripe. Payment method: %s"
95
  msgstr ""
@@ -131,18 +131,18 @@ msgstr ""
131
  msgid "A new payment method is required."
132
  msgstr ""
133
 
134
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:232
135
  #, php-format
136
  msgid "Recurring payment for order failed. Reason: %s"
137
  msgstr ""
138
 
139
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:249
140
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:315
141
  #, php-format
142
  msgid "Customer must manually complete payment for payment method %s"
143
  msgstr ""
144
 
145
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:298
146
  #, php-format
147
  msgid "Pre-order payment for order failed. Reason: %s"
148
  msgstr ""
@@ -556,7 +556,7 @@ msgid ""
556
  "the funds are received."
557
  msgstr ""
558
 
559
- #: includes/class-wc-stripe-gateway.php:173
560
  #, php-format
561
  msgid "Error capturing charge. Reason: %s"
562
  msgstr ""
@@ -820,28 +820,28 @@ msgid "Please update you product quantity before using Google Pay."
820
  msgstr ""
821
 
822
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:87
823
- #: includes/wc-stripe-functions.php:358
824
  msgid "Subscription"
825
  msgstr ""
826
 
827
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:107
828
- #: includes/wc-stripe-functions.php:344
829
  msgid "Shipping"
830
  msgstr ""
831
 
832
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:114
833
  #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:194
834
- #: includes/wc-stripe-functions.php:351
835
  msgid "Tax"
836
  msgstr ""
837
 
838
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:145
839
- #: includes/wc-stripe-functions.php:409
840
  msgid "Waiting..."
841
  msgstr ""
842
 
843
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:146
844
- #: includes/wc-stripe-functions.php:410
845
  msgid "loading shipping methods..."
846
  msgstr ""
847
 
@@ -1484,19 +1484,19 @@ msgstr ""
1484
  msgid "Gateway Title"
1485
  msgstr ""
1486
 
1487
- #: includes/wc-stripe-functions.php:252
1488
  msgid "Please enter a valid postcode / ZIP."
1489
  msgstr ""
1490
 
1491
- #: includes/wc-stripe-functions.php:631
1492
  msgid "Simple form"
1493
  msgstr ""
1494
 
1495
- #: includes/wc-stripe-functions.php:664
1496
  msgid "Inline Form"
1497
  msgstr ""
1498
 
1499
- #: includes/wc-stripe-functions.php:700
1500
  msgid "Rounded Form"
1501
  msgstr ""
1502
 
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: woo-stripe-payment\n"
5
+ "POT-Creation-Date: 2019-11-25 13:29-0800\n"
6
  "PO-Revision-Date: 2019-08-16 14:27-0700\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.2.4\n"
14
  "X-Poedit-Basepath: ../..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-KeywordsList: __;_e;_x\n"
46
  msgstr ""
47
 
48
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:136
49
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:217
50
  #, php-format
51
  msgid "Error voiding charge. Reason: %s"
52
  msgstr ""
53
 
54
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:138
55
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:219
56
  msgid "Charge voided in Stripe."
57
  msgstr ""
58
 
63
  msgstr ""
64
 
65
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:169
66
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:258
67
  #, php-format
68
  msgid "Recurring payment captured in Stripe. Payment method: %s"
69
  msgstr ""
70
 
71
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:171
72
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:209
73
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:260
74
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:326
75
  #, php-format
76
  msgid "Recurring payment authorized in Stripe. Payment method: %s"
77
  msgstr ""
78
 
79
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:183
80
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:292
81
  #, php-format
82
  msgid "Error deleting Stripe card. Token Id: %s"
83
  msgstr ""
89
  msgstr ""
90
 
91
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:207
92
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:324
93
  #, php-format
94
  msgid "Pre-order payment captured in Stripe. Payment method: %s"
95
  msgstr ""
131
  msgid "A new payment method is required."
132
  msgstr ""
133
 
134
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:247
135
  #, php-format
136
  msgid "Recurring payment for order failed. Reason: %s"
137
  msgstr ""
138
 
139
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:264
140
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:330
141
  #, php-format
142
  msgid "Customer must manually complete payment for payment method %s"
143
  msgstr ""
144
 
145
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:313
146
  #, php-format
147
  msgid "Pre-order payment for order failed. Reason: %s"
148
  msgstr ""
556
  "the funds are received."
557
  msgstr ""
558
 
559
+ #: includes/class-wc-stripe-gateway.php:182
560
  #, php-format
561
  msgid "Error capturing charge. Reason: %s"
562
  msgstr ""
820
  msgstr ""
821
 
822
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:87
823
+ #: includes/wc-stripe-functions.php:365
824
  msgid "Subscription"
825
  msgstr ""
826
 
827
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:107
828
+ #: includes/wc-stripe-functions.php:351
829
  msgid "Shipping"
830
  msgstr ""
831
 
832
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:114
833
  #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:194
834
+ #: includes/wc-stripe-functions.php:358
835
  msgid "Tax"
836
  msgstr ""
837
 
838
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:145
839
+ #: includes/wc-stripe-functions.php:416
840
  msgid "Waiting..."
841
  msgstr ""
842
 
843
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:146
844
+ #: includes/wc-stripe-functions.php:417
845
  msgid "loading shipping methods..."
846
  msgstr ""
847
 
1484
  msgid "Gateway Title"
1485
  msgstr ""
1486
 
1487
+ #: includes/wc-stripe-functions.php:259
1488
  msgid "Please enter a valid postcode / ZIP."
1489
  msgstr ""
1490
 
1491
+ #: includes/wc-stripe-functions.php:638
1492
  msgid "Simple form"
1493
  msgstr ""
1494
 
1495
+ #: includes/wc-stripe-functions.php:671
1496
  msgid "Inline Form"
1497
  msgstr ""
1498
 
1499
+ #: includes/wc-stripe-functions.php:707
1500
  msgid "Rounded Form"
1501
  msgstr ""
1502
 
includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php CHANGED
@@ -201,11 +201,26 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
201
  }
202
 
203
  public function void_charge($order) {
204
- $result = $this->gateway->cancel_payment_intent ( $order->get_meta ( '_payment_intent_id', true ), wc_stripe_order_mode ( $order ) );
205
- if (is_wp_error ( $result )) {
206
- $order->add_order_note ( sprintf ( __ ( 'Error voiding charge. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ) );
207
- } else {
208
- $order->add_order_note ( __ ( 'Charge voided in Stripe.', 'woo-stripe-payment' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
210
  }
211
 
201
  }
202
 
203
  public function void_charge($order) {
204
+ // fetch the intent and check its status
205
+ $payment_intent = $this->gateway->fetch_payment_intent ( $order->get_meta ( '_payment_intent_id', true ), wc_stripe_order_mode ( $order ) );
206
+ if (is_wp_error ( $payment_intent )) {
207
+ return;
208
+ }
209
+ $statuses = array( 'requires_payment_method',
210
+ 'requires_capture', 'requires_confirmation',
211
+ 'requires_action'
212
+ );
213
+ if ('canceled' !== $payment_intent->status) {
214
+ if (in_array ( $payment_intent->status, $statuses )) {
215
+ $result = $this->gateway->cancel_payment_intent ( $payment_intent, wc_stripe_order_mode ( $order ) );
216
+ if (is_wp_error ( $result )) {
217
+ $order->add_order_note ( sprintf ( __ ( 'Error voiding charge. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ) );
218
+ } else {
219
+ $order->add_order_note ( __ ( 'Charge voided in Stripe.', 'woo-stripe-payment' ) );
220
+ }
221
+ } elseif ('succeeded' === $payment_intent->status) {
222
+ $this->process_refund ( $order->get_id (), $order->get_total () );
223
+ }
224
  }
225
  }
226
 
includes/class-stripe.php CHANGED
@@ -21,7 +21,7 @@ class WC_Stripe_Manager {
21
  *
22
  * @var string
23
  */
24
- public $version = '3.0.2';
25
 
26
  /**
27
  *
21
  *
22
  * @var string
23
  */
24
+ public $version = '3.0.3';
25
 
26
  /**
27
  *
includes/class-wc-stripe-gateway.php CHANGED
@@ -17,7 +17,7 @@ class WC_Stripe_Gateway {
17
 
18
  public static function init() {
19
  \Stripe\Stripe::setAppInfo ( 'Wordpress woo-stripe-payment', wc_stripe ()->version (), 'https://wordpress.org/plugins/woo-stripe-payment/', 'pp_partner_FdPtriN2Q7JLOe' );
20
- \Stripe\Stripe::setApiVersion ( '2019-05-16' );
21
  }
22
 
23
  /**
@@ -139,9 +139,18 @@ class WC_Stripe_Gateway {
139
  }
140
  }
141
 
 
 
 
 
 
142
  public function cancel_payment_intent($id, $mode = '') {
143
  try {
144
- $payment_intent = $this->fetch_payment_intent ( $id, $mode );
 
 
 
 
145
  return $payment_intent->cancel ( [], $this->get_api_options ( $mode ) );
146
  } catch ( \Stripe\Error\Base $e ) {
147
  $err = $e->getJsonBody ()[ 'error' ];
17
 
18
  public static function init() {
19
  \Stripe\Stripe::setAppInfo ( 'Wordpress woo-stripe-payment', wc_stripe ()->version (), 'https://wordpress.org/plugins/woo-stripe-payment/', 'pp_partner_FdPtriN2Q7JLOe' );
20
+ \Stripe\Stripe::setApiVersion ( '2019-11-05' );
21
  }
22
 
23
  /**
139
  }
140
  }
141
 
142
+ /**
143
+ *
144
+ * @param \Stripe\PaymentIntent|string $id
145
+ * @param string $mode
146
+ */
147
  public function cancel_payment_intent($id, $mode = '') {
148
  try {
149
+ if (! is_object ( $id )) {
150
+ $payment_intent = $this->fetch_payment_intent ( $id, $mode );
151
+ } else {
152
+ $payment_intent = $id;
153
+ }
154
  return $payment_intent->cancel ( [], $this->get_api_options ( $mode ) );
155
  } catch ( \Stripe\Error\Base $e ) {
156
  $err = $e->getJsonBody ()[ 'error' ];
includes/wc-stripe-functions.php CHANGED
@@ -214,27 +214,34 @@ function wc_stripe_payment_gateways($gateways) {
214
  * @param WC_Order $order
215
  */
216
  function wc_stripe_order_cancelled($order_id, $order) {
 
217
  /**
218
  *
219
  * @var WC_Payment_Gateway_Stripe $gateway
220
  */
221
- $gateway = WC ()->payment_gateways ()->payment_gateways ()[ $order->get_payment_method () ];
222
- $gateway->void_charge ( $order );
 
 
 
223
  }
224
 
225
  /**
226
  *
 
227
  * @package Stripe/Functions
228
  * @param int $order_id
229
  * @param WC_Order $order
230
  */
231
  function wc_stripe_order_status_completed($order_id, $order) {
 
232
  /**
233
  *
234
  * @var WC_Payment_Gateway_Stripe $gateway
235
  */
236
- $gateway = WC ()->payment_gateways ()->payment_gateways ()[ $order->get_payment_method () ];
237
- if (! $gateway->processing_payment) {
 
238
  $gateway->capture_charge ( $order->get_total (), $order );
239
  }
240
  }
@@ -772,9 +779,10 @@ function wc_stripe_display_prices_including_tax() {
772
 
773
  /**
774
  * Return true if the WC pre-orders plugin is active
 
775
  * @since 3.0.1
776
  * @package Stripe/Functions
777
  */
778
- function wc_stripe_pre_orders_active(){
779
- return class_exists('WC_Pre_Orders');
780
  }
214
  * @param WC_Order $order
215
  */
216
  function wc_stripe_order_cancelled($order_id, $order) {
217
+ $gateways = WC ()->payment_gateways ()->payment_gateways ();
218
  /**
219
  *
220
  * @var WC_Payment_Gateway_Stripe $gateway
221
  */
222
+ $gateway = isset ( $gateways[ $order->get_payment_method () ] ) ? $gateways[ $order->get_payment_method () ] : null;
223
+
224
+ if ($gateway && $gateway instanceof WC_Payment_Gateway_Stripe) {
225
+ $gateway->void_charge ( $order );
226
+ }
227
  }
228
 
229
  /**
230
  *
231
+ * @since 3.0.0
232
  * @package Stripe/Functions
233
  * @param int $order_id
234
  * @param WC_Order $order
235
  */
236
  function wc_stripe_order_status_completed($order_id, $order) {
237
+ $gateways = WC ()->payment_gateways ()->payment_gateways ();
238
  /**
239
  *
240
  * @var WC_Payment_Gateway_Stripe $gateway
241
  */
242
+ $gateway = isset ( $gateways[ $order->get_payment_method () ] ) ? $gateways[ $order->get_payment_method () ] : null;
243
+ // @since 3.0.3 check added to ensure this is a Stripe gateway.
244
+ if ($gateway && $gateway instanceof WC_Payment_Gateway_Stripe && ! $gateway->processing_payment) {
245
  $gateway->capture_charge ( $order->get_total (), $order );
246
  }
247
  }
779
 
780
  /**
781
  * Return true if the WC pre-orders plugin is active
782
+ *
783
  * @since 3.0.1
784
  * @package Stripe/Functions
785
  */
786
+ function wc_stripe_pre_orders_active() {
787
+ return class_exists ( 'WC_Pre_Orders' );
788
  }
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: mr.clayton
3
  Tags: stripe, klarna, credit card, apple pay, google pay, ideal, sepa, sofort
4
  Requires at least: 3.0.1
5
- Tested up to: 5.2.2
6
  Requires PHP: 5.4
7
- Stable tag: 3.0.2
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -51,6 +51,9 @@ If you're site is not loading over https, then Stripe won't render the Payment R
51
  7. Payment options at top of checkout page for easy one click checkout
52
 
53
  == Changelog ==
 
 
 
54
  = 3.0.2 =
55
  * Added - Klarna payments now supported
56
  * Added - Bancontact
2
  Contributors: mr.clayton
3
  Tags: stripe, klarna, credit card, apple pay, google pay, ideal, sepa, sofort
4
  Requires at least: 3.0.1
5
+ Tested up to: 5.3.0
6
  Requires PHP: 5.4
7
+ Stable tag: 3.0.3
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
51
  7. Payment options at top of checkout page for easy one click checkout
52
 
53
  == Changelog ==
54
+ = 3.0.3 =
55
+ * Fixed - Check added to wc_stripe_order_status_completed function to ensure capture charge is only called when Stripe is the payment gateway for the order.
56
+ * Updated - Stripe API version to 2019-11-05
57
  = 3.0.2 =
58
  * Added - Klarna payments now supported
59
  * Added - Bancontact
stripe-payments.php CHANGED
@@ -4,13 +4,13 @@
4
  * Plugin Name: Stripe For WooCommerce
5
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
6
  * Description: Accept credit cards, Google Pay, & Apple Pay, Klarna and more using Stripe.
7
- * Version: 3.0.2
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
11
- * Tested up to: 5.2.4
12
  * WC requires at least: 3.0.0
13
- * WC tested up to: 3.7.1
14
  */
15
  function wc_stripe_php_version_notice() {
16
  $message = sprintf ( __ ( 'Your PHP version is %s but Stripe requires version 5.4+.', 'woo-stripe-payment' ), PHP_VERSION );
4
  * Plugin Name: Stripe For WooCommerce
5
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
6
  * Description: Accept credit cards, Google Pay, & Apple Pay, Klarna and more using Stripe.
7
+ * Version: 3.0.3
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
11
+ * Tested up to: 5.3.0
12
  * WC requires at least: 3.0.0
13
+ * WC tested up to: 3.8.0
14
  */
15
  function wc_stripe_php_version_notice() {
16
  $message = sprintf ( __ ( 'Your PHP version is %s but Stripe requires version 5.4+.', 'woo-stripe-payment' ), PHP_VERSION );