WooCommerce Stripe Payment Gateway - Version 3.1.4

Version Description

  • Tweak - If Apple Pay is not enabled, prevent Apple Pay Init.
  • Fix - Update for WooCommerce 3.0 compatibility.
  • Fix - Apple Pay on product detail page causes qty issue when using normal add to cart.
  • Fix - A partial workaround for UK/CA postal codes issue for shipping methods that support partial postal code estimates.
  • Fix - Stripe checkout did not validate properly formatted email address.
  • Fix - Error messages were not able to translate when validating checkout form.
  • Fix - Prevent payment gateway title logic ( Apple Pay ) from hijacking other payment methods.
  • Remove - Stripe Checkout allow remember me setting as it is redundant to saved card setting.
Download this release

Release Info

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

Code changes from version 3.1.3 to 3.1.4

DEVELOPER.md DELETED
@@ -1,46 +0,0 @@
1
- # DEVELOPER.md
2
-
3
- ## Testing
4
-
5
- * In wp-admin > WooCommerce > Settings > Checkout > Stripe, Enable Stripe, Enable Test Mode, Enable Stripe Checkout and Enable Payment via Saved Cards
6
- * In wp-admin > WooCommerce > Settings > Checkout > Stripe, enter a Test Secret Key and a Test Publishable Key
7
- * Enable at least one other payment gateway (e.g. Cheques)
8
-
9
- * On the front side, place an item in your cart and proceed to Checkout
10
- * Fill in all required fields in the Billing Details area
11
- * Select Credit Card (Stripe) and "Use a new credit card"
12
- * Click on Continue to payment
13
- * Verify you get the stripe modal requesting card number, expiration and CVC
14
- * Enter 4242 4242 4242 4242, 12/17, 123
15
- * Leave Remember Me unchecked
16
- * Click Confirm and Pay
17
- * Verify the modal closes, the page dims for a bit, and then you are redirected to Order Received
18
-
19
- * Repeat the above steps, but this time instead of "Use a new credit card" use a stored card
20
- * Click on Continue to payment
21
- * Verify the page dims for a bit and then you are redirected to Order Received
22
-
23
- * Repeat the above steps, but this time clear the Billing Details (e.g. Name, etc)
24
- * Choose a stored card in Stripe
25
- * Click on Continue to payment
26
- * Verify you get prompted to fill in required fields.
27
- * Fill in the required fields
28
- * Click on Continue to payment
29
- * Verify the page dims for a bit and then you are redirected to Order Received
30
-
31
- * Repeat the above steps, but this time choose the "Cheque Payment" gateway
32
- * Click on Place Order
33
- * Verify the page dims for a bit and then you are redirected to Order Received
34
-
35
- * Repeat at least the "Use a new credit card" case on Chrome on an iPhone or iPad
36
-
37
- * In wp-admin > WooCommerce > Settings > Checkout > Stripe, uncheck Enable Payment via Saved Cards
38
- * On the front side, place an item in your cart and proceed to Checkout
39
- * Fill in all required fields in the Billing Details area
40
- * Select Credit Card (Stripe)
41
- * Click on Continue to payment
42
- * Verify you get the stripe modal requesting card number, expiration and CVC
43
- * Enter 4242 4242 4242 4242, 12/17, 123
44
- * Leave Remember Me unchecked
45
- * Click Confirm and Pay
46
- * Verify the modal closes, the page dims for a bit, and then you are redirected to Order Received
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/stripe-admin.js CHANGED
@@ -45,10 +45,10 @@ jQuery( function( $ ) {
45
  // Toggle Stripe Checkout settings.
46
  $( '#woocommerce_stripe_stripe_checkout' ).change( function() {
47
  if ( $( this ).is( ':checked' ) ) {
48
- $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image, #woocommerce_stripe_allow_remember_me' ).closest( 'tr' ).show();
49
  $( '#woocommerce_stripe_request_payment_api' ).closest( 'tr' ).hide();
50
  } else {
51
- $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image, #woocommerce_stripe_allow_remember_me' ).closest( 'tr' ).hide();
52
  $( '#woocommerce_stripe_request_payment_api' ).closest( 'tr' ).show();
53
  }
54
  }).change();
45
  // Toggle Stripe Checkout settings.
46
  $( '#woocommerce_stripe_stripe_checkout' ).change( function() {
47
  if ( $( this ).is( ':checked' ) ) {
48
+ $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image' ).closest( 'tr' ).show();
49
  $( '#woocommerce_stripe_request_payment_api' ).closest( 'tr' ).hide();
50
  } else {
51
+ $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image' ).closest( 'tr' ).hide();
52
  $( '#woocommerce_stripe_request_payment_api' ).closest( 'tr' ).show();
53
  }
54
  }).change();
assets/js/stripe-admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(a){"use strict";var b={isTestMode:function(){return a("#woocommerce_stripe_testmode").is(":checked")},getSecretKey:function(){return b.isTestMode()?a("#woocommerce_stripe_test_secret_key").val():a("#woocommerce_stripe_secret_key").val()},init:function(){a(document.body).on("change","#woocommerce_stripe_testmode",function(){var b=a("#woocommerce_stripe_test_secret_key").parents("tr").eq(0),c=a("#woocommerce_stripe_test_publishable_key").parents("tr").eq(0),d=a("#woocommerce_stripe_secret_key").parents("tr").eq(0),e=a("#woocommerce_stripe_publishable_key").parents("tr").eq(0);a(this).is(":checked")?(b.show(),c.show(),d.hide(),e.hide()):(b.hide(),c.hide(),d.show(),e.show())}),a("#woocommerce_stripe_testmode").change(),a("#woocommerce_stripe_stripe_checkout").change(function(){a(this).is(":checked")?(a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image, #woocommerce_stripe_allow_remember_me").closest("tr").show(),a("#woocommerce_stripe_request_payment_api").closest("tr").hide()):(a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image, #woocommerce_stripe_allow_remember_me").closest("tr").hide(),a("#woocommerce_stripe_request_payment_api").closest("tr").show())}).change(),a("#woocommerce_stripe_apple_pay").change(function(){a(this).is(":checked")?a("#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang").closest("tr").show():a("#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang").closest("tr").hide()}).change(),a("#woocommerce_stripe_secret_key, #woocommerce_stripe_publishable_key").on("input",function(){var b=a(this).val();b.indexOf("_test_")>=0?a(this).css("border-color","red").after('<span class="description stripe-error-description" style="color:red; display:block;">'+wc_stripe_admin_params.localized_messages.not_valid_live_key_msg+"</span>"):(a(this).css("border-color",""),a(".stripe-error-description",a(this).parent()).remove())}).trigger("input"),a("#woocommerce_stripe_test_secret_key, #woocommerce_stripe_test_publishable_key").on("input",function(){var b=a(this).val();b.indexOf("_live_")>=0?a(this).css("border-color","red").after('<span class="description stripe-error-description" style="color:red; display:block;">'+wc_stripe_admin_params.localized_messages.not_valid_test_key_msg+"</span>"):(a(this).css("border-color",""),a(".stripe-error-description",a(this).parent()).remove())}).trigger("input")}};b.init()});
1
+ jQuery(function(a){"use strict";var b={isTestMode:function(){return a("#woocommerce_stripe_testmode").is(":checked")},getSecretKey:function(){return b.isTestMode()?a("#woocommerce_stripe_test_secret_key").val():a("#woocommerce_stripe_secret_key").val()},init:function(){a(document.body).on("change","#woocommerce_stripe_testmode",function(){var b=a("#woocommerce_stripe_test_secret_key").parents("tr").eq(0),c=a("#woocommerce_stripe_test_publishable_key").parents("tr").eq(0),d=a("#woocommerce_stripe_secret_key").parents("tr").eq(0),e=a("#woocommerce_stripe_publishable_key").parents("tr").eq(0);a(this).is(":checked")?(b.show(),c.show(),d.hide(),e.hide()):(b.hide(),c.hide(),d.show(),e.show())}),a("#woocommerce_stripe_testmode").change(),a("#woocommerce_stripe_stripe_checkout").change(function(){a(this).is(":checked")?(a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image").closest("tr").show(),a("#woocommerce_stripe_request_payment_api").closest("tr").hide()):(a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image").closest("tr").hide(),a("#woocommerce_stripe_request_payment_api").closest("tr").show())}).change(),a("#woocommerce_stripe_apple_pay").change(function(){a(this).is(":checked")?a("#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang").closest("tr").show():a("#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang").closest("tr").hide()}).change(),a("#woocommerce_stripe_secret_key, #woocommerce_stripe_publishable_key").on("input",function(){var b=a(this).val();b.indexOf("_test_")>=0?a(this).css("border-color","red").after('<span class="description stripe-error-description" style="color:red; display:block;">'+wc_stripe_admin_params.localized_messages.not_valid_live_key_msg+"</span>"):(a(this).css("border-color",""),a(".stripe-error-description",a(this).parent()).remove())}).trigger("input"),a("#woocommerce_stripe_test_secret_key, #woocommerce_stripe_test_publishable_key").on("input",function(){var b=a(this).val();b.indexOf("_live_")>=0?a(this).css("border-color","red").after('<span class="description stripe-error-description" style="color:red; display:block;">'+wc_stripe_admin_params.localized_messages.not_valid_test_key_msg+"</span>"):(a(this).css("border-color",""),a(".stripe-error-description",a(this).parent()).remove())}).trigger("input")}};b.init()});
assets/js/stripe-apple-pay-single.js CHANGED
@@ -26,16 +26,6 @@ jQuery( function( $ ) {
26
  init: function() {
27
  Stripe.applePay.checkAvailability( function( available ) {
28
  if ( available ) {
29
- $( document.body ).on( 'woocommerce_variation_has_changed', function() {
30
- wc_stripe_apple_pay_single.generate_cart();
31
- })
32
-
33
- .on( 'change', '.quantity .qty', function() {
34
- wc_stripe_apple_pay_single.generate_cart();
35
- });
36
-
37
- wc_stripe_apple_pay_single.generate_cart();
38
-
39
  $( '.apple-pay-button' ).show();
40
  }
41
  });
@@ -61,9 +51,14 @@ jQuery( function( $ ) {
61
  currencyCode: wc_stripe_apple_pay_single_params.currency_code,
62
  total: {
63
  label: wc_stripe_apple_pay_single_params.label,
64
- amount: wc_stripe_apple_pay_single_params.total
 
 
 
 
 
 
65
  },
66
- lineItems: wc_stripe_apple_pay_single_params.line_items,
67
  requiredBillingContactFields: ['postalAddress'],
68
  requiredShippingContactFields: 'yes' === wc_stripe_apple_pay_single_params.needs_shipping ? ['postalAddress', 'phone', 'email', 'name'] : ['phone', 'email', 'name']
69
  };
@@ -94,39 +89,57 @@ jQuery( function( $ ) {
94
  }
95
  }
96
  });
 
 
 
 
 
 
 
 
 
 
 
97
  });
98
 
99
  // If shipping is needed -- get shipping methods.
100
  if ( 'yes' === wc_stripe_apple_pay_single_params.needs_shipping ) {
101
  // After the shipping contact/address has been selected
102
  applePaySession.onshippingcontactselected = function( shipping ) {
103
- var data = {
104
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_get_shipping_methods_nonce,
105
- 'address': shipping.shippingContact
106
- };
107
-
108
- $.ajax({
109
- type: 'POST',
110
- data: data,
111
- url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay_get_shipping_methods' ),
112
- success: function( response ) {
113
- var total = {
114
- 'label': wc_stripe_apple_pay_single_params.label,
115
- 'amount': response.total
116
- };
117
-
118
- if ( 'true' === response.success ) {
119
- applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_SUCCESS, response.shipping_methods, total, response.line_items );
120
- }
121
-
122
- if ( 'false' === response.success ) {
123
- applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, response.shipping_methods, total, response.line_items );
 
 
 
 
 
 
 
124
  }
125
- }
126
  });
127
  };
128
 
129
- // After the shipping method has been selected
130
  applePaySession.onshippingmethodselected = function( event ) {
131
  var data = {
132
  'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_update_shipping_method_nonce,
@@ -155,6 +168,24 @@ jQuery( function( $ ) {
155
  };
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  applePaySession.begin();
159
  });
160
  },
@@ -200,6 +231,19 @@ jQuery( function( $ ) {
200
  wc_stripe_apple_pay_single_params.line_items = response.line_items;
201
  }
202
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
  };
205
 
26
  init: function() {
27
  Stripe.applePay.checkAvailability( function( available ) {
28
  if ( available ) {
 
 
 
 
 
 
 
 
 
 
29
  $( '.apple-pay-button' ).show();
30
  }
31
  });
51
  currencyCode: wc_stripe_apple_pay_single_params.currency_code,
52
  total: {
53
  label: wc_stripe_apple_pay_single_params.label,
54
+ amount: 1,
55
+ type: 'pending'
56
+ },
57
+ lineItems: {
58
+ label: wc_stripe_apple_pay_single_params.i18n.sub_total,
59
+ amount: 1,
60
+ type: 'pending'
61
  },
 
62
  requiredBillingContactFields: ['postalAddress'],
63
  requiredShippingContactFields: 'yes' === wc_stripe_apple_pay_single_params.needs_shipping ? ['postalAddress', 'phone', 'email', 'name'] : ['phone', 'email', 'name']
64
  };
89
  }
90
  }
91
  });
92
+ }, function( error ) {
93
+ var data = {
94
+ 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,
95
+ 'errors': error.message
96
+ };
97
+
98
+ $.ajax({
99
+ type: 'POST',
100
+ data: data,
101
+ url: wc_stripe_apple_pay_single.getAjaxURL( 'log_apple_pay_errors' )
102
+ });
103
  });
104
 
105
  // If shipping is needed -- get shipping methods.
106
  if ( 'yes' === wc_stripe_apple_pay_single_params.needs_shipping ) {
107
  // After the shipping contact/address has been selected
108
  applePaySession.onshippingcontactselected = function( shipping ) {
109
+ $.when( wc_stripe_apple_pay_single.generate_cart() ).then( function() {
110
+ var data = {
111
+ 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_get_shipping_methods_nonce,
112
+ 'address': shipping.shippingContact
113
+ };
114
+
115
+ $.ajax({
116
+ type: 'POST',
117
+ data: data,
118
+ url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay_get_shipping_methods' ),
119
+ success: function( response ) {
120
+ var total = {
121
+ 'label': wc_stripe_apple_pay_single_params.label,
122
+ 'amount': response.total
123
+ };
124
+
125
+ if ( response.total <= 0 ) {
126
+ total.amount = 1;
127
+ total.type = 'pending';
128
+ }
129
+
130
+ if ( 'true' === response.success ) {
131
+ applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_SUCCESS, response.shipping_methods, total, response.line_items );
132
+ }
133
+
134
+ if ( 'false' === response.success ) {
135
+ applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, response.shipping_methods, total, response.line_items );
136
+ }
137
  }
138
+ });
139
  });
140
  };
141
 
142
+ // After the shipping method has been selected.
143
  applePaySession.onshippingmethodselected = function( event ) {
144
  var data = {
145
  'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_update_shipping_method_nonce,
168
  };
169
  }
170
 
171
+ // When payment is selected, we need to fetch cart.
172
+ applePaySession.onpaymentmethodselected = function( event ) {
173
+ $.when( wc_stripe_apple_pay_single.generate_cart() ).then( function() {
174
+
175
+ var total = {
176
+ label: wc_stripe_apple_pay_single_params.label,
177
+ amount: wc_stripe_apple_pay_single_params.total
178
+ },
179
+ lineItems = wc_stripe_apple_pay_single_params.line_items;
180
+
181
+ applePaySession.completePaymentMethodSelection( total, lineItems );
182
+ });
183
+ };
184
+
185
+ applePaySession.oncancel = function( event ) {
186
+ wc_stripe_apple_pay_single.clear_cart();
187
+ };
188
+
189
  applePaySession.begin();
190
  });
191
  },
231
  wc_stripe_apple_pay_single_params.line_items = response.line_items;
232
  }
233
  });
234
+ },
235
+
236
+ clear_cart: function() {
237
+ var data = {
238
+ 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce
239
+ };
240
+
241
+ return $.ajax({
242
+ type: 'POST',
243
+ data: data,
244
+ url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay_clear_cart' ),
245
+ success: function( response ) {}
246
+ });
247
  }
