Payment Plugins for Stripe WooCommerce - Version 3.0.7

Version Description

  • Added - WPML support for gateway titles and descriptions
  • Added - ACH fee option
  • Added - Webhook registration option in Admin
  • Updated - Cart one click checkout buttons
  • Updated - WC 3.9
Download this release

Release Info

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

Code changes from version 3.0.6 to 3.0.7

assets/css/admin/admin.css CHANGED
@@ -135,4 +135,27 @@
135
  }
136
  .wc-stripe-user-info{
137
  padding: 10px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
135
  }
136
  .wc-stripe-user-info{
137
  padding: 10px 0;
138
+ }
139
+ .woocommerce table.form-table [id="woocommerce_stripe_ach_fee[type]"] + .select2-container{
140
+ width: 125px !important;
141
+ min-width: 125px !important;
142
+ }
143
+ [id="woocommerce_stripe_ach_fee[type]"] {
144
+ width: 150px !important;
145
+ }
146
+ .wc-stripe-fee-container{
147
+ display: flex;
148
+ flex-direction: row;
149
+ flex-flow: wrap;
150
+ }
151
+ .wc-stripe-fee-col{
152
+ display: flex;
153
+ flex-direction: column;
154
+ }
155
+ .wc-stripe-fee-col{
156
+ margin-right: 15px;
157
+ }
158
+ .wc-stripe-fee-container input{
159
+ display: block;
160
+ margin-top: 1px;
161
  }
assets/js/admin/admin-settings.js CHANGED
@@ -99,17 +99,18 @@ jQuery(function($) {
99
  Settings.prototype.create_webhook = function(e) {
100
  e.preventDefault();
101
  this.block();
 
102
  $.ajax({
103
  url: this.params.routes.create_webhook,
104
  dataType: 'json',
105
  method: 'POST',
106
- data: { _wpnonce: this.params.rest_nonce }
107
  }).done(function(response) {
108
  this.unblock();
109
  if (response.code) {
110
  window.alert(response.message);
111
  } else {
112
- $('#woocommerce_stripe_api_webhook_secret').val(response.secret);
113
  window.alert(response.message);
114
  }
115
  }.bind(this)).fail(function(xhr, textStatus, errorThrown) {
99
  Settings.prototype.create_webhook = function(e) {
100
  e.preventDefault();
101
  this.block();
102
+ var env = $('#woocommerce_stripe_api_mode').val();
103
  $.ajax({
104
  url: this.params.routes.create_webhook,
105
  dataType: 'json',
106
  method: 'POST',
107
+ data: { _wpnonce: this.params.rest_nonce, environment: env }
108
  }).done(function(response) {
109
  this.unblock();
110
  if (response.code) {
111
  window.alert(response.message);
112
  } else {
113
+ $('#woocommerce_stripe_api_webhook_secret_' + env).val(response.secret);
114
  window.alert(response.message);
115
  }
116
  }.bind(this)).fail(function(xhr, textStatus, errorThrown) {
assets/js/frontend/ach-payments.js CHANGED
@@ -4,6 +4,8 @@
4
  wc_stripe.BaseGateway.call(this, wc_stripe_ach_params);
5
  wc_stripe.CheckoutGateway.call(this);
6
  this.metadata_key = this.params.metadata_key;
 
 
7
  }
8
 
9
  ACH.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype);
@@ -57,6 +59,16 @@
57
  $(this.metadata_key).val(JSON.stringify(metadata));
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
60
  new ACH();
61
 
62
  }(jQuery, window.wc_stripe))
4
  wc_stripe.BaseGateway.call(this, wc_stripe_ach_params);
5
  wc_stripe.CheckoutGateway.call(this);
6
  this.metadata_key = this.params.metadata_key;
7
+
8
+ $(document.body).on('payment_method_selected', this.payment_method_selected.bind(this));
9
  }
10
 
11
  ACH.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype);
59
  $(this.metadata_key).val(JSON.stringify(metadata));
60
  }
61
 
62
+ ACH.prototype.fees_enabled = function() {
63
+ return this.params.fees_enabled == "1";
64
+ }
65
+
66
+ ACH.prototype.payment_method_selected = function() {
67
+ if (this.fees_enabled()) {
68
+ $(document.body).trigger('update_checkout');
69
+ }
70
+ }
71
+
72
  new ACH();
73
 
74
  }(jQuery, window.wc_stripe))
assets/js/frontend/applepay-cart.js CHANGED
@@ -31,7 +31,7 @@
31
  ApplePay.prototype.updated_html = function() {
32
  if (this.can_pay) {
33
  this.create_button();
34
- $(this.container).show().addClass('active');
35
  }
36
  }
37
 
31
  ApplePay.prototype.updated_html = function() {
32
  if (this.can_pay) {
33
  this.create_button();
34
+ $(this.container).show().addClass('active').parent().addClass('active');
35
  }
36
  }
37
 
assets/js/frontend/googlepay-cart.js CHANGED
@@ -38,7 +38,7 @@
38
  GPay.prototype.updated_html = function() {
39
  if (this.can_pay) {
40
  this.create_button();
41
- $(this.container).show().addClass('active');
42
  }
43
  }
44
 
38
  GPay.prototype.updated_html = function() {
39
  if (this.can_pay) {
40
  this.create_button();
41
+ $(this.container).show().addClass('active').parent().addClass('active');
42
  }
43
  }
44
 
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: 2020-01-07 12:49-0800\n"
6
  "PO-Revision-Date: 2019-08-16 14:27-0700\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
@@ -21,7 +21,7 @@ msgstr ""
21
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:69
22
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:53
23
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:71
24
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:100
25
  #, php-format
26
  msgid "Error processing payment. Reason: %s"
27
  msgstr ""
@@ -171,65 +171,69 @@ msgstr ""
171
  msgid "Total"
172
  msgstr ""
173
 
174
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:379
 
 
 
 
175
  #, php-format
176
  msgid "Error saving your payment method. Reason: %s"
177
  msgstr ""
178
 
179
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:390
180
  #, php-format
181
  msgid "Error saving payment method. Reason: %s"
182
  msgstr ""
183
 
184
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:402
185
  msgid "Transaction Id cannot be empty."
186
  msgstr ""
187
 
188
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:409
189
  #, php-format
190
  msgid "Order refunded in Stripe. Amount: %s"
191
  msgstr ""
192
 
193
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:586
194
  msgid "n/a"
195
  msgstr ""
196
 
197
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:607
198
  #: includes/admin/meta-boxes/views/html-order-pay.php:42
199
  msgid "New Card"
200
  msgstr ""
201
 
202
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:611
203
  #: includes/admin/meta-boxes/views/html-order-pay.php:30
204
  msgid "Saved Cards"
205
  msgstr ""
206
 
207
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:820
208
  #, php-format
209
  msgid "Attemp to save payment method failed. Reason: %s"
210
  msgstr ""
211
 
212
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:840
213
  msgid ""
214
  "We were not able to save your payment method. To prevent billing issues with "
215
  "your subscription, please add a payment method to the subscription."
216
  msgstr ""
217
 
218
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:842
219
  #, php-format
220
  msgid "We were not able to save your payment method. Reason: %s"
221
  msgstr ""
222
 
223
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:874
224
  msgid "Payment Method Token"
225
  msgstr ""
226
 
227
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:900
228
  #, php-format
229
  msgid "Error saving payment method for subscription. Reason: %s"
230
  msgstr ""
231
 
232
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:953
233
  #, php-format
234
  msgid "Order %s from %s"
235
  msgstr ""
@@ -294,11 +298,13 @@ msgstr ""
294
 
295
  #: includes/admin/meta-boxes/views/html-charge-data-subview.php:25
296
  #: includes/admin/settings/class-wc-stripe-api-settings.php:33
 
297
  msgid "Live"
298
  msgstr ""
299
 
300
  #: includes/admin/meta-boxes/views/html-charge-data-subview.php:25
301
  #: includes/admin/settings/class-wc-stripe-api-settings.php:32
 
302
  msgid "Test"
303
  msgstr ""
304
 
@@ -340,6 +346,7 @@ msgid "Title"
340
  msgstr ""
341
 
342
  #: includes/admin/meta-boxes/views/html-charge-data-subview.php:51
 
343
  #: includes/gateways/settings/payment-request-settings.php:87
344
  msgid "Type"
345
  msgstr ""
@@ -479,10 +486,11 @@ msgid ""
479
  msgstr ""
480
 
481
  #: includes/admin/settings/class-wc-stripe-api-settings.php:98
482
- msgid "Webhook Secret"
483
  msgstr ""
484
 
485
  #: includes/admin/settings/class-wc-stripe-api-settings.php:99
 
486
  #, php-format
487
  msgid ""
488
  "The webhook secret is used to authenticate webhooks sent from Stripe. It "
@@ -490,16 +498,28 @@ msgid ""
490
  "guide%s"
491
  msgstr ""
492
 
493
- #: includes/admin/settings/class-wc-stripe-api-settings.php:102
 
 
 
 
494
  msgid "Debug Log"
495
  msgstr ""
496
 
497
- #: includes/admin/settings/class-wc-stripe-api-settings.php:106
498
  msgid ""
499
  "When enabled, the plugin logs important errors and info that can help you "
500
  "troubleshoot potential issues."
501
  msgstr ""
502
 
 
 
 
 
 
 
 
 
503
  #: includes/admin/views/html-user-profile.php:7
504
  msgid "Stripe Customer ID's"
505
  msgstr ""
@@ -603,6 +623,11 @@ msgstr ""
603
  msgid "%1$s is an invalid controller name."
604
  msgstr ""
605
 
 
 
 
 
 
606
  #: includes/controllers/class-wc-stripe-controller-cart.php:93
607
  msgid "Quantity must be greater than zero."
608
  msgstr ""
@@ -618,32 +643,32 @@ msgstr ""
618
  msgid "Please review your order details then click Place Order."
619
  msgstr ""
620
 
621
- #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:62
622
  msgid ""
623
  "You cannot register your domain until you have configured your Live API keys."
624
  msgstr ""
625
 
626
- #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:69
627
- #, php-format
628
  msgid ""
629
- "Domain %s registered successfully. You can confirm in your Stripe Dashboard "
630
- "at https://dashboard.stripe.com/account/apple_pay."
631
  msgstr ""
632
 
633
- #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:90
634
  msgid "You must configure your secret key before creating webhooks."
635
  msgstr ""
636
 
637
- #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:99
638
  msgid ""
639
  "There is already a webhook configured for this site. If you want to delete "
640
  "the webhook, login to your Stripe Dashboard."
641
  msgstr ""
642
 
643
- #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:120
 
644
  msgid ""
645
- "Webhook created in Stripe. You can test your webhook by logging in to the "
646
- "Stripe dashboard"
647
  msgstr ""
648
 
649
  #: includes/controllers/class-wc-stripe-controller-googlepay.php:86
@@ -674,9 +699,9 @@ msgstr ""
674
  msgid "Error creating payment intent. Reason: %s"
675
  msgstr ""
676
 
677
- #: includes/controllers/class-wc-stripe-controller-webhook.php:42
678
- #: includes/controllers/class-wc-stripe-controller-webhook.php:43
679
- msgid "Invalid signaute received. Verify that your webhook secret is correct."
680
  msgstr ""
681
 
682
  #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:20
@@ -695,14 +720,20 @@ msgstr ""
695
  msgid "Bank Payment"
696
  msgstr ""
697
 
698
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:182
699
  msgid "Saved Banks"
700
  msgstr ""
701
 
702
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:186
703
  msgid "New Bank"
704
  msgstr ""
705
 
 
 
 
 
 
 
706
  #: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:14
707
  #: includes/gateways/settings/applepay-settings.php:17
708
  msgid "Apple Pay"
@@ -1160,6 +1191,24 @@ msgid ""
1160
  "your customers on orders, subscriptions, etc."
1161
  msgstr ""
1162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1163
  #: includes/gateways/settings/applepay-settings.php:4
1164
  msgid "Register Domain"
1165
  msgstr ""
@@ -1677,7 +1726,7 @@ msgstr ""
1677
  msgid "Your PHP version is %s but Stripe requires version 5.4+."
1678
  msgstr ""
1679
 
1680
- #: templates/cart/payment-methods.php:12
1681
  msgid "or"
1682
  msgstr ""
1683
 
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: woo-stripe-payment\n"
5
+ "POT-Creation-Date: 2020-01-15 13:16-0800\n"
6
  "PO-Revision-Date: 2019-08-16 14:27-0700\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
21
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:69
22
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:53
23
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:71
24
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:107
25
  #, php-format
26
  msgid "Error processing payment. Reason: %s"
27
  msgstr ""
171
  msgid "Total"
172
  msgstr ""
173
 
174
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:381
175
+ msgid "User must be logged in."
176
+ msgstr ""
177
+
178
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:390
179
  #, php-format
180
  msgid "Error saving your payment method. Reason: %s"
181
  msgstr ""
182
 
183
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:404
184
  #, php-format
185
  msgid "Error saving payment method. Reason: %s"
186
  msgstr ""
187
 
188
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:416
189
  msgid "Transaction Id cannot be empty."
190
  msgstr ""
191
 
192
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:423
193
  #, php-format
194
  msgid "Order refunded in Stripe. Amount: %s"
195
  msgstr ""
196
 
197
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:600
198
  msgid "n/a"
199
  msgstr ""
200
 
201
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:621
202
  #: includes/admin/meta-boxes/views/html-order-pay.php:42
203
  msgid "New Card"
