WooCommerce Stripe Payment Gateway - Version 3.1.7

Version Description

  • Fix - Additional WC 3.0 compatibility with subscriptions addons.
  • Fix - Retry failed subscription payments with customer ID.
  • Add - Site URL to metadata when charging subscription orders for reference.
Download this release

Release Info

Developer royho
Plugin Icon 128x128 WooCommerce Stripe Payment Gateway
Version 3.1.7
Comparing to
See all releases

Code changes from version 3.1.6 to 3.1.7

.github/CONTRIBUTING.md DELETED
@@ -1,14 +0,0 @@
1
- ### Create Bug Reports
2
-
3
- If you find a bug or suggest enhancement, let us know by [opening a new issue](https://github.com/woothemes/woocommerce-gateway-stripe/issues/new).
4
-
5
- ### Write and submit a patch
6
-
7
- If you'd like to fix a bug, you can submit a Pull Request. If possible, raises an issue first and link the issue in your [commit message](https://help.github.com/articles/closing-issues-via-commit-messages/) or [PR's body](https://github.com/blog/1506-closing-issues-via-pull-requests).
8
-
9
- When creating Pull Requests, remember:
10
-
11
- - [Check In Early, Check In Often](http://blog.codinghorror.com/check-in-early-check-in-often/).
12
- - Write [good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
13
- - Respect the [Best practices for WordPress development](http://jetpack.com/contribute/#practices).
14
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/ISSUE_TEMPLATE.md DELETED
@@ -1,28 +0,0 @@
1
- <!-- Thanks for contributing to this extension! Pick a clear title ("Order: Unable to refund") and proceed. -->
2
-
3
- #### What I expected
4
-
5
- <!-- What you expected when performing the steps -->
6
-
7
- #### What happened instead
8
-
9
- <!-- What actual results you got -->
10
-
11
- #### Steps to reproduce the issue
12
-
13
- <!-- Please add detailed steps to reproduce the issue. Make sure it's reproducible locally. Other extensions should be deactivated and standard theme is used when reproducing the issue locally -->
14
-
15
- <!--
16
- PLEASE NOTE
17
- - These comments won't show up when you submit the issue.
18
- - Everything is optional, but try to add as many details as possible.
19
- - Screenshot worth a thousand words, use screenshots if possible.
20
- - If requesting a new feature, explain why you'd like to see it added.
21
- - Please apply appropriate labels on the issue
22
- -->
23
-
24
-
25
- -------------------
26
-
27
- - [ ] Issue assigned to next milestone.
28
- - [ ] Issue assigned a priority (will be assessed by maintainers).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/PULL_REQUEST_TEMPLATE.md DELETED
@@ -1,9 +0,0 @@
1
- Fixes # .
2
-
3
- #### Changes proposed in this Pull Request:
4
- -
5
-
6
- -------------------
7
- - [ ] Make sure your changes respect [WordPress' coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/).
8
- - [ ] Did you make changes, or create a **new .js file**? If **Gruntfile.js** exists in the repo, make sure to run `grunt`.
9
-
 
 
 
 
 
 
 
 
 
includes/class-wc-gateway-stripe-addons.php CHANGED
@@ -10,6 +10,8 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  */
11
  class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
12
 
 
 
13
  /**
14
  * Constructor
15
  */
@@ -33,6 +35,8 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
33
  if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
34
  add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) );
35
  }
 
 
36
  }
37
 
38
  /**
@@ -77,7 +81,7 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
77
  protected function save_source( $order, $source ) {
78
  parent::save_source( $order, $source );
79
 
80
- $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id();
81
 
82
  // Also store it on the subscriptions being purchased or paid for in the order
83
  if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
@@ -89,8 +93,9 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
89
  }
90
 
91
  foreach ( $subscriptions as $subscription ) {
92
- update_post_meta( $subscription->id, '_stripe_customer_id', $source->customer );
93
- update_post_meta( $subscription->id, '_stripe_card_id', $source->source );
 
94
  }
95
  }
96
 
@@ -111,7 +116,7 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
111
 
112
  // If no order source was defined, use user source instead.
113
  if ( ! $source->customer ) {
114
- $source = $this->get_source( $order->customer_user );
115
  }
116
 
117
  // Or fail :(
@@ -119,7 +124,7 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
119
  return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) );
120
  }
121
 
122
- $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id();
123
  $this->log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
124
 
125
  // Make the request
@@ -128,14 +133,27 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
128
  $request['amount'] = $this->get_stripe_amount( $amount, $request['currency'] );
129
  $request['metadata'] = array(
130
  'payment_type' => 'recurring',
 
131
  );
132
  $response = WC_Stripe_API::request( $request );
133
 
134
  // Process valid response
135
- if ( ! is_wp_error( $response ) ) {
136
- $this->process_response( $response, $order );
 
 
 
 
 
 
 
 
 
 
137
  }
138
 
 
 
139
  return $response;
140
  }
141
 
@@ -231,8 +249,8 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
231
  * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
232
  */
233
  public function delete_resubscribe_meta( $resubscribe_order ) {
234
- delete_post_meta( $resubscribe_order->id, '_stripe_customer_id' );
235
- delete_post_meta( $resubscribe_order->id, '_stripe_card_id' );
236
  $this->delete_renewal_meta( $resubscribe_order );
237
  }
238
 
@@ -241,9 +259,9 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
241
  * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
242
  */
243
  public function delete_renewal_meta( $renewal_order ) {
244
- delete_post_meta( $renewal_order->id, 'Stripe Fee' );
245
- delete_post_meta( $renewal_order->id, 'Net Revenue From Stripe' );
246
- delete_post_meta( $renewal_order->id, 'Stripe Payment ID' );
247
  return $renewal_order;
248
  }
249
 
@@ -266,7 +284,7 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
266
  * @param object $order
267
  */
268
  public function remove_order_source_before_retry( $order ) {
269
- $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id();
270
  delete_post_meta( $order_id, '_stripe_card_id' );
271
  }
272
 
@@ -275,7 +293,7 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
275
  * @param object $order
276
  */
277
  public function remove_order_customer_before_retry( $order ) {
278
- $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id();
279
  delete_post_meta( $order_id, '_stripe_customer_id' );
280
  }
281
 
@@ -289,8 +307,8 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
289
  * @return void
290
  */
291
  public function update_failing_payment_method( $subscription, $renewal_order ) {
292
- update_post_meta( $subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id );
293
- update_post_meta( $subscription->id, '_stripe_card_id', $renewal_order->stripe_card_id );
294
  }
295
 
296
  /**
@@ -306,11 +324,11 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
306
  $payment_meta[ $this->id ] = array(
307
  'post_meta' => array(
308
  '_stripe_customer_id' => array(
309
- 'value' => get_post_meta( $subscription->id, '_stripe_customer_id', true ),
310
  'label' => 'Stripe Customer ID',
311
  ),
312
  '_stripe_card_id' => array(
313
- 'value' => get_post_meta( $subscription->id, '_stripe_card_id', true ),
314
  'label' => 'Stripe Card ID',
315
  ),
316
  ),
@@ -351,26 +369,28 @@ class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
351
  * @return string the subscription payment method
352
  */
353
  public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
 
 
354
  // bail for other payment methods
355
- if ( $this->id !== $subscription->payment_method || ! $subscription->customer_user ) {
356
  return $payment_method_to_display;
357
  }
358
 
359
  $stripe_customer = new WC_Stripe_Customer();
360
- $stripe_customer_id = get_post_meta( $subscription->id, '_stripe_customer_id', true );
361
- $stripe_card_id = get_post_meta( $subscription->id, '_stripe_card_id', true );
362
 
363
  // If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
364
  if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
365
- $user_id = $subscription->customer_user;
366
  $stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true );