248
  };
249
 
assets/js/stripe-apple-pay-single.min.js CHANGED
@@ -1 +1 @@
1
- Stripe.setPublishableKey(wc_stripe_apple_pay_single_params.key),jQuery(function(a){"use strict";var b={getAjaxURL:function(a){return wc_stripe_apple_pay_single_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+a)},init:function(){Stripe.applePay.checkAvailability(function(c){c&&(a(document.body).on("woocommerce_variation_has_changed",function(){b.generate_cart()}).on("change",".quantity .qty",function(){b.generate_cart()}),b.generate_cart(),a(".apple-pay-button").show())}),a(document.body).on("click",".apple-pay-button",function(c){c.preventDefault();var d=a(".single_add_to_cart_button");if(d.is(".disabled"))return void(d.is(".wc-variation-is-unavailable")?window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):d.is(".wc-variation-selection-needed")&&window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text));var e={countryCode:wc_stripe_apple_pay_single_params.country_code,currencyCode:wc_stripe_apple_pay_single_params.currency_code,total:{label:wc_stripe_apple_pay_single_params.label,amount:wc_stripe_apple_pay_single_params.total},lineItems:wc_stripe_apple_pay_single_params.line_items,requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:"yes"===wc_stripe_apple_pay_single_params.needs_shipping?["postalAddress","phone","email","name"]:["phone","email","name"]},f=Stripe.applePay.buildSession(e,function(c,d){var e={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,result:c};a.ajax({type:"POST",data:e,url:b.getAjaxURL("apple_pay"),success:function(b){"true"===b.success&&(d(ApplePaySession.STATUS_SUCCESS),window.location.href=b.redirect),"false"===b.success&&(d(ApplePaySession.STATUS_FAILURE),a(".apple-pay-button").before('<p class="woocommerce-error wc-stripe-apple-pay-error">'+b.msg+"</p>"),a(document.body).animate({scrollTop:a(".wc-stripe-apple-pay-error").offset().top},500))}})});"yes"===wc_stripe_apple_pay_single_params.needs_shipping&&(f.onshippingcontactselected=function(c){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_get_shipping_methods_nonce,address:c.shippingContact};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_get_shipping_methods"),success:function(a){var b={label:wc_stripe_apple_pay_single_params.label,amount:a.total};"true"===a.success&&f.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,a.shipping_methods,b,a.line_items),"false"===a.success&&f.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,a.shipping_methods,b,a.line_items)}})},f.onshippingmethodselected=function(c){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_update_shipping_method_nonce,selected_shipping_method:c.shippingMethod};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_update_shipping_method"),success:function(a){var b={label:wc_stripe_apple_pay_single_params.label,amount:parseFloat(a.total).toFixed(2)};"true"===a.success&&f.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,b,a.line_items),"false"===a.success&&f.completeShippingMethodSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,b,a.line_items)}})}),f.begin()})},get_attributes:function(){var b=a(".variations_form").find(".variations select"),c={},d=0,e=0;return b.each(function(){var b=a(this).data("attribute_name")||a(this).attr("name"),f=a(this).val()||"";f.length>0&&e++,d++,c[b]=f}),{count:d,chosenCount:e,data:c}},generate_cart:function(){var c={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce,qty:a(".quantity .qty").val(),attributes:a(".variations_form").length?b.get_attributes().data:[]};return a.ajax({type:"POST",data:c,url:b.getAjaxURL("generate_apple_pay_single"),success:function(a){wc_stripe_apple_pay_single_params.total=a.total,wc_stripe_apple_pay_single_params.line_items=a.line_items}})}};b.init()});
1
+ Stripe.setPublishableKey(wc_stripe_apple_pay_single_params.key),jQuery(function(a){"use strict";var b={getAjaxURL:function(a){return wc_stripe_apple_pay_single_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+a)},init:function(){Stripe.applePay.checkAvailability(function(b){b&&a(".apple-pay-button").show()}),a(document.body).on("click",".apple-pay-button",function(c){c.preventDefault();var d=a(".single_add_to_cart_button");if(d.is(".disabled"))return void(d.is(".wc-variation-is-unavailable")?window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):d.is(".wc-variation-selection-needed")&&window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text));var e={countryCode:wc_stripe_apple_pay_single_params.country_code,currencyCode:wc_stripe_apple_pay_single_params.currency_code,total:{label:wc_stripe_apple_pay_single_params.label,amount:1,type:"pending"},lineItems:{label:wc_stripe_apple_pay_single_params.i18n.sub_total,amount:1,type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:"yes"===wc_stripe_apple_pay_single_params.needs_shipping?["postalAddress","phone","email","name"]:["phone","email","name"]},f=Stripe.applePay.buildSession(e,function(c,d){var e={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,result:c};a.ajax({type:"POST",data:e,url:b.getAjaxURL("apple_pay"),success:function(b){"true"===b.success&&(d(ApplePaySession.STATUS_SUCCESS),window.location.href=b.redirect),"false"===b.success&&(d(ApplePaySession.STATUS_FAILURE),a(".apple-pay-button").before('<p class="woocommerce-error wc-stripe-apple-pay-error">'+b.msg+"</p>"),a(document.body).animate({scrollTop:a(".wc-stripe-apple-pay-error").offset().top},500))}})},function(c){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,errors:c.message};a.ajax({type:"POST",data:d,url:b.getAjaxURL("log_apple_pay_errors")})});"yes"===wc_stripe_apple_pay_single_params.needs_shipping&&(f.onshippingcontactselected=function(c){a.when(b.generate_cart()).then(function(){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_get_shipping_methods_nonce,address:c.shippingContact};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_get_shipping_methods"),success:function(a){var b={label:wc_stripe_apple_pay_single_params.label,amount:a.total};a.total<=0&&(b.amount=1,b.type="pending"),"true"===a.success&&f.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,a.shipping_methods,b,a.line_items),"false"===a.success&&f.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,a.shipping_methods,b,a.line_items)}})})},f.onshippingmethodselected=function(c){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_update_shipping_method_nonce,selected_shipping_method:c.shippingMethod};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_update_shipping_method"),success:function(a){var b={label:wc_stripe_apple_pay_single_params.label,amount:parseFloat(a.total).toFixed(2)};"true"===a.success&&f.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,b,a.line_items),"false"===a.success&&f.completeShippingMethodSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,b,a.line_items)}})}),f.onpaymentmethodselected=function(c){a.when(b.generate_cart()).then(function(){var a={label:wc_stripe_apple_pay_single_params.label,amount:wc_stripe_apple_pay_single_params.total},b=wc_stripe_apple_pay_single_params.line_items;f.completePaymentMethodSelection(a,b)})},f.oncancel=function(a){b.clear_cart()},f.begin()})},get_attributes:function(){var b=a(".variations_form").find(".variations select"),c={},d=0,e=0;return b.each(function(){var b=a(this).data("attribute_name")||a(this).attr("name"),f=a(this).val()||"";f.length>0&&e++,d++,c[b]=f}),{count:d,chosenCount:e,data:c}},generate_cart:function(){var c={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce,qty:a(".quantity .qty").val(),attributes:a(".variations_form").length?b.get_attributes().data:[]};return a.ajax({type:"POST",data:c,url:b.getAjaxURL("generate_apple_pay_single"),success:function(a){wc_stripe_apple_pay_single_params.total=a.total,wc_stripe_apple_pay_single_params.line_items=a.line_items}})},clear_cart:function(){var c={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce};return a.ajax({type:"POST",data:c,url:b.getAjaxURL("apple_pay_clear_cart"),success:function(a){}})}};b.init()});
assets/js/stripe-apple-pay.js CHANGED
@@ -76,6 +76,17 @@ jQuery( function( $ ) {
76
  }
77
  }
78
  });
 
 
 
 
 
 
 
 
 
 
 
79
  });
80
 
81
  // If shipping is needed -- get shipping methods.
76
  }
77
  }
78
  });
79
+ }, function( error ) {
80
+ var data = {
81
+ 'nonce': wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce,
82
+ 'errors': error.message
83
+ };
84
+
85
+ $.ajax({
86
+ type: 'POST',
87
+ data: data,
88
+ url: wc_stripe_apple_pay.getAjaxURL( 'log_apple_pay_errors' )
89
+ });
90
  });
91
 
92
  // If shipping is needed -- get shipping methods.
assets/js/stripe-apple-pay.min.js CHANGED
@@ -1 +1 @@
1
- Stripe.setPublishableKey(wc_stripe_apple_pay_params.key),jQuery(function(a){"use strict";var b={getAjaxURL:function(a){return wc_stripe_apple_pay_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+a)},init:function(){Stripe.applePay.checkAvailability(function(c){c&&(a(".apple-pay-button").show(),a(".woocommerce-checkout .apple-pay-button").css("visibility","visible"),a(".apple-pay-button-checkout-separator").show(),b.generate_cart())}),a(document.body).on("click",".apple-pay-button",function(c){c.preventDefault();var d={countryCode:wc_stripe_apple_pay_params.country_code,currencyCode:wc_stripe_apple_pay_params.currency_code,total:{label:wc_stripe_apple_pay_params.label,amount:wc_stripe_apple_pay_params.total},lineItems:wc_stripe_apple_pay_params.line_items,requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:"yes"===wc_stripe_apple_pay_params.needs_shipping?["postalAddress","phone","email","name"]:["phone","email","name"]},e=Stripe.applePay.buildSession(d,function(c,d){var e={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_nonce,result:c};a.ajax({type:"POST",data:e,url:b.getAjaxURL("apple_pay"),success:function(b){"true"===b.success&&(d(ApplePaySession.STATUS_SUCCESS),window.location.href=b.redirect),"false"===b.success&&(d(ApplePaySession.STATUS_FAILURE),a(".apple-pay-button").before('<p class="woocommerce-error wc-stripe-apple-pay-error">'+b.msg+"</p>"),a(document.body).animate({scrollTop:a(".wc-stripe-apple-pay-error").offset().top},500))}})});"yes"===wc_stripe_apple_pay_params.needs_shipping&&(e.onshippingcontactselected=function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_get_shipping_methods_nonce,address:c.shippingContact};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_get_shipping_methods"),success:function(a){var b={label:wc_stripe_apple_pay_params.label,amount:a.total};"true"===a.success&&e.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,a.shipping_methods,b,a.line_items),"false"===a.success&&e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,a.shipping_methods,b,a.line_items)}})},e.onshippingmethodselected=function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_update_shipping_method_nonce,selected_shipping_method:c.shippingMethod};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_update_shipping_method"),success:function(a){var b={label:wc_stripe_apple_pay_params.label,amount:parseFloat(a.total).toFixed(2)};"true"===a.success&&e.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,b,a.line_items),"false"===a.success&&e.completeShippingMethodSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,b,a.line_items)}})}),e.begin()})},generate_cart:function(){var c={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce};a.ajax({type:"POST",data:c,url:b.getAjaxURL("generate_apple_pay_cart"),success:function(a){wc_stripe_apple_pay_params.total=a.total,wc_stripe_apple_pay_params.line_items=a.line_items}})}};b.init(),a(document.body).on("updated_cart_totals",function(){b.init()}),a(document.body).on("updated_checkout",function(){b.init()})});
1
+ Stripe.setPublishableKey(wc_stripe_apple_pay_params.key),jQuery(function(a){"use strict";var b={getAjaxURL:function(a){return wc_stripe_apple_pay_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+a)},init:function(){Stripe.applePay.checkAvailability(function(c){c&&(a(".apple-pay-button").show(),a(".woocommerce-checkout .apple-pay-button").css("visibility","visible"),a(".apple-pay-button-checkout-separator").show(),b.generate_cart())}),a(document.body).on("click",".apple-pay-button",function(c){c.preventDefault();var d={countryCode:wc_stripe_apple_pay_params.country_code,currencyCode:wc_stripe_apple_pay_params.currency_code,total:{label:wc_stripe_apple_pay_params.label,amount:wc_stripe_apple_pay_params.total},lineItems:wc_stripe_apple_pay_params.line_items,requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:"yes"===wc_stripe_apple_pay_params.needs_shipping?["postalAddress","phone","email","name"]:["phone","email","name"]},e=Stripe.applePay.buildSession(d,function(c,d){var e={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_nonce,result:c};a.ajax({type:"POST",data:e,url:b.getAjaxURL("apple_pay"),success:function(b){"true"===b.success&&(d(ApplePaySession.STATUS_SUCCESS),window.location.href=b.redirect),"false"===b.success&&(d(ApplePaySession.STATUS_FAILURE),a(".apple-pay-button").before('<p class="woocommerce-error wc-stripe-apple-pay-error">'+b.msg+"</p>"),a(document.body).animate({scrollTop:a(".wc-stripe-apple-pay-error").offset().top},500))}})},function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce,errors:c.message};a.ajax({type:"POST",data:d,url:b.getAjaxURL("log_apple_pay_errors")})});"yes"===wc_stripe_apple_pay_params.needs_shipping&&(e.onshippingcontactselected=function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_get_shipping_methods_nonce,address:c.shippingContact};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_get_shipping_methods"),success:function(a){var b={label:wc_stripe_apple_pay_params.label,amount:a.total};"true"===a.success&&e.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,a.shipping_methods,b,a.line_items),"false"===a.success&&e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,a.shipping_methods,b,a.line_items)}})},e.onshippingmethodselected=function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_update_shipping_method_nonce,selected_shipping_method:c.shippingMethod};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_update_shipping_method"),success:function(a){var b={label:wc_stripe_apple_pay_params.label,amount:parseFloat(a.total).toFixed(2)};"true"===a.success&&e.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,b,a.line_items),"false"===a.success&&e.completeShippingMethodSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,b,a.line_items)}})}),e.begin()})},generate_cart:function(){var c={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce};a.ajax({type:"POST",data:c,url:b.getAjaxURL("generate_apple_pay_cart"),success:function(a){wc_stripe_apple_pay_params.total=a.total,wc_stripe_apple_pay_params.line_items=a.line_items}})}};b.init(),a(document.body).on("updated_cart_totals",function(){b.init()}),a(document.body).on("updated_checkout",function(){b.init()})});
assets/js/stripe-checkout.js CHANGED
@@ -65,6 +65,16 @@ jQuery( function( $ ) {
65
  if ( $( this ).find( 'input.input-text, select' ).not( $( '#account_password, #account_username' ) ).val() === '' ) {
66
  required_error = true;
67
  }
 
 
 
 
 
 
 
 
 
 
68
  });
