solidus_stripe 3.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +58 -2
- data/Gemfile +7 -0
- data/LICENSE +2 -2
- data/README.md +26 -8
- data/Rakefile +1 -1
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-cart-page-checkout.js +42 -9
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-intents.js +3 -2
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-request-button-shared.js +56 -20
- data/app/controllers/solidus_stripe/intents_controller.rb +23 -18
- data/app/decorators/models/spree/refund_decorator.rb +9 -0
- data/app/models/solidus_stripe/address_from_params_service.rb +5 -2
- data/app/models/solidus_stripe/create_intents_payment_service.rb +113 -0
- data/app/models/spree/payment_method/stripe_credit_card.rb +16 -1
- data/bin/r +13 -0
- data/bin/rake +7 -0
- data/bin/sandbox +84 -0
- data/bin/sandbox_rails +18 -0
- data/bin/setup +1 -1
- data/config/routes.rb +4 -1
- data/lib/generators/solidus_stripe/install/install_generator.rb +7 -3
- data/lib/solidus_stripe/engine.rb +2 -2
- data/lib/solidus_stripe/factories.rb +4 -0
- data/lib/solidus_stripe/version.rb +1 -1
- data/lib/views/frontend/spree/checkout/payment/v3/_form_elements.html.erb +0 -1
- data/solidus_stripe.gemspec +34 -37
- data/spec/features/stripe_checkout_spec.rb +101 -48
- data/spec/models/solidus_stripe/address_from_params_service_spec.rb +19 -5
- data/spec/models/solidus_stripe/create_intents_payment_service_spec.rb +127 -0
- data/spec/models/spree/payment_method/stripe_credit_card_spec.rb +44 -1
- data/spec/spec_helper.rb +4 -1
- metadata +23 -16
- data/LICENSE.md +0 -26
- data/app/models/solidus_stripe/create_intents_order_service.rb +0 -70
data/LICENSE.md
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Spree Commerce Inc. and other contributors.
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without modification,
|
5
|
-
are permitted provided that the following conditions are met:
|
6
|
-
|
7
|
-
* Redistributions of source code must retain the above copyright notice,
|
8
|
-
this list of conditions and the following disclaimer.
|
9
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
-
this list of conditions and the following disclaimer in the documentation
|
11
|
-
and/or other materials provided with the distribution.
|
12
|
-
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
-
endorse or promote products derived from this software without specific
|
14
|
-
prior written permission.
|
15
|
-
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidusStripe
|
4
|
-
class CreateIntentsOrderService
|
5
|
-
attr_reader :intent, :stripe, :controller
|
6
|
-
|
7
|
-
delegate :request, :current_order, :params, to: :controller
|
8
|
-
|
9
|
-
def initialize(intent, stripe, controller)
|
10
|
-
@intent, @stripe, @controller = intent, stripe, controller
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
invalidate_previous_payment_intents_payments
|
15
|
-
payment = create_payment
|
16
|
-
description = "Solidus Order ID: #{payment.gateway_order_identifier}"
|
17
|
-
stripe.update_intent(nil, response['id'], nil, description: description)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def invalidate_previous_payment_intents_payments
|
23
|
-
if stripe.v3_intents?
|
24
|
-
current_order.payments.pending.where(payment_method: stripe).each(&:void_transaction!)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def create_payment
|
29
|
-
Spree::OrderUpdateAttributes.new(
|
30
|
-
current_order,
|
31
|
-
payment_params,
|
32
|
-
request_env: request.headers.env
|
33
|
-
).apply
|
34
|
-
|
35
|
-
Spree::Payment.find_by(response_code: response['id']).tap do |payment|
|
36
|
-
payment.update!(state: :pending)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def payment_params
|
41
|
-
card = response['charges']['data'][0]['payment_method_details']['card']
|
42
|
-
address_attributes = form_data['payment_source'][stripe.id.to_s]['address_attributes']
|
43
|
-
|
44
|
-
{
|
45
|
-
payments_attributes: [{
|
46
|
-
payment_method_id: stripe.id,
|
47
|
-
amount: current_order.total,
|
48
|
-
response_code: response['id'],
|
49
|
-
source_attributes: {
|
50
|
-
month: card['exp_month'],
|
51
|
-
year: card['exp_year'],
|
52
|
-
cc_type: card['brand'],
|
53
|
-
gateway_payment_profile_id: response['payment_method'],
|
54
|
-
last_digits: card['last4'],
|
55
|
-
name: current_order.bill_address.full_name,
|
56
|
-
address_attributes: address_attributes
|
57
|
-
}
|
58
|
-
}]
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
62
|
-
def response
|
63
|
-
intent.params
|
64
|
-
end
|
65
|
-
|
66
|
-
def form_data
|
67
|
-
Rack::Utils.parse_nested_query(params[:form_data])
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|