204
  msgstr ""
205
 
206
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:625
207
  #: includes/admin/meta-boxes/views/html-order-pay.php:30
208
  msgid "Saved Cards"
209
  msgstr ""
210
 
211
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:834
212
  #, php-format
213
  msgid "Attemp to save payment method failed. Reason: %s"
214
  msgstr ""
215
 
216
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:854
217
  msgid ""
218
  "We were not able to save your payment method. To prevent billing issues with "
219
  "your subscription, please add a payment method to the subscription."
220
  msgstr ""
221
 
222
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:856
223
  #, php-format
224
  msgid "We were not able to save your payment method. Reason: %s"
225
  msgstr ""
226
 
227
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:888
228
  msgid "Payment Method Token"
229
  msgstr ""
230
 
231
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:914
232
  #, php-format
233
  msgid "Error saving payment method for subscription. Reason: %s"
234
  msgstr ""
235
 
236
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:967
237
  #, php-format
238
  msgid "Order %s from %s"
239
  msgstr ""
298
 
299
  #: includes/admin/meta-boxes/views/html-charge-data-subview.php:25
300
  #: includes/admin/settings/class-wc-stripe-api-settings.php:33
301
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:134
302
  msgid "Live"
303
  msgstr ""
304
 
305
  #: includes/admin/meta-boxes/views/html-charge-data-subview.php:25
306
  #: includes/admin/settings/class-wc-stripe-api-settings.php:32
307
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:134
308
  msgid "Test"
309
  msgstr ""
310
 
346
  msgstr ""
347
 
348
  #: includes/admin/meta-boxes/views/html-charge-data-subview.php:51
349
+ #: includes/admin/views/html-ach-fee.php:10
350
  #: includes/gateways/settings/payment-request-settings.php:87
351
  msgid "Type"
352
  msgstr ""
486
  msgstr ""
487
 
488
  #: includes/admin/settings/class-wc-stripe-api-settings.php:98
489
+ msgid "Live Webhook Secret"
490
  msgstr ""
491
 
492
  #: includes/admin/settings/class-wc-stripe-api-settings.php:99
493
+ #: includes/admin/settings/class-wc-stripe-api-settings.php:109
494
  #, php-format
495
  msgid ""
496
  "The webhook secret is used to authenticate webhooks sent from Stripe. It "
498
  "guide%s"
499
  msgstr ""
500
 
501
+ #: includes/admin/settings/class-wc-stripe-api-settings.php:108
502
+ msgid "Test Webhook Secret"
503
+ msgstr ""
504
+
505
+ #: includes/admin/settings/class-wc-stripe-api-settings.php:117
506
  msgid "Debug Log"
507
  msgstr ""
508
 
509
+ #: includes/admin/settings/class-wc-stripe-api-settings.php:121
510
  msgid ""
511
  "When enabled, the plugin logs important errors and info that can help you "
512
  "troubleshoot potential issues."
513
  msgstr ""
514
 
515
+ #: includes/admin/views/html-ach-fee.php:18
516
+ msgid "Taxable"
517
+ msgstr ""
518
+
519
+ #: includes/admin/views/html-ach-fee.php:22
520
+ msgid "Value"
521
+ msgstr ""
522
+
523
  #: includes/admin/views/html-user-profile.php:7
524
  msgid "Stripe Customer ID's"
525
  msgstr ""
623
  msgid "%1$s is an invalid controller name."
624
  msgstr ""
625
 
626
+ #: includes/class-wc-stripe-update.php:34
627
+ #, php-format
628
+ msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
629
+ msgstr ""
630
+
631
  #: includes/controllers/class-wc-stripe-controller-cart.php:93
632
  msgid "Quantity must be greater than zero."
633
  msgstr ""
643
  msgid "Please review your order details then click Place Order."
644
  msgstr ""
645
 
646
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:71
647
  msgid ""
648
  "You cannot register your domain until you have configured your Live API keys."
649
  msgstr ""
650
 
651
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:87
 
652
  msgid ""
653
+ "Domain registered successfully. You can confirm in your Stripe Dashboard at "
654
+ "https://dashboard.stripe.com/account/apple_pay."
655
  msgstr ""
656
 
657
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:104
658
  msgid "You must configure your secret key before creating webhooks."
659
  msgstr ""
660
 
661
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:113
662
  msgid ""
663
  "There is already a webhook configured for this site. If you want to delete "
664
  "the webhook, login to your Stripe Dashboard."
665
  msgstr ""
666
 
667
+ #: includes/controllers/class-wc-stripe-controller-gateway-settings.php:134
668
+ #, php-format
669
  msgid ""
670
+ "Webhook created in Stripe for %s environment. You can test your webhook by "
671
+ "logging in to the Stripe dashboard"
672
  msgstr ""
673
 
674
  #: includes/controllers/class-wc-stripe-controller-googlepay.php:86
699
  msgid "Error creating payment intent. Reason: %s"
700
  msgstr ""
701
 
702
+ #: includes/controllers/class-wc-stripe-controller-webhook.php:44
703
+ #: includes/controllers/class-wc-stripe-controller-webhook.php:45
704
+ msgid "Invalid signature received. Verify that your webhook secret is correct."
705
  msgstr ""
706
 
707
  #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:20
720
  msgid "Bank Payment"
721
  msgstr ""
722
 
723
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:189
724
  msgid "Saved Banks"
725
  msgstr ""
726
 
727
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:193
728
  msgid "New Bank"
729
  msgstr ""
730
 
731
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:258
732
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:261
733
+ #: includes/gateways/settings/ach-settings.php:79
734
+ msgid "ACH Fee"
735
+ msgstr ""
736
+
737
  #: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:14
738
  #: includes/gateways/settings/applepay-settings.php:17
739
  msgid "Apple Pay"
1191
  "your customers on orders, subscriptions, etc."
1192
  msgstr ""
1193
 
1194
+ #: includes/gateways/settings/ach-settings.php:86
1195
+ msgid "None"
1196
+ msgstr ""
1197
+
1198
+ #: includes/gateways/settings/ach-settings.php:87
1199
+ msgid "Amount"
1200
+ msgstr ""
1201
+
1202
+ #: includes/gateways/settings/ach-settings.php:88
1203
+ msgid "Percentage"
1204
+ msgstr ""
1205
+
1206
+ #: includes/gateways/settings/ach-settings.php:90
1207
+ msgid ""
1208
+ "You can assign a fee to the order for ACH payments. Amount is a static "
1209
+ "amount and percentage is a percentage of the cart amount."
1210
+ msgstr ""
1211
+
1212
  #: includes/gateways/settings/applepay-settings.php:4
1213
  msgid "Register Domain"
1214
  msgstr ""
1726
  msgid "Your PHP version is %s but Stripe requires version 5.4+."
1727
  msgstr ""
1728
 
