Payment Plugins for Stripe WooCommerce - Version 3.0.10

Version Description

  • Fixed - Subscription error when capture_charge function called on order complete status.
  • Fixed - Pre-order error for payment intent when capture_charge called.
Download this release

Release Info

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

Code changes from version 3.0.9 to 3.0.10

assets/css/stripe.css CHANGED
@@ -317,6 +317,7 @@ li.payment_method_stripe_ach label:first-of-type img{
317
  }
318
  }
319
  .wc-stripe-banner-checkout{
 
320
  padding: 20px 15px 0 15px;
321
  border: 1px solid #d1d1d1;
322
  border-width: 0 0 1px;
@@ -324,6 +325,9 @@ li.payment_method_stripe_ach label:first-of-type img{
324
  margin: 1em 0;
325
 
326
  }
 
 
 
327
  .wc-stripe-banner-checkout span.banner-title{
328
  position: absolute;
329
  display: flex;
317
  }
318
  }
319
  .wc-stripe-banner-checkout{
320
+ display: none;
321
  padding: 20px 15px 0 15px;
322
  border: 1px solid #d1d1d1;
323
  border-width: 0 0 1px;
325
  margin: 1em 0;
326
 
327
  }
328
+ .wc-stripe-banner-checkout.active{
329
+ display: block;
330
+ }
331
  .wc-stripe-banner-checkout span.banner-title{
332
  position: absolute;
333
  display: flex;
assets/js/admin/meta-boxes-order.js CHANGED
@@ -11,7 +11,8 @@
11
  $(document.body).on('click', '.do-transaction-view',
12
  this.render_charge_view.bind(this)).on('click',
13
  '.do-api-capture', this.do_api_capture.bind(this)).on('click',
14
- '.do-api-cancel', this.do_api_cancel.bind(this)).on('click', '.wc-stripe-pay-order', this.open_pay_order_modal.bind(this));
 
15
  }
16
 
17
  /**
@@ -122,6 +123,26 @@
122
  })
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  *
127
  */
11
  $(document.body).on('click', '.do-transaction-view',
12
  this.render_charge_view.bind(this)).on('click',
13
  '.do-api-capture', this.do_api_capture.bind(this)).on('click',
14
+ '.do-api-cancel', this.do_api_cancel.bind(this)).on('click', '.wc-stripe-pay-order', this.open_pay_order_modal.bind(this)).on(
15
+ 'change', '#customer_user', this.fetch_payment_methods.bind(this));
16
  }
17
 
18
  /**
123
  })
124
  }
125
 
126
+ MetaBox.prototype.fetch_payment_methods = function(e) {
127
+ wc_stripe_order_pay_params.payment_methods = [];
128
+ var customer_id = $('#customer_user').val();
129
+ if (customer_id) {
130
+ $.ajax({
131
+ method: 'GET',
132
+ dataType: 'json',
133
+ url: this.params.routes.payment_methods,
134
+ data: {
135
+ _wpnonce: this.params._wpnonce,
136
+ customer_id: customer_id
137
+ }
138
+ }).done(function(response) {
139
+ wc_stripe_order_pay_params.payment_methods = response.payment_methods;
140
+ }.bind(this)).fail(function() {
141
+
142
+ }.bind(this))
143
+ }
144
+ }
145
+
146
  /**
147
  *
148
  */
assets/js/frontend/applepay-checkout.js CHANGED
@@ -19,7 +19,7 @@
19
  if (this.banner_enabled()) {
20
  var $button = $(this.params.button);
21
  $button.addClass('banner-checkout');
22
- $(this.banner_container).show();
23
  $(this.banner_container).append($button);
24
  }
25
  }.bind(this))
19
  if (this.banner_enabled()) {
20
  var $button = $(this.params.button);
21
  $button.addClass('banner-checkout');
22
+ $(this.banner_container).show().parent().parent().addClass('active');
23
  $(this.banner_container).append($button);
24
  }
25
  }.bind(this))
assets/js/frontend/googlepay-checkout.js CHANGED
@@ -29,7 +29,7 @@
29
  buttonColor: this.params.button_color,
30
  buttonType: this.params.button_style
31
  }));
32
- $(this.banner_container).show();
33
  $(this.banner_container).append($button);
34
  }
35
  }.bind(this))
29
  buttonColor: this.params.button_color,
30
  buttonType: this.params.button_style
31
  }));
32
+ $(this.banner_container).show().parent().parent().addClass('active');
33
  $(this.banner_container).append($button);
34
  }
35
  }.bind(this))