69
 
70
  if ( required_error ) {
65
  if ( $( this ).find( 'input.input-text, select' ).not( $( '#account_password, #account_username' ) ).val() === '' ) {
66
  required_error = true;
67
  }
68
+
69
+ var emailField = $( this ).find( '#billing_email' );
70
+
71
+ if ( emailField.length ) {
72
+ var re = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
73
+
74
+ if ( ! re.test( emailField.val() ) ) {
75
+ required_error = true;
76
+ }
77
+ }
78
  });
79
 
80
  if ( required_error ) {
assets/js/stripe-checkout.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(a){"use strict";var b={init:function(b){this.form=b,this.stripe_submit=!1,a(this.form).on("click","#place_order",this.onSubmit).on("submit checkout_place_order_stripe"),a(document.body).on("checkout_error",this.resetModal)},isStripeChosen:function(){return a("#payment_method_stripe").is(":checked")&&(!a('input[name="wc-stripe-payment-token"]:checked').length||"new"===a('input[name="wc-stripe-payment-token"]:checked').val())},isStripeModalNeeded:function(c){var d,e=b.form.find("input.stripe_token");if(b.stripe_submit&&e)return!1;if(!b.isStripeChosen())return!1;if(1===a("input#terms").length&&0===a("input#terms:checked").length)return!1;if(a("#createaccount").is(":checked")&&a("#account_password").length&&""===a("#account_password").val())return!1;if(d=a(a("#ship-to-different-address-checkbox").is(":checked")?".woocommerce-billing-fields .validate-required, .woocommerce-shipping-fields .validate-required":".woocommerce-billing-fields .validate-required"),d.length){var f=!1;if(d.each(function(){""===a(this).find("input.input-text, select").not(a("#account_password, #account_username")).val()&&(f=!0)}),f)return!1}return!0},block:function(){b.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){b.form.unblock()},onClose:function(){b.unblock()},onSubmit:function(c){if(b.isStripeModalNeeded()){c.preventDefault();var d=b.form,e=a("#stripe-payment-data"),f=d.find("input.stripe_token");f.val("");var g=function(a){d.find("input.stripe_token").remove(),d.append('<input type="hidden" class="stripe_token" name="stripe_token" value="'+a.id+'"/>'),b.stripe_submit=!0,d.submit()};return StripeCheckout.open({key:wc_stripe_params.key,billingAddress:"yes"===wc_stripe_params.stripe_checkout_require_billing_address,amount:e.data("amount"),name:e.data("name"),description:e.data("description"),currency:e.data("currency"),image:e.data("image"),bitcoin:e.data("bitcoin"),locale:e.data("locale"),email:a("#billing_email").val()||e.data("email"),panelLabel:e.data("panel-label"),allowRememberMe:e.data("allow-remember-me"),token:g,closed:b.onClose()}),!1}return!0},resetModal:function(){b.form.find("input.stripe_token").remove(),b.stripe_submit=!1}};b.init(a("form.checkout, form#order_review, form#add_payment_method"))});
1
+ jQuery(function(a){"use strict";var b={init:function(b){this.form=b,this.stripe_submit=!1,a(this.form).on("click","#place_order",this.onSubmit).on("submit checkout_place_order_stripe"),a(document.body).on("checkout_error",this.resetModal)},isStripeChosen:function(){return a("#payment_method_stripe").is(":checked")&&(!a('input[name="wc-stripe-payment-token"]:checked').length||"new"===a('input[name="wc-stripe-payment-token"]:checked').val())},isStripeModalNeeded:function(c){var d,e=b.form.find("input.stripe_token");if(b.stripe_submit&&e)return!1;if(!b.isStripeChosen())return!1;if(1===a("input#terms").length&&0===a("input#terms:checked").length)return!1;if(a("#createaccount").is(":checked")&&a("#account_password").length&&""===a("#account_password").val())return!1;if(d=a(a("#ship-to-different-address-checkbox").is(":checked")?".woocommerce-billing-fields .validate-required, .woocommerce-shipping-fields .validate-required":".woocommerce-billing-fields .validate-required"),d.length){var f=!1;if(d.each(function(){""===a(this).find("input.input-text, select").not(a("#account_password, #account_username")).val()&&(f=!0);var b=a(this).find("#billing_email");if(b.length){var c=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;c.test(b.val())||(f=!0)}}),f)return!1}return!0},block:function(){b.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){b.form.unblock()},onClose:function(){b.unblock()},onSubmit:function(c){if(b.isStripeModalNeeded()){c.preventDefault();var d=b.form,e=a("#stripe-payment-data"),f=d.find("input.stripe_token");f.val("");var g=function(a){d.find("input.stripe_token").remove(),d.append('<input type="hidden" class="stripe_token" name="stripe_token" value="'+a.id+'"/>'),b.stripe_submit=!0,d.submit()};return StripeCheckout.open({key:wc_stripe_params.key,billingAddress:"yes"===wc_stripe_params.stripe_checkout_require_billing_address,amount:e.data("amount"),name:e.data("name"),description:e.data("description"),currency:e.data("currency"),image:e.data("image"),bitcoin:e.data("bitcoin"),locale:e.data("locale"),email:a("#billing_email").val()||e.data("email"),panelLabel:e.data("panel-label"),allowRememberMe:e.data("allow-remember-me"),token:g,closed:b.onClose()}),!1}return!0},resetModal:function(){b.form.find("input.stripe_token").remove(),b.stripe_submit=!1}};b.init(a("form.checkout, form#order_review, form#add_payment_method"))});
includes/class-wc-gateway-stripe.php CHANGED
@@ -73,13 +73,6 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
73
  */
74
  public $bitcoin;
75
 
76
- /**
77
- * Alow Remember me setting for Stripe Checkout
78
- *
79
- * @var bool
80
- */
81
- public $allow_remember_me;
82
-
83
  /**
84
  * Do we accept Apple Pay?
85
  *
@@ -115,6 +108,13 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
115
  */
116
  public $logging;
117
 
 
 
 
 
 
 
 
118
  /**
119
  * Constructor
120
  */
@@ -149,24 +149,24 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
149
  $this->init_settings();
150
 
151
  // Get setting values.
152
- $this->title = $this->get_option( 'title' );
153
- $this->description = $this->get_option( 'description' );
154
- $this->enabled = $this->get_option( 'enabled' );
155
- $this->testmode = 'yes' === $this->get_option( 'testmode' );
156
- $this->capture = 'yes' === $this->get_option( 'capture', 'yes' );
157
- $this->statement_descriptor = $this->get_option( 'statement_descriptor', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
158
- $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' );
159
- $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' );
160
- $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' );
161
- $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' );
162
- $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
163
- $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
164
- $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
165
- $this->apple_pay = 'yes' === $this->get_option( 'apple_pay', 'yes' );
166
- $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
167
- $this->apple_pay_button = $this->get_option( 'apple_pay_button', 'black' );
168
- $this->logging = 'yes' === $this->get_option( 'logging' );
169
- $this->allow_remember_me = 'yes' === $this->get_option( 'allow_remember_me', 'no' );
170
 
171
  if ( $this->stripe_checkout ) {
172
  $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
@@ -277,7 +277,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
277
  * @version 3.1.0
278
  * @param string $secret_key
279
  */
280
- private function _register_apple_pay_domain( $secret_key = '' ) {
281
  if ( empty( $secret_key ) ) {
282
  throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
283
  }
@@ -299,7 +299,11 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
299
  ) );
300
 
301
  if ( 200 !== $response['response']['code'] ) {
302
- throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response['response']['message'] ) );
 
 
 
 
303
  }
304
  }
305
 
@@ -318,7 +322,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
318
  $file = 'apple-developer-merchantid-domain-association';
319
  $fullpath = $path . '/' . $dir . '/' . $file;
320
 
321
- if ( 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists( $fullpath ) ) {
322
  return;
323
  }
324
 
@@ -336,7 +340,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
336
 
337
  // At this point then the domain association folder and file should be available.
338
  // Proceed to verify/and or verify again.
339
- $this->_register_apple_pay_domain( $this->secret_key );
340
 
341
  // No errors to this point, verification success!
342
  $gateway_settings['apple_pay_domain_set'] = 'yes';
@@ -363,13 +367,17 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
363
  return;
364
  }
365
 
 
 
 
 
366
  /**
367
  * Apple pay is enabled by default and domain verification initializes
368
  * when setting screen is displayed. So if domain verification is not set,
369
  * something went wrong so lets notify user.
370
  */
371
  if ( ! empty( $this->secret_key ) && $this->apple_pay && ! $this->apple_pay_domain_set ) {
372
- echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue.', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>';
373
  }
374
 
375
  // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
@@ -439,7 +447,7 @@ class WC_Gateway_Stripe extends WC_Payment_Gateway_CC {
439
  data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
440
  data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '"
441
  data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '"
442
- data-allow-remember-me="' . esc_attr( $this->allow_remember_me ? 'true' : 'false' ) . '">';
443
 
444
  if ( $this->description ) {
445
  echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
73
  */
74
  public $bitcoin;
75
 
 
 
 
 
 
 
 
76
  /**
77
  * Do we accept Apple Pay?
78
  *
108
  */
109
  public $logging;
110
 
111
+ /**
112
+ * Stores Apple Pay domain verification issues.
113
+ *
114
+ * @var string
115
+ */
116
+ public $apple_pay_verify_notice;
117
+
118
  /**
119
  * Constructor
120
  */
149
  $this->init_settings();
150
 
151
  // Get setting values.
152
+ $this->title = $this->get_option( 'title' );
153
+ $this->description = $this->get_option( 'description' );
154
+ $this->enabled = $this->get_option( 'enabled' );
155
+ $this->testmode = 'yes' === $this->get_option( 'testmode' );
156
+ $this->capture = 'yes' === $this->get_option( 'capture', 'yes' );
157
+ $this->statement_descriptor = $this->get_option( 'statement_descriptor', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
158
+ $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' );
159
+ $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' );
160
+ $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' );
161
+ $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' );
162
+ $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
163
+ $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
164
+ $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
165
+ $this->apple_pay = 'yes' === $this->get_option( 'apple_pay', 'yes' );
166
+ $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
167
+ $this->apple_pay_button = $this->get_option( 'apple_pay_button', 'black' );
168
+ $this->logging = 'yes' === $this->get_option( 'logging' );
169
+ $this->apple_pay_verify_notice = '';
170
 
171
  if ( $this->stripe_checkout ) {
172
  $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
277
  * @version 3.1.0
278
  * @param string $secret_key
279
  */
280
+ private function register_apple_pay_domain( $secret_key = '' ) {
281
  if ( empty( $secret_key ) ) {
282
  throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
283
  }
299
  ) );
300
 
301
  if ( 200 !== $response['response']['code'] ) {
302
+ $parsed_response = json_decode( $response['body'] );
303
+
304
+ $this->apple_pay_verify_notice = $parsed_response->error->message;
305
+
306
+ throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
307
  }
308
  }
309
 
322
  $file = 'apple-developer-merchantid-domain-association';
323
  $fullpath = $path . '/' . $dir . '/' . $file;
324
 
325
+ if ( ! empty( $gateway_settings['apple_pay_domain_set'] ) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists( $fullpath ) ) {
326
  return;
327
  }
328
 
340
 
341
  // At this point then the domain association folder and file should be available.
342
  // Proceed to verify/and or verify again.
343
+ $this->register_apple_pay_domain( $this->secret_key );
344
 
345
  // No errors to this point, verification success!
346
  $gateway_settings['apple_pay_domain_set'] = 'yes';
367
  return;
368
  }
369
 
370
+ if ( $this->apple_pay && ! empty( $this->apple_pay_verify_notice ) ) {
371
+ echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ) ) . '</p></div>';
372
+ }
373
+
374
  /**
375
  * Apple pay is enabled by default and domain verification initializes
376
  * when setting screen is displayed. So if domain verification is not set,
377
  * something went wrong so lets notify user.
378
  */
379
  if ( ! empty( $this->secret_key ) && $this->apple_pay && ! $this->apple_pay_domain_set ) {
380
+ echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>';
381
  }
382
 
383
  // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
447
  data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
448
  data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '"
