effective_orders 4.5.3 → 4.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/app/assets/javascripts/effective_orders/providers/stripe.js.coffee +3 -1
- data/app/controllers/effective/carts_controller.rb +2 -0
- data/app/controllers/effective/customers_controller.rb +2 -0
- data/app/models/effective/order.rb +15 -7
- data/app/views/effective/orders/stripe/_form.html.haml +1 -1
- data/lib/effective_orders/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe17b4322391ee31880303afd90c92998a86da1cb2cd0fb82fa716783e481635
|
4
|
+
data.tar.gz: d3370f18d4c440ffdde9aa59207f586ba38abcf73e91974ee1e7f8866ba1ab82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00af503a2181c78ad3ac1d587aeda9bbc9b35bafab752cb37f28f5c64c5ba787070b6685bdb455745b16ee33fcd7940e272cdedea8b672188788bd496e21e6aa
|
7
|
+
data.tar.gz: eb5199b72923d9236016e2a81ed0b102d9a28b0112cba3924dc72c1dbaad1d5b1b5cc9c2ea73141af58010ab12d517de3c34b544e46e3c64b5d08c5ea18fa241
|
data/README.md
CHANGED
@@ -828,6 +828,12 @@ effective_orders works around this by appending a timestamp to the order ID.
|
|
828
828
|
|
829
829
|
Make sure `gem 'stripe'` is included in your Gemfile.
|
830
830
|
|
831
|
+
Add to your application layout / header
|
832
|
+
|
833
|
+
```
|
834
|
+
= javascript_include_tag 'https://js.stripe.com/v3/'
|
835
|
+
```
|
836
|
+
|
831
837
|
First register for an account with Stripe
|
832
838
|
|
833
839
|
https://manage.stripe.com/register
|
@@ -1001,4 +1007,3 @@ MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
|
1001
1007
|
4. Push to the branch (`git push origin my-new-feature`)
|
1002
1008
|
5. Bonus points for test coverage
|
1003
1009
|
6. Create new Pull Request
|
1004
|
-
|
@@ -8,7 +8,7 @@ this.StripeForm ||= class StripeForm
|
|
8
8
|
@card = null
|
9
9
|
|
10
10
|
initialize: ->
|
11
|
-
@form = $('form[data-stripe-form]').first()
|
11
|
+
@form = $('form[data-stripe-form]:not(.initialized)').first()
|
12
12
|
return false unless @form.length > 0
|
13
13
|
|
14
14
|
@paymentIntent = @form.find("input[name$='[payment_intent_id]']").first()
|
@@ -17,6 +17,7 @@ this.StripeForm ||= class StripeForm
|
|
17
17
|
@card = @stripe.elements().create('card', @style())
|
18
18
|
|
19
19
|
@mount()
|
20
|
+
@form.addClass('initialized')
|
20
21
|
|
21
22
|
style: ->
|
22
23
|
style: {
|
@@ -75,3 +76,4 @@ this.StripeForm ||= class StripeForm
|
|
75
76
|
EffectiveForm.invalidate(@form);
|
76
77
|
|
77
78
|
$ -> (new StripeForm()).initialize()
|
79
|
+
$(document).on 'turbolinks:load', -> (new StripeForm()).initialize()
|
@@ -2,6 +2,8 @@ module Effective
|
|
2
2
|
class CartsController < ApplicationController
|
3
3
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:carts] : EffectiveOrders.layout)
|
4
4
|
|
5
|
+
before_action :authenticate_user!
|
6
|
+
|
5
7
|
def show
|
6
8
|
@cart = current_cart
|
7
9
|
@pending_orders = Effective::Order.pending.where(user: current_user) if current_user.present?
|
@@ -228,13 +228,13 @@ module Effective
|
|
228
228
|
|
229
229
|
def update_prices!
|
230
230
|
raise('already purchased') if purchased?
|
231
|
-
raise('must be pending') unless pending?
|
231
|
+
raise('must be pending or confirmed') unless pending? || confirmed?
|
232
232
|
|
233
233
|
order_items.each do |item|
|
234
234
|
purchasable = item.purchasable
|
235
235
|
|
236
236
|
if purchasable.blank? || purchasable.marked_for_destruction?
|
237
|
-
item.mark_for_destruction
|
237
|
+
item.mark_for_destruction
|
238
238
|
else
|
239
239
|
item.price = purchasable.price
|
240
240
|
end
|
@@ -382,11 +382,11 @@ module Effective
|
|
382
382
|
|
383
383
|
raise "Failed to purchase order: #{error || errors.full_messages.to_sentence}" unless error.nil?
|
384
384
|
|
385
|
+
run_purchasable_callbacks(:after_purchase)
|
386
|
+
|
385
387
|
send_refund_notification! if email && refund?
|
386
388
|
send_order_receipts! if email
|
387
389
|
|
388
|
-
run_purchasable_callbacks(:after_purchase)
|
389
|
-
|
390
390
|
true
|
391
391
|
end
|
392
392
|
|
@@ -487,13 +487,17 @@ module Effective
|
|
487
487
|
|
488
488
|
def get_tax
|
489
489
|
return nil unless tax_rate.present?
|
490
|
-
|
490
|
+
present_order_items.reject { |oi| oi.tax_exempt? }.map { |oi| (oi.subtotal * (tax_rate / 100.0)).round(0).to_i }.sum
|
491
491
|
end
|
492
492
|
|
493
493
|
private
|
494
494
|
|
495
|
+
def present_order_items
|
496
|
+
order_items.reject { |oi| oi.marked_for_destruction? }
|
497
|
+
end
|
498
|
+
|
495
499
|
def assign_order_totals
|
496
|
-
self.subtotal =
|
500
|
+
self.subtotal = present_order_items.map { |oi| oi.subtotal }.sum
|
497
501
|
self.tax_rate = get_tax_rate() unless (tax_rate || 0) > 0
|
498
502
|
self.tax = get_tax()
|
499
503
|
self.total = subtotal + (tax || 0)
|
@@ -534,7 +538,11 @@ module Effective
|
|
534
538
|
end
|
535
539
|
|
536
540
|
def send_email(email, *mailer_args)
|
537
|
-
|
541
|
+
begin
|
542
|
+
Effective::OrdersMailer.public_send(email, *mailer_args).public_send(EffectiveOrders.mailer[:deliver_method])
|
543
|
+
rescue => e
|
544
|
+
raise if Rails.env.development? || Rails.env.test?
|
545
|
+
end
|
538
546
|
end
|
539
547
|
|
540
548
|
def truthy?(value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.5.
|
4
|
+
version: 4.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|