367
  $stripe_card_id = get_user_meta( $user_id, '_stripe_card_id', true );
368
  }
369
 
370
  // If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
371
  if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
372
- $stripe_customer_id = get_post_meta( $subscription->order->id, '_stripe_customer_id', true );
373
- $stripe_card_id = get_post_meta( $subscription->order->id, '_stripe_card_id', true );
374
  }
375
 
376
  $stripe_customer->set_id( $stripe_customer_id );
10
  */
11
  class WC_Gateway_Stripe_Addons extends WC_Gateway_Stripe {
12
 
13
+ public $wc_pre_30;
14
+
15
  /**
16
  * Constructor
17
  */
35
  if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
36
  add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) );
37
  }
38
+
39
+ $this->wc_pre_30 = version_compare( WC_VERSION, '3.0.0', '<' );
40
  }
41
 
42
  /**
81
  protected function save_source( $order, $source ) {
82
  parent::save_source( $order, $source );
83
 
84
+ $order_id = $this->wc_pre_30 ? $order->id : $order->get_id();
85
 
86
  // Also store it on the subscriptions being purchased or paid for in the order
87
  if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
93
  }
94
 
95
  foreach ( $subscriptions as $subscription ) {
96
+ $subscription_id = $this->wc_pre_30 ? $subscription->id : $subscription->get_id();
97
+ update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
98
+ update_post_meta( $subscription_id, '_stripe_card_id', $source->source );
99
  }
100
  }
101
 
116
 
117
  // If no order source was defined, use user source instead.
118
  if ( ! $source->customer ) {
119
+ $source = $this->get_source( ( $this->wc_pre_30 ? $order->customer_user : $order->get_customer_id() ) );
120
  }
121
 
122
  // Or fail :(
124
  return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) );
125
  }
126
 
127
+ $order_id = $this->wc_pre_30 ? $order->id : $order->get_id();
128
  $this->log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
129
 
130
  // Make the request
133
  $request['amount'] = $this->get_stripe_amount( $amount, $request['currency'] );
134
  $request['metadata'] = array(
135
  'payment_type' => 'recurring',
136
+ 'site_url' => esc_url( get_site_url() ),
137
  );
138
  $response = WC_Stripe_API::request( $request );
139
 
140
  // Process valid response
141
+ if ( is_wp_error( $response ) ) {
142
+ if ( 'missing' === $response->get_error_code() ) {
143
+ // If we can't link customer to a card, we try to charge by customer ID.
144
+ $request = $this->generate_payment_request( $order, $this->get_source( ( $this->wc_pre_30 ? $order->customer_user : $order->get_customer_id() ) ) );
145
+ $request['capture'] = 'true';
146
+ $request['amount'] = $this->get_stripe_amount( $amount, $request['currency'] );
147
+ $request['metadata'] = array(
148
+ 'payment_type' => 'recurring',
149
+ 'site_url' => esc_url( get_site_url() ),
150
+ );
151
+ $response = WC_Stripe_API::request( $request );
152
+ }
153
  }
154
 
155
+ $this->process_response( $response, $order );
156
+
157
  return $response;
158
  }
159
 
249
  * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
250
  */
251
  public function delete_resubscribe_meta( $resubscribe_order ) {
252
+ delete_post_meta( ( $this->wc_pre_30 ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_customer_id' );
253
+ delete_post_meta( ( $this->wc_pre_30 ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_card_id' );
254
  $this->delete_renewal_meta( $resubscribe_order );
255
  }
256
 
259
  * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
260
  */
261
  public function delete_renewal_meta( $renewal_order ) {
262
+ delete_post_meta( ( $this->wc_pre_30 ? $renewal_order->id : $renewal_order->get_id() ), 'Stripe Fee' );
263
+ delete_post_meta( ( $this->wc_pre_30 ? $renewal_order->id : $renewal_order->get_id() ), 'Net Revenue From Stripe' );
264
+ delete_post_meta( ( $this->wc_pre_30 ? $renewal_order->id : $renewal_order->get_id() ), 'Stripe Payment ID' );
265
  return $renewal_order;
266
  }
267
 
284
  * @param object $order
285
  */
286
  public function remove_order_source_before_retry( $order ) {
287
+ $order_id = $this->wc_pre_30 ? $order->id : $order->get_id();
288
  delete_post_meta( $order_id, '_stripe_card_id' );
289
  }
290
 
293
  * @param object $order
294
  */
295
  public function remove_order_customer_before_retry( $order ) {
296
+ $order_id = $this->wc_pre_30 ? $order->id : $order->get_id();
297
  delete_post_meta( $order_id, '_stripe_customer_id' );
298
  }
299
 
307
  * @return void
308
  */
309
  public function update_failing_payment_method( $subscription, $renewal_order ) {
310
+ update_post_meta( ( $this->wc_pre_30 ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', $renewal_order->stripe_customer_id );
311
+ update_post_meta( ( $this->wc_pre_30 ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', $renewal_order->stripe_card_id );
312
  }
313
 
314
  /**
324
  $payment_meta[ $this->id ] = array(
325
  'post_meta' => array(
326
  '_stripe_customer_id' => array(
327
+ 'value' => get_post_meta( ( $this->wc_pre_30 ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ),
328
  'label' => 'Stripe Customer ID',
329
  ),
330
  '_stripe_card_id' => array(
331
+ 'value' => get_post_meta( ( $this->wc_pre_30 ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true ),
332
  'label' => 'Stripe Card ID',
333
  ),
334
  ),
369
  * @return string the subscription payment method
370
  */
371
  public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
372
+ $customer_user = $this->wc_pre_30 ? $subscription->customer_user : $subscription->get_customer_id();
373
+
374
  // bail for other payment methods
375
+ if ( $this->id !== ( $this->wc_pre_30 ? $subscription->payment_method : $subscription->get_payment_method() ) || ! $customer_user ) {
376
  return $payment_method_to_display;
377
  }
378
 
379
  $stripe_customer = new WC_Stripe_Customer();
380
+ $stripe_customer_id = get_post_meta( ( $this->wc_pre_30 ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true );
381
+ $stripe_card_id = get_post_meta( ( $this->wc_pre_30 ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
382
 
383
  // If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
384
  if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
385
+ $user_id = $customer_user;
386
  $stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true );
387
  $stripe_card_id = get_user_meta( $user_id, '_stripe_card_id', true );
388
  }
389
 
390
  // If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
391
  if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
392
+ $stripe_customer_id = get_post_meta( ( $this->wc_pre_30 ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true );
393
+ $stripe_card_id = get_post_meta( ( $this->wc_pre_30 ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true );
394
  }
395
 
396
  $stripe_customer->set_id( $stripe_customer_id );
includes/class-wc-gateway-stripe.php CHANGED
@@ -262,9 +262,9 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
262
  * @version 3.1.0
263
  */
264
  public function init_apple_pay() {
265
- if (
266
- is_admin() &&
267
- isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
268
  isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
269
  isset( $_GET['section'] ) && 'stripe' === $_GET['section']
270
  ) {
@@ -301,7 +301,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
301
  ) );
302
 
303
  if ( is_wp_error( $response ) ) {
304
- throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
305
  }
306
 
307
  if ( 200 !== $response['response']['code'] ) {
@@ -385,7 +385,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
385
  }
386
 
387
  /**
388
- * Apple pay is enabled by default and domain verification initializes
389
  * when setting screen is displayed. So if domain verification is not set,
390
  * something went wrong so lets notify user.
391
  */
@@ -529,7 +529,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
529
  'missing_secret_key' => __( 'Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe' ),
530
  ),
531
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
532
- 'nonce' => array(
533
  'apple_pay_domain_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_domain_nonce' ),
534
  ),
535
  );
@@ -751,6 +751,9 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
751
  // Store source to order meta.
752
  $this->save_source( $order, $source );
753
 
 
 
 
754
  // Handle payment.
755
  if ( $order->get_total() > 0 ) {
756
 
262
  * @version 3.1.0
263
  */
264
  public function init_apple_pay() {
265
+ if (
266
+ is_admin() &&
267
+ isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
268
  isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
269
  isset( $_GET['section'] ) && 'stripe' === $_GET['section']
270
  ) {
301
  ) );
302
 
303
  if ( is_wp_error( $response ) ) {
304
+ throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
305
  }
306
 
307
  if ( 200 !== $response['response']['code'] ) {
385
  }
386
 
387
  /**
388
+ * Apple pay is enabled by default and domain verification initializes
389
  * when setting screen is displayed. So if domain verification is not set,
390
  * something went wrong so lets notify user.
391
  */
529
  'missing_secret_key' => __( 'Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe' ),
530
  ),
531
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
532
+ 'nonce' => array(
533
  'apple_pay_domain_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_domain_nonce' ),
534
  ),
535
  );
751
  // Store source to order meta.
752
  $this->save_source( $order, $source );
753
 
754
+ // Result from Stripe API request.
755
+ $response = null;
756
+
757
  // Handle payment.
758
  if ( $order->get_total() > 0 ) {
759
 
includes/class-wc-stripe-apple-pay.php CHANGED
@@ -399,7 +399,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
399
 
400
  ?>
401
  <div class="apple-pay-button-wrapper">
402
- <button class="apple-pay-button" lang="<?php echo esc_attr( $this->apple_pay_button_lang ); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr( $this->apple_pay_button ); ?>;"></button>
403
  </div>
404
  <?php
405
  }
@@ -539,7 +539,9 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
539
  WC()->customer->set_shipping_to_base();
540
  }
541
 
542
- WC()->customer->calculated_shipping( true );
 
 
543
 
544
  /**
545
  * Set the shipping package.
@@ -830,9 +832,11 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
830
  $subtotal += $cart_item['line_subtotal'];
831
  $quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
832
 
 
 
833
  $item = array(
834
  'type' => 'final',
835
- 'label' => $cart_item['data']->post->post_title . $quantity_label,
836
  'amount' => wc_format_decimal( $amount, $decimals ),
837
  );
838
 
@@ -1096,14 +1100,21 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
1096
 
1097
  $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
1098
  $order->set_payment_method( $available_gateways['stripe'] );
1099
- $order->set_total( WC()->cart->shipping_total, 'shipping' );
1100
- $order->set_total( WC()->cart->get_cart_discount_total(), 'cart_discount' );
1101
- $order->set_total( WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax' );
1102
- $order->set_total( WC()->cart->tax_total, 'tax' );
1103
- $order->set_total( WC()->cart->shipping_tax_total, 'shipping_tax' );
1104
- $order->set_total( WC()->cart->total );
1105
-
1106
- if ( version_compare( WC_VERSION, '3.0', '>=' ) ) {
 
 
 
 
 
 
 
1107
  $order->save();
1108
  }
1109
 
399
 
400
  ?>
401
  <div class="apple-pay-button-wrapper">
402
+ <button class="apple-pay-button" lang="<?php echo esc_attr( $this->apple_pay_button_lang ); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr( $this->apple_pay_button ); ?>;" alt="<?php esc_attr_e( 'Buy with Apple Pay', 'woocommerce-gateway-stripe' ); ?>"></button>
403
  </div>
404
  <?php
405
  }
539
  WC()->customer->set_shipping_to_base();
540
  }
541
 
542
+ version_compare( WC_VERSION, '3.0', '<' ) ? WC()->customer->calculated_shipping( true ) : WC()->customer->set_calculated_shipping( true );
543
+
544
+ WC()->customer->save();
545
 
546
  /**
547
  * Set the shipping package.
832
  $subtotal += $cart_item['line_subtotal'];
833
  $quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
834
 
835
+ $product_name = version_compare( WC_VERSION, '3.0', '<' ) ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
836
+
837
  $item = array(
838
  'type' => 'final',
839
+ 'label' => $product_name . $quantity_label,
840
  'amount' => wc_format_decimal( $amount, $decimals ),
841
  );
842
 
1100
 
1101
  $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
1102
  $order->set_payment_method( $available_gateways['stripe'] );
1103
+
1104
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
1105
+ $order->set_total( WC()->cart->shipping_total, 'shipping' );
1106
+ $order->set_total( WC()->cart->get_cart_discount_total(), 'cart_discount' );
1107
+ $order->set_total( WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax' );
1108
+ $order->set_total( WC()->cart->tax_total, 'tax' );
1109
+ $order->set_total( WC()->cart->shipping_tax_total, 'shipping_tax' );
1110
+ $order->set_total( WC()->cart->total );
1111
+ } else {
1112
+ $order->set_shipping_total( WC()->cart->shipping_total );
1113
+ $order->set_discount_total( WC()->cart->get_cart_discount_total() );
1114
+ $order->set_discount_tax( WC()->cart->get_cart_discount_tax_total() );
1115
+ $order->set_cart_tax( WC()->cart->tax_total );
1116
+ $order->set_shipping_tax( WC()->cart->shipping_tax_total );
1117
+ $order->set_total( WC()->cart->total );
1118
  $order->save();
1119
  }
1120
 
includes/class-wc-stripe-payment-request.php CHANGED
@@ -162,7 +162,9 @@ class WC_Stripe_Payment_Request {
162
  WC()->customer->set_shipping_to_base();
163
  }
164
 
165
- WC()->customer->calculated_shipping( true );
 
 
166
 
167
  $packages = array();
168
 
162
  WC()->customer->set_shipping_to_base();
163
  }
164
 
165
+ version_compare( WC_VERSION, '3.0', '<' ) ? WC()->customer->calculated_shipping( true ) : WC()->customer->set_calculated_shipping( true );
166
+
167
+ WC()->customer->save();
168
 
169
  $packages = array();
170
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: automattic, woothemes, mikejolley, akeda, royho, mattyza, slash1an
3
  Tags: credit card, stripe, woocommerce
4
  Requires at least: 4.4
5
  Tested up to: 4.7.2
6
- Stable tag: 3.1.6
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -95,6 +95,11 @@ If you get stuck, you can ask for help in the Plugin Forum.
95
 
96
  == Changelog ==
97
 
 
 
 
 
 
98
  = 3.1.6 =
99
  * Fix - TypeError issues on single product page when using Apple Pay on Desktop.
100
  * Fix - In certain case, Apple Pay on single product page does not show shipping info.
@@ -128,6 +133,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
128
  = 3.1.0 =
129
  * New - Apple Pay Support.
130
  * New - Add Google Payment Request API.
 
131
 
132
  = 3.0.7 =
133
  * New - Option to allow/disallow remember me on Stripe checkout modal.
@@ -176,8 +182,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
176
 
177
  == Upgrade Notice ==
178
 
179
- = 3.1.6 =
180
- * Fix - TypeError issues on single product page when using Apple Pay on Desktop.
181
- * Fix - In certain case, Apple Pay on single product page does not show shipping info.
182
- * Fix - Use store's base location to show/hide accepted credit cards instead of currency.
183
- * Fix - Unsupported product type when a variable product is added with Apple Pay.
3
  Tags: credit card, stripe, woocommerce
4
  Requires at least: 4.4
5
  Tested up to: 4.7.2
6
+ Stable tag: 3.1.7
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
95
 
96
  == Changelog ==
97
 
98
+ = 3.1.7 =
99
+ * Fix - Additional WC 3.0 compatibility with subscriptions addons.
100
+ * Fix - Retry failed subscription payments with customer ID.
101
+ * Add - Site URL to metadata when charging subscription orders for reference.
102
+
103
  = 3.1.6 =
104
  * Fix - TypeError issues on single product page when using Apple Pay on Desktop.
105
  * Fix - In certain case, Apple Pay on single product page does not show shipping info.
133
  = 3.1.0 =
134
  * New - Apple Pay Support.
135
  * New - Add Google Payment Request API.
136
+ * New - Minimum PHP 5.6.
137
 
138
  = 3.0.7 =
139
  * New - Option to allow/disallow remember me on Stripe checkout modal.
182
 
183
  == Upgrade Notice ==
184
 
185
+ = 3.1.7 =
186
+ * Fix - Additional WC 3.0 compatibility with subscriptions addons.
187
+ * Fix - Retry failed subscription payments with customer ID.
188
+ * Add - Site URL to metadata when charging subscription orders for reference.
 
woocommerce-gateway-stripe.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Take credit card payments on your store using Stripe.
6
  * Author: WooCommerce
7
  * Author URI: https://woocommerce.com/
8
- * Version: 3.1.6
9
  * Text Domain: woocommerce-gateway-stripe
10
  * Domain Path: /languages
11
  *
@@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
32
  /**
33
  * Required minimums and constants
34
  */
35
- define( 'WC_STRIPE_VERSION', '3.1.6' );
36
  define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
37
  define( 'WC_STRIPE_MIN_WC_VER', '2.5.0' );
38
  define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
5
  * Description: Take credit card payments on your store using Stripe.
6
  * Author: WooCommerce
7
  * Author URI: https://woocommerce.com/
8
+ * Version: 3.1.7
9
  * Text Domain: woocommerce-gateway-stripe
10
  * Domain Path: /languages
11
  *
32
  /**
33
  * Required minimums and constants
34
  */
35
+ define( 'WC_STRIPE_VERSION', '3.1.7' );
36
  define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
37
  define( 'WC_STRIPE_MIN_WC_VER', '2.5.0' );
38
  define( 'WC_STRIPE_MAIN_FILE', __FILE__ );