449
  data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '"
450
+ data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">';
451
 
452
  if ( $this->description ) {
453
  echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
includes/class-wc-stripe-api.php CHANGED
@@ -74,11 +74,10 @@ class WC_Stripe_API {
74
  }
75
 
76
  $parsed_response = json_decode( $response['body'] );
 
77
  // Handle response
78
  if ( ! empty( $parsed_response->error ) ) {
79
- if ( ! empty( $parsed_response->error->param ) ) {
80
- $code = $parsed_response->error->param;
81
- } elseif ( ! empty( $parsed_response->error->code ) ) {
82
  $code = $parsed_response->error->code;
83
  } else {
84
  $code = 'stripe_error';
74
  }
75
 
76
  $parsed_response = json_decode( $response['body'] );
77
+
78
  // Handle response
79
  if ( ! empty( $parsed_response->error ) ) {
80
+ if ( ! empty( $parsed_response->error->code ) ) {
 
 
81
  $code = $parsed_response->error->code;
82
  } else {
83
  $code = 'stripe_error';
includes/class-wc-stripe-apple-pay.php CHANGED
@@ -17,25 +17,67 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
17
  private static $_this;
18
 
19
  /**
20
- * Gateway.
21
  *
22
  * @var
23
  */
24
- private $_gateway;
25
 
26
  /**
27
- * Statement Description
28
  *
29
- * @var
30
  */
31
- public $statement_descriptor;
32
 
33
  /**
34
- * Gateway settings.
35
  *
36
- * @var
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  */
38
- private $_gateway_settings;
39
 
40
  /**
41
  * Constructor.
@@ -47,9 +89,28 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
47
  public function __construct() {
48
  self::$_this = $this;
49
 
50
- $this->_gateway_settings = get_option( 'woocommerce_stripe_settings', '' );
51
 
52
- $this->statement_descriptor = ! empty( $this->_gateway_settings['statement_descriptor'] ) ? $this->_gateway_settings['statement_descriptor'] : wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  $this->init();
55
  }
@@ -63,15 +124,20 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
63
  *
64
  * @access public
65
  * @since 3.1.0
66
- * @version 3.1.0
67
  */
68
  public function init() {
 
 
 
 
 
69
  add_action( 'wp_enqueue_scripts', array( $this, 'cart_scripts' ) );
70
  add_action( 'wp_enqueue_scripts', array( $this, 'single_scripts' ) );
71
 
72
  /**
73
  * In order to display the Apple Pay button in the correct position,
74
- * a new hook was added to WooCommerce 2.7. In older versions of WooCommerce,
75
  * CSS is used to position the button.
76
  */
77
  if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
@@ -84,12 +150,15 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
84
  add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_apple_pay_separator_html' ), 2 );
85
  add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_apple_pay_button' ), 1 );
86
  add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_apple_pay_separator_html' ), 2 );
 
87
  add_action( 'wc_ajax_wc_stripe_apple_pay', array( $this, 'process_apple_pay' ) );
88
  add_action( 'wc_ajax_wc_stripe_generate_apple_pay_cart', array( $this, 'generate_apple_pay_cart' ) );
 
89
  add_action( 'wc_ajax_wc_stripe_generate_apple_pay_single', array( $this, 'generate_apple_pay_single' ) );
90
  add_action( 'wc_ajax_wc_stripe_apple_pay_get_shipping_methods', array( $this, 'get_shipping_methods' ) );
91
  add_action( 'wc_ajax_wc_stripe_apple_pay_update_shipping_method', array( $this, 'update_shipping_method' ) );
92
  add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
 
93
  }
94
 
95
  /**
@@ -105,18 +174,61 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
105
 
106
  $method_title = get_post_meta( $post->ID, '_payment_method_title', true );
107
 
108
- if ( 'stripe' === $id && ! empty( $method_title ) ) {
109
  return $method_title;
110
  }
111
 
112
  return $title;
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /**
116
  * Enqueue JS scripts and styles for single product page.
117
  *
118
  * @since 3.1.0
119
- * @version 3.1.0
120
  */
121
  public function single_scripts() {
122
  if ( ! is_single() ) {
@@ -138,10 +250,8 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
138
  wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
139
  wp_enqueue_script( 'woocommerce_stripe_apple_pay_single', plugins_url( 'assets/js/stripe-apple-pay-single' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
140
 
141
- $publishable_key = 'yes' === $this->_gateway_settings['testmode'] ? $this->_gateway_settings['test_publishable_key'] : $this->_gateway_settings['publishable_key'];
142
-
143
  $stripe_params = array(
144
- 'key' => $publishable_key,
145
  'currency_code' => get_woocommerce_currency(),
146
  'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
147
  'label' => $this->statement_descriptor,
@@ -150,7 +260,10 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
150
  'stripe_apple_pay_cart_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_cart_nonce' ),
151
  'stripe_apple_pay_get_shipping_methods_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_get_shipping_methods_nonce' ),
152
  'stripe_apple_pay_update_shipping_method_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_update_shipping_method_nonce' ),
153
- 'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no',
 
 
 
154
  );
155
 
156
  wp_localize_script( 'woocommerce_stripe_apple_pay_single', 'wc_stripe_apple_pay_single_params', apply_filters( 'wc_stripe_apple_pay_single_params', $stripe_params ) );
@@ -174,10 +287,8 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
174
  wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
175
  wp_enqueue_script( 'woocommerce_stripe_apple_pay', plugins_url( 'assets/js/stripe-apple-pay' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
176
 
177
- $publishable_key = 'yes' === $this->_gateway_settings['testmode'] ? $this->_gateway_settings['test_publishable_key'] : $this->_gateway_settings['publishable_key'];
178
-
179
  $stripe_params = array(
180
- 'key' => $publishable_key,
181
  'currency_code' => get_woocommerce_currency(),
182
  'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
183
  'label' => $this->statement_descriptor,
@@ -196,6 +307,9 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
196
  /**
197
  * Checks to make sure product type is supported by Apple Pay.
198
  *
 
 
 
199
  */
200
  public function supported_product_types() {
201
  return array(
@@ -204,6 +318,26 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
204
  );
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * Display Apple Pay button on the cart page
209
  *
@@ -214,13 +348,11 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
214
  $gateways = WC()->payment_gateways->get_available_payment_gateways();
215
 
216
  /**
217
- * In order for the Apple Pay button to show on cart page,
218
  * Apple Pay must be enabled and Stripe gateway must be enabled.
219
  */
220
- if (
221
- 'yes' !== $this->_gateway_settings['apple_pay']
222
- || ! isset( $gateways['stripe'] )
223
- ) {
224
  return;
225
  }
226
 
@@ -229,16 +361,19 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
229
 
230
  $product = wc_get_product( $post->ID );
231
 
232
- if ( ! in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
 
 
 
 
 
233
  return;
234
  }
235
  }
236
 
237
- $apple_pay_button = ! empty( $this->_gateway_settings['apple_pay_button'] ) ? $this->_gateway_settings['apple_pay_button'] : 'black';
238
- $button_lang = ! empty( $this->_gateway_settings['apple_pay_button_lang'] ) ? strtolower( $this->_gateway_settings['apple_pay_button_lang'] ) : 'en';
239
  ?>
240
  <div class="apple-pay-button-wrapper">
241
- <button class="apple-pay-button" lang="<?php echo esc_attr( $button_lang ); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr( $apple_pay_button ); ?>;"></button>
242
  </div>
243
  <?php
244
  }
@@ -256,21 +391,14 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
256
  * In order for the Apple Pay button to show on cart page,
257
  * Apple Pay must be enabled and Stripe gateway must be enabled.
258
  */
259
- if (
260
- 'yes' !== $this->_gateway_settings['apple_pay']
261
- || ! isset( $gateways['stripe'] )
262
- ) {
263
  return;
264
  }
265
 
266
- if ( is_single() ) {
267
- global $post;
268
-
269
- $product = wc_get_product( $post->ID );
270
-
271
- if ( ! in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
272
- return;
273
- }
274
  }
275
  ?>
276
  <p class="apple-pay-button-checkout-separator">- <?php esc_html_e( 'Or', 'woocommerce-gateway-stripe' ); ?> -</p>
@@ -297,7 +425,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
297
  global $post;
298
 
299
  $product = wc_get_product( $post->ID );
300
- $qty = absint( $_POST['qty'] );
301
 
302
  /**
303
  * If this page is single product page, we need to simulate
@@ -311,7 +439,12 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
311
  if ( 'variable' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) {
312
  $attributes = array_map( 'wc_clean', $_POST['attributes'] );
313
 
314
- $variation_id = $product->get_matching_variation( $attributes );
 
 
 
 
 
315
 
316
  WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
317
  }
@@ -340,6 +473,17 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
340
  wp_send_json( array( 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total ) );
341
  }
342
 
 
 
 
 
 
 
 
 
 
 
 
343
  /**
344
  * Calculate and set shipping method.
345
  *
@@ -540,7 +684,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
540
  return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe::get_minimum_amount() / 100 ) ) );
541
  }
542
 
543
- WC_Stripe::log( "Info: Begin processing payment for order {$order_id} for the amount of {$order->get_total()}" );
544
 
545
  // Make the request.
546
  $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $result['token']['id'] ) );
@@ -561,7 +705,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
561
  WC()->cart->empty_cart();
562
 
563
  update_post_meta( $order_id, '_customer_user', get_current_user_id() );
564
- update_post_meta( $order_id, '_payment_method_title', __( 'Apple Pay (Stripe)', 'woocommerce-gateway-stripe' ) );
565
 
566
  // Return thank you page redirect.
567
  wp_send_json( array(
@@ -571,7 +715,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
571
 
572
  } catch ( Exception $e ) {
573
  WC()->session->set( 'refresh_totals', true );
574
- WC_Stripe::log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) );
575
 
576
  if ( is_object( $order ) && isset( $order_id ) && $order->has_status( array( 'pending', 'failed' ) ) ) {
577
  $this->send_failed_order_email( $order_id );
@@ -592,7 +736,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
592
  $post_data['currency'] = strtolower( version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->get_order_currency() : $order->get_currency() );
593
  $post_data['amount'] = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
594
  $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), $this->statement_descriptor, $order->get_order_number() );
595
- $post_data['capture'] = 'yes' === $this->_gateway_settings['capture'] ? 'true' : 'false';
596
 
597
  $billing_email = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_email : $order->get_billing_email();
598
 
@@ -655,14 +799,14 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
655
  $items = array();
656
  $subtotal = 0;
657
 
658
- foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
659
- $amount = wc_format_decimal( $values['line_subtotal'], $decimals );
660
- $subtotal += $values['line_subtotal'];
661
- $quantity_label = 1 < $values['quantity'] ? ' (x' . $values['quantity'] . ')' : '';
662
 
663
  $item = array(
664
  'type' => 'final',
665
- 'label' => $values['data']->post->post_title . $quantity_label,
666
  'amount' => wc_format_decimal( $amount, $decimals ),
667
  );
668
 
@@ -674,7 +818,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
674
  $items = array();
675
  $items[] = array(
676
  'type' => 'final',
677
- 'label' => __( 'Sub-Total', 'woocommerce-gateway-stripe' ),
678
  'amount' => wc_format_decimal( $subtotal, $decimals ),
679
  );
680
  }
@@ -688,7 +832,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
688
  if ( wc_tax_enabled() ) {
689
  $items[] = array(
690
  'type' => 'final',
691
- 'label' => __( 'Tax', 'woocommerce-gateway-stripe' ),
692
  'amount' => $tax,
693
  );
694
  }
@@ -696,7 +840,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
696
  if ( WC()->cart->needs_shipping() ) {
697
  $items[] = array(
698
  'type' => 'final',
699
- 'label' => __( 'Shipping', 'woocommerce-gateway-stripe' ),
700
  'amount' => $shipping,
701
  );
702
  }
@@ -704,7 +848,7 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
704
  if ( WC()->cart->has_discount() ) {
705
  $items[] = array(
706
  'type' => 'final',
707
- 'label' => __( 'Discount', 'woocommerce-gateway-stripe' ),
708
  'amount' => '-' . $discounts,
709
  );
710
  }
@@ -758,31 +902,90 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
758
  }
759
 
760
  // Allow plugins to add order item meta
761
- do_action( 'woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key );
 
 
 
 
762
  }
763
 
764
  // Store fees
765
  foreach ( WC()->cart->get_fees() as $fee_key => $fee ) {
766
- $item_id = $order->add_fee( $fee );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
767
 
768
  if ( ! $item_id ) {
769
  throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 526 ) );
770
  }
771
 
772
  // Allow plugins to add order item meta to fees
773
- do_action( 'woocommerce_add_order_fee_meta', $order_id, $item_id, $fee, $fee_key );
 
 
 
 
774
  }
775
 
776
  // Store tax rows
777
  foreach ( array_keys( WC()->cart->taxes + WC()->cart->shipping_taxes ) as $tax_rate_id ) {
778
- if ( $tax_rate_id && ! $order->add_tax( $tax_rate_id, WC()->cart->get_tax_amount( $tax_rate_id ), WC()->cart->get_shipping_tax_amount( $tax_rate_id ) ) && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
779
  throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 528 ) );
780
  }
781
  }
782
 
783
  // Store coupons
 
 
 
784
  foreach ( WC()->cart->get_coupons() as $code => $coupon ) {
785
- if ( ! $order->add_coupon( $code, WC()->cart->get_coupon_discount_amount( $code ), WC()->cart->get_coupon_discount_tax_amount( $code ) ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
786
  throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 529 ) );
787
  }
788
  }
@@ -843,7 +1046,23 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
843
  // Loop through user chosen shipping methods.
844
  foreach ( WC()->session->get( 'chosen_shipping_methods' ) as $method ) {
845
  if ( $method === $key ) {
846
- $order->add_shipping( $rate );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
  }
848
  }
849
  }
@@ -863,6 +1082,20 @@ class WC_Stripe_Apple_Pay extends WC_Gateway_Stripe {
863
 
864
  return $order;
865
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
866
  }
867
 
868
  new WC_Stripe_Apple_Pay();
17
  private static $_this;
18
 
19
  /**
20
+ * Statement Description
21
  *
22
  * @var
23
  */
24
+ public $statement_descriptor;
25
 
26
  /**
27
+ * Check if we capture the transaction immediately.
28
  *
29
+ * @var bool
30
  */
31
+ public $capture;
32
 
33
  /**
34
+ * Do we accept Apple Pay?
35
  *
36
+ * @var bool
37
+ */
38
+ public $apple_pay;
39
+
40
+ /**
41
+ * Apple Pay button style.
42
+ *
43
+ * @var bool
44
+ */
45
+ public $apple_pay_button;
46
+
47
+ /**
48
+ * Apple Pay button language.
49
+ *
50
+ * @var bool
51
+ */
52
+ public $apple_pay_button_lang;
53
+
54
+ /**
55
+ * Is test mode active?
56
+ *
57
+ * @var bool
58
+ */
59
+ public $testmode;
60
+
61
+ /**
62
+ * Logging enabled?
63
+ *
64
+ * @var bool
65
+ */
66
+ public $logging;
67
+
68
+ /**
69
+ * Should we store the users credit cards?
70
+ *
71
+ * @var bool
72
+ */
73
+ public $saved_cards;
74
+
75
+ /**
76
+ * Publishable key credentials.
77
+ *
78
+ * @var bool
79
  */
80
+ public $publishable_key;
81
 
82
  /**
83
  * Constructor.
89
  public function __construct() {
90
  self::$_this = $this;
91
 
92
+ $gateway_settings = get_option( 'woocommerce_stripe_settings', '' );
93
 
94
+ $this->statement_descriptor = ! empty( $gateway_settings['statement_descriptor'] ) ? $gateway_settings['statement_descriptor'] : wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
95
+
96
+ // If both site title and statement descriptor is not set. Fallback.
97
+ if ( empty( $this->statement_descriptor ) ) {
98
+ $this->statement_descriptor = $_SERVER['SERVER_NAME'];
99
+ }
100
+
101
+ $this->enabled = ( ! empty( $gateway_settings['enabled'] ) && 'yes' === $gateway_settings['enabled'] ) ? true : false;
102
+ $this->testmode = ( ! empty( $gateway_settings['testmode'] ) && 'yes' === $gateway_settings['testmode'] ) ? true : false;
103
+ $this->capture = ( ! empty( $gateway_settings['capture'] ) && 'yes' === $gateway_settings['capture'] ) ? true : false;
104
+ $this->saved_cards = ( ! empty( $gateway_settings['saved_cards'] ) && 'yes' === $gateway_settings['saved_cards'] ) ? true : false;
105
+ $this->apple_pay = ( ! empty( $gateway_settings['apple_pay'] ) && 'yes' === $gateway_settings['apple_pay'] ) ? true : false;
106
+ $this->apple_pay_button = ! empty( $gateway_settings['apple_pay_button'] ) ? $gateway_settings['apple_pay_button'] : 'black';
107
+ $this->apple_pay_button_lang = ! empty( $gateway_settings['apple_pay_button_lang'] ) ? $gateway_settings['apple_pay_button_lang'] : 'en';
108
+ $this->logging = ( ! empty( $gateway_settings['logging'] ) && 'yes' === $gateway_settings['logging'] ) ? true : false;
109
+ $this->publishable_key = ! empty( $gateway_settings['publishable_key'] ) ? $gateway_settings['publishable_key'] : '';
110
+
111
+ if ( $this->testmode ) {
112
+ $this->publishable_key = ! empty( $gateway_settings['test_publishable_key'] ) ? $gateway_settings['test_publishable_key'] : '';
113
+ }
114
 
115
  $this->init();
116
  }
124
  *
125
  * @access public
126
  * @since 3.1.0
127
+ * @version 3.1.4
128
  */
129
  public function init() {
130
+ // If Apple Pay is not enabled no need to proceed further.
131
+ if ( ! $this->apple_pay ) {
132
+ return;
133
+ }
134
+
135
  add_action( 'wp_enqueue_scripts', array( $this, 'cart_scripts' ) );
136
  add_action( 'wp_enqueue_scripts', array( $this, 'single_scripts' ) );
137
 
138
  /**
139
  * In order to display the Apple Pay button in the correct position,
140
+ * a new hook was added to WooCommerce 3.0. In older versions of WooCommerce,
141
  * CSS is used to position the button.
142
  */
143
  if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
150
  add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_apple_pay_separator_html' ), 2 );
151
  add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_apple_pay_button' ), 1 );
152
  add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_apple_pay_separator_html' ), 2 );
153
+ add_action( 'wc_ajax_wc_stripe_log_apple_pay_errors', array( $this, 'log_apple_pay_errors' ) );
154
  add_action( 'wc_ajax_wc_stripe_apple_pay', array( $this, 'process_apple_pay' ) );
155
  add_action( 'wc_ajax_wc_stripe_generate_apple_pay_cart', array( $this, 'generate_apple_pay_cart' ) );
156
+ add_action( 'wc_ajax_wc_stripe_apple_pay_clear_cart', array( $this, 'clear_cart' ) );
157
  add_action( 'wc_ajax_wc_stripe_generate_apple_pay_single', array( $this, 'generate_apple_pay_single' ) );
158
  add_action( 'wc_ajax_wc_stripe_apple_pay_get_shipping_methods', array( $this, 'get_shipping_methods' ) );
159
  add_action( 'wc_ajax_wc_stripe_apple_pay_update_shipping_method', array( $this, 'update_shipping_method' ) );
160
  add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
161
+ add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 );
162
  }
163
 
164
  /**
174
 
175
  $method_title = get_post_meta( $post->ID, '_payment_method_title', true );
176
 
177
+ if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) {
178
  return $method_title;
179
  }
180
 
181
  return $title;
182
  }
183
 
184
+ /**
185
+ * Log errors coming from Apple Pay.
186
+ *
187
+ * @since 3.1.4
188
+ * @version 3.1.4
189
+ */
190
+ public function log_apple_pay_errors() {
191
+ if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_nonce' ) && ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_cart_nonce' ) ) {
192
+ wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
193
+ }
194
+
195
+ $errors = wc_clean( stripslashes( $_POST['errors'] ) );
196
+
197
+ $this->log( $errors );
198
+
199
+ exit;
200
+ }
201
+
202
+ /**
203
+ * Removes postal code validation from WC.
204
+ *
205
+ * @since 3.1.4
206
+ * @version 3.1.4
207
+ */
208
+ public function postal_code_validation( $valid, $postcode, $country ) {
209
+ $gateways = WC()->payment_gateways->get_available_payment_gateways();
210
+
211
+ if ( ! $this->apple_pay || ! isset( $gateways['stripe'] ) ) {
212
+ return $valid;
213
+ }
214
+
215
+ /**
216
+ * Currently Apple Pay truncates postal codes from UK and Canada to first 3 characters
217
+ * when passing it back from the shippingcontactselected object. This causes WC to invalidate
218
+ * the order and not let it go through. The remedy for now is just to remove this validation.
219
+ */
220
+ if ( 'GB' === $country || 'CA' === $country ) {
221
+ return true;
222
+ }
223
+
224
+ return $valid;
225
+ }
226
+
227
  /**
228
  * Enqueue JS scripts and styles for single product page.
229
  *
230
  * @since 3.1.0
231
+ * @version 3.1.4
232
  */
233
  public function single_scripts() {
234
  if ( ! is_single() ) {
250
  wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
251
  wp_enqueue_script( 'woocommerce_stripe_apple_pay_single', plugins_url( 'assets/js/stripe-apple-pay-single' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
252
 
 
 
253
  $stripe_params = array(
254
+ 'key' => $this->publishable_key,
255
  'currency_code' => get_woocommerce_currency(),
256
  'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
257
  'label' => $this->statement_descriptor,
260
  'stripe_apple_pay_cart_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_cart_nonce' ),
261
  'stripe_apple_pay_get_shipping_methods_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_get_shipping_methods_nonce' ),
262
  'stripe_apple_pay_update_shipping_method_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_update_shipping_method_nonce' ),
263
+ 'needs_shipping' => $product->needs_shipping() ? 'yes' : 'no',
264
+ 'i18n' => array(
265
+ 'sub_total' => __( 'Sub-Total', 'woocommerce-gateway-stripe' ),
266
+ ),
267
  );
268
 
269
  wp_localize_script( 'woocommerce_stripe_apple_pay_single', 'wc_stripe_apple_pay_single_params', apply_filters( 'wc_stripe_apple_pay_single_params', $stripe_params ) );
287
  wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
288
  wp_enqueue_script( 'woocommerce_stripe_apple_pay', plugins_url( 'assets/js/stripe-apple-pay' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
289
 
 
 
290
  $stripe_params = array(
291
+ 'key' => $this->publishable_key,
292
  'currency_code' => get_woocommerce_currency(),
293
  'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
294
  'label' => $this->statement_descriptor,
307
  /**
308
  * Checks to make sure product type is supported by Apple Pay.
309
  *
310
+ * @since 3.1.0
311
+ * @version 3.1.0
312
+ * @return array
313
  */
314
  public function supported_product_types() {
315
  return array(
318
  );
319
  }
320
 
321
+ /**
322
+ * Checks the cart to see if all items are allowed to use
323
+ * Apple Pay.
324
+ *
325
+ * @since 3.1.4
326
+ * @version 3.1.4
327
+ * @return bool
328
+ */
329
+ public function allowed_items_in_cart() {
330
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
331
+ $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
332
+
333
+ if ( ! in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->product_type : $_product->get_type() ), $this->supported_product_types() ) ) {
334
+ return false;
335
+ }
336
+ }
337
+
338
+ return true;
339
+ }
340
+
341
  /**
342
  * Display Apple Pay button on the cart page
343
  *
348
  $gateways = WC()->payment_gateways->get_available_payment_gateways();
349
 
350
  /**
351
+ * In order for the Apple Pay button to show on product detail page,
352
  * Apple Pay must be enabled and Stripe gateway must be enabled.
353
  */
354
+ if ( ! $this->apple_pay || ! isset( $gateways['stripe'] ) ) {
355
+ $this->log( 'Apple Pay not enabled or Stripe is not an available gateway ( Apple Pay button disabled )' );
 
 
356
  return;
357
  }
358
 
361
 
362
  $product = wc_get_product( $post->ID );
363
 
364
+ if ( ! is_object( $product ) || ! in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
365
+ return;
366
+ }
367
+ } else {
368
+ if ( ! $this->allowed_items_in_cart() ) {
369
+ $this->log( 'Items in the cart has unsupported product type ( Apple Pay button disabled )' );
370
  return;
371
  }
372
  }
373
 
 
 
374
  ?>
375
  <div class="apple-pay-button-wrapper">
376
+ <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>
377
  </div>
378
  <?php
379
  }
391
  * In order for the Apple Pay button to show on cart page,
392
  * Apple Pay must be enabled and Stripe gateway must be enabled.
393
  */
394
+ if ( ! $this->apple_pay || ! isset( $gateways['stripe'] ) ) {
395
+ $this->log( 'Apple Pay not enabled or Stripe is not an available gateway ( Apple Pay button disabled )' );
 
 
396
  return;
397
  }
398
 
399
+ if ( ! $this->allowed_items_in_cart() ) {
400
+ $this->log( 'Items in the cart has unsupported product type ( Apple Pay button disabled )' );
401
+ return;
 
 
 
 
 
402
  }
403
  ?>
404
  <p class="apple-pay-button-checkout-separator">- <?php esc_html_e( 'Or', 'woocommerce-gateway-stripe' ); ?> -</p>
425
  global $post;
426
 
427
  $product = wc_get_product( $post->ID );
428
+ $qty = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] );
429
 
430
  /**
431
  * If this page is single product page, we need to simulate
439
  if ( 'variable' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) {
440
  $attributes = array_map( 'wc_clean', $_POST['attributes'] );
441
 
442
+ if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
443
+ $variation_id = $product->get_matching_variation( $attributes );
444
+ } else {
445
+ $data_store = WC_Data_Store::load( 'product' );
446
+ $variation_id = $data_store->find_matching_product_variation( $product, $attributes );
447
+ }
448
 
449
  WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
450
  }
473
  wp_send_json( array( 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total ) );
474
  }
475
 
476
+ /**
477
+ * Clears Apple Pay cart.
478
+ *
479
+ * @since 3.1.4
480
+ * @version 3.1.4
481
+ */
482
+ public function clear_cart() {
483
+ WC()->cart->empty_cart();
484
+ exit;
485
+ }
486
+
487
  /**
488
  * Calculate and set shipping method.
489
  *
684
  return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe::get_minimum_amount() / 100 ) ) );
685
  }
686
 
687
+ $this->log( "Info: Begin processing payment for order {$order_id} for the amount of {$order->get_total()}" );
688
 
689
  // Make the request.
690
  $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $result['token']['id'] ) );
705
  WC()->cart->empty_cart();
706
 
707
  update_post_meta( $order_id, '_customer_user', get_current_user_id() );
708
+ update_post_meta( $order_id, '_payment_method_title', 'Apple Pay (Stripe)' );
709
 
710
  // Return thank you page redirect.
711
  wp_send_json( array(
715
 
716
  } catch ( Exception $e ) {
717
  WC()->session->set( 'refresh_totals', true );
718
+ $this->log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) );
719
 
720
  if ( is_object( $order ) && isset( $order_id ) && $order->has_status( array( 'pending', 'failed' ) ) ) {
721
  $this->send_failed_order_email( $order_id );
736
  $post_data['currency'] = strtolower( version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->get_order_currency() : $order->get_currency() );
737
  $post_data['amount'] = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
738
  $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), $this->statement_descriptor, $order->get_order_number() );
739
+ $post_data['capture'] = $this->capture ? 'true' : 'false';
740
 
741
  $billing_email = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_email : $order->get_billing_email();
742
 
799
  $items = array();
800
  $subtotal = 0;
801
 
802
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
803
+ $amount = wc_format_decimal( $cart_item['line_subtotal'], $decimals );
804
+ $subtotal += $cart_item['line_subtotal'];
805
+ $quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
806
 
807
  $item = array(
808
  'type' => 'final',
809
+ 'label' => $cart_item['data']->post->post_title . $quantity_label,
810
  'amount' => wc_format_decimal( $amount, $decimals ),
811
  );
812
 
818
  $items = array();
819
  $items[] = array(
820
  'type' => 'final',
821
+ 'label' => esc_html( __( 'Sub-Total', 'woocommerce-gateway-stripe' ) ),
822
  'amount' => wc_format_decimal( $subtotal, $decimals ),
823
  );
824
  }
832
  if ( wc_tax_enabled() ) {
833
  $items[] = array(
834
  'type' => 'final',
835
+ 'label' => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ),
836
  'amount' => $tax,
837
  );
838
  }
840
  if ( WC()->cart->needs_shipping() ) {
841
  $items[] = array(
842
  'type' => 'final',
843
+ 'label' => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ),
844
  'amount' => $shipping,
845
  );
846
  }
848
  if ( WC()->cart->has_discount() ) {
849
  $items[] = array(
850
  'type' => 'final',
851
+ 'label' => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ),
852
  'amount' => '-' . $discounts,
853
  );
854
  }
902
  }
903
 
904
  // Allow plugins to add order item meta
905
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
906
+ do_action( 'woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key );
907
+ } else {
908
+ do_action( 'woocommerce_new_order_item', $item_id, wc_get_product( $item_id ), $order->get_id() );
909
+ }
910
  }
911
 
912
  // Store fees
913
  foreach ( WC()->cart->get_fees() as $fee_key => $fee ) {
914
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
915
+ $item_id = $order->add_fee( $fee );
916
+ } else {
917
+ $item = new WC_Order_Item_Fee();
918
+ $item->set_props( array(
919
+ 'name' => $fee->name,
920
+ 'tax_class' => $fee->taxable ? $fee->tax_class : 0,
921
+ 'total' => $fee->amount,
922
+ 'total_tax' => $fee->tax,
923
+ 'taxes' => array(
924
+ 'total' => $fee->tax_data,
925
+ ),
926
+ 'order_id' => $order->get_id(),
927
+ ) );
928
+ $item_id = $item->save();
929
+ $order->add_item( $item );
930
+ }
931
 
932
  if ( ! $item_id ) {
933
  throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 526 ) );
934
  }
935
 
936
  // Allow plugins to add order item meta to fees
937
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
938
+ do_action( 'woocommerce_add_order_fee_meta', $order_id, $item_id, $fee, $fee_key );
939
+ } else {
940
+ do_action( 'woocommerce_new_order_item', $item_id, $fee, $order->get_id() );
941
+ }
942
  }
943
 
944
  // Store tax rows
945
  foreach ( array_keys( WC()->cart->taxes + WC()->cart->shipping_taxes ) as $tax_rate_id ) {
946
+ $tax_amount = WC()->cart->get_tax_amount( $tax_rate_id );
947
+ $shipping_tax_amount = WC()->cart->get_shipping_tax_amount( $tax_rate_id );
948
+
949
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
950
+ $item_id = $order->add_tax( $tax_rate_id, $tax_amount, $shipping_tax_amount );
951
+ } else {
952
+ $item = new WC_Order_Item_Tax();
953
+ $item->set_props( array(
954
+ 'rate_id' => $tax_rate_id,
955
+ 'tax_total' => $tax_amount,
956
+ 'shipping_tax_total' => $shipping_tax_amount,
957
+ ) );
958
+ $item->set_rate( $tax_rate_id );
959
+ $item->set_order_id( $order->get_id() );
960
+ $item_id = $item->save();
961
+ $order->add_item( $item );
962
+ }
963
+
964
+ if ( $tax_rate_id && ! $item_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
965
  throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 528 ) );
966
  }
967
  }
968
 
969
  // Store coupons
970
+ $discount = WC()->cart->get_coupon_discount_amount( $code );
971
+ $discount_tax = WC()->cart->get_coupon_discount_tax_amount( $code );
972
+
973
  foreach ( WC()->cart->get_coupons() as $code => $coupon ) {
974
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
975
+ $coupon_id = $order->add_coupon( $code, $discount, $discount_tax );
976
+ } else {
977
+ $item = new WC_Order_Item_Coupon();
978
+ $item->set_props( array(
979
+ 'code' => $code,
980
+ 'discount' => $discount,
981
+ 'discount_tax' => $discount_tax,
982
+ 'order_id' => $order->get_id(),
983
+ ) );
984
+ $coupon_id = $item->save();
985
+ $order->add_item( $item );
986
+ }
987
+
988
+ if ( ! $coupon_id ) {
989
  throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 529 ) );
990
  }
991
  }
1046
  // Loop through user chosen shipping methods.
1047
  foreach ( WC()->session->get( 'chosen_shipping_methods' ) as $method ) {
1048
  if ( $method === $key ) {
1049
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
1050
+ $order->add_shipping( $rate );
1051
+ } else {
1052
+ $item = new WC_Order_Item_Shipping();
1053
+ $item->set_props( array(
1054
+ 'method_title' => $rate->label,
1055
+ 'method_id' => $rate->id,
1056
+ 'total' => wc_format_decimal( $rate->cost ),
1057
+ 'taxes' => $rate->taxes,
1058
+ 'order_id' => $order->get_id(),
1059
+ ) );
1060
+ foreach ( $rate->get_meta_data() as $key => $value ) {
1061
+ $item->add_meta_data( $key, $value, true );
1062
+ }
1063
+ $item->save();
1064
+ $order->add_item( $item );
1065
+ }
1066
  }
1067
  }
1068
  }
1082
 
1083
  return $order;
1084
  }
1085
+
1086
+ /**
1087
+ * Logs
1088
+ *
1089
+ * @since 3.1.0
1090
+ * @version 3.1.0
1091
+ *
1092
+ * @param string $message
1093
+ */
1094
+ public function log( $message ) {
1095
+ if ( $this->logging ) {
1096
+ WC_Stripe::log( 'Apple Pay: ' . $message );
1097
+ }
1098
+ }
1099
  }