1729
+ #: templates/cart/payment-methods.php:13 templates/cart/payment-methods.php:28
1730
  msgid "or"
1731
  msgstr ""
1732
 
includes/abstract/abstract-wc-payment-gateway-stripe.php CHANGED
@@ -368,13 +368,24 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
368
  */
369
  public abstract function get_payment_method_from_charge($charge);
370
 
 
 
 
 
 
 
371
  public function add_payment_method() {
372
  $customer_id = wc_stripe_get_customer_id ();
373
- if (empty ( $customer_id )) {
374
- $customer_id = $this->create_customer ( get_current_user_id () );
375
- }
376
  try {
 
 
 
 
 
 
 
377
  $result = $this->create_payment_method ( $this->get_new_source_token (), $customer_id );
 
378
  if (is_wp_error ( $result )) {
379
  wc_add_notice ( sprintf ( __ ( 'Error saving your payment method. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ), 'error' );
380
  return array( 'result' => 'error'
@@ -383,6 +394,9 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
383
  $result->set_user_id ( get_current_user_id () );
384
  $result->save ();
385
  WC_Payment_Tokens::set_users_default ( get_current_user_id (), $result->get_id () );
 
 
 
386
  return array( 'result' => 'success',
387
  'redirect' => wc_get_account_endpoint_url ( 'payment-methods' )
388
  );
@@ -569,7 +583,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
569
  * WC Stripe customer ID
570
  * @return WC_Payment_Token_Stripe|WP_Error
571
  */
572
- public function create_payment_method($id, $customer_id) {}
573
 
574
  /**
575
  *
368
  */
369
  public abstract function get_payment_method_from_charge($charge);
370
 
371
+ /**
372
+ *
373
+ * {@inheritDoc}
374
+ *
375
+ * @see WC_Payment_Gateway::add_payment_method()
376
+ */
377
  public function add_payment_method() {
378
  $customer_id = wc_stripe_get_customer_id ();
 
 
 
379
  try {
380
+ if (! is_user_logged_in ()) {
381
+ throw new Exception ( __ ( 'User must be logged in.', 'woo-stripe-payment' ) );
382
+ }
383
+ if (empty ( $customer_id )) {
384
+ $customer_id = $this->create_customer ( get_current_user_id () );
385
+ }
386
+
387
  $result = $this->create_payment_method ( $this->get_new_source_token (), $customer_id );
388
+
389
  if (is_wp_error ( $result )) {
390
  wc_add_notice ( sprintf ( __ ( 'Error saving your payment method. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ), 'error' );
391
  return array( 'result' => 'error'
394
  $result->set_user_id ( get_current_user_id () );
395
  $result->save ();
396
  WC_Payment_Tokens::set_users_default ( get_current_user_id (), $result->get_id () );
397
+
398
+ do_action ( 'wc_stripe_add_payment_method_success', $result );
399
+
400
  return array( 'result' => 'success',
401
  'redirect' => wc_get_account_endpoint_url ( 'payment-methods' )
402
  );
583
  * WC Stripe customer ID
584
  * @return WC_Payment_Token_Stripe|WP_Error
585
  */
586
+ abstract public function create_payment_method($id, $customer_id);
587
 
588
  /**
589
  *
includes/admin/settings/class-wc-stripe-api-settings.php CHANGED
@@ -93,10 +93,25 @@ class WC_Stripe_API_Settings extends WC_Stripe_Settings_API {
93
  'text' => wc_stripe ()->rest_api->webhook->rest_url ( 'webhook' ),
94
  'description' => sprintf ( __ ( '<strong>Important:</strong> the webhook url is called by Stripe when events occur in your account, like a source becomes chargeable. You must add this webhook to your Stripe Dashboard if you are using any of the local gateways. %sWebhook guide%s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' )
95
  ),
96
- 'webhook_secret' => array(
97
  'type' => 'password',
98
- 'title' => __ ( 'Webhook Secret', 'woo-stripe-payment' ),
99
- 'description' => sprintf ( __ ( 'The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %sWebhook guide%s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  ),
101
  'debug_log' => array(
102
  'title' => __ ( 'Debug Log', 'woo-stripe-payment' ),
93
  'text' => wc_stripe ()->rest_api->webhook->rest_url ( 'webhook' ),
94
  'description' => sprintf ( __ ( '<strong>Important:</strong> the webhook url is called by Stripe when events occur in your account, like a source becomes chargeable. You must add this webhook to your Stripe Dashboard if you are using any of the local gateways. %sWebhook guide%s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' )
95
  ),
96
+ 'webhook_secret_live' => array(
97
  'type' => 'password',
98
+ 'title' => __ ( 'Live Webhook Secret', 'woo-stripe-payment' ),
99
+ 'description' => sprintf ( __ ( 'The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %sWebhook guide%s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' ),
100
+ 'custom_attributes' => array(
101
+ 'data-show-if' => array(
102
+ 'mode' => 'live'
103
+ )
104
+ )
105
+ ),
106
+ 'webhook_secret_test' => array(
107
+ 'type' => 'password',
108
+ 'title' => __ ( 'Test Webhook Secret', 'woo-stripe-payment' ),
109
+ 'description' => sprintf ( __ ( 'The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %sWebhook guide%s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' ),
110
+ 'custom_attributes' => array(
111
+ 'data-show-if' => array(
112
+ 'mode' => 'test'
113
+ )
114
+ )
115
  ),
116
  'debug_log' => array(
117
  'title' => __ ( 'Debug Log', 'woo-stripe-payment' ),
includes/admin/views/html-ach-fee.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <tr valign="top">
2
+ <th scope="row" class="titledesc">
3
+ <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
4
+ </th>
5
+ <td class="forminp">
6
+ <fieldset>
7
+ <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
8
+ <div class="wc-stripe-fee-container">
9
+ <div class="wc-stripe-fee-col">
10
+ <label><?php _e('Type', 'woo-stripe-payment')?></label>
11
+ <select class="select wc-enhanced-select ach-fee" name="<?php echo esc_attr( $field_key ); ?>[type]" id="<?php echo esc_attr( $field_key ); ?>[type]" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>>
12
+ <?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?>
13
+ <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( (string) $option_key, esc_attr( $this->get_option( $key )['type'] ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
14
+ <?php endforeach; ?>
15
+ </select>
16
+ </div>
17
+ <div class="wc-stripe-fee-col">
18
+ <label><?php _e('Taxable', 'woo-stripe-payment')?></label>
19
+ <input type="checkbox" name="<?php echo esc_attr( $field_key ); ?>[taxable]" id="<?php echo esc_attr( $field_key ); ?>[taxable]" value="yes" <?php checked($this->get_option('fee')['taxable'], 'yes')?>/>
20
+ </div>
21
+ <div class="wc-stripe-fee-col">
22
+ <label><?php _e('Value', 'woo-stripe-payment')?></label>
23
+ <input class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>[value]" id="<?php echo esc_attr( $field_key ); ?>[value]" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key )['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
24
+ </div>
25
+ </div>
26
+ <?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
27
+ </fieldset>
28
+ </td>
29
+ </tr>
includes/class-stripe.php CHANGED
@@ -21,7 +21,7 @@ class WC_Stripe_Manager {
21
  *
22
  * @var string
23
  */
24
- public $version = '3.0.6';
25
 
26
  /**
27
  *
@@ -60,7 +60,7 @@ class WC_Stripe_Manager {
60
  'woocommerce_dependencies'
61
  ) );
62
  $this->includes ();
63
- //$this->version = rand(0, 12000);
64
  }
65
 
66
  /**
@@ -105,6 +105,7 @@ class WC_Stripe_Manager {
105
 
106
  public function includes() {
107
  include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-install.php';
 
108
  include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-rest-api.php';
109
 
110
  if (is_admin ()) {
21
  *
22
  * @var string
23
  */
24
+ public $version = '3.0.7';
25
 
26
  /**
27
  *
60
  'woocommerce_dependencies'
61
  ) );
62
  $this->includes ();
63
+ // $this->version = rand(0, 12000);
64
  }
65
 
66
  /**
105
 
106
  public function includes() {
107
  include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-install.php';
108
+ include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-update.php';
109
  include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-rest-api.php';
110
 
111
  if (is_admin ()) {
includes/class-wc-stripe-field-manager.php CHANGED
@@ -16,8 +16,8 @@ class WC_Stripe_Field_Manager {
16
  add_action ( 'woocommerce_after_add_to_cart_button', array(
17
  __CLASS__, 'output_product_checkout_fields'
18
  ) );
19
- add_action ( 'template_redirect', [ __CLASS__,
20
- 'template_redirect'
21
  ] );
22
  add_action ( 'woocommerce_review_order_after_order_total', [
23
  __CLASS__, 'output_checkout_fields'
@@ -36,13 +36,11 @@ class WC_Stripe_Field_Manager {
36
  ) );
37
  }
38
 
39
- public static function template_redirect() {
40
- if (is_cart ()) {
41
- self::$_cart_priority = apply_filters ( 'wc_stripe_cart_buttons_order', 30 );
42
- add_action ( 'woocommerce_proceed_to_checkout', [
43
- __CLASS__, 'output_cart_fields'
44
- ], apply_filters ( 'wc_stripe_cart_buttons_order', self::$_cart_priority ) );
45
- }
46
  }
47
 
48
  public static function output_banner_checkout_fields() {
16
  add_action ( 'woocommerce_after_add_to_cart_button', array(
17
  __CLASS__, 'output_product_checkout_fields'
18
  ) );
19
+ add_action ( 'init', [ __CLASS__,
20
+ 'init_action'
21
  ] );
22
  add_action ( 'woocommerce_review_order_after_order_total', [
23
  __CLASS__, 'output_checkout_fields'
36
  ) );
37
  }
38
 
39
+ public static function init_action() {
40
+ self::$_cart_priority = apply_filters ( 'wc_stripe_cart_buttons_order', 30 );
41
+ add_action ( 'woocommerce_proceed_to_checkout', [
42
+ __CLASS__, 'output_cart_fields'
43
+ ], apply_filters ( 'wc_stripe_cart_buttons_order', self::$_cart_priority ) );
 
 
44
  }
45
 
46
  public static function output_banner_checkout_fields() {
includes/class-wc-stripe-install.php CHANGED
@@ -9,6 +9,13 @@ class WC_Stripe_Install {
9
  add_filter ( 'plugin_action_links_' . WC_STRIPE_PLUGIN_NAME, array(
10
  __CLASS__, 'plugin_action_links'
11
  ) );
 
 
 
 
 
 
 
12
  }
13
 
14
  /**
9
  add_filter ( 'plugin_action_links_' . WC_STRIPE_PLUGIN_NAME, array(
10
  __CLASS__, 'plugin_action_links'
11
  ) );
12
+ register_activation_hook ( WC_STRIPE_PLUGIN_NAME, array(
13
+ __CLASS__, 'install'
14
+ ) );
15
+ }
16
+
17
+ public static function install() {
18
+ update_option ( 'stripe_wc_version', wc_stripe ()->version () );
19
  }
20
 
21
  /**
includes/class-wc-stripe-update.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WC_Stripe_Update {
3
+
4
+ private static $updates = [
5
+ '3.0.7' => 'update-3.0.7.php'
6
+ ];
7
+
8
+ public static function init() {
9
+ add_action ( 'init', [ __CLASS__, 'update'
10
+ ] );
11
+ }
12
+
13
+ /**
14
+ * Performs an update on the plugin if required.
15
+ */
16
+ public static function update() {
17
+ // if option is not set, make the default version 3.0.6.
18
+ $current_version = get_option ( 'stripe_wc_version', '3.0.6' );
19
+
20
+ // if database version is less than plugin version, an update might be required.
21
+ if (version_compare ( $current_version, wc_stripe ()->version (), '<' )) {
22
+ foreach ( self::$updates as $version => $path ) {
23
+ /*
24
+ * If the current version is less than the version in the loop, then perform upgrade.
25
+ */
26
+ if (version_compare ( $current_version, $version, '<' )) {
27
+ $file = wc_stripe ()->plugin_path () . 'includes/updates/' . $path;
28
+ if (file_exists ( $file )) {
29
+ include $file;
30
+ }
31
+ $current_version = $version;
32
+ update_option ( 'stripe_wc_version', $current_version );
33
+ add_action ( 'admin_notices', function () use ($current_version) {
34
+ $message = sprintf ( __ ( 'Thank you for updating Stripe for WooCommerce to version %1$s.', 'woo-stripe-payment' ), $current_version );
35
+ if (( $text = self::get_messages ( $current_version ) )) {
36
+ $message .= ' ' . $text;
37
+ }
38
+ printf ( '<div class="notice notice-success is-dismissible"><p>%1$s</p></div>', $message );
39
+ } );
40
+ }
41
+ }
42
+ // save latest version.
43
+ update_option ( 'stripe_wc_version', wc_stripe ()->version () );
44
+ }
45
+ }
46
+
47
+ public static function get_messages($version) {
48
+ $messages = [];
49
+ return isset ( $messages[ $version ] ) ? $messages[ $version ] : false;
50
+ }
51
+ }
52
+ WC_Stripe_Update::init ();
includes/controllers/class-wc-stripe-controller-gateway-settings.php CHANGED
@@ -56,23 +56,36 @@ class WC_Stripe_Controller_Gateway_Settings extends WC_Stripe_Rest_Controller {
56
  }
57
  }
58
  $server_name = $_SERVER[ 'SERVER_NAME' ];
 
 
 
 
 
 
 
59
  try {
60
- $api_key = wc_stripe_get_secret_key ( 'live' );
61
- if (empty ( $api_key )) {
62
- throw new Exception ( __ ( 'You cannot register your domain until you have configured your Live API keys.', 'woo-stripe-payment' ) );
63
- }
64
- $result = $gateway->register_domain ( $server_name, 'live' );
65
- if (is_wp_error ( $result )) {
66
- throw new Exception ( $result->get_error_message () );
 
 
 
 
 
 
67
  }
68
- return rest_ensure_response ( [
69
- 'message' => sprintf ( __ ( 'Domain %s registered successfully. You can confirm in your Stripe Dashboard at https://dashboard.stripe.com/account/apple_pay.', 'woo-stripe-payment' ), $server_name )
70
- ] );
71
  } catch ( Exception $e ) {
72
  return new WP_Error ( 'domain-error', $e->getMessage (), [
73
  'status' => 200
74
  ] );
75
  }
 
 
 
76
  }
77
 
78
  /**
@@ -83,9 +96,10 @@ class WC_Stripe_Controller_Gateway_Settings extends WC_Stripe_Rest_Controller {
83
  public function create_webhook($request) {
84
  $url = wc_stripe ()->rest_api->webhook->rest_url ( 'webhook' );
85
  $api_settings = wc_stripe ()->api_settings;
86
- $gateway = new WC_Stripe_Gateway ( $api_settings->get_option ( 'mode' ) );
 
87
  // first fetch all webhooks
88
- $private_key = wc_stripe_get_secret_key ( $api_settings->get_option ( 'mode' ) );
89
  if (empty ( $private_key )) {
90
  return new WP_Error ( 'webhook-error', __ ( 'You must configure your secret key before creating webhooks.', 'woo-stripe-payment' ), [
91
  'status' => 200
@@ -113,12 +127,12 @@ class WC_Stripe_Controller_Gateway_Settings extends WC_Stripe_Rest_Controller {
113
  'status' => 200
114
  ] );
115
  } else {
116
- $api_settings->update_option ( 'webhook_url', $webhook[ 'url' ] );
117
- $api_settings->update_option ( 'webhook_secret', $webhook[ 'secret' ] );
118
- $api_settings->update_option ( 'webhook_id', $webhook[ 'id' ] );
119
  return rest_ensure_response ( [
120
- 'message' => __ ( 'Webhook created in Stripe. You can test your webhook by logging in to the Stripe dashboard', 'woo-stripe-payment' ),
121
- 'secret' => $api_settings->get_option ( 'webhook_secret' )
122
  ] );
123
  }
124
  }
56
  }
57
  }
58
  $server_name = $_SERVER[ 'SERVER_NAME' ];
59
+ if (strstr ( $server_name, 'www.' )) {
60
+ $server_name_2 = str_replace ( 'www.', '', $server_name );
61
+ } else {
62
+ $server_name_2 = 'www.' . $server_name;
63
+ }
64
+ $domains = [ $server_name, $server_name_2
65
+ ];
66
  try {
67
+ $failures = 0;
68
+ foreach ( $domains as $domain ) {
69
+ $api_key = wc_stripe_get_secret_key ( 'live' );
70
+ if (empty ( $api_key )) {
71
+ throw new Exception ( __ ( 'You cannot register your domain until you have configured your Live API keys.', 'woo-stripe-payment' ) );
72
+ }
73
+ $result = $gateway->register_domain ( $domain, 'live' );
74
+ if (is_wp_error ( $result )) {
75
+ $failures ++;
76
+ if ($failures > 1) {
77
+ throw new Exception ( $result->get_error_message () );
78
+ }
79
+ }
80
  }
 
 
 
81
  } catch ( Exception $e ) {
82
  return new WP_Error ( 'domain-error', $e->getMessage (), [
83
  'status' => 200
84
  ] );
85
  }
86
+ return rest_ensure_response ( [
87
+ 'message' => sprintf ( __ ( 'Domain registered successfully. You can confirm in your Stripe Dashboard at https://dashboard.stripe.com/account/apple_pay.', 'woo-stripe-payment' ) )
88
+ ] );
89
  }
90
 
91
  /**
96
  public function create_webhook($request) {
97
  $url = wc_stripe ()->rest_api->webhook->rest_url ( 'webhook' );
98
  $api_settings = wc_stripe ()->api_settings;
99
+ $env = $request->get_param ( 'environment' );
100
+ $gateway = new WC_Stripe_Gateway ( $env );
101
  // first fetch all webhooks
102
+ $private_key = wc_stripe_get_secret_key ( $env );
103
  if (empty ( $private_key )) {
104
  return new WP_Error ( 'webhook-error', __ ( 'You must configure your secret key before creating webhooks.', 'woo-stripe-payment' ), [
105
  'status' => 200
127
  'status' => 200
128
  ] );
129
  } else {
130
+ $api_settings->update_option ( "webhook_url_{$env}", $webhook[ 'url' ] );
131
+ $api_settings->update_option ( "webhook_secret_{$env}", $webhook[ 'secret' ] );
132
+ $api_settings->update_option ( "webhook_id_{$env}", $webhook[ 'id' ] );
133
  return rest_ensure_response ( [
134
+ 'message' => sprintf ( __ ( 'Webhook created in Stripe for %s environment. You can test your webhook by logging in to the Stripe dashboard', 'woo-stripe-payment' ), 'live' == $env ? __ ( 'Live', 'woo-stripe-payment' ) : __ ( 'Test', 'woo-stripe-payment' ) ),
135
+ 'secret' => $webhook[ 'secret' ]
136
  ] );
137
  }
138
  }
includes/controllers/class-wc-stripe-controller-webhook.php CHANGED
@@ -25,11 +25,13 @@ class WC_Stripe_Controller_Webhook extends WC_Stripe_Rest_Controller {
25
  */
26
  public function webhook($request) {
27
  $payload = $request->get_body ();
28
- $this->secret = wc_stripe ()->api_settings->get_option ( 'webhook_secret' );
 
 
29
  $header = isset ( $_SERVER[ 'HTTP_STRIPE_SIGNATURE' ] ) ? $_SERVER[ 'HTTP_STRIPE_SIGNATURE' ] : '';
30
  try {
31
  $event = \Stripe\Webhook::constructEvent ( $payload, $header, $this->secret );
32
- //$event = \Stripe\StripeObject::constructFrom(json_decode($payload, true));
33
  wc_stripe_log_info ( sprintf ( 'Webhook notficiation received: Event: %s. Payload: %s', $event->type, print_r ( $payload, true ) ) );
34
  $type = $event->type;
35
  $type = str_replace ( '.', '_', $type );
@@ -39,8 +41,8 @@ class WC_Stripe_Controller_Webhook extends WC_Stripe_Rest_Controller {
39
 
40
  return rest_ensure_response ( apply_filters ( 'wc_stripe_webhook_response', [], $event, $request ) );
41
  } catch ( \Stripe\Error\SignatureVerification $e ) {
42
- wc_stripe_log_info ( __ ( 'Invalid signaute received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
43
- return $this->send_error_response ( __ ( 'Invalid signaute received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
44
  } catch ( Exception $e ) {
45
  return $this->send_error_response ( $e->getMessage () );
46
  }
25
  */
26
  public function webhook($request) {
27
  $payload = $request->get_body ();
28
+ $json_payload = json_decode ( $payload, true );
29
+ $environment = $json_payload[ 'livemode' ] == true ? 'live' : 'test';
30
+ $this->secret = wc_stripe ()->api_settings->get_option ( 'webhook_secret_' . $environment );
31
  $header = isset ( $_SERVER[ 'HTTP_STRIPE_SIGNATURE' ] ) ? $_SERVER[ 'HTTP_STRIPE_SIGNATURE' ] : '';
32
  try {
33
  $event = \Stripe\Webhook::constructEvent ( $payload, $header, $this->secret );
34
+ // $event = \Stripe\StripeObject::constructFrom(json_decode($payload, true));
35
  wc_stripe_log_info ( sprintf ( 'Webhook notficiation received: Event: %s. Payload: %s', $event->type, print_r ( $payload, true ) ) );
36
  $type = $event->type;
37
  $type = str_replace ( '.', '_', $type );
41
 
42
  return rest_ensure_response ( apply_filters ( 'wc_stripe_webhook_response', [], $event, $request ) );
43
  } catch ( \Stripe\Error\SignatureVerification $e ) {
44
+ wc_stripe_log_info ( __ ( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
45
+ return $this->send_error_response ( __ ( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
46
  } catch ( Exception $e ) {
47
  return $this->send_error_response ( $e->getMessage () );
48
  }
includes/gateways/class-wc-payment-gateway-stripe-ach.php CHANGED
@@ -29,6 +29,12 @@ class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe_Charge {
29
  $this->settings[ 'charge_type' ] = 'capture';
30
  }
31
 
 
 
 
 
 
 
32
  /**
33
  *
34
  * {@inheritDoc}
@@ -75,7 +81,8 @@ class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe_Charge {
75
  'env' => $this->get_plaid_environment (),
76
  'client_name' => $this->get_option ( 'client_name' ),
77
  'public_key' => $this->get_option ( 'public_key' ),
78
- 'metadata_key' => '[name="' . $this->metadata_key . '"]'
 
79
  ) );
80
  }
81
 
@@ -185,4 +192,88 @@ class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe_Charge {
185
  public function get_new_method_label() {
186
  return __ ( 'New Bank', 'woo-stripe-payment' );
187
  }
188
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  $this->settings[ 'charge_type' ] = 'capture';
30
  }
31
 
32
+ public static function init() {
33
+ add_action ( 'woocommerce_checkout_update_order_review', [
34
+ __CLASS__, 'update_order_review'
35
+ ] );
36
+ }
37
+
38
  /**
39
  *
40
  * {@inheritDoc}
81
  'env' => $this->get_plaid_environment (),
82
  'client_name' => $this->get_option ( 'client_name' ),
83
  'public_key' => $this->get_option ( 'public_key' ),
84
+ 'metadata_key' => '[name="' . $this->metadata_key . '"]',
85
+ 'fees_enabled' => $this->fees_enabled ()
86
  ) );
87
  }
88
 
192
  public function get_new_method_label() {
193
  return __ ( 'New Bank', 'woo-stripe-payment' );
194
  }
195
+
196
+ public function generate_ach_fee_html($key, $data) {
197
+ $field_key = $this->get_field_key ( $key );
198
+ $defaults = array( 'title' => '',
199
+ 'disabled' => false, 'class' => '',
200
+ 'css' => 'max-width: 150px; min-width: 150px;',
201
+ 'placeholder' => '', 'type' => 'text',
202
+ 'desc_tip' => false, 'description' => '',
203
+ 'custom_attributes' => array(),
204
+ 'options' => array()
205
+ );
206
+ $data = wp_parse_args ( $data, $defaults );
207
+ ob_start ();
208
+ include wc_stripe ()->plugin_path () . 'includes/admin/views/html-ach-fee.php';
209
+ return ob_get_clean ();
210
+ }
211
+
212
+ public function validate_ach_fee_field($key, $value) {
213
+ $value = empty ( $value ) ? [ 'type' => 'none',
214
+ 'taxable' => 'no', 'value' => '0'
215
+ ] : $value;
216
+ if (! isset ( $value[ 'taxable' ] )) {
217
+ $value[ 'taxable' ] = 'no';
218
+ }
219
+ return $value;
220
+ }
221
+
222
+ public function fees_enabled() {
223
+ $fee = $this->get_option ( 'fee', [
224
+ 'type' => 'none', 'value' => '0'
225
+ ] );
226
+ return ! empty ( $fee ) && $fee[ 'type' ] != 'none';
227
+ }
228
+
229
+ /**
230
+ *
231
+ * @param WC_Cart $cart
232
+ */
233
+ public function after_calculate_totals($cart) {
234
+ remove_action ( 'woocommerce_after_calculate_totals', [
235
+ $this, 'after_calculate_totals'
236
+ ] );
237
+
238
+ add_action ( 'woocommerce_cart_calculate_fees', array(
239
+ $this, 'calculate_fees'
240
+ ) );
241
+
242
+ WC ()->session->set ( 'wc_stripe_cart_total', $cart->total );
243
+ $cart->calculate_totals ();
244
+ }
245
+
246
+ /**
247
+ *
248
+ * @param WC_Cart $cart
249
+ */
250
+ public function calculate_fees($cart) {
251
+ remove_action ( 'woocommerce_cart_calculate_fees', array(
252
+ $this, 'calculate_fees'
253
+ ) );
254
+ $fee = $this->get_option ( 'fee' );
255
+ $taxable = $fee[ 'taxable' ] == 'yes';
256
+ switch ($fee[ 'type' ]) {
257
+ case 'amount' :
258
+ $cart->add_fee ( __ ( 'ACH Fee' ), $fee[ 'value' ], $taxable );
259
+ break;
260
+ case 'percent' :
261
+ $cart->add_fee ( __ ( 'ACH Fee' ), $fee[ 'value' ] * WC ()->session->get ( 'wc_stripe_cart_total', 0 ), $taxable );
262
+ break;
263
+ }
264
+ unset ( WC ()->session->wc_stripe_cart_total );
265
+ }
266
+
267
+ public static function update_order_review() {
268
+ if (! empty ( $_POST[ 'payment_method' ] ) && $_POST[ 'payment_method' ] == 'stripe_ach') {
269
+ $payment_method = new WC_Payment_Gateway_Stripe_ACH ();
270
+ if ($payment_method->fees_enabled ()) {
271
+ add_action ( 'woocommerce_after_calculate_totals', [
272
+ $payment_method,
273
+ 'after_calculate_totals'
274
+ ] );
275
+ }
276
+ }
277
+ }
278
+ }
279
+ WC_Payment_Gateway_Stripe_ACH::init ();
includes/gateways/settings/ach-settings.php CHANGED
@@ -74,5 +74,19 @@ return array(
74
  'value' => '', 'default' => 'type_ending_in',
75
  'desc_tip' => true,
76
  'description' => __ ( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  )
78
  );
74
  'value' => '', 'default' => 'type_ending_in',
75
  'desc_tip' => true,
76
  'description' => __ ( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' )
77
+ ),
78
+ 'fee' => array(
79
+ 'title' => __ ( 'ACH Fee', 'woo-stripe-payment' ),
80
+ 'type' => 'ach_fee', 'class' => '',
81
+ 'value' => '',
82
+ 'default' => [ 'type' => 'none',
83
+ 'taxable' => 'no', 'value' => '0'
84
+ ],
85
+ 'options' => [
86
+ 'none' => __ ( 'None', 'woo-stripe-payment' ),
87
+ 'amount' => __ ( 'Amount', 'woo-stripe-payment' ),
88
+ 'percent' => __ ( 'Percentage', 'woo-stripe-payment' )
89
+ ], 'desc_tip' => true,
90
+ 'description' => __ ( 'You can assign a fee to the order for ACH payments. Amount is a static amount and percentage is a percentage of the cart amount.', 'woo-stripe-payment' )
91
  )
92
  );
includes/updates/update-3.0.7.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use Stripe\Webhook;
3
+ use Stripe\WebhookEndpoint;
4
+ use Stripe\ApiOperations\Delete;
5
+
6
+ /**
7
+ * This update reconfigured the webhooks for each environment.
8
+ */
9
+ $environments = [ 'live', 'test'
10
+ ];
11
+ $api_settings = wc_stripe ()->api_settings;
12
+ $url = wc_stripe ()->rest_api->webhook->rest_url ( 'webhook' );
13
+
14
+ foreach ( $environments as $env ) {
15
+ $gateway = new WC_Stripe_Gateway ();
16
+ $webhooks = $gateway->webhooks ( $env );
17
+
18
+ if (! is_wp_error ( $webhooks )) {
19
+ // first delete the webhook if it matches the wp-json webhook. Then re-create it.
20
+ foreach ( $webhooks->data as $webhook ) {
21
+ /**
22
+ *
23
+ * @var Stripe\WebhookEndpoint $webhook
24
+ */
25
+ if ($webhook[ 'url' ] == $url) {
26
+ $webhook->delete ();
27
+ }
28
+ }
29
+ }
30
+ // now that endpoint is deleted, re-create it and store details.
31
+ $webhook = $gateway->create_webhook ( $url, [
32
+ 'charge.failed', 'charge.succeeded',
33
+ 'source.chargeable'
34
+ ], $env );
35
+ if (! is_wp_error ( $webhook )) {
36
+ $api_settings->update_option ( "webhook_url_{$env}", $webhook[ 'url' ] );
37
+ $api_settings->update_option ( "webhook_secret_{$env}", $webhook[ 'secret' ] );
38
+ $api_settings->update_option ( "webhook_id_{$env}", $webhook[ 'id' ] );
39
+ }
40
+ }
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.6
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -53,6 +53,12 @@ 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.6 =
57
  * Added - ACH subscription support
58
  * Updated - Top of checkout styling
4
  Requires at least: 3.0.1
5
  Tested up to: 5.3
6
  Requires PHP: 5.4
7
+ Stable tag: 3.0.7
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.7 =
57
+ * Added - WPML support for gateway titles and descriptions
58
+ * Added - ACH fee option
59
+ * Added - Webhook registration option in Admin
60
+ * Updated - Cart one click checkout buttons
61
+ * Updated - WC 3.9
62
  = 3.0.6 =
63
  * Added - ACH subscription support
64
  * Updated - Top of checkout styling
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, ACH, Klarna and more using Stripe.
7
- * Version: 3.0.6
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
11
  * Tested up to: 5.3
12
  * WC requires at least: 3.0.0
13
- * WC tested up to: 3.8.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, ACH, Klarna and more using Stripe.
7
+ * Version: 3.0.7
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
11
  * Tested up to: 5.3
12
  * WC requires at least: 3.0.0
13
+ * WC tested up to: 3.9
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 );
wpml-config.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wpml-config>
3
+ <admin-texts>
4
+ <key name="woocommerce_stripe_cc_settings">
5
+ <key name="title_text" />
6
+ <key name="description" />
7
+ </key>
8
+ <key name="woocommerce_stripe_googlepay_settings">
9
+ <key name="title_text" />
10
+ <key name="description" />
11
+ </key>
12
+ <key name="woocommerce_stripe_applepay_settings">
13
+ <key name="title_text" />
14
+ <key name="description" />
15
+ </key>
16
+ <key name="woocommerce_stripe_payment_request_settings">
17
+ <key name="title_text" />
18
+ <key name="description" />
19
+ </key>
20
+ <key name="woocommerce_stripe_ach_settings">
21
+ <key name="title_text" />
22
+ <key name="description" />
23
+ </key>
24
+ <key name="woocommerce_stripe_bancontact_settings">
25
+ <key name="title_text" />
26
+ <key name="description" />
27
+ </key>
28
+ <key name="woocommerce_stripe_eps_settings">
29
+ <key name="title_text" />
30
+ <key name="description" />
31
+ </key>
32
+ <key name="woocommerce_stripe_giropay_settings">
33
+ <key name="title_text" />
34
+ <key name="description" />
35
+ </key>
36
+ <key name="woocommerce_stripe_ideal_settings">
37
+ <key name="title_text" />
38
+ <key name="description" />
39
+ </key>
40
+ <key name="woocommerce_stripe_klarna_settings">
41
+ <key name="title_text" />
42
+ <key name="description" />
43
+ </key>
44
+ <key name="woocommerce_stripe_multibanco_settings">
45
+ <key name="title_text" />
46
+ <key name="description" />
47
+ </key>
48
+ <key name="woocommerce_stripe_p24_settings">
49
+ <key name="title_text" />
50
+ <key name="description" />
51
+ </key>
52
+ <key name="woocommerce_stripe_sepa_settings">
53
+ <key name="title_text" />
54
+ <key name="description" />
55
+ </key>
56
+ <key name="woocommerce_stripe_sofort_settings">
57
+ <key name="title_text" />
58
+ <key name="description" />
59
+ </key>
60
+ <key name="woocommerce_stripe_wechat_settings">
61
+ <key name="title_text" />
62
+ <key name="description" />
63
+ </key>
64
+ </admin-texts>
65
+ </wpml-config>