assets/js/frontend/payment-request.js CHANGED
@@ -172,6 +172,7 @@
172
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function(result) {
173
  if (this.banner_enabled()) {
174
  $(this.banner_container).show().append('<div id="wc-stripe-payment-request-banner"></div>');
 
175
  var elements = this.stripe.elements();
176
  var button = elements.create("paymentRequestButton", {
177
  paymentRequest: this.paymentRequest,
172
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function(result) {
173
  if (this.banner_enabled()) {
174
  $(this.banner_container).show().append('<div id="wc-stripe-payment-request-banner"></div>');
175
+ $(this.banner_container).show().parent().parent().addClass('active');
176
  var elements = this.stripe.elements();
177
  var button = elements.create("paymentRequestButton", {
178
  paymentRequest: this.paymentRequest,
includes/abstract/abstract-wc-payment-gateway-stripe-charge.php CHANGED
@@ -162,6 +162,8 @@ abstract class WC_Payment_Gateway_Stripe_Charge extends WC_Payment_Gateway_Strip
162
  }
163
 
164
  public function scheduled_subscription_payment($amount, $order) {
 
 
165
  $args = $this->get_order_charge_args ( $order, [
166
  'customer' => $order->get_meta ( '_wc_stripe_customer', true ),
167
  'source' => $order->get_meta ( '_payment_method_token', true ),
@@ -200,6 +202,8 @@ abstract class WC_Payment_Gateway_Stripe_Charge extends WC_Payment_Gateway_Strip
200
  * @param WC_Order $order
201
  */
202
  public function process_pre_order_payment($order) {
 
 
203
  $args = $this->get_order_charge_args ( $order, [
204
  'customer' => wc_stripe_get_customer_id ( $order->get_customer_id (), wc_stripe_order_mode ( $order ) ),
205
  'source' => $order->get_meta ( '_payment_method_token', true ),
162
  }
163
 
164
  public function scheduled_subscription_payment($amount, $order) {
165
+ $this->processing_payment = true;
166
+
167
  $args = $this->get_order_charge_args ( $order, [
168
  'customer' => $order->get_meta ( '_wc_stripe_customer', true ),
169
  'source' => $order->get_meta ( '_payment_method_token', true ),
202
  * @param WC_Order $order
203
  */
204
  public function process_pre_order_payment($order) {
205
+ $this->processing_payment = true;
206
+
207
  $args = $this->get_order_charge_args ( $order, [
208
  'customer' => wc_stripe_get_customer_id ( $order->get_customer_id (), wc_stripe_order_mode ( $order ) ),
209
  'source' => $order->get_meta ( '_payment_method_token', true ),
includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php CHANGED
@@ -188,6 +188,13 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
188
  public function capture_charge($amount, $order) {
189
  $amount_in_cents = wc_stripe_add_number_precision ( $amount );
190
  $payment_intent = $order->get_meta ( '_payment_intent_id', true );
 
 
 
 
 
 
 
191
  $result = $this->gateway->capture_payment_intent ( $payment_intent, array(
192
  'amount_to_capture' => $amount_in_cents
193
  ), wc_stripe_order_mode ( $order ) );
@@ -197,9 +204,7 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
197
  'currency' => $order->get_currency ()
198
  ) ) ) );
199
  } else {
200
- $order->add_order_note ( sprintf ( __ ( 'Error capturing charge in Stripe. Reason: %s', 'woo-stripe-payment' ), wc_price ( $amount, array(
201
- 'currency' => $order->get_currency ()
202
- ) ) ) );
203
  }
204
  return $result;
205
  }
@@ -235,6 +240,8 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
235
  * @see WC_Payment_Gateway_Stripe::scheduled_subscription_payment()
236
  */
237
  public function scheduled_subscription_payment($amount, $order) {
 
 
238
  $args = array_merge ( $this->get_payment_intent_args ( $order ), [
239
  'amount' => wc_stripe_add_number_precision ( $amount ),
240
  'payment_method' => $order->get_meta ( '_payment_method_token', true ),
@@ -255,6 +262,8 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
255
  if (isset ( $charges[ 0 ] )) {
256
  $charge = $charges[ 0 ];
257
 
 
 
258
  $this->save_order_meta ( $order, $charge );
259
 
260
  if ($charge->captured) {
@@ -302,6 +311,8 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
302
  * @param WC_Order $order
303
  */
304
  public function process_pre_order_payment($order) {
 
 
305
  $args = array_merge ( $this->get_payment_intent_args ( $order ), [
306
  'amount' => wc_stripe_add_number_precision ( $order->get_total () ),
307
  'payment_method' => $order->get_meta ( '_payment_method_token', true ),
@@ -321,6 +332,8 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
321
  if (isset ( $charges[ 0 ] )) {
322
  $charge = $charges[ 0 ];
323
 
 
 
324
  $this->save_order_meta ( $order, $charge );
325
 
326
  if ($charge->captured) {
188
  public function capture_charge($amount, $order) {
189
  $amount_in_cents = wc_stripe_add_number_precision ( $amount );
190
  $payment_intent = $order->get_meta ( '_payment_intent_id', true );
191
+ // if the intent was not saved before, then fetch it from the charge and save it to the order.
192
+ if (empty ( $payment_intent )) {
193
+ $charge = $this->retrieve_charge ( $order->get_transaction_id (), wc_stripe_order_mode ( $order ) );
194
+ $payment_intent = $charge->payment_intent;
195
+ $order->update_meta_data ( '_payment_intent_id', $payment_intent );
196
+ $order->save ();
197
+ }
198
  $result = $this->gateway->capture_payment_intent ( $payment_intent, array(
199
  'amount_to_capture' => $amount_in_cents
200
  ), wc_stripe_order_mode ( $order ) );
204
  'currency' => $order->get_currency ()
205
  ) ) ) );
206
  } else {
207
+ $order->add_order_note ( sprintf ( __ ( 'Error capturing charge in Stripe. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ) );
 
 
208
  }
209
  return $result;
210
  }
240
  * @see WC_Payment_Gateway_Stripe::scheduled_subscription_payment()
241
  */
242
  public function scheduled_subscription_payment($amount, $order) {
243
+ $this->processing_payment = true;
244
+
245
  $args = array_merge ( $this->get_payment_intent_args ( $order ), [
246
  'amount' => wc_stripe_add_number_precision ( $amount ),
247
  'payment_method' => $order->get_meta ( '_payment_method_token', true ),
262
  if (isset ( $charges[ 0 ] )) {
263
  $charge = $charges[ 0 ];
264
 
265
+ $order->update_meta_data ( '_payment_intent_id', $intent->id );
266
+ $order->save ();
267
  $this->save_order_meta ( $order, $charge );
268
 
269
  if ($charge->captured) {
311
  * @param WC_Order $order
312
  */
313
  public function process_pre_order_payment($order) {
314
+ $this->processing_payment = true;
315
+
316
  $args = array_merge ( $this->get_payment_intent_args ( $order ), [
317
  'amount' => wc_stripe_add_number_precision ( $order->get_total () ),
318
  'payment_method' => $order->get_meta ( '_payment_method_token', true ),
332
  if (isset ( $charges[ 0 ] )) {
333
  $charge = $charges[ 0 ];
334
 
335
+ $order->update_meta_data ( '_payment_intent_id', $intent->id );
336
+ $order->save ();
337
  $this->save_order_meta ( $order, $charge );
338
 
339
  if ($charge->captured) {
includes/admin/meta-boxes/class-wc-stripe-admin-order-metaboxes.php CHANGED
@@ -58,7 +58,7 @@ class WC_Stripe_Admin_Order_Metaboxes {
58
  * @param WC_Order $order
59
  */
60
  public static function pay_order_section($order) {
61
- if ($order->get_type () === 'shop_order' && $order->has_status ( 'pending' )) {
62
  include 'views/html-order-pay.php';
63
  $payment_methods = array();
64
  foreach ( WC ()->payment_gateways ()->payment_gateways () as $gateway ) {
@@ -91,7 +91,8 @@ class WC_Stripe_Admin_Order_Metaboxes {
91
  'charge_view' => wc_stripe ()->rest_api->order_actions->rest_url ( 'charge-view' ),
92
  'capture' => wc_stripe ()->rest_api->order_actions->rest_url ( 'capture' ),
93
  'void' => wc_stripe ()->rest_api->order_actions->rest_url ( 'void' ),
94
- 'pay' => wc_stripe ()->rest_api->order_actions->rest_url ( 'pay' )
 
95
  )
96
  ) );
97
  }
58
  * @param WC_Order $order
59
  */
60
  public static function pay_order_section($order) {
61
+ if ($order->get_type () === 'shop_order' && $order->has_status ( ['pending', 'auto-draft'] )) {
62
  include 'views/html-order-pay.php';
63
  $payment_methods = array();
64
  foreach ( WC ()->payment_gateways ()->payment_gateways () as $gateway ) {
91
  'charge_view' => wc_stripe ()->rest_api->order_actions->rest_url ( 'charge-view' ),
92
  'capture' => wc_stripe ()->rest_api->order_actions->rest_url ( 'capture' ),
93
  'void' => wc_stripe ()->rest_api->order_actions->rest_url ( 'void' ),
94
+ 'pay' => wc_stripe ()->rest_api->order_actions->rest_url ( 'pay' ),
95
+ 'payment_methods' => wc_stripe ()->rest_api->order_actions->rest_url ( 'customer-payment-methods' )
96
  )
97
  ) );
98
  }
includes/admin/meta-boxes/views/html-order-pay.php CHANGED
@@ -15,7 +15,7 @@
15
  </header>
16
  <article>
17
  <form id="wc-stripe-pay-order-form">
18
- <input type="hidden" name="wc_stripe_payment_method" value="stripe_cc"/>
19
  <input type="hidden" name="order_id" value="{{{data.order_id}}}"/>
20
  <div class="modal-wide option">
21
  <label><?php _e('Charge Type', 'woo-stripe-payment')?></label>
15
  </header>
16
  <article>
17
  <form id="wc-stripe-pay-order-form">
18
+ <input type="hidden" name="customer_id" value="{{{data.customer_id}}}"/>
19
  <input type="hidden" name="order_id" value="{{{data.order_id}}}"/>
20
  <div class="modal-wide option">
21
  <label><?php _e('Charge Type', 'woo-stripe-payment')?></label>
includes/class-stripe.php CHANGED
@@ -21,7 +21,7 @@ class WC_Stripe_Manager {
21
  *
22
  * @var string
23
  */
24
- public $version = '3.0.9';
25
 
26
  /**
27
  *
21
  *
22
  * @var string
23
  */
24
+ public $version = '3.0.10';
25
 
26
  /**
27
  *
includes/class-wc-stripe-customer-manager.php CHANGED
@@ -27,7 +27,7 @@ class WC_Stripe_Customer_Manager {
27
  if ($this->should_update_customer ( $customer )) {
28
  $result = $this->update_customer ( $customer );
29
  if (is_wp_error ( $result )) {
30
- wc_add_notice ( __ ( 'Error saving customer. Reason: %s', 'woo-stripe-payment' ), $customer_id->get_error_message () );
31
  }
32
  }
33
  } else {
27
  if ($this->should_update_customer ( $customer )) {
28
  $result = $this->update_customer ( $customer );
29
  if (is_wp_error ( $result )) {
30
+ wc_add_notice ( __ ( 'Error saving customer. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () );
31
  }
32
  }
33
  } else {
includes/controllers/class-wc-stripe-controller-order-actions.php CHANGED
@@ -170,6 +170,11 @@ class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
170
  }
171
  }
172
  }
 
 
 
 
 
173
  if ($order->get_transaction_id ()) {
174
  throw new Exception ( sprintf ( __ ( 'This order has already been processed. Transaction ID: %s. Payment method: %s', 'woo-stripe-payment' ), $order->get_transaction_id (), $order->get_payment_method_title () ) );
175
  }
170
  }
171
  }
172
  }
173
+ // update the order's customer ID if it has changed.
174
+ if ($order->get_customer_id () != $request->get_param ( 'customer_id' )) {
175
+ $order->set_customer_id ( $request->get_param ( 'customer_id' ) );
176
+ }
177
+
178
  if ($order->get_transaction_id ()) {
179
  throw new Exception ( sprintf ( __ ( 'This order has already been processed. Transaction ID: %s. Payment method: %s', 'woo-stripe-payment' ), $order->get_transaction_id (), $order->get_payment_method_title () ) );
180
  }
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: 5.3
6
  Requires PHP: 5.4
7
- Stable tag: 3.0.9
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -53,6 +53,9 @@ If you're site is not loading over https, then Stripe won't render the Payment R
53
  7. Payment options at top of checkout page for easy one click checkout
54
 
55
  == Changelog ==
 
 
 
56
  = 3.0.9 =
57
  * Added - Payment methods with payment sheets like Apple Pay now show order items on order pay page instead of just total.
58
  * Fixed - Error if 100% off coupon is used on checkout page.
4
  Requires at least: 3.0.1
5
  Tested up to: 5.3
6
  Requires PHP: 5.4
7
+ Stable tag: 3.0.10
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
53
  7. Payment options at top of checkout page for easy one click checkout
54
 
55
  == Changelog ==
56
+ = 3.0.10 =
57
+ * Fixed - Subscription error when capture_charge function called on order complete status.
58
+ * Fixed - Pre-order error for payment intent when capture_charge called.
59
  = 3.0.9 =
60
  * Added - Payment methods with payment sheets like Apple Pay now show order items on order pay page instead of just total.
61
  * Fixed - Error if 100% off coupon is used on checkout page.
stripe-payments.php CHANGED
@@ -4,7 +4,7 @@
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, ACH, Klarna and more using Stripe.
7
- * Version: 3.0.9
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
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, ACH, Klarna and more using Stripe.
7
+ * Version: 3.0.10
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/