1100
 
1101
  new WC_Stripe_Apple_Pay();
includes/settings-stripe.php CHANGED
@@ -85,14 +85,6 @@ return apply_filters( 'wc_stripe_settings',
85
  'default' => 'no',
86
  'desc_tip' => true,
87
  ),
88
- 'allow_remember_me' => array(
89
- 'title' => __( 'Allow Remember Me', 'woocommerce-gateway-stripe' ),
90
- 'label' => __( 'Enable Remember Me', 'woocommerce-gateway-stripe' ),
91
- 'type' => 'checkbox',
92
- 'description' => __( 'If enabled, this option shows a "Remember Me" checkbox which when checked by the customer will persist their details.', 'woocommerce-gateway-stripe' ),
93
- 'default' => 'yes',
94
- 'desc_tip' => true,
95
- ),
96
  'stripe_checkout_locale' => array(
97
  'title' => __( 'Stripe Checkout locale', 'woocommerce-gateway-stripe' ),
98
  'type' => 'select',
85
  'default' => 'no',
86
  'desc_tip' => true,
87
  ),
 
 
 
 
 
 
 
 
88
  'stripe_checkout_locale' => array(
89
  'title' => __( 'Stripe Checkout locale', 'woocommerce-gateway-stripe' ),
90
  'type' => 'select',
languages/woocommerce-gateway-stripe.pot CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WooCommerce Stripe Gateway\n"
4
- "POT-Creation-Date: 2017-03-13 07:42-0800\n"
5
- "PO-Revision-Date: 2017-03-13 07:42-0800\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: en_US\n"
@@ -21,8 +21,8 @@ msgstr ""
21
 
22
  #: includes/class-wc-gateway-stripe-addons.php:106
23
  #: includes/class-wc-gateway-stripe-addons.php:153
24
- #: includes/class-wc-gateway-stripe.php:737
25
- #: includes/class-wc-stripe-apple-pay.php:556
26
  #: includes/legacy/class-wc-gateway-stripe.php:446
27
  #, php-format
28
  msgid ""
@@ -79,39 +79,39 @@ msgstr ""
79
  msgid "Unable to verify domain - missing secret key."
80
  msgstr ""
81
 
82
- #: includes/class-wc-gateway-stripe.php:302
83
  #, php-format
84
  msgid "Unable to verify domain - %s"
85
  msgstr ""
86
 
87
- #: includes/class-wc-gateway-stripe.php:327
88
  msgid "Unable to create domain association folder to domain root."
89
  msgstr ""
90
 
91
- #: includes/class-wc-gateway-stripe.php:332
92
  msgid "Unable to copy domain association file to domain root."
93
  msgstr ""
94
 
95
- #: includes/class-wc-gateway-stripe.php:347
96
  msgid "Your domain has been verified with Apple Pay!"
97
  msgstr ""
98
 
99
- #: includes/class-wc-gateway-stripe.php:354
100
- #: includes/class-wc-gateway-stripe.php:787
101
- #: includes/class-wc-stripe-apple-pay.php:590
102
  #: includes/legacy/class-wc-gateway-stripe.php:481
103
  #, php-format
104
  msgid "Error: %s"
105
  msgstr ""
106
 
107
- #: includes/class-wc-gateway-stripe.php:372
108
  #, php-format
109
  msgid ""
110
  "Apple Pay domain verification failed. Please check the %1$slog%2$s to see "
111
- "the issue."
112
  msgstr ""
113
 
114
- #: includes/class-wc-gateway-stripe.php:377
115
  #: includes/legacy/class-wc-gateway-stripe.php:165
116
  #, php-format
117
  msgid ""
@@ -120,133 +120,133 @@ msgid ""
120
  "has a valid SSL certificate - Stripe will only work in test mode."
121
  msgstr ""
122
 
123
- #: includes/class-wc-gateway-stripe.php:426
124
  msgid "Add Card"
125
  msgstr ""
126
 
127
- #: includes/class-wc-gateway-stripe.php:473
128
  msgid "The card number is not a valid credit card number."
129
  msgstr ""
130
 
131
- #: includes/class-wc-gateway-stripe.php:474
132
  msgid "The card's expiration month is invalid."
133
  msgstr ""
134
 
135
- #: includes/class-wc-gateway-stripe.php:475
136
  msgid "The card's expiration year is invalid."
137
  msgstr ""
138
 
139
- #: includes/class-wc-gateway-stripe.php:476
140
  msgid "The card's security code is invalid."
141
  msgstr ""
142
 
143
- #: includes/class-wc-gateway-stripe.php:477
144
  msgid "The card number is incorrect."
145
  msgstr ""
146
 
147
- #: includes/class-wc-gateway-stripe.php:478
148
  msgid "The card has expired."
149
  msgstr ""
150
 
151
- #: includes/class-wc-gateway-stripe.php:479
152
  msgid "The card's security code is incorrect."
153
  msgstr ""
154
 
155
- #: includes/class-wc-gateway-stripe.php:480
156
  msgid "The card's zip code failed validation."
157
  msgstr ""
158
 
159
- #: includes/class-wc-gateway-stripe.php:481
160
  msgid "The card was declined."
161
  msgstr ""
162
 
163
- #: includes/class-wc-gateway-stripe.php:482
164
  msgid "There is no card on a customer that is being charged."
165
  msgstr ""
166
 
167
- #: includes/class-wc-gateway-stripe.php:483
168
  msgid "An error occurred while processing the card."
169
  msgstr ""
170
 
171
- #: includes/class-wc-gateway-stripe.php:484
172
  msgid "Could not find payment information."
173
  msgstr ""
174
 
175
- #: includes/class-wc-gateway-stripe.php:505
176
  msgid ""
177
  "This is not a valid live key. Live keys start with \"sk_live_\" and "
178
  "\"pk_live_\"."
179
  msgstr ""
180
 
181
- #: includes/class-wc-gateway-stripe.php:506
182
  msgid ""
183
  "This is not a valid test key. Test keys start with \"sk_test_\" and "
184
  "\"pk_test_\"."
185
  msgstr ""
186
 
187
- #: includes/class-wc-gateway-stripe.php:507
188
  msgid "Re-verify Domain"
189
  msgstr ""
190
 
191
- #: includes/class-wc-gateway-stripe.php:508
192
  msgid "Missing Secret Key. Please set the secret key field above and re-try."
193
  msgstr ""
194
 
195
- #: includes/class-wc-gateway-stripe.php:543
196
  #: includes/legacy/class-wc-gateway-stripe.php:296
197
  msgid "Please accept the terms and conditions first"
198
  msgstr ""
199
 
200
- #: includes/class-wc-gateway-stripe.php:544
201
  #: includes/legacy/class-wc-gateway-stripe.php:297
202
  msgid "Please fill in required checkout fields first"
203
  msgstr ""
204
 
205
- #: includes/class-wc-gateway-stripe.php:562
206
  #: includes/class-wc-stripe-payment-request.php:95
207
  msgid "Sorry, we're not accepting prepaid cards at this time."
208
  msgstr ""
209
 
210
- #: includes/class-wc-gateway-stripe.php:582
211
- #: includes/class-wc-stripe-apple-pay.php:610
212
  #, php-format
213
  msgid "%1$s - Order %2$s"
214
  msgstr ""
215
 
216
- #: includes/class-wc-gateway-stripe.php:596
217
  msgid "Customer Name"
218
  msgstr ""
219
 
220
- #: includes/class-wc-gateway-stripe.php:597
221
  msgid "Customer Email"
222
  msgstr ""
223
 
224
- #: includes/class-wc-gateway-stripe.php:660
225
  msgid "Invalid payment method. Please input a new card number."
226
  msgstr ""
227
 
228
- #: includes/class-wc-gateway-stripe.php:725
229
  #: includes/legacy/class-wc-gateway-stripe.php:434
230
  msgid "Please enter your card details to make a payment."
231
  msgstr ""
232
 
233
- #: includes/class-wc-gateway-stripe.php:726
234
  #: includes/legacy/class-wc-gateway-stripe.php:435
235
  msgid ""
236
  "Developers: Please make sure that you are including jQuery and there are no "
237
  "JavaScript errors on the page."
238
  msgstr ""
239
 
240
- #: includes/class-wc-gateway-stripe.php:754
241
  msgid "This card is no longer available and has been removed."
242
  msgstr ""
243
 
244
- #: includes/class-wc-gateway-stripe.php:845 woocommerce-gateway-stripe.php:470
245
  #, php-format
246
  msgid "Stripe charge complete (Charge ID: %s)"
247
  msgstr ""
248
 
249
- #: includes/class-wc-gateway-stripe.php:856
250
  #: includes/legacy/class-wc-gateway-stripe.php:526
251
  #, php-format
252
  msgid ""
@@ -254,13 +254,13 @@ msgid ""
254
  "cancel to remove the pre-authorization."
255
  msgstr ""
256
 
257
- #: includes/class-wc-gateway-stripe.php:870
258
- #: includes/class-wc-gateway-stripe.php:879
259
  #: includes/legacy/class-wc-gateway-stripe.php:540
260
  msgid "There was a problem adding the card."
261
  msgstr ""
262
 
263
- #: includes/class-wc-gateway-stripe.php:931
264
  #, php-format
265
  msgid "Refunded %1$s - Refund ID: %2$s - Reason: %3$s"
266
  msgstr ""
@@ -269,56 +269,54 @@ msgstr ""
269
  msgid "There was a problem connecting to the payment gateway."
270
  msgstr ""
271
 
272
- #: includes/class-wc-stripe-apple-pay.php:277
273
- msgid "Or"
274
- msgstr ""
275
-
276
- #: includes/class-wc-stripe-apple-pay.php:304
277
- #: includes/class-wc-stripe-apple-pay.php:353
278
- #: includes/class-wc-stripe-apple-pay.php:431
279
- #: includes/class-wc-stripe-apple-pay.php:494
280
- #: includes/class-wc-stripe-apple-pay.php:542
281
  msgid "Cheatin&#8217; huh?"
282
  msgstr ""
283
 
284
- #: includes/class-wc-stripe-apple-pay.php:375
285
- msgid "Please enter a valid postcode/ZIP."
 
286
  msgstr ""
287
 
288
- #: includes/class-wc-stripe-apple-pay.php:452
289
- #: includes/class-wc-stripe-apple-pay.php:475
290
- msgid "Unable to find shipping method for address."
291
  msgstr ""
292
 
293
- #: includes/class-wc-stripe-apple-pay.php:522
294
- #: includes/class-wc-stripe-apple-pay.php:707
295
- #: includes/class-wc-stripe-payment-request.php:348
296
- msgid "Tax"
297
  msgstr ""
298
 
299
  #: includes/class-wc-stripe-apple-pay.php:580
300
- msgid "Apple Pay (Stripe)"
 
301
  msgstr ""
302
 
303
- #: includes/class-wc-stripe-apple-pay.php:693
304
- msgid "Sub-Total"
 
 
305
  msgstr ""
306
 
307
- #: includes/class-wc-stripe-apple-pay.php:715
308
  msgid "Shipping"
309
  msgstr ""
310
 
311
- #: includes/class-wc-stripe-apple-pay.php:723
312
  msgid "Discount"
313
  msgstr ""
314
 
315
- #: includes/class-wc-stripe-apple-pay.php:741
316
- #: includes/class-wc-stripe-apple-pay.php:748
317
- #: includes/class-wc-stripe-apple-pay.php:750
318
- #: includes/class-wc-stripe-apple-pay.php:773
319
- #: includes/class-wc-stripe-apple-pay.php:785
320
- #: includes/class-wc-stripe-apple-pay.php:795
321
- #: includes/class-wc-stripe-apple-pay.php:802
322
  #, php-format
323
  msgid "Error %d: Unable to create order. Please try again."
324
  msgstr ""
@@ -547,190 +545,176 @@ msgid ""
547
  msgstr ""
548
 
549
  #: includes/settings-stripe.php:89
550
- msgid "Allow Remember Me"
551
- msgstr ""
552
-
553
- #: includes/settings-stripe.php:90
554
- msgid "Enable Remember Me"
555
- msgstr ""
556
-
557
- #: includes/settings-stripe.php:92
558
- msgid ""
559
- "If enabled, this option shows a \"Remember Me\" checkbox which when checked "
560
- "by the customer will persist their details."
561
- msgstr ""
562
-
563
- #: includes/settings-stripe.php:97
564
  msgid "Stripe Checkout locale"
565
  msgstr ""
566
 
567
- #: includes/settings-stripe.php:100
568
  msgid ""
569
  "Language to display in Stripe Checkout modal. Specify Auto to display "
570
  "Checkout in the user's preferred language, if available. English will be "
571
  "used by default."
572
  msgstr ""
573
 
574
- #: includes/settings-stripe.php:104
575
  msgid "Auto"
576
  msgstr ""
577
 
578
- #: includes/settings-stripe.php:105
579
  msgid "Simplified Chinese"
580
  msgstr ""
581
 
582
- #: includes/settings-stripe.php:106
583
  msgid "Danish"
584
  msgstr ""
585
 
586
- #: includes/settings-stripe.php:107
587
  msgid "Dutch"
588
  msgstr ""
589
 
590
- #: includes/settings-stripe.php:108
591
  msgid "English"
592
  msgstr ""
593
 
594
- #: includes/settings-stripe.php:109
595
  msgid "Finnish"
596
  msgstr ""
597
 
598
- #: includes/settings-stripe.php:110
599
  msgid "French"
600
  msgstr ""
601
 
602
- #: includes/settings-stripe.php:111
603
  msgid "German"
604
  msgstr ""
605
 
606
- #: includes/settings-stripe.php:112
607
  msgid "Italian"
608
  msgstr ""
609
 
610
- #: includes/settings-stripe.php:113
611
  msgid "Japanese"
612
  msgstr ""
613
 
614
- #: includes/settings-stripe.php:114
615
  msgid "Norwegian"
616
  msgstr ""
617
 
618
- #: includes/settings-stripe.php:115
619
  msgid "Spanish"
620
  msgstr ""
621
 
622
- #: includes/settings-stripe.php:116
623
  msgid "Swedish"
624
  msgstr ""
625
 
626
- #: includes/settings-stripe.php:120
627
  msgid "Bitcoin Currency"
628
  msgstr ""
629
 
630
- #: includes/settings-stripe.php:121
631
  msgid "Enable Bitcoin Currency"
632
  msgstr ""
633
 
634
- #: includes/settings-stripe.php:123
635
  msgid ""
636
  "If enabled, an option to accept bitcoin will show on the checkout modal. "
637
  "Note: Stripe Checkout needs to be enabled and store currency must be set to "
638
  "USD."
639
  msgstr ""
640
 
641
- #: includes/settings-stripe.php:128
642
  msgid "Stripe Checkout Image"
643
  msgstr ""
644
 
645
- #: includes/settings-stripe.php:129
646
  msgid ""
647
  "Optionally enter the URL to a 128x128px image of your brand or product. e.g. "
648
  "<code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>"
649
  msgstr ""
650
 
651
- #: includes/settings-stripe.php:135
652
  msgid "Payment Request API"
653
  msgstr ""
654
 
655
- #: includes/settings-stripe.php:136
656
  msgid "Enable Payment Request API"
657
  msgstr ""
658
 
659
- #: includes/settings-stripe.php:138
660
  msgid ""
661
  "If enabled, users will be able to pay using the Payment Request API if "
662
  "supported by the browser."
663
  msgstr ""
664
 
665
- #: includes/settings-stripe.php:143
666
  msgid "Apple Pay"
667
  msgstr ""
668
 
669
- #: includes/settings-stripe.php:144
670
  #, php-format
671
  msgid ""
672
  "Enable Apple Pay. %1$sBy using Apple Pay, you agree to %2$s and %3$s's terms "
673
  "of service."
674
  msgstr ""
675
 
676
- #: includes/settings-stripe.php:146
677
  msgid "If enabled, users will be able to pay with Apple Pay."
678
  msgstr ""
679
 
680
- #: includes/settings-stripe.php:151
681
  msgid "Apple Pay Button Style"
682
  msgstr ""
683
 
684
- #: includes/settings-stripe.php:152
685
  msgid "Button Style"
686
  msgstr ""
687
 
688
- #: includes/settings-stripe.php:154
689
  msgid "Select the button style you would like to show."
690
  msgstr ""
691
 
692
- #: includes/settings-stripe.php:158
693
  msgid "Black"
694
  msgstr ""
695
 
696
- #: includes/settings-stripe.php:159
697
  msgid "White"
698
  msgstr ""
699
 
700
- #: includes/settings-stripe.php:163
701
  msgid "Apple Pay Button Language"
702
  msgstr ""
703
 
704
- #: includes/settings-stripe.php:164
705
  msgid ""
706
  "Enter the 2 letter ISO code for the language you would like your Apple Pay "
707
  "Button to display in. Reference available ISO codes here <code>http://www."
708
  "w3schools.com/tags/ref_language_codes.asp</code>"
709
  msgstr ""
710
 
711
- #: includes/settings-stripe.php:170
712
  msgid "Saved Cards"
713
  msgstr ""
714
 
715
- #: includes/settings-stripe.php:171
716
  msgid "Enable Payment via Saved Cards"
717
  msgstr ""
718
 
719
- #: includes/settings-stripe.php:173
720
  msgid ""
721
  "If enabled, users will be able to pay with a saved card during checkout. "
722
  "Card details are saved on Stripe servers, not on your store."
723
  msgstr ""
724
 
725
- #: includes/settings-stripe.php:178
726
  msgid "Logging"
727
  msgstr ""
728
 
729
- #: includes/settings-stripe.php:179
730
  msgid "Log debug messages"
731
  msgstr ""
732
 
733
- #: includes/settings-stripe.php:181
734
  msgid "Save debug messages to the WooCommerce System Status log."
735
  msgstr ""
736
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WooCommerce Stripe Gateway\n"
4
+ "POT-Creation-Date: 2017-03-30 12:28-0800\n"
5
+ "PO-Revision-Date: 2017-03-30 12:28-0800\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: en_US\n"
21
 
22
  #: includes/class-wc-gateway-stripe-addons.php:106
23
  #: includes/class-wc-gateway-stripe-addons.php:153
24
+ #: includes/class-wc-gateway-stripe.php:745
25
+ #: includes/class-wc-stripe-apple-pay.php:684
26
  #: includes/legacy/class-wc-gateway-stripe.php:446
27
  #, php-format
28
  msgid ""
79
  msgid "Unable to verify domain - missing secret key."
80
  msgstr ""
81
 
82
+ #: includes/class-wc-gateway-stripe.php:306
83
  #, php-format
84
  msgid "Unable to verify domain - %s"
85
  msgstr ""
86
 
87
+ #: includes/class-wc-gateway-stripe.php:331
88
  msgid "Unable to create domain association folder to domain root."
89
  msgstr ""
90
 
91
+ #: includes/class-wc-gateway-stripe.php:337
92
  msgid "Unable to copy domain association file to domain root."
93
  msgstr ""
94
 
95
+ #: includes/class-wc-gateway-stripe.php:351
96
  msgid "Your domain has been verified with Apple Pay!"
97
  msgstr ""
98
 
99
+ #: includes/class-wc-gateway-stripe.php:358
100
+ #: includes/class-wc-gateway-stripe.php:795
101
+ #: includes/class-wc-stripe-apple-pay.php:718
102
  #: includes/legacy/class-wc-gateway-stripe.php:481
103
  #, php-format
104
  msgid "Error: %s"
105
  msgstr ""
106
 
107
+ #: includes/class-wc-gateway-stripe.php:380
108
  #, php-format
109
  msgid ""
110
  "Apple Pay domain verification failed. Please check the %1$slog%2$s to see "
111
+ "the issue. (Logging must be enabled to see recorded logs)"
112
  msgstr ""
113
 
114
+ #: includes/class-wc-gateway-stripe.php:385
115
  #: includes/legacy/class-wc-gateway-stripe.php:165
116
  #, php-format
117
  msgid ""
120
  "has a valid SSL certificate - Stripe will only work in test mode."
121
  msgstr ""
122
 
123
+ #: includes/class-wc-gateway-stripe.php:434
124
  msgid "Add Card"
125
  msgstr ""
126
 
127
+ #: includes/class-wc-gateway-stripe.php:481
128
  msgid "The card number is not a valid credit card number."
129
  msgstr ""
130
 
131
+ #: includes/class-wc-gateway-stripe.php:482
132
  msgid "The card's expiration month is invalid."
133
  msgstr ""
134
 
135
+ #: includes/class-wc-gateway-stripe.php:483
136
  msgid "The card's expiration year is invalid."
137
  msgstr ""
138
 
139
+ #: includes/class-wc-gateway-stripe.php:484
140
  msgid "The card's security code is invalid."
141
  msgstr ""
142
 
143
+ #: includes/class-wc-gateway-stripe.php:485
144
  msgid "The card number is incorrect."
145
  msgstr ""
146
 
147
+ #: includes/class-wc-gateway-stripe.php:486
148
  msgid "The card has expired."
149
  msgstr ""
150
 
151
+ #: includes/class-wc-gateway-stripe.php:487
152
  msgid "The card's security code is incorrect."
153
  msgstr ""
154
 
155
+ #: includes/class-wc-gateway-stripe.php:488
156
  msgid "The card's zip code failed validation."
157
  msgstr ""
158
 
159
+ #: includes/class-wc-gateway-stripe.php:489
160
  msgid "The card was declined."
161
  msgstr ""
162
 
163
+ #: includes/class-wc-gateway-stripe.php:490
164
  msgid "There is no card on a customer that is being charged."
165
  msgstr ""
166
 
167
+ #: includes/class-wc-gateway-stripe.php:491
168
  msgid "An error occurred while processing the card."
169
  msgstr ""
170
 
171
+ #: includes/class-wc-gateway-stripe.php:492
172
  msgid "Could not find payment information."
173
  msgstr ""
174
 
175
+ #: includes/class-wc-gateway-stripe.php:513
176
  msgid ""
177
  "This is not a valid live key. Live keys start with \"sk_live_\" and "
178
  "\"pk_live_\"."
179
  msgstr ""
180
 
181
+ #: includes/class-wc-gateway-stripe.php:514
182
  msgid ""
183
  "This is not a valid test key. Test keys start with \"sk_test_\" and "
184
  "\"pk_test_\"."
185
  msgstr ""
186
 
187
+ #: includes/class-wc-gateway-stripe.php:515
188
  msgid "Re-verify Domain"
189
  msgstr ""
190
 
191
+ #: includes/class-wc-gateway-stripe.php:516
192
  msgid "Missing Secret Key. Please set the secret key field above and re-try."
193
  msgstr ""
194
 
195
+ #: includes/class-wc-gateway-stripe.php:551
196
  #: includes/legacy/class-wc-gateway-stripe.php:296
197
  msgid "Please accept the terms and conditions first"
198
  msgstr ""
199
 
200
+ #: includes/class-wc-gateway-stripe.php:552
201
  #: includes/legacy/class-wc-gateway-stripe.php:297
202
  msgid "Please fill in required checkout fields first"
203
  msgstr ""
204
 
205
+ #: includes/class-wc-gateway-stripe.php:570
206
  #: includes/class-wc-stripe-payment-request.php:95
207
  msgid "Sorry, we're not accepting prepaid cards at this time."
208
  msgstr ""
209
 
210
+ #: includes/class-wc-gateway-stripe.php:590
211
+ #: includes/class-wc-stripe-apple-pay.php:738
212
  #, php-format
213
  msgid "%1$s - Order %2$s"
214
  msgstr ""
215
 
216
+ #: includes/class-wc-gateway-stripe.php:604
217
  msgid "Customer Name"
218
  msgstr ""
219
 
220
+ #: includes/class-wc-gateway-stripe.php:605
221
  msgid "Customer Email"
222
  msgstr ""
223
 
224
+ #: includes/class-wc-gateway-stripe.php:668
225
  msgid "Invalid payment method. Please input a new card number."
226
  msgstr ""
227
 
228
+ #: includes/class-wc-gateway-stripe.php:733
229
  #: includes/legacy/class-wc-gateway-stripe.php:434
230
  msgid "Please enter your card details to make a payment."
231
  msgstr ""
232
 
233
+ #: includes/class-wc-gateway-stripe.php:734
234
  #: includes/legacy/class-wc-gateway-stripe.php:435
235
  msgid ""
236
  "Developers: Please make sure that you are including jQuery and there are no "
237
  "JavaScript errors on the page."
238
  msgstr ""
239
 
240
+ #: includes/class-wc-gateway-stripe.php:762
241
  msgid "This card is no longer available and has been removed."
242
  msgstr ""
243
 
244
+ #: includes/class-wc-gateway-stripe.php:853 woocommerce-gateway-stripe.php:470
245
  #, php-format
246
  msgid "Stripe charge complete (Charge ID: %s)"
247
  msgstr ""
248
 
249
+ #: includes/class-wc-gateway-stripe.php:864
250
  #: includes/legacy/class-wc-gateway-stripe.php:526
251
  #, php-format
252
  msgid ""
254
  "cancel to remove the pre-authorization."
255
  msgstr ""
256
 
257
+ #: includes/class-wc-gateway-stripe.php:878
258
+ #: includes/class-wc-gateway-stripe.php:887
259
  #: includes/legacy/class-wc-gateway-stripe.php:540
260
  msgid "There was a problem adding the card."
261
  msgstr ""
262
 
263
+ #: includes/class-wc-gateway-stripe.php:939
264
  #, php-format
265
  msgid "Refunded %1$s - Refund ID: %2$s - Reason: %3$s"
266
  msgstr ""
269
  msgid "There was a problem connecting to the payment gateway."
270
  msgstr ""
271
 
272
+ #: includes/class-wc-stripe-apple-pay.php:192
273
+ #: includes/class-wc-stripe-apple-pay.php:416
274
+ #: includes/class-wc-stripe-apple-pay.php:470
275
+ #: includes/class-wc-stripe-apple-pay.php:559
276
+ #: includes/class-wc-stripe-apple-pay.php:622
277
+ #: includes/class-wc-stripe-apple-pay.php:670
 
 
 
278
  msgid "Cheatin&#8217; huh?"
279
  msgstr ""
280
 
281
+ #: includes/class-wc-stripe-apple-pay.php:265
282
+ #: includes/class-wc-stripe-apple-pay.php:821
283
+ msgid "Sub-Total"
284
  msgstr ""
285
 
286
+ #: includes/class-wc-stripe-apple-pay.php:404
287
+ msgid "Or"
 
288
  msgstr ""
289
 
290
+ #: includes/class-wc-stripe-apple-pay.php:503
291
+ msgid "Please enter a valid postcode/ZIP."
 
 
292
  msgstr ""
293
 
294
  #: includes/class-wc-stripe-apple-pay.php:580
295
+ #: includes/class-wc-stripe-apple-pay.php:603
296
+ msgid "Unable to find shipping method for address."
297
  msgstr ""
298
 
299
+ #: includes/class-wc-stripe-apple-pay.php:650
300
+ #: includes/class-wc-stripe-apple-pay.php:835
301
+ #: includes/class-wc-stripe-payment-request.php:348
302
+ msgid "Tax"
303
  msgstr ""
304
 
305
+ #: includes/class-wc-stripe-apple-pay.php:843
306
  msgid "Shipping"
307
  msgstr ""
308
 
309
+ #: includes/class-wc-stripe-apple-pay.php:851
310
  msgid "Discount"
311
  msgstr ""
312
 
313
+ #: includes/class-wc-stripe-apple-pay.php:869
314
+ #: includes/class-wc-stripe-apple-pay.php:876
315
+ #: includes/class-wc-stripe-apple-pay.php:878
316
+ #: includes/class-wc-stripe-apple-pay.php:901
317
+ #: includes/class-wc-stripe-apple-pay.php:933
318
+ #: includes/class-wc-stripe-apple-pay.php:965
319
+ #: includes/class-wc-stripe-apple-pay.php:989
320
  #, php-format
321
  msgid "Error %d: Unable to create order. Please try again."
322
  msgstr ""
545
  msgstr ""
546
 
547
  #: includes/settings-stripe.php:89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  msgid "Stripe Checkout locale"
549
  msgstr ""
550
 
551
+ #: includes/settings-stripe.php:92
552
  msgid ""
553
  "Language to display in Stripe Checkout modal. Specify Auto to display "
554
  "Checkout in the user's preferred language, if available. English will be "
555
  "used by default."
556
  msgstr ""
557
 
558
+ #: includes/settings-stripe.php:96
559
  msgid "Auto"
560
  msgstr ""
561
 
562
+ #: includes/settings-stripe.php:97
563
  msgid "Simplified Chinese"
564
  msgstr ""
565
 
566
+ #: includes/settings-stripe.php:98
567
  msgid "Danish"
568
  msgstr ""
569
 
570
+ #: includes/settings-stripe.php:99
571
  msgid "Dutch"
572
  msgstr ""
573
 
574
+ #: includes/settings-stripe.php:100
575
  msgid "English"
576
  msgstr ""
577
 
578
+ #: includes/settings-stripe.php:101
579
  msgid "Finnish"
580
  msgstr ""
581
 
582
+ #: includes/settings-stripe.php:102
583
  msgid "French"
584
  msgstr ""
585
 
586
+ #: includes/settings-stripe.php:103
587
  msgid "German"
588
  msgstr ""
589
 
590
+ #: includes/settings-stripe.php:104
591
  msgid "Italian"
592
  msgstr ""
593
 
594
+ #: includes/settings-stripe.php:105
595
  msgid "Japanese"
596
  msgstr ""
597
 
598
+ #: includes/settings-stripe.php:106
599
  msgid "Norwegian"
600
  msgstr ""
601
 
602
+ #: includes/settings-stripe.php:107
603
  msgid "Spanish"
604
  msgstr ""
605
 
606
+ #: includes/settings-stripe.php:108
607
  msgid "Swedish"
608
  msgstr ""
609
 
610
+ #: includes/settings-stripe.php:112
611
  msgid "Bitcoin Currency"
612
  msgstr ""
613
 
614
+ #: includes/settings-stripe.php:113
615
  msgid "Enable Bitcoin Currency"
616
  msgstr ""
617
 
618
+ #: includes/settings-stripe.php:115
619
  msgid ""
620
  "If enabled, an option to accept bitcoin will show on the checkout modal. "
621
  "Note: Stripe Checkout needs to be enabled and store currency must be set to "
622
  "USD."
623
  msgstr ""
624
 
625
+ #: includes/settings-stripe.php:120
626
  msgid "Stripe Checkout Image"
627
  msgstr ""
628
 
629
+ #: includes/settings-stripe.php:121
630
  msgid ""
631
  "Optionally enter the URL to a 128x128px image of your brand or product. e.g. "
632
  "<code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>"
633
  msgstr ""
634
 
635
+ #: includes/settings-stripe.php:127
636
  msgid "Payment Request API"
637
  msgstr ""
638
 
639
+ #: includes/settings-stripe.php:128
640
  msgid "Enable Payment Request API"
641
  msgstr ""
642
 
643
+ #: includes/settings-stripe.php:130
644
  msgid ""
645
  "If enabled, users will be able to pay using the Payment Request API if "
646
  "supported by the browser."
647
  msgstr ""
648
 
649
+ #: includes/settings-stripe.php:135
650
  msgid "Apple Pay"
651
  msgstr ""
652
 
653
+ #: includes/settings-stripe.php:136
654
  #, php-format
655
  msgid ""
656
  "Enable Apple Pay. %1$sBy using Apple Pay, you agree to %2$s and %3$s's terms "
657
  "of service."
658
  msgstr ""
659
 
660
+ #: includes/settings-stripe.php:138
661
  msgid "If enabled, users will be able to pay with Apple Pay."
662
  msgstr ""
663
 
664
+ #: includes/settings-stripe.php:143
665
  msgid "Apple Pay Button Style"
666
  msgstr ""
667
 
668
+ #: includes/settings-stripe.php:144
669
  msgid "Button Style"
670
  msgstr ""
671
 
672
+ #: includes/settings-stripe.php:146
673
  msgid "Select the button style you would like to show."
674
  msgstr ""
675
 
676
+ #: includes/settings-stripe.php:150
677
  msgid "Black"
678
  msgstr ""
679
 
680
+ #: includes/settings-stripe.php:151
681
  msgid "White"
682
  msgstr ""
683
 
684
+ #: includes/settings-stripe.php:155
685
  msgid "Apple Pay Button Language"
686
  msgstr ""
687
 
688
+ #: includes/settings-stripe.php:156
689
  msgid ""
690
  "Enter the 2 letter ISO code for the language you would like your Apple Pay "
691
  "Button to display in. Reference available ISO codes here <code>http://www."
692
  "w3schools.com/tags/ref_language_codes.asp</code>"
693
  msgstr ""
694
 
695
+ #: includes/settings-stripe.php:162
696
  msgid "Saved Cards"
697
  msgstr ""
698
 
699
+ #: includes/settings-stripe.php:163
700
  msgid "Enable Payment via Saved Cards"
701
  msgstr ""
702
 
703
+ #: includes/settings-stripe.php:165
704
  msgid ""
705
  "If enabled, users will be able to pay with a saved card during checkout. "
706
  "Card details are saved on Stripe servers, not on your store."
707
  msgstr ""
708
 
709
+ #: includes/settings-stripe.php:170
710
  msgid "Logging"
711
  msgstr ""
712
 
713
+ #: includes/settings-stripe.php:171
714
  msgid "Log debug messages"
715
  msgstr ""
716
 
717
+ #: includes/settings-stripe.php:173
718
  msgid "Save debug messages to the WooCommerce System Status log."
719
  msgstr ""
720
 
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.3
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -95,6 +95,16 @@ If you get stuck, you can ask for help in the Plugin Forum.
95
 
96
  == Changelog ==
97
 
 
 
 
 
 
 
 
 
 
 
98
  = 3.1.3 =
99
  * Fix - When using Stripe Checkout, add payment method was disabled.
100
  * Fix - Possible non object type when using preview pages.
@@ -157,6 +167,12 @@ If you get stuck, you can ask for help in the Plugin Forum.
157
 
158
  == Upgrade Notice ==
159
 
160
- = 3.1.3 =
161
- * Fix - When using Stripe Checkout, add payment method was disabled.
162
- * Fix - Possible non object type when using preview pages.
 
 
 
 
 
 
3
  Tags: credit card, stripe, woocommerce
4
  Requires at least: 4.4
5
  Tested up to: 4.7.2
6
+ Stable tag: 3.1.4
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
95
 
96
  == Changelog ==
97
 
98
+ = 3.1.4 =
99
+ * Tweak - If Apple Pay is not enabled, prevent Apple Pay Init.
100
+ * Fix - Update for WooCommerce 3.0 compatibility.
101
+ * Fix - Apple Pay on product detail page causes qty issue when using normal add to cart.
102
+ * Fix - A partial workaround for UK/CA postal codes issue for shipping methods that support partial postal code estimates.
103
+ * Fix - Stripe checkout did not validate properly formatted email address.
104
+ * Fix - Error messages were not able to translate when validating checkout form.
105
+ * Fix - Prevent payment gateway title logic ( Apple Pay ) from hijacking other payment methods.
106
+ * Remove - Stripe Checkout allow remember me setting as it is redundant to saved card setting.
107
+
108
  = 3.1.3 =
109
  * Fix - When using Stripe Checkout, add payment method was disabled.
110
  * Fix - Possible non object type when using preview pages.
167
 
168
  == Upgrade Notice ==
169
 
170
+ = 3.1.4 =
171
+ * Tweak - If Apple Pay is not enabled, prevent Apple Pay Init.
172
+ * Fix - Update for WooCommerce 3.0 compatibility.
173
+ * Fix - Apple Pay on product detail page causes qty issue when using normal add to cart.
174
+ * Fix - A partial workaround for UK/CA postal codes issue for shipping methods that support partial postal code estimates.
175
+ * Fix - Stripe checkout did not validate properly formatted email address.
176
+ * Fix - Error messages were not able to translate when validating checkout form.
177
+ * Fix - Prevent payment gateway title logic ( Apple Pay ) from hijacking other payment methods.
178
+ * Remove - Stripe Checkout allow remember me setting as it is redundant to saved card setting.
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.3
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.3' );
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__ );
@@ -269,8 +269,8 @@ if ( ! class_exists( 'WC_Stripe' ) ) :
269
 
270
  $plugin_links = array(
271
  '<a href="' . $setting_link . '">' . __( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
272
- '<a href="https://docs.woothemes.com/document/stripe/">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
273
- '<a href="http://support.woothemes.com/">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
274
  );
275
  return array_merge( $plugin_links, $links );
276
  }
5
  * Description: Take credit card payments on your store using Stripe.
6
  * Author: WooCommerce
7
  * Author URI: https://woocommerce.com/
8
+ * Version: 3.1.4
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.4' );
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__ );
269
 
270
  $plugin_links = array(
271
  '<a href="' . $setting_link . '">' . __( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
272
+ '<a href="https://docs.woocommerce.com/document/stripe/">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
273
+ '<a href="https://woocommerce.com/contact-us/">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
274
  );
275
  return array_merge( $plugin_links, $links );
276
  }