effective_orders 6.6.3 → 6.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02717fdbe9f5c91a4c6331982a1af5dd676fc06ababd575d0df0d8d80d2c5849
4
- data.tar.gz: de81310a27bedc63d827cc0aaaff6073afa5c634136bceabe2ad7e286964b8c3
3
+ metadata.gz: 7b95b58112e836a932ba93507f74ab11a551110d5e656100be363fef929dff4f
4
+ data.tar.gz: baa58804ceab0264a4f87b9c97c1268c90a765d5d1d3bc86e224b6ec2e558982
5
5
  SHA512:
6
- metadata.gz: 8792b83fbfc309b9c351665c8f4a3cf34e3d87014c27465c8211d98ae7e1623b16a34cdea8199fab78647b060e75e38f53b89189d955317188e9a630543015d7
7
- data.tar.gz: a514c76ef7b8ccba74b3ae81bb2da0a9534193044471811d2a09a9ca65b93d6caa86aa57e27cf90f05041b9a6ef9e591b9f6a224c63b5455e4ca3db60bc1d077
6
+ metadata.gz: a4bd65c532f86d5eeb602a4699ff87922f010137825bcfa960f82584f33fd61bb5d7f2db962fdbc93c7044c076597ee677e84b9285909a24d99864f192d8c360
7
+ data.tar.gz: fe9c072ee1aad78d10216fa930faafe7ebd569b21488347c674c9dc34fe590f23352e6a3820701df89d4366b869cc26d007c94bc2155d4bf4bf162bbb6db20e0
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2021 Code and Effect Inc.
1
+ Copyright 2023 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -353,7 +353,7 @@ The permissions you actually want to define for a regular user are as follows (u
353
353
  can [:manage], Effective::Cart, user_id: user.id
354
354
 
355
355
  can [:manage], Effective::Order, user_id: user.id # Orders cannot be deleted
356
- cannot [:edit, :update], Effective::Order, state: 'purchased'
356
+ cannot [:edit, :update], Effective::Order, status: 'purchased'
357
357
 
358
358
  can [:manage], Effective::Subscription, user_id: user.id
359
359
  ```
@@ -46,8 +46,7 @@ module Admin
46
46
 
47
47
  if request.get?
48
48
  @order.assign_confirmed_if_valid!
49
- render(:checkout)
50
- return
49
+ return render(:checkout)
51
50
  end
52
51
 
53
52
  # Otherwise a post
@@ -96,7 +95,7 @@ module Admin
96
95
 
97
96
  @orders.each { |order| order.send_payment_request_to_buyer! }
98
97
  render json: { status: 200, message: "Successfully sent #{@orders.length} payment request emails"}
99
- rescue => e
98
+ rescue Exception => e
100
99
  render json: { status: 500, message: "Bulk send payment request error: #{e.message}" }
101
100
  end
102
101
  end
@@ -33,7 +33,7 @@ module Effective
33
33
  def add_to_cart
34
34
  @purchasable = (add_to_cart_params[:purchasable_type].constantize.find(add_to_cart_params[:purchasable_id].to_i) rescue nil)
35
35
 
36
- EffectiveResources.authorize!(self, :update, current_cart)
36
+ EffectiveResources.authorize!(self, :add_to_cart, current_cart)
37
37
 
38
38
  begin
39
39
  raise "Please select a valid #{add_to_cart_params[:purchasable_type] || 'item' }." unless @purchasable
@@ -42,7 +42,7 @@ module Effective
42
42
  flash[:success] = 'Successfully added item to cart.'
43
43
  rescue EffectiveOrders::SoldOutException
44
44
  flash[:warning] = 'This item is sold out.'
45
- rescue => e
45
+ rescue Exception => e
46
46
  flash[:danger] = 'Unable to add item to cart: ' + e.message
47
47
  end
48
48
 
@@ -52,7 +52,7 @@ module Effective
52
52
  def remove_from_cart
53
53
  @cart_item = current_cart.cart_items.find(remove_from_cart_params[:id])
54
54
 
55
- EffectiveResources.authorize!(self, :update, current_cart)
55
+ EffectiveResources.authorize!(self, :remove_from_cart, current_cart)
56
56
 
57
57
  if @cart_item.destroy
58
58
  flash[:success] = 'Successfully removed item from cart.'
@@ -25,7 +25,7 @@ module Effective
25
25
  def order_deferred(provider:, email: true, deferred_url: nil)
26
26
  @order.defer!(provider: provider, email: email)
27
27
 
28
- Effective::Cart.where(user: @order.user).destroy_all if @order.user.present?
28
+ Effective::Cart.where(user: current_user).destroy_all if current_user.present?
29
29
 
30
30
  if flash[:success].blank?
31
31
  if email
@@ -133,7 +133,7 @@ module Effective
133
133
  end
134
134
 
135
135
  render json: { status: 200, message: "Successfully sent #{@orders.length} receipt emails"}
136
- rescue => e
136
+ rescue Exception => e
137
137
  render json: { status: 500, message: "Bulk send buyer receipt error: #{e.message}" }
138
138
  end
139
139
  end
@@ -20,6 +20,7 @@ module Admin
20
20
  scope :purchased
21
21
 
22
22
  scope :deferred if EffectiveOrders.deferred_providers.present?
23
+ scope :voided
23
24
 
24
25
  scope :pending_refunds if EffectiveOrders.refund && !EffectiveOrders.buyer_purchases_refund?
25
26
  scope :refunds if EffectiveOrders.refund
@@ -40,6 +41,8 @@ module Admin
40
41
  '#' + order.to_param
41
42
  end
42
43
 
44
+ col :status
45
+
43
46
  col :purchased_at do |order|
44
47
  order.purchased_at&.strftime('%F %H:%M') || ('pending refund' if order.pending_refund?) || ("pending #{order.payment_provider}" if order.deferred?) || 'not purchased'
45
48
  end
@@ -24,6 +24,8 @@ class EffectiveOrdersDatatable < Effective::Datatable
24
24
 
25
25
  col :parent, visible: false, search: :string
26
26
 
27
+ col :status
28
+
27
29
  unless attributes[:not_purchased]
28
30
  col :purchased_at do |order|
29
31
  order.purchased_at&.strftime('%F %H:%M') || 'not purchased'
@@ -50,7 +50,7 @@ module EffectiveStripeHelper
50
50
 
51
51
  begin
52
52
  stripe_payment_intent_payload(order, customer)
53
- rescue => e
53
+ rescue Exception => e
54
54
  raise unless Rails.env.development?
55
55
  stripe_payment_intent_payload(order, Effective::Customer.new(user: order.user))
56
56
  end
@@ -30,10 +30,10 @@ module ActsAsPurchasable
30
30
  has_many :order_items, as: :purchasable, class_name: 'Effective::OrderItem'
31
31
  has_many :orders, -> { order(:id) }, through: :order_items, class_name: 'Effective::Order'
32
32
 
33
- has_many :purchased_orders, -> { where(state: EffectiveOrders::PURCHASED).order(:purchased_at) },
33
+ has_many :purchased_orders, -> { where(status: :purchased).order(:purchased_at) },
34
34
  through: :order_items, class_name: 'Effective::Order', source: :order
35
35
 
36
- has_many :deferred_orders, -> { where(state: EffectiveOrders::DEFERRED).order(:created_at) },
36
+ has_many :deferred_orders, -> { where(status: :deferred).order(:created_at) },
37
37
  through: :order_items, class_name: 'Effective::Order', source: :order
38
38
 
39
39
  # Database max integer value is 2147483647. So let's round that down and use a max/min of $20 million (2000000000)
@@ -52,10 +52,8 @@ module ActsAsPurchasable
52
52
  scope :purchased, -> { where.not(purchased_order_id: nil) }
53
53
  scope :not_purchased, -> { where(purchased_order_id: nil) }
54
54
 
55
- # scope :purchased, -> { joins(order_items: :order).where(orders: {state: EffectiveOrders::PURCHASED}).distinct }
56
- # scope :not_purchased, -> { where('id NOT IN (?)', purchased.pluck(:id).presence || [0]) }
57
- scope :purchased_by, lambda { |user| joins(order_items: :order).where(orders: { user_id: user.try(:id), state: EffectiveOrders::PURCHASED }).distinct }
58
- scope :not_purchased_by, lambda { |user| where('id NOT IN (?)', purchased_by(user).pluck(:id).presence || [0]) }
55
+ scope :purchased_by, lambda { |user| joins(order_items: :order).where(orders: { purchased_by: user, status: :purchased }).distinct }
56
+ scope :not_purchased_by, lambda { |user| where.not(id: purchased_by(user)) }
59
57
  end
60
58
 
61
59
  module ClassMethods
@@ -110,7 +108,7 @@ module ActsAsPurchasable
110
108
  end
111
109
 
112
110
  def purchased_by?(user)
113
- purchased_orders.any? { |order| order.user_id == user.id }
111
+ purchased_orders.any? { |order| order.purchased_by_id == user.id }
114
112
  end
115
113
 
116
114
  def purchased_download_url # Override me if this is a digital purchase.
@@ -1,24 +1,41 @@
1
- # When an Order is first initialized it is done in the pending state
2
- # - when it's in the pending state, none of the buyer entered information is required
1
+ # When an Order is first initialized it is done in the pending status
2
+ # - when it's in the pending status, none of the buyer entered information is required
3
3
  # - when a pending order is rendered:
4
4
  # - if the user has a billing address, go to step 2
5
5
  # - if the user has no billing address, go to step 1
6
6
  #
7
- # After Step1, we go to the confirmed state
8
- # After Step2, we are in the purchased or declined state
7
+ # After Step1, we go to the confirmed status
8
+ # After Step2, we are in the purchased or declined status
9
9
 
10
10
  module Effective
11
11
  class Order < ActiveRecord::Base
12
12
  self.table_name = EffectiveOrders.orders_table_name.to_s
13
13
 
14
+ # Effective Resources
15
+ acts_as_statused(
16
+ :pending, # New orders are created in a pending state
17
+ :confirmed, # Once the order has passed checkout step 1
18
+ :deferred, # Deferred providers. cheque, etransfer or phone was selected.
19
+ :purchased, # Purchased by provider
20
+ :declined, # Declined by provider
21
+ :voided, # Voided by admin
22
+ :abandoned # Not set by this gem. Can be set outside it.
23
+ )
24
+
25
+ # Effective Addresses
26
+ acts_as_addressable(billing: { singular: true }, shipping: { singular: true })
27
+
28
+ # Effective Logging
29
+ log_changes if respond_to?(:log_changes)
30
+
31
+ # Effective Obfuscation
14
32
  if EffectiveOrders.obfuscate_order_ids
15
33
  raise('unsupported obfuscation with tenant') if defined?(Tenant)
16
34
  acts_as_obfuscated format: '###-####-###'
17
35
  end
18
36
 
19
- acts_as_addressable(billing: { singular: true }, shipping: { singular: true })
37
+ # Effective Reports
20
38
  acts_as_reportable if respond_to?(:acts_as_reportable)
21
- log_changes if respond_to?(:log_changes)
22
39
 
23
40
  attr_accessor :terms_and_conditions # Yes, I agree to the terms and conditions
24
41
  attr_accessor :confirmed_checkout # Set on the Checkout Step 1
@@ -47,7 +64,10 @@ module Effective
47
64
 
48
65
  # Attributes
49
66
  effective_resource do
50
- state :string
67
+ # Acts as Statused
68
+ status :string
69
+ status_steps :text
70
+
51
71
  purchased_at :datetime
52
72
 
53
73
  note :text # From buyer to admin
@@ -82,16 +102,17 @@ module Effective
82
102
  scope :deep, -> { includes(:addresses, :user, :purchased_by, :organization, order_items: :purchasable) }
83
103
  scope :sorted, -> { order(:id) }
84
104
 
85
- scope :purchased, -> { where(state: EffectiveOrders::PURCHASED) }
105
+ scope :purchased, -> { where(status: :purchased) }
86
106
  scope :purchased_by, lambda { |user| purchased.where(user: user) }
87
- scope :not_purchased, -> { where.not(state: [EffectiveOrders::PURCHASED, EffectiveOrders::DEFERRED]) }
88
- scope :was_not_purchased, -> { where.not(state: EffectiveOrders::PURCHASED) }
107
+ scope :not_purchased, -> { where.not(status: [:purchased, :deferred]) }
108
+ scope :was_not_purchased, -> { where.not(status: :purchased) }
89
109
 
90
- scope :pending, -> { where(state: EffectiveOrders::PENDING) }
91
- scope :confirmed, -> { where(state: EffectiveOrders::CONFIRMED) }
92
- scope :deferred, -> { where(state: EffectiveOrders::DEFERRED) }
93
- scope :declined, -> { where(state: EffectiveOrders::DECLINED) }
94
- scope :abandoned, -> { where(state: EffectiveOrders::ABANDONED) }
110
+ scope :pending, -> { where(status: :pending) }
111
+ scope :confirmed, -> { where(status: :confirmed) }
112
+ scope :deferred, -> { where(status: :deferred) }
113
+ scope :declined, -> { where(status: :declined) }
114
+ scope :abandoned, -> { where(status: :abandoned) }
115
+ scope :voided, -> { where(status: :voided) }
95
116
 
96
117
  scope :refunds, -> { purchased.where('total < ?', 0) }
97
118
  scope :pending_refunds, -> { not_purchased.where('total < ?', 0) }
@@ -102,8 +123,7 @@ module Effective
102
123
  end
103
124
 
104
125
  before_validation do
105
- self.state ||= EffectiveOrders::PENDING
106
- self.state = EffectiveOrders::CONFIRMED if pending? && confirmed_checkout
126
+ assign_attributes(status: :confirmed) if pending? && confirmed_checkout
107
127
  end
108
128
 
109
129
  before_validation do
@@ -126,7 +146,6 @@ module Effective
126
146
  validates :cc, email_cc: true
127
147
 
128
148
  validates :order_items, presence: { message: 'No items are present. Please add additional items.' }
129
- validates :state, inclusion: { in: EffectiveOrders::STATES.keys }
130
149
 
131
150
  validate do
132
151
  if EffectiveOrders.organization_enabled?
@@ -179,8 +198,12 @@ module Effective
179
198
  end
180
199
  end
181
200
 
201
+ validate(if: -> { was_voided? }) do
202
+ errors.add(:status, "cannot update a voided order") unless (voided? || pending?)
203
+ end
204
+
182
205
  # Sanity check
183
- before_save(if: -> { was_purchased? }) do
206
+ before_save(if: -> { status_was.to_s == 'purchased' }) do
184
207
  raise('cannot unpurchase an order') unless purchased?
185
208
 
186
209
  raise('cannot change subtotal of a purchased order') if changes[:subtotal].present?
@@ -204,7 +227,7 @@ module Effective
204
227
  # Effective::Order.new(items: Product.first, user: User.first, billing_address: Effective::Address.new, shipping_address: Effective::Address.new)
205
228
 
206
229
  def initialize(atts = nil, &block)
207
- super(state: EffectiveOrders::PENDING) # Initialize with state: PENDING
230
+ super(status: :pending) # Initialize with status pending
208
231
 
209
232
  return self unless atts.present?
210
233
 
@@ -406,24 +429,12 @@ module Effective
406
429
  Array(billing_name.to_s.split(' ')[1..-1]).join(' ')
407
430
  end
408
431
 
409
- def pending?
410
- state == EffectiveOrders::PENDING
411
- end
412
-
413
- def confirmed?
414
- state == EffectiveOrders::CONFIRMED
415
- end
416
-
417
- def deferred?
418
- state == EffectiveOrders::DEFERRED
419
- end
420
-
421
432
  def in_progress?
422
433
  pending? || confirmed? || deferred?
423
434
  end
424
435
 
425
436
  def done?
426
- persisted? && (purchased? || declined?)
437
+ persisted? && (purchased? || declined? || voided? || abandoned?)
427
438
  end
428
439
 
429
440
  # A custom order is one that was created by an admin
@@ -433,15 +444,11 @@ module Effective
433
444
  end
434
445
 
435
446
  def purchased?(provider = nil)
436
- return false if (state != EffectiveOrders::PURCHASED)
447
+ return false if (status.to_sym != :purchased)
437
448
  return true if provider.nil? || payment_provider == provider.to_s
438
449
  false
439
450
  end
440
451
 
441
- def was_purchased?
442
- state_was == EffectiveOrders::PURCHASED
443
- end
444
-
445
452
  def purchased_with_credit_card?
446
453
  purchased? && EffectiveOrders.credit_card_payment_providers.include?(payment_provider)
447
454
  end
@@ -450,14 +457,6 @@ module Effective
450
457
  purchased? && EffectiveOrders.credit_card_payment_providers.exclude?(payment_provider)
451
458
  end
452
459
 
453
- def declined?
454
- state == EffectiveOrders::DECLINED
455
- end
456
-
457
- def abandoned?
458
- state == EffectiveOrders::ABANDONED
459
- end
460
-
461
460
  def purchasables
462
461
  present_order_items.map { |order_item| order_item.purchasable }.compact
463
462
  end
@@ -558,7 +557,7 @@ module Effective
558
557
  def pending!
559
558
  return false if purchased?
560
559
 
561
- self.state = EffectiveOrders::PENDING
560
+ assign_attributes(status: :pending)
562
561
  self.addresses.clear if addresses.any? { |address| address.valid? == false }
563
562
  save!
564
563
 
@@ -572,18 +571,18 @@ module Effective
572
571
  # Used by admin checkout only
573
572
  def confirm!
574
573
  return false if purchased?
575
- update!(state: EffectiveOrders::CONFIRMED)
574
+ confirmed!
576
575
  end
577
576
 
578
577
  # This lets us skip to the confirmed workflow for an admin...
579
578
  def assign_confirmed_if_valid!
580
579
  return unless pending?
581
580
 
582
- self.state = EffectiveOrders::CONFIRMED
581
+ assign_attributes(status: :confirmed)
583
582
  return true if valid?
584
583
 
585
584
  self.errors.clear
586
- self.state = EffectiveOrders::PENDING
585
+ assign_attributes(status: :pending)
587
586
  false
588
587
  end
589
588
 
@@ -604,11 +603,13 @@ module Effective
604
603
  def purchase!(payment: nil, provider: nil, card: nil, email: true, skip_buyer_validations: false, skip_quickbooks: false, current_user: nil)
605
604
  return true if purchased?
606
605
 
606
+ raise('unable to purchase voided order') if voided?
607
+
607
608
  # Assign attributes
608
609
  assign_attributes(
609
- state: EffectiveOrders::PURCHASED,
610
610
  skip_buyer_validations: skip_buyer_validations,
611
611
 
612
+ status: :purchased,
612
613
  purchased_at: (purchased_at.presence || Time.zone.now),
613
614
  purchased_by: (purchased_by.presence || current_user),
614
615
 
@@ -633,7 +634,7 @@ module Effective
633
634
 
634
635
  run_purchasable_callbacks(:after_purchase)
635
636
  end
636
- rescue => e
637
+ rescue ActiveRecord::RecordInvalid => e
637
638
  Effective::Order.transaction do
638
639
  save!(validate: false)
639
640
  update_purchasables_purchased_order!
@@ -668,8 +669,8 @@ module Effective
668
669
  def defer!(provider: 'none', email: true)
669
670
  return false if purchased?
670
671
 
671
- assign_attributes(state: EffectiveOrders::DEFERRED, payment_provider: provider)
672
- save!
672
+ assign_attributes(payment_provider: provider)
673
+ deferred!
673
674
 
674
675
  send_payment_request_to_buyer! if email
675
676
 
@@ -684,12 +685,15 @@ module Effective
684
685
  error = nil
685
686
 
686
687
  assign_attributes(
687
- state: EffectiveOrders::DECLINED,
688
+ skip_buyer_validations: true,
689
+
690
+ status: :declined,
688
691
  purchased_at: nil,
692
+ purchased_by: nil,
693
+
689
694
  payment: payment_to_h(payment),
690
695
  payment_provider: provider,
691
- payment_card: (card.presence || 'none'),
692
- skip_buyer_validations: true
696
+ payment_card: (card.presence || 'none')
693
697
  )
694
698
 
695
699
  Effective::Order.transaction do
@@ -697,8 +701,8 @@ module Effective
697
701
  run_purchasable_callbacks(:before_decline)
698
702
  save!(validate: validate)
699
703
  run_purchasable_callbacks(:after_decline)
700
- rescue => e
701
- self.state = state_was
704
+ rescue ActiveRecord::RecordInvalid => e
705
+ self.status = status_was
702
706
 
703
707
  error = e.message
704
708
  raise ::ActiveRecord::Rollback
@@ -710,6 +714,16 @@ module Effective
710
714
  true
711
715
  end
712
716
 
717
+ def void!
718
+ raise('unable to void a purchased order') if purchased?
719
+ voided!
720
+ end
721
+
722
+ def unvoid!
723
+ raise('order must be voided to unvoid') unless voided?
724
+ pending!
725
+ end
726
+
713
727
  # These are all the emails we send all notifications to
714
728
  def emails
715
729
  ([purchased_by.try(:email)] + [email] + [user.try(:email)] + Array(organization.try(:billing_emails))).map(&:presence).compact.uniq
@@ -1,5 +1,8 @@
1
1
  = dropdown(variation: :dropleft) do
2
- = dropdown_link_to (order.purchased? ? 'View' : 'Checkout'), effective_orders.order_path(order)
2
+ - if EffectiveResources.authorized?(controller, :checkout, order)
3
+ = dropdown_link_to 'Checkout', effective_orders.order_path(order)
4
+ - else
5
+ = dropdown_link_to 'View', effective_orders.order_path(order)
3
6
 
4
7
  - if EffectiveResources.authorized?(controller, :send_buyer_receipt, order)
5
8
  = dropdown_link_to 'E-mail Receipt', effective_orders.send_buyer_receipt_order_path(order),
@@ -5,3 +5,7 @@
5
5
  %h2 #{order.label} from Example Inc.
6
6
 
7
7
  %p.text-muted= order.to_s
8
+
9
+ - if order.voided?
10
+ %p
11
+ %strong VOID
@@ -1,7 +1,7 @@
1
1
  = render 'layout' do
2
2
  %h1.effective-heading= @page_title
3
3
 
4
- - if !@order.purchased? && EffectiveResources.authorized?(self, :update, @order)
4
+ - if EffectiveResources.authorized?(self, :checkout, @order)
5
5
  = render_checkout(@order)
6
6
  - else
7
7
  = render(@order)
data/config/routes.rb CHANGED
@@ -51,6 +51,9 @@ EffectiveOrders::Engine.routes.draw do
51
51
  post :send_payment_request
52
52
  post :send_buyer_receipt
53
53
 
54
+ post :void
55
+ post :unvoid
56
+
54
57
  # GET should be last here
55
58
  post :checkout
56
59
  patch :checkout
@@ -10,7 +10,9 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
10
10
  t.integer :parent_id
11
11
  t.string :parent_type
12
12
 
13
- t.string :state
13
+ t.string :status
14
+ t.text :status_steps
15
+
14
16
  t.datetime :purchased_at
15
17
 
16
18
  t.integer :purchased_by_id
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.6.3'.freeze
2
+ VERSION = '6.7.0'.freeze
3
3
  end
@@ -4,22 +4,6 @@ require 'effective_orders/engine'
4
4
  require 'effective_orders/version'
5
5
 
6
6
  module EffectiveOrders
7
- # Order states
8
- PENDING = 'pending' # New orders are created in a pending state
9
- CONFIRMED = 'confirmed' # Once the order has passed checkout step 1
10
- DEFERRED = 'deferred' # Deferred providers. cheque, etransfer or phone was selected.
11
- PURCHASED = 'purchased' # Purchased by provider
12
- DECLINED = 'declined' # Declined by provider
13
- ABANDONED = 'abandoned' # Not set by this gem. Can be set outside it.
14
-
15
- STATES = {
16
- PENDING => PENDING,
17
- CONFIRMED => CONFIRMED,
18
- DEFERRED => DEFERRED,
19
- PURCHASED => PURCHASED,
20
- DECLINED => DECLINED,
21
- ABANDONED => ABANDONED
22
- }
23
7
 
24
8
  # Subscription statuses (as per stripe)
25
9
  ACTIVE = 'active'
@@ -238,7 +222,7 @@ module EffectiveOrders
238
222
 
239
223
  plans = begin
240
224
  Stripe::Plan.respond_to?(:all) ? Stripe::Plan.all : Stripe::Plan.list
241
- rescue => e
225
+ rescue Exception => e
242
226
  raise e if Rails.env.production?
243
227
  Rails.logger.info "[STRIPE ERROR]: #{e.message}"
244
228
  Rails.logger.info "[STRIPE ERROR]: effective_orders continuing with empty stripe plans. This would fail loudly in Rails.env.production."
@@ -310,8 +294,4 @@ module EffectiveOrders
310
294
 
311
295
  class SoldOutException < Exception; end
312
296
 
313
- def self.gem_path
314
- __dir__.chomp('/lib')
315
- end
316
-
317
297
  end
@@ -62,7 +62,7 @@ class EffectiveOrdersMailerPreview < ActionMailer::Preview
62
62
  order.user = preview_user
63
63
  preview_order_items.each { |atts| order.order_items.build(atts) }
64
64
 
65
- order.state = 'purchased'
65
+ order.status = :purchased
66
66
  order.payment_card = 'visa'
67
67
  order.purchased_at = Time.zone.now
68
68
  order.payment = { 'f4l4' => '1234'}
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: 6.6.3
4
+ version: 6.7.0
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: 2023-08-03 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails