Payment Plugins for Stripe WooCommerce - Version 3.3.24

Version Description

  • 7/5/22 =
  • Fixed - Remove payment intent from session when intent's status is processing
  • Updated - If payment intent's status transitions to requires_payment_method, update order status to pending
  • Added - Filter wc_stripe_asynchronous_payment_method_order_status which can be used to change the order's status before redirect to payment page like Sofort, etc
  • Added - Filter wc_stripe_get_api_error_messages which can be used to customize error messages
Download this release

Release Info

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

Code changes from version 3.3.23 to 3.3.24

assets/js/admin/admin-settings.js CHANGED
@@ -132,6 +132,7 @@ jQuery(function ($) {
132
  } else {
133
  $('#woocommerce_stripe_api_webhook_secret_' + env).val(response.secret);
134
  window.alert(response.message);
 
135
  }
136
  }.bind(this)).fail(function (xhr, textStatus, errorThrown) {
137
  this.unblock();
132
  } else {
133
  $('#woocommerce_stripe_api_webhook_secret_' + env).val(response.secret);
134
  window.alert(response.message);
135
+ window.location.reload();
136
  }
137
  }.bind(this)).fail(function (xhr, textStatus, errorThrown) {
138
  this.unblock();
i18n/languages/woo-stripe-payment.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the same license as the Payment Plugins for Stripe WooCommerce plugin.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Payment Plugins for Stripe WooCommerce 3.3.23\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2022-06-27T22:05:16+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: woo-stripe-payment\n"
@@ -1055,15 +1055,11 @@ msgstr ""
1055
  msgid "Payment authorization failed. Please select another payment method."
1056
  msgstr ""
1057
 
1058
- #: includes/class-wc-stripe-redirect-handler.php:68
1059
- msgid "Payment authorization failed."
1060
- msgstr ""
1061
-
1062
  #: includes/class-wc-stripe-rest-api.php:47
1063
  msgid "%1$s is an invalid controller name."
1064
  msgstr ""
1065
 
1066
- #: includes/class-wc-stripe-update.php:56
1067
  msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
1068
  msgstr ""
1069
 
@@ -1385,7 +1381,7 @@ msgstr ""
1385
  msgid "If enabled, the Afterpay message will contain the interest free text."
1386
  msgstr ""
1387
 
1388
- #: includes/gateways/class-wc-payment-gateway-stripe-afterpay.php:401
1389
  msgid "Store currency must be %s for Afterpay to show because your Stripe account is registered in %s. This is a requirement of Afterpay."
1390
  msgstr ""
1391
 
@@ -1427,12 +1423,12 @@ msgstr ""
1427
  msgid "Please select a product option before updating quantity."
1428
  msgstr ""
1429
 
 
1430
  #: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:27
1431
- #: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:28
1432
  msgid "Bancontact"
1433
  msgstr ""
1434
 
1435
- #: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:29
1436
  msgid "Bancontact gateway that integrates with your Stripe account."
1437
  msgstr ""
1438
 
@@ -2622,6 +2618,10 @@ msgstr ""
2622
  msgid "A review has been closed for charge %1$s. Reason: %2$s."
2623
  msgstr ""
2624
 
 
 
 
 
2625
  #: packages/blocks/src/Payments/Gateways/CreditCardPayment.php:44
2626
  #: templates/checkout/credit-card.php:23
2627
  msgid "Save Card"
@@ -2661,6 +2661,22 @@ msgid_plural "months"
2661
  msgstr[0] ""
2662
  msgstr[1] ""
2663
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2664
  #: stripe-payments.php:18
2665
  msgid "Your PHP version is %s but Stripe requires version 5.6+."
2666
  msgstr ""
2
  # This file is distributed under the same license as the Payment Plugins for Stripe WooCommerce plugin.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Payment Plugins for Stripe WooCommerce 3.3.24\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2022-07-05T21:10:27+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: woo-stripe-payment\n"
1055
  msgid "Payment authorization failed. Please select another payment method."
1056
  msgstr ""
1057
 
 
 
 
 
1058
  #: includes/class-wc-stripe-rest-api.php:47
1059
  msgid "%1$s is an invalid controller name."
1060
  msgstr ""
1061
 
1062
+ #: includes/class-wc-stripe-update.php:57
1063
  msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
1064
  msgstr ""
1065
 
1381
  msgid "If enabled, the Afterpay message will contain the interest free text."
1382
  msgstr ""
1383
 
1384
+ #: includes/gateways/class-wc-payment-gateway-stripe-afterpay.php:399
1385
  msgid "Store currency must be %s for Afterpay to show because your Stripe account is registered in %s. This is a requirement of Afterpay."
1386
  msgstr ""
1387
 
1423
  msgid "Please select a product option before updating quantity."
1424
  msgstr ""
1425
 
1426
+ #: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:26
1427
  #: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:27
 
1428
  msgid "Bancontact"
1429
  msgstr ""
1430
 
1431
+ #: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:28
1432
  msgid "Bancontact gateway that integrates with your Stripe account."
1433
  msgstr ""
1434
 
2618
  msgid "A review has been closed for charge %1$s. Reason: %2$s."
2619
  msgstr ""
2620
 
2621
+ #: includes/wc-stripe-webhook-functions.php:392
2622
+ msgid "Order status updated via charge.pending webhook."
2623
+ msgstr ""
2624
+
2625
  #: packages/blocks/src/Payments/Gateways/CreditCardPayment.php:44
2626
  #: templates/checkout/credit-card.php:23
2627
  msgid "Save Card"
2661
  msgstr[0] ""
2662
  msgstr[1] ""
2663
 
2664
+ #: src/Messages/MessageController.php:53
2665
+ msgid "This customer ID does not exist in your Stripe account. To resolve, navigate to the Edit Profile page in the WordPress Admin and delete the user's Stripe customer ID."
2666
+ msgstr ""
2667
+
2668
+ #: src/Messages/MessageController.php:56
2669
+ msgid "This customer ID does not exist in the merchant's Stripe account. Please contact us and we'll update your account."
2670
+ msgstr ""
2671
+
2672
+ #: src/Messages/MessageController.php:61
2673
+ msgid "This payment method does not exist in your Stripe account. This usually happens when you change the Stripe account the plugin is connected to. To resolve, you can remove the Stripe customer ID on the Edit Profile page in the WordPress Admin."
2674
+ msgstr ""
2675
+
2676
+ #: src/Messages/MessageController.php:65
2677
+ msgid "This payment method does not exist in the merchant's Stripe account. Please contact us and we'll update your account."
2678
+ msgstr ""
2679
+
2680
  #: stripe-payments.php:18
2681
  msgid "Your PHP version is %s but Stripe requires version 5.6+."
2682
  msgstr ""
includes/admin/settings/class-wc-stripe-advanced-settings.php CHANGED
@@ -33,7 +33,7 @@ class WC_Stripe_Advanced_Settings extends WC_Stripe_Settings_API {
33
  'locale' => array(
34
  'title' => __( 'Locale Type', 'woo-stripe-payment' ),
35
  'type' => 'select',
36
- 'default' => 'auto',
37
  'options' => array(
38
  'auto' => __( 'Auto', 'woo-stripe-payment' ),
39
  'site' => __( 'Site Locale', 'woo-stripe-payment' )
33
  'locale' => array(
34
  'title' => __( 'Locale Type', 'woo-stripe-payment' ),
35
  'type' => 'select',
36
+ 'default' => 'site',
37
  'options' => array(
38
  'auto' => __( 'Auto', 'woo-stripe-payment' ),
39
  'site' => __( 'Site Locale', 'woo-stripe-payment' )
includes/admin/settings/class-wc-stripe-api-settings.php CHANGED
@@ -348,6 +348,7 @@ class WC_Stripe_API_Settings extends WC_Stripe_Settings_API {
348
  array_values( array_unique( array_merge( array(
349
  'charge.failed',
350
  'charge.succeeded',
 
351
  'source.chargeable',
352
  'payment_intent.succeeded',
353
  'payment_intent.requires_action',
348
  array_values( array_unique( array_merge( array(
349
  'charge.failed',
350
  'charge.succeeded',
351
+ 'charge.pending',
352
  'source.chargeable',
353
  'payment_intent.succeeded',
354
  'payment_intent.requires_action',
includes/class-stripe.php CHANGED
@@ -26,7 +26,7 @@ class WC_Stripe_Manager {
26
  *
27
  * @var string
28
  */
29
- public $version = '3.3.23';
30
 
31
  /**
32
  *
@@ -313,6 +313,7 @@ class WC_Stripe_Manager {
313
 
314
  new \PaymentPlugins\Stripe\Link\LinkIntegration( $this->advanced_settings, $this->account_settings, $this->assets(), $this->data_api() );
315
  new \PaymentPlugins\Stripe\Controllers\PaymentIntent( WC_Stripe_Gateway::load(), [ 'stripe_cc' ] );
 
316
  }
317
 
318
  /**
26
  *
27
  * @var string
28
  */
29
+ public $version = '3.3.24';
30
 
31
  /**
32
  *
313
 
314
  new \PaymentPlugins\Stripe\Link\LinkIntegration( $this->advanced_settings, $this->account_settings, $this->assets(), $this->data_api() );
315
  new \PaymentPlugins\Stripe\Controllers\PaymentIntent( WC_Stripe_Gateway::load(), [ 'stripe_cc' ] );
316
+ new \PaymentPlugins\Stripe\Messages\MessageController();
317
  }
318
 
319
  /**
includes/class-wc-stripe-gateway.php CHANGED
@@ -400,7 +400,8 @@ class WC_Stripe_Gateway {
400
 
401
  public function get_api_options( $mode = '' ) {
402
  if ( empty( $mode ) && $this->mode != null ) {
403
- $mode = $this->mode;
 
404
  }
405
  $args = array( 'api_key' => $this->secret_key ? $this->secret_key : wc_stripe_get_secret_key( $mode ) );
406
 
@@ -459,7 +460,6 @@ class WC_Stripe_Gateway {
459
  * @param string $code
460
  *
461
  * @since 3.1.1
462
- * @todo use in future version to replace manual returns of WP_Error in each method
463
  */
464
  public function get_wp_error( $e, $code = 'stripe-error' ) {
465
  if ( ( $json_body = $e->getJsonBody() ) ) {
@@ -468,7 +468,7 @@ class WC_Stripe_Gateway {
468
  $err = '';
469
  }
470
 
471
- return new WP_Error( $code, $this->get_error_message( $err ), $err );
472
  }
473
 
474
  /**
400
 
401
  public function get_api_options( $mode = '' ) {
402
  if ( empty( $mode ) && $this->mode != null ) {
403
+ $mode = $this->mode;
404
+ $this->secret_key = wc_stripe_get_secret_key( $mode );
405
  }
406
  $args = array( 'api_key' => $this->secret_key ? $this->secret_key : wc_stripe_get_secret_key( $mode ) );
407
 
460
  * @param string $code
461
  *
462
  * @since 3.1.1
 
463
  */
464
  public function get_wp_error( $e, $code = 'stripe-error' ) {
465
  if ( ( $json_body = $e->getJsonBody() ) ) {
468
  $err = '';
469
  }
470
 
471
+ return apply_filters( 'wc_stripe_api_get_wp_error', new WP_Error( $code, $this->get_error_message( $err ), $err ), $e, $code );
472
  }
473
 
474
  /**
includes/class-wc-stripe-payment-intent.php CHANGED
@@ -93,11 +93,13 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
93
  );
94
  }
95
  if ( in_array( $intent->status, array( 'requires_action', 'requires_payment_method', 'requires_source_action', 'requires_source' ), true ) ) {
96
- // If the payment method isn't synchronous, set its status to on-hold so if the customer
97
- // skips the redirect and the payment takes 1 or more days, the payment won't be cancelled
98
- // due to the WooCommerce pending payment status.
99
- if ( apply_filters( 'wc_stripe_asyncronous_payment_method_' . $this->payment_method->id, ! $this->payment_method->synchronous && ! $this->payment_method->is_voucher_payment, $order, $this->payment_method ) ) {
100
- $order->update_status( 'on-hold' );
 
 
101
  }
102
 
103
  return (object) array(
@@ -237,10 +239,13 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
237
  $args['confirmation_method'] = $this->payment_method->get_confirmation_method( $order );
238
  $args['confirm'] = false;
239
  } else {
240
- if ( ! $this->payment_method->id === 'stripe_cc' || $this->payment_method->get_confirmation_method() !== WC_Stripe_Constants::AUTOMATIC ) {
241
  // have to add a validation since capture_method is only allowed for gated accounts and in test mode
242
  // you must request to be gated in.
243
  unset( $args['capture_method'] );
 
 
 
244
  }
245
  if ( isset( $intent['payment_method']['type'] ) && $intent['payment_method']['type'] === 'link' ) {
246
  /**
@@ -370,7 +375,7 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
370
  }
371
  $intent = $intent ? $this->gateway->paymentIntents->retrieve( $intent['id'], apply_filters( 'wc_stripe_payment_intent_retrieve_args', array( 'expand' => array( 'payment_method' ) ), $order, $intent['id'] ) ) : false;
372
  if ( $intent && ! is_wp_error( $intent ) ) {
373
- if ( \in_array( $intent->status, array( 'succeeded', 'requires_capture' ) ) && ! defined( WC_Stripe_Constants::REDIRECT_HANDLER ) ) {
374
  /**
375
  * If the status is succeeded, and the order ID on the intent doesn't match this checkout's order ID, we know this is
376
  * a previously processed intent and so should not be used.
93
  );
94
  }
95
  if ( in_array( $intent->status, array( 'requires_action', 'requires_payment_method', 'requires_source_action', 'requires_source' ), true ) ) {
96
+ /**
97
+ * Allow 3rd party code to alter the order status of an asynchronous payment method.
98
+ * The plugin uses the charge.pending event to set the order's status to on-hold.
99
+ */
100
+ $status = apply_filters( 'wc_stripe_asynchronous_payment_method_order_status', 'pending', $order, $intent );
101
+ if ( 'pending' !== $status ) {
102
+ $order->update_status( $status );
103
  }
104
 
105
  return (object) array(
239
  $args['confirmation_method'] = $this->payment_method->get_confirmation_method( $order );
240
  $args['confirm'] = false;
241
  } else {
242
+ /*if ( $this->payment_method->id !== 'stripe_cc' || $this->payment_method->get_confirmation_method() !== WC_Stripe_Constants::AUTOMATIC ) {
243
  // have to add a validation since capture_method is only allowed for gated accounts and in test mode
244
  // you must request to be gated in.
245
  unset( $args['capture_method'] );
246
+ }*/
247
+ if ( $intent && $intent['status'] === 'requires_action' ) {
248
+ unset( $args['capture_method'] );
249
  }
250
  if ( isset( $intent['payment_method']['type'] ) && $intent['payment_method']['type'] === 'link' ) {
251
  /**
375
  }
376
  $intent = $intent ? $this->gateway->paymentIntents->retrieve( $intent['id'], apply_filters( 'wc_stripe_payment_intent_retrieve_args', array( 'expand' => array( 'payment_method' ) ), $order, $intent['id'] ) ) : false;
377
  if ( $intent && ! is_wp_error( $intent ) ) {
378
+ if ( \in_array( $intent->status, array( 'succeeded', 'requires_capture', 'processing' ) ) && ! defined( WC_Stripe_Constants::REDIRECT_HANDLER ) ) {
379
  /**
380
  * If the status is succeeded, and the order ID on the intent doesn't match this checkout's order ID, we know this is
381
  * a previously processed intent and so should not be used.
includes/class-wc-stripe-redirect-handler.php CHANGED
@@ -60,12 +60,13 @@ class WC_Stripe_Redirect_Handler {
60
  }
61
  } elseif ( in_array( $result->status, array( 'requires_payment_method', 'failed' ) ) ) {
62
  wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
 
63
  if ( $result instanceof \Stripe\PaymentIntent ) {
64
- $order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, WC_Stripe_Utils::sanitize_intent( $result->jsonSerialize() ) );
65
  } else {
66
  $order->delete_meta_data( WC_Stripe_Constants::SOURCE_ID );
67
  }
68
- $order->update_status( 'failed', __( 'Payment authorization failed.', 'woo-stripe-payment' ) );
69
 
70
  return;
71
  } elseif ( 'chargeable' === $result->status ) {
@@ -88,6 +89,8 @@ class WC_Stripe_Redirect_Handler {
88
  }
89
  } elseif ( $result->status === 'processing' && isset( $result->charges->data ) ) {
90
  $payment_method->save_order_meta( $order, $result->charges->data[0] );
 
 
91
  // if this isn't the checkout page, then skip redirect
92
  if ( ! is_checkout() ) {
93
  return;
60
  }
61
  } elseif ( in_array( $result->status, array( 'requires_payment_method', 'failed' ) ) ) {
62
  wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
63
+ wc_stripe_log_info( sprintf( 'User cancelled their payment and has been redirected to the checkout page. Payment Method: %s. Order ID: %s', $payment_method->id, $order->get_id() ) );
64
  if ( $result instanceof \Stripe\PaymentIntent ) {
65
+ $order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, WC_Stripe_Utils::sanitize_intent( $result->toArray() ) );
66
  } else {
67
  $order->delete_meta_data( WC_Stripe_Constants::SOURCE_ID );
68
  }
69
+ $order->update_status( 'pending' );
70
 
71
  return;
72
  } elseif ( 'chargeable' === $result->status ) {
89
  }
90
  } elseif ( $result->status === 'processing' && isset( $result->charges->data ) ) {
91
  $payment_method->save_order_meta( $order, $result->charges->data[0] );
92
+ $order->update_status( 'on-hold' );
93
+ WC_Stripe_Utils::delete_payment_intent_to_session();
94
  // if this isn't the checkout page, then skip redirect
95
  if ( ! is_checkout() ) {
96
  return;
includes/class-wc-stripe-update.php CHANGED
@@ -23,7 +23,8 @@ class WC_Stripe_Update {
23
  '3.3.19' => 'update-3.3.19.php',
24
  '3.3.20' => 'update-3.3.20.php',
25
  '3.3.21' => 'update-3.3.21.php',
26
- '3.3.23' => 'update-3.3.23.php'
 
27
  );
28
 
29
  public static function init() {
23
  '3.3.19' => 'update-3.3.19.php',
24
  '3.3.20' => 'update-3.3.20.php',
25
  '3.3.21' => 'update-3.3.21.php',
26
+ '3.3.23' => 'update-3.3.23.php',
27
+ '3.3.24' => 'update-3.3.24.php'
28
  );
29
 
30
  public static function init() {
includes/gateways/class-wc-payment-gateway-stripe-afterpay.php CHANGED
@@ -338,8 +338,7 @@ class WC_Payment_Gateway_Stripe_Afterpay extends WC_Payment_Gateway_Stripe_Local
338
  $params['supported_locales'] = $this->get_supported_locales();
339
  $params['requirements'] = $this->get_required_parameters();
340
  $params['hide_ineligible'] = $this->is_active( 'hide_ineligible' ) ? 'yes' : 'no';
341
- $locale = get_locale();
342
- $params['locale'] = $locale ? str_replace( '_', '-', substr( $locale, 0, 5 ) ) : 'auto';
343
 
344
  return $params;
345
  }
@@ -349,7 +348,6 @@ class WC_Payment_Gateway_Stripe_Afterpay extends WC_Payment_Gateway_Stripe_Local
349
  }
350
 
351
  public function get_element_options( $options = array() ) {
352
- $locale = get_locale();
353
  $locale = wc_stripe_get_site_locale();
354
  if ( ! in_array( $locale, $this->get_supported_locales() ) ) {
355
  $locale = 'auto';
338
  $params['supported_locales'] = $this->get_supported_locales();
339
  $params['requirements'] = $this->get_required_parameters();
340
  $params['hide_ineligible'] = $this->is_active( 'hide_ineligible' ) ? 'yes' : 'no';
341
+ $params['locale'] = wc_stripe_get_site_locale();
 
342
 
343
  return $params;
344
  }
348
  }
349
 
350
  public function get_element_options( $options = array() ) {
 
351
  $locale = wc_stripe_get_site_locale();
352
  if ( ! in_array( $locale, $this->get_supported_locales() ) ) {
353
  $locale = 'auto';
includes/gateways/class-wc-payment-gateway-stripe-bancontact.php CHANGED
@@ -19,7 +19,6 @@ class WC_Payment_Gateway_Stripe_Bancontact extends WC_Payment_Gateway_Stripe_Loc
19
  protected $payment_method_type = 'bancontact';
20
 
21
  public function __construct() {
22
- $this->synchronous = false;
23
  $this->local_payment_type = 'bancontact';
24
  $this->currencies = array( 'EUR' );
25
  $this->countries = array( 'BE' );
19
  protected $payment_method_type = 'bancontact';
20
 
21
  public function __construct() {
 
22
  $this->local_payment_type = 'bancontact';
23
  $this->currencies = array( 'EUR' );
24
  $this->countries = array( 'BE' );
includes/updates/update-3.3.24.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'ABSPATH' ) || exit();
4
+
5
+ if ( function_exists( 'WC' ) ) {
6
+ $client = WC_Stripe_Gateway::load();
7
+ $api_settings = stripe_wc()->api_settings;
8
+ foreach ( array( 'live', 'test' ) as $mode ) {
9
+ $id = $api_settings->get_option( "webhook_id_{$mode}" );
10
+ if ( $id ) {
11
+ $webhook = $client->mode( $mode )->webhookEndpoints->retrieve( $id );
12
+ if ( ! is_wp_error( $webhook ) && ! in_array( '*', $webhook->enabled_events, true ) ) {
13
+ $events = array_values( array_unique( array_merge( $webhook->enabled_events, array( 'charge.pending' ) ) ) );
14
+ $client->mode( $mode )->webhookEndpoints->update( $id, array( 'enabled_events' => $events ) );
15
+ wc_stripe_log_info( sprintf( 'Mode: %s. charge.pending event added to webhook %s in version 3.3.24 update.', $mode, $id ) );
16
+ }
17
+ }
18
+ }
19
+ }
includes/wc-stripe-hooks.php CHANGED
@@ -17,6 +17,7 @@ add_action( 'wc_stripe_retry_source_chargeable', 'wc_stripe_retry_source_chargea
17
  add_action( 'wc_stripe_webhook_source_chargeable', 'wc_stripe_process_source_chargeable', 10, 2 );
18
  add_action( 'wc_stripe_webhook_charge_succeeded', 'wc_stripe_process_charge_succeeded', 10, 2 );
19
  add_action( 'wc_stripe_webhook_charge_failed', 'wc_stripe_process_charge_failed', 10, 2 );
 
20
  add_action( 'wc_stripe_webhook_payment_intent_succeeded', 'wc_stripe_process_payment_intent_succeeded', 10, 2 );
21
  add_action( 'wc_stripe_webhook_payment_intent_requires_action', 'wc_stripe_process_requires_action', 10, 1 );
22
  add_action( 'wc_stripe_webhook_charge_refunded', 'wc_stripe_process_create_refund' );
17
  add_action( 'wc_stripe_webhook_source_chargeable', 'wc_stripe_process_source_chargeable', 10, 2 );
18
  add_action( 'wc_stripe_webhook_charge_succeeded', 'wc_stripe_process_charge_succeeded', 10, 2 );
19
  add_action( 'wc_stripe_webhook_charge_failed', 'wc_stripe_process_charge_failed', 10, 2 );
20
+ add_action( 'wc_stripe_webhook_charge_pending', 'wc_stripe_process_charge_pending', 10, 1 );
21
  add_action( 'wc_stripe_webhook_payment_intent_succeeded', 'wc_stripe_process_payment_intent_succeeded', 10, 2 );
22
  add_action( 'wc_stripe_webhook_payment_intent_requires_action', 'wc_stripe_process_requires_action', 10, 1 );
23
  add_action( 'wc_stripe_webhook_charge_refunded', 'wc_stripe_process_create_refund' );
includes/wc-stripe-webhook-functions.php CHANGED
@@ -377,3 +377,20 @@ function wc_stripe_process_requires_action( $payment_intent ) {
377
  }
378
  }
379
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
  }
379
  }
380
+
381
+ /**
382
+ * @param Stripe\Charge $charge
383
+ */
384
+ function wc_stripe_process_charge_pending( $charge ) {
385
+ if ( isset( $charge->metadata['gateway_id'], $charge->metadata['order_id'] ) ) {
386
+ $payment_methods = WC()->payment_gateways()->payment_gateways();
387
+ $payment_method = $charge->metadata['gateway_id'];
388
+ $payment_method = isset( $payment_methods[ $payment_method ] ) ? $payment_methods[ $payment_method ] : null;
389
+ if ( $payment_method && $payment_method instanceof \WC_Payment_Gateway_Stripe && ! $payment_method->synchronous ) {
390
+ $order = wc_get_order( wc_stripe_filter_order_id( $charge->metadata['order_id'], $charge ) );
391
+ if ( $order ) {
392
+ $order->update_status( apply_filters( 'wc_stripe_charge_pending_order_status', 'on-hold', $charge, $order ), __( 'Order status updated via charge.pending webhook.', 'woo-stripe-payment' ) );
393
+ }
394
+ }
395
+ }
396
+ }
packages/blocks/src/Payments/Gateways/CreditCardPayment.php CHANGED
@@ -105,6 +105,7 @@ class CreditCardPayment extends AbstractStripePayment {
105
  $payment_intent = \WC_Stripe_Utils::get_payment_intent_from_session();
106
  }
107
  if ( $payment_intent ) {
 
108
  $result['clientSecret'] = $payment_intent->client_secret;
109
  }
110
 
105
  $payment_intent = \WC_Stripe_Utils::get_payment_intent_from_session();
106
  }
107
  if ( $payment_intent ) {
108
+ $this->payment_intent_ctrl->set_intent_exists( true );
109
  $result['clientSecret'] = $payment_intent->client_secret;
110
  }
111
 
packages/blocks/src/Payments/Gateways/LinkPayment.php CHANGED
@@ -86,6 +86,7 @@ class LinkPayment extends AbstractStripePayment {
86
  $payment_intent = \WC_Stripe_Utils::get_payment_intent_from_session();
87
  }
88
  if ( $payment_intent ) {
 
89
  $result['clientSecret'] = $payment_intent->client_secret;
90
  }
91
 
86
  $payment_intent = \WC_Stripe_Utils::get_payment_intent_from_session();
87
  }
88
  if ( $payment_intent ) {
89
+ $this->payment_intent_ctrl->set_intent_exists( true );
90
  $result['clientSecret'] = $payment_intent->client_secret;
91
  }
92
 
packages/blocks/src/Payments/PaymentsApi.php CHANGED
@@ -216,8 +216,8 @@ class PaymentsApi {
216
  'publishableKey' => wc_stripe_get_publishable_key(),
217
  'stripeParams' => [
218
  'stripeAccount' => wc_stripe_get_account_id(),
219
- 'apiVersion' => '2020-08-27;server_side_confirmation_beta=v1',
220
- 'betas' => array( 'server_side_confirmation_beta_1' )
221
  ],
222
  'version' => $this->config->get_version(),
223
  'blocksVersion' => \Automattic\WooCommerce\Blocks\Package::get_version(),
216
  'publishableKey' => wc_stripe_get_publishable_key(),
217
  'stripeParams' => [
218
  'stripeAccount' => wc_stripe_get_account_id(),
219
+ 'apiVersion' => '2020-08-27',
220
+ 'betas' => []
221
  ],
222
  'version' => $this->config->get_version(),
223
  'blocksVersion' => \Automattic\WooCommerce\Blocks\Package::get_version(),
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: stripe, ach, klarna, credit card, apple pay, google pay, ideal, sepa, sofo
4
  Requires at least: 3.0.1
5
  Tested up to: 6.0
6
  Requires PHP: 5.6
7
- Stable tag: 3.3.23
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -62,6 +62,11 @@ If you're site is not loading over https, then Stripe won't render the Payment R
62
  9. Stripe Link for high conversion
63
 
64
  == Changelog ==
 
 
 
 
 
65
  = 3.3.23 - 6/27/22 =
66
  * Fixed - Conflict with the WooCommerce Pay Trace plugin
67
  * Updated - Billing phone required if Stripe payment form card design used.
4
  Requires at least: 3.0.1
5
  Tested up to: 6.0
6
  Requires PHP: 5.6
7
+ Stable tag: 3.3.24
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
62
  9. Stripe Link for high conversion
63
 
64
  == Changelog ==
65
+ = 3.3.24 - 7/5/22 =
66
+ * Fixed - Remove payment intent from session when intent's status is processing
67
+ * Updated - If payment intent's status transitions to requires_payment_method, update order status to pending
68
+ * Added - Filter wc_stripe_asynchronous_payment_method_order_status which can be used to change the order's status before redirect to payment page like Sofort, etc
69
+ * Added - Filter wc_stripe_get_api_error_messages which can be used to customize error messages
70
  = 3.3.23 - 6/27/22 =
71
  * Fixed - Conflict with the WooCommerce Pay Trace plugin
72
  * Updated - Billing phone required if Stripe payment form card design used.
src/Controllers/PaymentIntent.php CHANGED
@@ -42,6 +42,7 @@ class PaymentIntent {
42
  add_action( 'woocommerce_before_pay_action', [ $this, 'set_order_pay_constants' ] );
43
  add_action( 'woocommerce_checkout_update_order_review', [ $this, 'update_order_review' ] );
44
  add_filter( 'wc_stripe_localize_script_wc-stripe', [ $this, 'add_script_params' ], 10, 2 );
 
45
  add_filter( 'wc_stripe_can_update_payment_intent', [ $this, 'can_update_payment_intent' ], 10, 2 );
46
  }
47
 
@@ -227,12 +228,12 @@ class PaymentIntent {
227
  }
228
 
229
  private function save_payment_intent_to_session( \Stripe\PaymentIntent $payment_intent ) {
230
- $this->intent_exists = true;
231
  \WC_Stripe_Utils::save_payment_intent_to_session( $payment_intent );
232
  }
233
 
234
  private function save_setup_intent_to_session( \Stripe\SetupIntent $setup_intent ) {
235
- $this->intent_exists = true;
236
  \WC_Stripe_Utils::save_payment_intent_to_session( $setup_intent->toArray() );
237
  }
238
 
@@ -295,6 +296,20 @@ class PaymentIntent {
295
  return $data;
296
  }
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  /**
299
  * @param bool $result
300
  * @param \Stripe\PaymentIntent $payment_intent
@@ -309,4 +324,8 @@ class PaymentIntent {
309
  return $result;
310
  }
311
 
 
 
 
 
312
  }
42
  add_action( 'woocommerce_before_pay_action', [ $this, 'set_order_pay_constants' ] );
43
  add_action( 'woocommerce_checkout_update_order_review', [ $this, 'update_order_review' ] );
44
  add_filter( 'wc_stripe_localize_script_wc-stripe', [ $this, 'add_script_params' ], 10, 2 );
45
+ add_filter( 'wc_stripe_blocks_general_data', [ $this, 'add_blocks_general_data' ] );
46
  add_filter( 'wc_stripe_can_update_payment_intent', [ $this, 'can_update_payment_intent' ], 10, 2 );
47
  }
48
 
228
  }
229
 
230
  private function save_payment_intent_to_session( \Stripe\PaymentIntent $payment_intent ) {
231
+ $this->set_intent_exists( true );
232
  \WC_Stripe_Utils::save_payment_intent_to_session( $payment_intent );
233
  }
234
 
235
  private function save_setup_intent_to_session( \Stripe\SetupIntent $setup_intent ) {
236
+ $this->set_intent_exists( true );
237
  \WC_Stripe_Utils::save_payment_intent_to_session( $setup_intent->toArray() );
238
  }
239
 
296
  return $data;
297
  }
298
 
299
+ /**
300
+ * @param $data
301
+ *
302
+ * @todo remove once betas and headers are no longer needed.
303
+ */
304
+ public function add_blocks_general_data( $data ) {
305
+ if ( $this->intent_exists ) {
306
+ $data['stripeParams']['apiVersion'] .= ';server_side_confirmation_beta=v1';
307
+ $data['stripeParams']['betas'][] = 'server_side_confirmation_beta_1';
308
+ }
309
+
310
+ return $data;
311
+ }
312
+
313
  /**
314
  * @param bool $result
315
  * @param \Stripe\PaymentIntent $payment_intent
324
  return $result;
325
  }
326
 
327
+ public function set_intent_exists( $bool ) {
328
+ $this->intent_exists = $bool;
329
+ }
330
+
331
  }
src/Messages/MessageController.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PaymentPlugins\Stripe\Messages;
4
+
5
+ class MessageController {
6
+
7
+ public function __construct() {
8
+ $this->initialize();
9
+ }
10
+
11
+ private function initialize() {
12
+ add_filter( 'wc_stripe_api_get_wp_error', [ $this, 'filter_error_message' ] );
13
+ }
14
+
15
+ /**
16
+ * @param \WP_Error $error
17
+ */
18
+ public function filter_error_message( $error ) {
19
+ if ( $error ) {
20
+ $data = $error->get_error_data();
21
+ if ( $data && isset( $data['code'] ) && $this->is_frontend_request() ) {
22
+ $code = $data['code'];
23
+ if ( isset( $data['param'] ) ) {
24
+ $code = $code . ':' . $data['param'];
25
+ }
26
+ if ( $this->has_code( $code ) ) {
27
+ $message = $this->get_messages()[ $code ];
28
+ if ( \is_callable( $message ) ) {
29
+ $message = $message( $error, $data );
30
+ }
31
+ $error = new \WP_Error( $code, $message, $data );
32
+ }
33
+ }
34
+ }
35
+
36
+ return $error;
37
+ }
38
+
39
+ private function is_frontend_request() {
40
+ return ! is_admin() || defined( 'DOING_AJAX' ) && ! defined( 'DOING_CRON' );
41
+ }
42
+
43
+ private function has_code( $key ) {
44
+ return array_key_exists( $key, $this->get_messages() );
45
+ }
46
+
47
+ private function get_messages() {
48
+ static $messages = null;
49
+ if ( ! $messages ) {
50
+ $messages = [
51
+ 'resource_missing:customer' => function ( $error, $data ) {
52
+ if ( current_user_can( 'manage_woocommerce' ) ) {
53
+ return sprintf( '%s. %s', $error->get_error_message(), __( 'This customer ID does not exist in your Stripe account. To resolve, navigate to the Edit Profile page in the WordPress Admin and delete the user\'s Stripe customer ID.', 'woo-stripe-payment' ) );
54
+ }
55
+
56
+ return sprintf( '%s. %s', $error->get_error_message(), __( 'This customer ID does not exist in the merchant\'s Stripe account. Please contact us and we\'ll update your account.', 'woo-stripe-payment' ) );
57
+ },
58
+ 'resource_missing:payment_method' => function ( $error, $data ) {
59
+ if ( current_user_can( 'manage_woocommerce' ) ) {
60
+ return sprintf( '%s. %s', $error->get_error_message(),
61
+ __( 'This payment method does not exist in your Stripe account. This usually happens when you change the Stripe account the plugin is connected to. To resolve, you can remove the Stripe customer ID on the Edit Profile page in the WordPress Admin.',
62
+ 'woo-stripe-payment' ) );
63
+ }
64
+
65
+ return sprintf( '%s. %s', $error->get_error_message(), __( 'This payment method does not exist in the merchant\'s Stripe account. Please contact us and we\'ll update your account.', 'woo-stripe-payment' ) );
66
+ }
67
+ ];
68
+ $messages = apply_filters( 'wc_stripe_get_api_error_messages', $messages );
69
+ }
70
+
71
+ return $messages;
72
+ }
73
+
74
+ }
stripe-payments.php CHANGED
@@ -4,13 +4,13 @@
4
  * Plugin Name: Payment Plugins for Stripe WooCommerce
5
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
6
  * Description: Accept Credit Cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
7
- * Version: 3.3.23
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
11
  * Tested up to: 6.0
12
  * WC requires at least: 3.0.0
13
- * WC tested up to: 6.6
14
  */
15
  defined( 'ABSPATH' ) || exit ();
16
 
4
  * Plugin Name: Payment Plugins for Stripe WooCommerce
5
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
6
  * Description: Accept Credit Cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
7
+ * Version: 3.3.24
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
11
  * Tested up to: 6.0
12
  * WC requires at least: 3.0.0
13
+ * WC tested up to: 6.7
14
  */
15
  defined( 'ABSPATH' ) || exit ();
16
 
vendor/composer/installed.php CHANGED
@@ -5,7 +5,7 @@
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => 'ae84eceb68a7b1705cd6e561465acdf25b8dcca1',
9
  'name' => '__root__',
10
  'dev' => false,
11
  ),
@@ -16,7 +16,7 @@
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
- 'reference' => 'ae84eceb68a7b1705cd6e561465acdf25b8dcca1',
20
  'dev_requirement' => false,
21
  ),
22
  'stripe/stripe-php' => array(
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => '0977434b1f22bd484f222a21c2cf60c02734d0dc',
9
  'name' => '__root__',
10
  'dev' => false,
11
  ),
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
+ 'reference' => '0977434b1f22bd484f222a21c2cf60c02734d0dc',
20
  'dev_requirement' => false,
21
  ),
22
  'stripe/stripe-php' => array(