solidus_stripe 3.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +5 -0
  4. data/CHANGELOG.md +55 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE +2 -2
  7. data/README.md +69 -11
  8. data/Rakefile +1 -1
  9. data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-cart-page-checkout.js +42 -9
  10. data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-elements.js +61 -25
  11. data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-intents.js +4 -2
  12. data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-request-button-shared.js +56 -19
  13. data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment.js +7 -1
  14. data/app/controllers/solidus_stripe/intents_controller.rb +42 -28
  15. data/app/decorators/models/spree/order_update_attributes_decorator.rb +39 -0
  16. data/app/decorators/models/spree/payment_decorator.rb +11 -0
  17. data/app/decorators/models/spree/refund_decorator.rb +9 -0
  18. data/app/models/solidus_stripe/address_from_params_service.rb +5 -2
  19. data/app/models/solidus_stripe/create_intents_payment_service.rb +113 -0
  20. data/app/models/spree/payment_method/stripe_credit_card.rb +19 -9
  21. data/bin/r +13 -0
  22. data/bin/rake +7 -0
  23. data/bin/sandbox +84 -0
  24. data/bin/sandbox_rails +18 -0
  25. data/bin/setup +1 -1
  26. data/config/routes.rb +4 -1
  27. data/lib/generators/solidus_stripe/install/install_generator.rb +7 -3
  28. data/lib/solidus_stripe/engine.rb +2 -2
  29. data/lib/solidus_stripe/factories.rb +4 -0
  30. data/lib/solidus_stripe/version.rb +1 -1
  31. data/lib/views/frontend/spree/checkout/payment/v3/_form_elements.html.erb +0 -1
  32. data/solidus_stripe.gemspec +34 -37
  33. data/spec/features/stripe_checkout_spec.rb +159 -64
  34. data/spec/models/solidus_stripe/address_from_params_service_spec.rb +19 -5
  35. data/spec/models/solidus_stripe/create_intents_payment_service_spec.rb +127 -0
  36. data/spec/models/spree/payment_method/stripe_credit_card_spec.rb +44 -1
  37. data/spec/spec_helper.rb +4 -1
  38. metadata +22 -12
  39. data/LICENSE.md +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9e6ec7ddfb05d802b145edb2e2e50d58510148be740c085dd0a7eb99a8e367b
4
- data.tar.gz: c6598070cbe6c6e18504f27ab999ef0ca6d1b331ecdee9e1838434c261fe699d
3
+ metadata.gz: c27f15c92bf2fcee8f467f66e8c1c261baf7d0909f86e7df87e8ce9547cc2951
4
+ data.tar.gz: b6ae23186cd51fc4b7938081d26df066a1b45903a3fcbb29db39d83106e520e4
5
5
  SHA512:
6
- metadata.gz: 8faba0fdc2be35b90a936273a8d3aedf2411a10e8c01489c5a66b5859fbbcccb38ffcfec3e9d2a34dcdbf065228396b3047210cdbcbb0818c495ff2abf76f098
7
- data.tar.gz: 82f01e68ff9a5fa8bcc74c759c3974d78cf05411b83cb732ca0ef32553d62d920697093db371a174c826d3391ca19908f0e4a35a4ae152863c61a94ae595f2c4
6
+ metadata.gz: 799216217f0bf2353e94c598dc9e49187c44004f9c25dc254d13a3e5805751e8fddabaf45f83c3cc422ed561b12d0e7260cf4367d71dd614086c4d9f2d2521c6
7
+ data.tar.gz: 322e5c0299a3afc1555057cd10685a1f5c6ad3f446dd592326084be7959e93c009cb092f8d9fe688682527653d7078ec58c49506ba593f4b4b688d8fa81a549e
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ pkg
16
16
  *.swp
17
17
  spec/dummy
18
18
  spec/examples.txt
19
+ /sandbox
@@ -1,2 +1,7 @@
1
1
  require:
2
2
  - solidus_dev_support/rubocop
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - sandbox/**/*
7
+ - spec/dummy/**/*
@@ -1,5 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.0.0](https://github.com/solidusio/solidus_stripe/tree/v4.0.0) (2020-04-29)
4
+
5
+ [Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.0.0...v4.0.0)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Duplicates charges with Payment Intents [\#44](https://github.com/solidusio/solidus_stripe/issues/44)
10
+ - Fix for 3D-Secure payments on cart page checkout [\#49](https://github.com/solidusio/solidus_stripe/pull/49) ([spaghetticode](https://github.com/spaghetticode))
11
+ - Send form data also when paying with payment request button [\#47](https://github.com/solidusio/solidus_stripe/pull/47) ([spaghetticode](https://github.com/spaghetticode))
12
+ - Create a single charge when using Stripe Payment Intents [\#45](https://github.com/solidusio/solidus_stripe/pull/45) ([spaghetticode](https://github.com/spaghetticode))
13
+
14
+ **Closed issues:**
15
+
16
+ - Custom stripe element field options \(e.g for showing a credit card icon\) [\#41](https://github.com/solidusio/solidus_stripe/issues/41)
17
+ - Stripe Elements submit button stuck in disabled state. [\#39](https://github.com/solidusio/solidus_stripe/issues/39)
18
+ - Visa credit card type is blank [\#36](https://github.com/solidusio/solidus_stripe/issues/36)
19
+ - Pay with Apple Pay from cart page [\#23](https://github.com/solidusio/solidus_stripe/issues/23)
20
+ - Clearer documentation on how to implement [\#15](https://github.com/solidusio/solidus_stripe/issues/15)
21
+
22
+ **Merged pull requests:**
23
+
24
+ - Relax solidus\_support dependency [\#48](https://github.com/solidusio/solidus_stripe/pull/48) ([kennyadsl](https://github.com/kennyadsl))
25
+ - Replace deprecated route `/stripe/confirm\_payment` [\#46](https://github.com/solidusio/solidus_stripe/pull/46) ([spaghetticode](https://github.com/spaghetticode))
26
+ - Custom Stripe Elements field options [\#42](https://github.com/solidusio/solidus_stripe/pull/42) ([stuffmatic](https://github.com/stuffmatic))
27
+ - Improve the way Stripe Elements validation errors are displayed [\#40](https://github.com/solidusio/solidus_stripe/pull/40) ([stuffmatic](https://github.com/stuffmatic))
28
+ - Fix stripe-to-solidus card type mapping [\#38](https://github.com/solidusio/solidus_stripe/pull/38) ([stuffmatic](https://github.com/stuffmatic))
29
+ - Add hook to provide custom Stripe Elements options [\#37](https://github.com/solidusio/solidus_stripe/pull/37) ([stuffmatic](https://github.com/stuffmatic))
30
+ - Change order description that we pass to Stripe [\#35](https://github.com/solidusio/solidus_stripe/pull/35) ([kennyadsl](https://github.com/kennyadsl))
31
+
32
+ ## [v3.0.0](https://github.com/solidusio/solidus_stripe/tree/v3.0.0) (2020-03-11)
33
+
34
+ [Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v2.1.0...v3.0.0)
35
+
36
+ **Implemented enhancements:**
37
+
38
+ - Rename v3/stripe partial as v3/elements [\#30](https://github.com/solidusio/solidus_stripe/pull/30) ([spaghetticode](https://github.com/spaghetticode))
39
+
40
+ **Merged pull requests:**
41
+
42
+ - Allow to customize Stripe Elements styles via JS [\#34](https://github.com/solidusio/solidus_stripe/pull/34) ([spaghetticode](https://github.com/spaghetticode))
43
+ - Stop injecting css in host app while installing [\#33](https://github.com/solidusio/solidus_stripe/pull/33) ([kennyadsl](https://github.com/kennyadsl))
44
+ - Manage Stripe V3 JS code via Sprokets [\#32](https://github.com/solidusio/solidus_stripe/pull/32) ([spaghetticode](https://github.com/spaghetticode))
45
+
46
+ ## [v2.1.0](https://github.com/solidusio/solidus_stripe/tree/v2.1.0) (2020-03-11)
47
+
48
+ [Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v2.0.0...v2.1.0)
49
+
50
+ **Closed issues:**
51
+
52
+ - Preference :stripe\_country is not defined on Spree::PaymentMethod::StripeCreditCard \(RuntimeError\) [\#27](https://github.com/solidusio/solidus_stripe/issues/27)
53
+
54
+ **Merged pull requests:**
55
+
56
+ - Refactor Stripe V3 Intents, Elements and cart checkout JS code [\#31](https://github.com/solidusio/solidus_stripe/pull/31) ([spaghetticode](https://github.com/spaghetticode))
57
+
3
58
  ## [v2.0.0](https://github.com/solidusio/solidus_stripe/tree/v2.0.0) (2020-03-03)
4
59
 
5
60
  [Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v1.2.0...v2.0.0)
data/Gemfile CHANGED
@@ -30,3 +30,10 @@ group :development, :test do
30
30
  end
31
31
 
32
32
  gemspec
33
+
34
+ # Use a local Gemfile to include development dependencies that might not be
35
+ # relevant for the project or for other contributors, e.g. pry-byebug.
36
+ #
37
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
38
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
39
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 Solidus Team
1
+ Copyright (c) 2014 Spree Commerce Inc. and other contributors.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
@@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
9
9
  * Redistributions in binary form must reproduce the above copyright notice,
10
10
  this list of conditions and the following disclaimer in the documentation
11
11
  and/or other materials provided with the distribution.
12
- * Neither the name Solidus nor the names of its contributors may be used to
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
13
  endorse or promote products derived from this software without specific
14
14
  prior written permission.
15
15
 
data/README.md CHANGED
@@ -13,7 +13,7 @@ Installation
13
13
  In your Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'solidus_stripe', '~> 1.0.0'
16
+ gem 'solidus_stripe', '~> 3.0'
17
17
  ```
18
18
 
19
19
  Then run from the command line:
@@ -107,6 +107,25 @@ Spree.config do |config|
107
107
  end
108
108
  ```
109
109
 
110
+ When using the Payment Intents API, be aware that the charge flow will be a bit
111
+ different than when using the old V2 API or Elements. It's advisable that all
112
+ Payment Intents charges are captured only by using the Solidus backend, as it is
113
+ the final source of truth in regards of Solidus orders payments.
114
+
115
+ A Payment Intent is created as soon as the customer enters their credit card
116
+ data. A tentative charge will be created on Stripe, easily recognizable by its
117
+ description: `Solidus Order ID: R987654321 (pending)`. As soon as the credit
118
+ card is confirmed (ie. when the customer passes the 3DSecure authorization, when
119
+ required) then the charge description gets updated to include the Solidus payment
120
+ number: `Solidus Order ID: R987654321-Z4VYUDB3`.
121
+
122
+ These charges are created `uncaptured` and will need to be captured in Solidus
123
+ backend later, after the customer confirms the order. If the customer never
124
+ completes the checkout, that charge must remain uncaptured. If the customer
125
+ decides to change their payment method after creating a Payment Request, then
126
+ that Payment Request charge will be canceled.
127
+
128
+
110
129
  Apple Pay and Google Pay
111
130
  -----------------------
112
131
 
@@ -119,14 +138,11 @@ Stripe account to receive payments via Apple Pay.
119
138
  It's possible to pay with Apple Pay and Google Pay directly from the cart
120
139
  page. The functionality is self-contained in the view partial
121
140
  `_stripe_payment_request_button.html.erb`. In order to use it, you need
122
- to load that partial in the `orders#edit` frontend page, and pass it the
141
+ to render that partial in the `orders#edit` frontend page, and pass it the
123
142
  payment method configured for Stripe via the local variable
124
- `cart_checkout_payment_method`, for example using `deface`:
143
+ `cart_checkout_payment_method`:
125
144
 
126
145
  ```ruby
127
- # app/overrides/spree/orders/edit/add_payment_request_button.html.erb.deface
128
-
129
- <!-- insert_after '[data-hook="cart_container"]' -->
130
146
  <%= render 'stripe_payment_request_button', cart_checkout_payment_method: Spree::PaymentMethod::StripeCreditCard.first %>
131
147
  ```
132
148
 
@@ -155,13 +171,13 @@ SolidusStripe.CartPageCheckout.prototype.onPrButtonMounted = function(id, result
155
171
  }
156
172
  ```
157
173
 
158
- Styling Stripe Elements
174
+ Customizing Stripe Elements
159
175
  -----------------------
160
176
 
161
- The Elements feature built in this gem come with some standard styles. If you want
162
- to customize it, you can override the `SolidusStripe.Elements.prototype.baseStyle`
163
- method and make it return a valid [Stripe Style](https://stripe.com/docs/js/appendix/style)
164
- object:
177
+ ### Styling input fields
178
+
179
+ The default style this gem provides for Stripe Elements input fields is defined in `SolidusStripe.Elements.prototype.baseStyle`. You can override this method to return your own custom style (make sure it returns a valid [Stripe Style](https://stripe.com/docs/js/appendix/style)
180
+ object):
165
181
 
166
182
  ```js
167
183
  SolidusStripe.Elements.prototype.baseStyle = function () {
@@ -208,6 +224,46 @@ You can also style your element containers directly by using CSS rules like this
208
224
  }
209
225
  ```
210
226
 
227
+ ### Customizing individual input fields
228
+
229
+ If you want to customize individual input fields, you can override these methods
230
+
231
+ * `SolidusStripe.Elements.prototype.cardNumberElementOptions`
232
+ * `SolidusStripe.Elements.prototype.cardExpiryElementOptions`
233
+ * `SolidusStripe.Elements.prototype.cardCvcElementOptions`
234
+
235
+ and return a valid [options object](https://stripe.com/docs/js/elements_object/create_element?type=cardNumber) for the corresponding field type. For example, this code sets a custom placeholder and enables the credit card icon for the card number field
236
+
237
+ ```js
238
+ SolidusStripe.Elements.prototype.cardNumberElementOptions = function () {
239
+ return {
240
+ style: this.baseStyle(),
241
+ showIcon: true,
242
+ placeholder: "I'm a custom placeholder!"
243
+ }
244
+ }
245
+ ```
246
+
247
+ ### Passing options to the Stripe Elements instance
248
+
249
+ By overriding the `SolidusStripe.Payment.prototype.elementsBaseOptions` method and returning a [valid options object](https://stripe.com/docs/js/elements_object/create), you can pass custom options to the Stripe Elements instance.
250
+
251
+ Note that in order to use web fonts with Stripe Elements, you must specify the fonts when creating the Stripe Elements instance. Here's an example specifying a custom web font and locale:
252
+
253
+ ```js
254
+ SolidusStripe.Payment.prototype.elementsBaseOptions = function () {
255
+ return {
256
+ locale: 'de',
257
+ fonts: [
258
+ {
259
+ cssSrc: 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600'
260
+ }
261
+ ]
262
+ };
263
+ };
264
+ ```
265
+
266
+
211
267
  Migrating from solidus_gateway
212
268
  ------------------------------
213
269
 
@@ -254,3 +310,5 @@ gem bump --version minor --remote upstream
254
310
  gem tag --remote upstream
255
311
  gem release
256
312
  ```
313
+
314
+ Copyright (c) 2020 Spree Commerce Inc., released under the New BSD License
data/Rakefile CHANGED
@@ -3,4 +3,4 @@
3
3
  require 'solidus_dev_support/rake_tasks'
4
4
  SolidusDevSupport::RakeTasks.install
5
5
 
6
- task default: %w[extension:test_app extension:specs]
6
+ task default: 'extension:specs'
@@ -16,11 +16,14 @@ SolidusStripe.CartPageCheckout.prototype.init = function() {
16
16
  };
17
17
 
18
18
  SolidusStripe.CartPageCheckout.prototype.showError = function(error) {
19
- this.errorElement.text(error).show();
19
+ var message = error.message || error;
20
+
21
+ this.errorElement.text(message).show();
20
22
  };
21
23
 
22
24
  SolidusStripe.CartPageCheckout.prototype.submitPayment = function(payment) {
23
25
  var showError = this.showError.bind(this);
26
+ var prTokenHandler = this.prTokenHandler.bind(this);
24
27
 
25
28
  $.ajax({
26
29
  url: $('[data-submit-url]').data('submit-url'),
@@ -29,7 +32,7 @@ SolidusStripe.CartPageCheckout.prototype.submitPayment = function(payment) {
29
32
  },
30
33
  type: 'PATCH',
31
34
  contentType: 'application/json',
32
- data: JSON.stringify(this.prTokenHandler(payment.paymentMethod)),
35
+ data: JSON.stringify(prTokenHandler(payment.paymentMethod)),
33
36
  success: function() {
34
37
  window.location = $('[data-complete-url]').data('complete-url');
35
38
  },
@@ -39,26 +42,56 @@ SolidusStripe.CartPageCheckout.prototype.submitPayment = function(payment) {
39
42
  });
40
43
  };
41
44
 
42
- SolidusStripe.CartPageCheckout.prototype.onPrPayment = function(result) {
43
- var handleServerResponse = this.handleServerResponse.bind(this);
45
+ SolidusStripe.CartPageCheckout.prototype.onPrPayment = function(payment) {
46
+ var createIntent = this.createIntent.bind(this);
44
47
 
45
48
  fetch('/stripe/update_order', {
46
49
  method: 'POST',
47
50
  headers: { 'Content-Type': 'application/json' },
48
51
  body: JSON.stringify({
49
- shipping_address: result.shippingAddress,
50
- shipping_option: result.shippingOption,
51
- email: result.payerEmail,
52
- name: result.payerName,
52
+ shipping_address: payment.shippingAddress,
53
+ shipping_option: payment.shippingOption,
54
+ email: payment.payerEmail,
55
+ name: payment.payerName,
53
56
  authenticity_token: this.authToken
54
57
  })
55
58
  }).then(function(response) {
56
59
  response.json().then(function(json) {
57
- handleServerResponse(json, result);
60
+ createIntent(json, payment);
58
61
  })
59
62
  });
60
63
  };
61
64
 
65
+ SolidusStripe.CartPageCheckout.prototype.createIntent = function(result, payment) {
66
+ var handleServerResponse = this.handleServerResponse.bind(this);
67
+
68
+ if (result.error) {
69
+ this.completePaymentRequest(payment, 'fail');
70
+ this.showError(result.error);
71
+ } else {
72
+ if (payment.error) {
73
+ this.showError(payment.error.message);
74
+ } else {
75
+ fetch('/stripe/create_intent', {
76
+ method: 'POST',
77
+ headers: {
78
+ 'Content-Type': 'application/json'
79
+ },
80
+ body: JSON.stringify({
81
+ form_data: payment.shippingAddress,
82
+ spree_payment_method_id: this.config.id,
83
+ stripe_payment_method_id: payment.paymentMethod.id,
84
+ authenticity_token: this.authToken
85
+ })
86
+ }).then(function(response) {
87
+ response.json().then(function(result) {
88
+ handleServerResponse(result, payment)
89
+ })
90
+ });
91
+ }
92
+ }
93
+ };
94
+
62
95
  SolidusStripe.CartPageCheckout.prototype.onPrButtonMounted = function(buttonId, success) {
63
96
  var container = document.getElementById(buttonId).parentElement;
64
97
 
@@ -18,29 +18,45 @@ SolidusStripe.Elements.prototype.init = function() {
18
18
  };
19
19
 
20
20
  SolidusStripe.Elements.prototype.initElements = function() {
21
- var buildElements = function(elements) {
22
- var style = this.baseStyle();
21
+ var cardExpiry = this.elements.create('cardExpiry', this.cardExpiryElementOptions());
22
+ cardExpiry.mount('#card_expiry');
23
23
 
24
- elements.create('cardExpiry', {style: style}).mount('#card_expiry');
25
- elements.create('cardCvc', {style: style}).mount('#card_cvc');
24
+ var cardCvc = this.elements.create('cardCvc', this.cardCvcElementOptions());
25
+ cardCvc.mount('#card_cvc');
26
26
 
27
- var cardNumber = elements.create('cardNumber', {style: style});
28
- cardNumber.mount('#card_number');
27
+ this.cardNumber = this.elements.create('cardNumber', this.cardNumberElementOptions());
28
+ this.cardNumber.mount('#card_number');
29
29
 
30
- return cardNumber;
31
- }.bind(this);
32
-
33
- this.cardNumber = buildElements(this.elements);
34
-
35
- var cardChange = function(event) {
36
- if (event.error) {
37
- this.showError(event.error.message);
38
- } else {
39
- this.errorElement.hide().text('');
40
- }
41
- };
42
- this.cardNumber.addEventListener('change', cardChange.bind(this));
43
30
  this.form.bind('submit', this.onFormSubmit.bind(this));
31
+
32
+ // Listen for errors from each input field.
33
+ // Adapted from https://github.com/stripe/elements-examples/blob/master/js/index.js
34
+ var savedErrors = {};
35
+ [cardExpiry, cardCvc, this.cardNumber].forEach(function(element, idx) {
36
+ element.on('change', function(event) {
37
+ if (event.error) {
38
+ savedErrors[idx] = event.error.message;
39
+ this.showError(event.error.message);
40
+ } else {
41
+ savedErrors[idx] = null;
42
+
43
+ // Loop over the saved errors and find the first one, if any.
44
+ var nextError = Object.keys(savedErrors)
45
+ .sort()
46
+ .reduce(function(maybeFoundError, key) {
47
+ return maybeFoundError || savedErrors[key];
48
+ }, null);
49
+
50
+ if (nextError) {
51
+ // Now that they've fixed the current error, show another one.
52
+ this.showError(nextError);
53
+ } else {
54
+ // The user fixed the last error; no more errors.
55
+ this.errorElement.hide().text('');
56
+ }
57
+ }
58
+ }.bind(this));
59
+ }.bind(this));
44
60
  };
45
61
 
46
62
  SolidusStripe.Elements.prototype.baseStyle = function () {
@@ -61,6 +77,24 @@ SolidusStripe.Elements.prototype.baseStyle = function () {
61
77
  };
62
78
  };
63
79
 
80
+ SolidusStripe.Elements.prototype.cardNumberElementOptions = function () {
81
+ return {
82
+ style: this.baseStyle()
83
+ }
84
+ }
85
+
86
+ SolidusStripe.Elements.prototype.cardExpiryElementOptions = function () {
87
+ return {
88
+ style: this.baseStyle()
89
+ }
90
+ }
91
+
92
+ SolidusStripe.Elements.prototype.cardCvcElementOptions = function () {
93
+ return {
94
+ style: this.baseStyle()
95
+ }
96
+ }
97
+
64
98
  SolidusStripe.Elements.prototype.showError = function(error) {
65
99
  var message = error.message || error;
66
100
 
@@ -87,18 +121,20 @@ SolidusStripe.Elements.prototype.onFormSubmit = function(event) {
87
121
 
88
122
  SolidusStripe.Elements.prototype.elementsTokenHandler = function(token) {
89
123
  var mapCC = function(ccType) {
90
- if (ccType === 'MasterCard') {
124
+ if (ccType === 'MasterCard' || ccType === 'mastercard') {
91
125
  return 'mastercard';
92
- } else if (ccType === 'Visa') {
126
+ } else if (ccType === 'Visa' || ccType === 'visa') {
93
127
  return 'visa';
94
- } else if (ccType === 'American Express') {
128
+ } else if (ccType === 'American Express' || ccType === 'amex') {
95
129
  return 'amex';
96
- } else if (ccType === 'Discover') {
130
+ } else if (ccType === 'Discover' || ccType === 'discover') {
97
131
  return 'discover';
98
- } else if (ccType === 'Diners Club') {
132
+ } else if (ccType === 'Diners Club' || ccType === 'diners') {
99
133
  return 'dinersclub';
100
- } else if (ccType === 'JCB') {
134
+ } else if (ccType === 'JCB' || ccType === 'jcb') {
101
135
  return 'jcb';
136
+ } else if (ccType === 'Unionpay' || ccType === 'unionpay') {
137
+ return 'unionpay';
102
138
  }
103
139
  };
104
140
 
@@ -21,12 +21,13 @@ SolidusStripe.PaymentIntents.prototype.onPrPayment = function(payment) {
21
21
  var that = this;
22
22
 
23
23
  this.elementsTokenHandler(payment.paymentMethod);
24
- fetch('/stripe/confirm_payment', {
24
+ fetch('/stripe/create_intent', {
25
25
  method: 'POST',
26
26
  headers: {
27
27
  'Content-Type': 'application/json'
28
28
  },
29
29
  body: JSON.stringify({
30
+ form_data: this.form.serialize(),
30
31
  spree_payment_method_id: this.config.id,
31
32
  stripe_payment_method_id: payment.paymentMethod.id,
32
33
  authenticity_token: this.authToken
@@ -63,12 +64,13 @@ SolidusStripe.PaymentIntents.prototype.onIntentsPayment = function(payment) {
63
64
  var that = this;
64
65
 
65
66
  this.elementsTokenHandler(payment.paymentMethod);
66
- fetch('/stripe/confirm_intents', {
67
+ fetch('/stripe/create_intent', {
67
68
  method: 'POST',
68
69
  headers: {
69
70
  'Content-Type': 'application/json'
70
71
  },
71
72
  body: JSON.stringify({
73
+ form_data: this.form.serialize(),
72
74
  spree_payment_method_id: this.config.id,
73
75
  stripe_payment_method_id: payment.paymentMethod.id,
74
76
  authenticity_token: this.authToken