solidus_core 2.11.16 → 3.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -13
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -2
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +0 -37
- data/app/models/concerns/spree/user_methods.rb +2 -11
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -187
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +12 -48
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -11
- data/app/models/spree/country.rb +1 -6
- data/app/models/spree/credit_card.rb +0 -27
- data/app/models/spree/customer_return.rb +1 -4
- data/app/models/spree/image/active_storage_attachment.rb +2 -10
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +2 -45
- data/app/models/spree/order.rb +4 -137
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_shipping.rb +9 -6
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment/cancellation.rb +3 -22
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +9 -13
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
- data/app/models/spree/payment_method.rb +2 -106
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/product.rb +0 -39
- data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/rules/taxon.rb +2 -15
- data/app/models/spree/promotion.rb +2 -6
- data/app/models/spree/promotion_action.rb +2 -12
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +2 -2
- data/app/models/spree/promotion_rule.rb +0 -4
- data/app/models/spree/refund.rb +0 -60
- data/app/models/spree/reimbursement.rb +3 -41
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +1 -4
- data/app/models/spree/return_item.rb +1 -19
- data/app/models/spree/shipment.rb +1 -54
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/state.rb +0 -4
- data/app/models/spree/stock/simple_coordinator.rb +1 -20
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +1 -7
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +0 -8
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
- data/app/models/spree/tax_rate.rb +0 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
- data/app/models/spree/taxon.rb +0 -11
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/variant.rb +2 -46
- data/config/locales/en.yml +0 -8
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +13 -2
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +6 -73
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -14
- data/lib/spree/core/controller_helpers/order.rb +2 -22
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +0 -43
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +0 -40
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +0 -26
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +9 -8
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +3 -1
- data/lib/spree/event.rb +0 -31
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +3 -60
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +6 -16
- data/lib/spree/testing_support/factories/order_factory.rb +0 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/order_walkthrough.rb +0 -3
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support.rb +1 -1
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +20 -15
- data/solidus_core.gemspec +1 -24
- metadata +9 -74
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/preferences/persistable.rb +0 -23
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/spree/testing_support/fixtures/file.txt +0 -1
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
data/app/models/spree/order.rb
CHANGED
@@ -50,18 +50,13 @@ module Spree
|
|
50
50
|
go_to_state :confirm
|
51
51
|
end
|
52
52
|
|
53
|
-
ransack_alias :bill_address_firstname_or_lastname, :bill_address_firstname_or_bill_address_lastname
|
54
53
|
self.whitelisted_ransackable_associations = %w[shipments user order_promotions promotions bill_address ship_address line_items]
|
55
|
-
self.whitelisted_ransackable_attributes = %w[
|
54
|
+
self.whitelisted_ransackable_attributes = %w[bill_address_name completed_at created_at email number state payment_state shipment_state total store_id]
|
56
55
|
|
57
56
|
attr_reader :coupon_code
|
58
57
|
attr_accessor :temporary_address
|
59
58
|
|
60
59
|
attr_accessor :temporary_payment_source
|
61
|
-
alias_method :temporary_credit_card, :temporary_payment_source
|
62
|
-
alias_method :temporary_credit_card=, :temporary_payment_source=
|
63
|
-
deprecate temporary_credit_card: :temporary_payment_source, deprecator: Spree::Deprecation
|
64
|
-
deprecate :temporary_credit_card= => :temporary_payment_source=, deprecator: Spree::Deprecation
|
65
60
|
|
66
61
|
# Customer info
|
67
62
|
belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
|
@@ -147,14 +142,9 @@ module Spree
|
|
147
142
|
find_by! number: value
|
148
143
|
end
|
149
144
|
|
150
|
-
delegate :name,
|
151
|
-
alias_method :billing_firstname, :bill_address_firstname
|
152
|
-
alias_method :billing_lastname, :bill_address_lastname
|
145
|
+
delegate :name, to: :bill_address, prefix: true, allow_nil: true
|
153
146
|
alias_method :billing_name, :bill_address_name
|
154
147
|
|
155
|
-
class_attribute :update_hooks
|
156
|
-
self.update_hooks = Set.new
|
157
|
-
|
158
148
|
class_attribute :line_item_comparison_hooks
|
159
149
|
self.line_item_comparison_hooks = Set.new
|
160
150
|
|
@@ -190,15 +180,6 @@ module Spree
|
|
190
180
|
where.not(state: 'canceled')
|
191
181
|
end
|
192
182
|
|
193
|
-
# Use this method in other gems that wish to register their own custom logic
|
194
|
-
# that should be called after Order#update
|
195
|
-
def self.register_update_hook(hook)
|
196
|
-
Spree::Deprecation.warn \
|
197
|
-
"Spree::Order::update_hooks are deprecated. Please remove them " \
|
198
|
-
"and subscribe to `order_recalculated` and/or `order_finalized` event instead", caller(1)
|
199
|
-
update_hooks.add(hook)
|
200
|
-
end
|
201
|
-
|
202
183
|
# Use this method in other gems that wish to register their own custom logic
|
203
184
|
# that should be called when determining if two line items are equal.
|
204
185
|
def self.register_line_item_comparison_hook(hook)
|
@@ -210,12 +191,6 @@ module Spree
|
|
210
191
|
line_items.sum(&:amount)
|
211
192
|
end
|
212
193
|
|
213
|
-
# Sum of all line item amounts after promotions, before added tax
|
214
|
-
def discounted_item_amount
|
215
|
-
line_items.to_a.sum(&:discounted_amount)
|
216
|
-
end
|
217
|
-
deprecate discounted_item_amount: :item_total_before_tax, deprecator: Spree::Deprecation
|
218
|
-
|
219
194
|
def item_total_before_tax
|
220
195
|
line_items.to_a.sum(&:total_before_tax)
|
221
196
|
end
|
@@ -224,8 +199,6 @@ module Spree
|
|
224
199
|
def item_total_excluding_vat
|
225
200
|
line_items.to_a.sum(&:total_excluding_vat)
|
226
201
|
end
|
227
|
-
alias pre_tax_item_amount item_total_excluding_vat
|
228
|
-
deprecate pre_tax_item_amount: :item_total_excluding_vat, deprecator: Spree::Deprecation
|
229
202
|
|
230
203
|
def currency
|
231
204
|
self[:currency] || Spree::Config[:currency]
|
@@ -256,11 +229,6 @@ module Spree
|
|
256
229
|
total > 0
|
257
230
|
end
|
258
231
|
|
259
|
-
def confirmation_required?
|
260
|
-
true
|
261
|
-
end
|
262
|
-
deprecate :confirmation_required?, deprecator: Spree::Deprecation
|
263
|
-
|
264
232
|
def backordered?
|
265
233
|
shipments.any?(&:backordered?)
|
266
234
|
end
|
@@ -282,15 +250,6 @@ module Spree
|
|
282
250
|
updater.update
|
283
251
|
end
|
284
252
|
|
285
|
-
def update!(*args)
|
286
|
-
if args.empty?
|
287
|
-
Spree::Deprecation.warn "Calling order.update! with no arguments as a way to invoke the OrderUpdater is deprecated, since it conflicts with AR::Base#update! Please use order.recalculate instead"
|
288
|
-
recalculate
|
289
|
-
else
|
290
|
-
super
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
253
|
def assign_billing_to_shipping_address
|
295
254
|
self.ship_address = bill_address if bill_address
|
296
255
|
true
|
@@ -336,14 +295,7 @@ module Spree
|
|
336
295
|
assign_attributes(attrs_to_set)
|
337
296
|
end
|
338
297
|
|
339
|
-
def generate_order_number
|
340
|
-
if options
|
341
|
-
Spree::Deprecation.warn \
|
342
|
-
"Passing options to Order#generate_order_number is deprecated. " \
|
343
|
-
"Please add your own instance of the order number generator " \
|
344
|
-
"with your options (#{options.inspect}) and store it as " \
|
345
|
-
"Spree::Config.order_number_generator in your stores config."
|
346
|
-
end
|
298
|
+
def generate_order_number
|
347
299
|
self.number ||= Spree::Config.order_number_generator.generate
|
348
300
|
end
|
349
301
|
|
@@ -384,14 +336,6 @@ module Spree
|
|
384
336
|
}
|
385
337
|
end
|
386
338
|
|
387
|
-
# Creates new tax charges if there are any applicable rates. If prices already
|
388
|
-
# include taxes then price adjustments are created instead.
|
389
|
-
# @deprecated This now happens during #recalculate
|
390
|
-
def create_tax_charge!
|
391
|
-
recalculate
|
392
|
-
end
|
393
|
-
deprecate create_tax_charge!: :recalculate, deprecator: Spree::Deprecation
|
394
|
-
|
395
339
|
def reimbursement_total
|
396
340
|
reimbursements.sum(:total)
|
397
341
|
end
|
@@ -450,18 +394,10 @@ module Spree
|
|
450
394
|
|
451
395
|
updater.update_shipment_state
|
452
396
|
save!
|
453
|
-
updater.run_hooks if update_hooks.any?
|
454
397
|
|
455
398
|
touch :completed_at
|
456
399
|
|
457
400
|
Spree::Event.fire 'order_finalized', order: self
|
458
|
-
|
459
|
-
if method(:deliver_order_confirmation_email).owner != self.class
|
460
|
-
Spree::Deprecation.warn \
|
461
|
-
"deliver_order_confirmation_email has been deprecated and moved to " \
|
462
|
-
"Spree::MailerSubscriber#order_finalized, please move there any customizations.",
|
463
|
-
caller(1)
|
464
|
-
end
|
465
401
|
end
|
466
402
|
|
467
403
|
def fulfill!
|
@@ -470,16 +406,6 @@ module Spree
|
|
470
406
|
save!
|
471
407
|
end
|
472
408
|
|
473
|
-
def deliver_order_confirmation_email
|
474
|
-
Spree::Deprecation.warn \
|
475
|
-
"deliver_order_confirmation_email has been deprecated and moved to " \
|
476
|
-
"Spree::MailerSubscriber#order_finalized.",
|
477
|
-
caller(1)
|
478
|
-
|
479
|
-
Spree::Config.order_mailer_class.confirm_email(self).deliver_later
|
480
|
-
update_column(:confirmation_delivered, true)
|
481
|
-
end
|
482
|
-
|
483
409
|
# Helper methods for checkout steps
|
484
410
|
def paid?
|
485
411
|
%w(paid credit_owed).include?(payment_state)
|
@@ -523,26 +449,6 @@ module Spree
|
|
523
449
|
recalculate
|
524
450
|
end
|
525
451
|
|
526
|
-
alias_method :has_step?, :has_checkout_step?
|
527
|
-
deprecate has_step?: :has_checkout_step?, deprecator: Spree::Deprecation
|
528
|
-
|
529
|
-
def state_changed(name)
|
530
|
-
state = "#{name}_state"
|
531
|
-
if persisted?
|
532
|
-
old_state = send("#{state}_was")
|
533
|
-
new_state = send(state)
|
534
|
-
unless old_state == new_state
|
535
|
-
state_changes.create(
|
536
|
-
previous_state: old_state,
|
537
|
-
next_state: new_state,
|
538
|
-
name: name,
|
539
|
-
user_id: user_id
|
540
|
-
)
|
541
|
-
end
|
542
|
-
end
|
543
|
-
end
|
544
|
-
deprecate :state_changed, deprecator: Spree::Deprecation
|
545
|
-
|
546
452
|
def coupon_code=(code)
|
547
453
|
@coupon_code = begin
|
548
454
|
code.strip.downcase
|
@@ -584,7 +490,7 @@ module Spree
|
|
584
490
|
raise CannotRebuildShipments.new(I18n.t('spree.cannot_rebuild_shipments_shipments_not_pending'))
|
585
491
|
else
|
586
492
|
shipments.destroy_all
|
587
|
-
shipments
|
493
|
+
self.shipments = Spree::Config.stock.coordinator_class.new(self).shipments
|
588
494
|
end
|
589
495
|
end
|
590
496
|
|
@@ -599,8 +505,6 @@ module Spree
|
|
599
505
|
Spree::PromotionHandler::Shipping.new(self).activate
|
600
506
|
recalculate
|
601
507
|
end
|
602
|
-
alias_method :apply_free_shipping_promotions, :apply_shipping_promotions
|
603
|
-
deprecate apply_free_shipping_promotions: :apply_shipping_promotions, deprecator: Spree::Deprecation
|
604
508
|
|
605
509
|
# Clean shipments and make order back to address state
|
606
510
|
#
|
@@ -633,12 +537,6 @@ module Spree
|
|
633
537
|
bill_address == ship_address
|
634
538
|
end
|
635
539
|
|
636
|
-
# @deprecated This now happens during #recalculate
|
637
|
-
def set_shipments_cost
|
638
|
-
recalculate
|
639
|
-
end
|
640
|
-
deprecate set_shipments_cost: :recalculate, deprecator: Spree::Deprecation
|
641
|
-
|
642
540
|
def is_risky?
|
643
541
|
payments.risky.count > 0
|
644
542
|
end
|
@@ -669,11 +567,6 @@ module Spree
|
|
669
567
|
payments.offset_payment.exists? # how old versions of spree stored refunds
|
670
568
|
end
|
671
569
|
|
672
|
-
def token
|
673
|
-
Spree::Deprecation.warn("Spree::Order#token is DEPRECATED, please use #guest_token instead.", caller)
|
674
|
-
guest_token
|
675
|
-
end
|
676
|
-
|
677
570
|
def tax_total
|
678
571
|
additional_tax_total + included_tax_total
|
679
572
|
end
|
@@ -778,11 +671,6 @@ module Spree
|
|
778
671
|
end
|
779
672
|
end
|
780
673
|
|
781
|
-
alias_method :assign_default_user_addresses!, :assign_default_user_addresses
|
782
|
-
deprecate assign_default_user_addresses!: :assign_default_user_addresses, deprecator: Spree::Deprecation
|
783
|
-
alias_method :assign_default_addresses!, :assign_default_user_addresses
|
784
|
-
deprecate assign_default_addresses!: :assign_default_user_addresses, deprecator: Spree::Deprecation
|
785
|
-
|
786
674
|
def persist_user_address!
|
787
675
|
if !temporary_address && user && user.respond_to?(:persist_order_address) && bill_address_id
|
788
676
|
user.persist_order_address(self)
|
@@ -794,8 +682,6 @@ module Spree
|
|
794
682
|
add_payment_sources_to_wallet_class.new(self).
|
795
683
|
add_to_wallet
|
796
684
|
end
|
797
|
-
alias_method :persist_user_credit_card, :add_payment_sources_to_wallet
|
798
|
-
deprecate persist_user_credit_card: :add_payment_sources_to_wallet, deprecator: Spree::Deprecation
|
799
685
|
|
800
686
|
def add_default_payment_from_wallet
|
801
687
|
builder = Spree::Config.default_payment_builder_class.new(self)
|
@@ -810,8 +696,6 @@ module Spree
|
|
810
696
|
end
|
811
697
|
end
|
812
698
|
end
|
813
|
-
alias_method :assign_default_credit_card, :add_default_payment_from_wallet
|
814
|
-
deprecate assign_default_credit_card: :add_default_payment_from_wallet, deprecator: Spree::Deprecation
|
815
699
|
|
816
700
|
def record_ip_address(ip_address)
|
817
701
|
if new_record?
|
@@ -857,23 +741,6 @@ module Spree
|
|
857
741
|
end
|
858
742
|
end
|
859
743
|
|
860
|
-
# In case a existing credit card is provided it needs to build the payment
|
861
|
-
# attributes from scratch so we can set the amount. example payload:
|
862
|
-
#
|
863
|
-
# {
|
864
|
-
# "order": {
|
865
|
-
# "existing_card": "2"
|
866
|
-
# }
|
867
|
-
# }
|
868
|
-
#
|
869
|
-
def update_params_payment_source
|
870
|
-
Spree::Deprecation.warn('update_params_payment_source is deprecated. Please use set_payment_parameters_amount instead.', caller)
|
871
|
-
if @updating_params[:order] && (@updating_params[:order][:payments_attributes] || @updating_params[:order][:existing_card])
|
872
|
-
@updating_params[:order][:payments_attributes] ||= [{}]
|
873
|
-
@updating_params[:order][:payments_attributes].first[:amount] = total
|
874
|
-
end
|
875
|
-
end
|
876
|
-
|
877
744
|
def associate_store
|
878
745
|
self.store ||= Spree::Store.default
|
879
746
|
end
|
@@ -23,16 +23,10 @@ class Spree::OrderCancellations
|
|
23
23
|
# @api public
|
24
24
|
#
|
25
25
|
# @param [Array<InventoryUnit>] inventory_units the inventory units to be short shipped
|
26
|
-
# @param [Spree.user_class] whodunnit (deprecated) the system or person that is short shipping the inventory unit
|
27
26
|
# @param [Spree.user_class] created_by the system or person that is short shipping the inventory unit
|
28
27
|
#
|
29
28
|
# @return [Array<UnitCancel>] the units that have been canceled due to short shipping
|
30
|
-
def short_ship(inventory_units,
|
31
|
-
if whodunnit
|
32
|
-
created_by ||= whodunnit
|
33
|
-
Spree::Deprecation.warn("Calling #short_ship on #{self} with whodunnit is deprecated, use created_by instead")
|
34
|
-
end
|
35
|
-
|
29
|
+
def short_ship(inventory_units, created_by: nil)
|
36
30
|
if inventory_units.map(&:order_id).uniq != [@order.id]
|
37
31
|
raise ArgumentError, "Not all inventory units belong to this order"
|
38
32
|
end
|
@@ -65,16 +59,10 @@ class Spree::OrderCancellations
|
|
65
59
|
#
|
66
60
|
# @param [InventoryUnit] inventory_unit the inventory unit to be canceled
|
67
61
|
# @param [String] reason the reason that you are canceling the inventory unit
|
68
|
-
# @param [Spree.user_class] whodunnit (deprecated) the system or person that is canceling the inventory unit
|
69
62
|
# @param [Spree.user_class] created_by the system or person that is canceling the inventory unit
|
70
63
|
#
|
71
64
|
# @return [UnitCancel] the unit that has been canceled
|
72
|
-
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON,
|
73
|
-
if whodunnit
|
74
|
-
created_by ||= whodunnit
|
75
|
-
Spree::Deprecation.warn("Calling #cancel_unit on #{self} with whodunnit is deprecated, use created_by instead")
|
76
|
-
end
|
77
|
-
|
65
|
+
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, created_by: nil)
|
78
66
|
unit_cancel = nil
|
79
67
|
|
80
68
|
Spree::OrderMutex.with_lock!(@order) do
|
@@ -96,10 +84,7 @@ class Spree::OrderCancellations
|
|
96
84
|
# @param [Array<InventoryUnit>] inventory_units the inventory units to be reimbursed
|
97
85
|
# @param [Spree.user_class] created_by the user that is performing this action
|
98
86
|
# @return [Reimbursement] the reimbursement for inventory being canceled
|
99
|
-
def reimburse_units(inventory_units, created_by:
|
100
|
-
unless created_by
|
101
|
-
Spree::Deprecation.warn("Calling #reimburse_units on #{self} without created_by is deprecated")
|
102
|
-
end
|
87
|
+
def reimburse_units(inventory_units, created_by:)
|
103
88
|
reimbursement = nil
|
104
89
|
|
105
90
|
Spree::OrderMutex.with_lock!(@order) do
|
@@ -113,12 +98,7 @@ class Spree::OrderCancellations
|
|
113
98
|
|
114
99
|
private
|
115
100
|
|
116
|
-
def short_ship_unit(inventory_unit,
|
117
|
-
if whodunnit
|
118
|
-
created_by ||= whodunnit
|
119
|
-
Spree::Deprecation.warn("Calling #short_ship_unit on #{self} with whodunnit is deprecated, use created_by instead")
|
120
|
-
end
|
121
|
-
|
101
|
+
def short_ship_unit(inventory_unit, created_by: nil)
|
122
102
|
unit_cancel = Spree::UnitCancel.create!(
|
123
103
|
inventory_unit: inventory_unit,
|
124
104
|
reason: Spree::UnitCancel::SHORT_SHIP,
|
@@ -62,15 +62,18 @@ class Spree::OrderShipping
|
|
62
62
|
end
|
63
63
|
|
64
64
|
inventory_units.map(&:shipment).uniq.each do |shipment|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
# Temporarily propagate the tracking number to the shipment as well
|
66
|
+
# TODO: Remove tracking numbers from shipments.
|
67
|
+
shipment.update!(tracking: tracking_number)
|
68
|
+
|
69
|
+
next unless shipment.inventory_units.reload.all? { |iu| iu.shipped? || iu.canceled? }
|
70
|
+
# TODO: make OrderShipping#ship_shipment call Shipment#ship! rather than
|
71
|
+
# having Shipment#ship! call OrderShipping#ship_shipment. We only really
|
72
|
+
# need this `update_columns` for the specs, until we make that change.
|
73
|
+
shipment.update_columns(state: 'shipped', shipped_at: Time.current)
|
70
74
|
end
|
71
75
|
|
72
76
|
send_shipment_emails(carton) if stock_location.fulfillable? && !suppress_mailer # e.g. digital gift cards that aren't actually shipped
|
73
|
-
@order.shipments.reload
|
74
77
|
@order.recalculate
|
75
78
|
|
76
79
|
carton
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Spree
|
4
4
|
class OrderUpdater
|
5
5
|
attr_reader :order
|
6
|
-
delegate :payments, :line_items, :adjustments, :all_adjustments, :shipments, :
|
6
|
+
delegate :payments, :line_items, :adjustments, :all_adjustments, :shipments, :quantity, to: :order
|
7
7
|
|
8
8
|
def initialize(order)
|
9
9
|
@order = order
|
@@ -26,20 +26,11 @@ module Spree
|
|
26
26
|
update_shipments
|
27
27
|
update_shipment_state
|
28
28
|
end
|
29
|
-
run_hooks if update_hooks.any?
|
30
29
|
Spree::Event.fire 'order_recalculated', order: order
|
31
30
|
persist_totals
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
def run_hooks
|
36
|
-
Spree::Deprecation.warn \
|
37
|
-
"This method is deprecated. Please run your hooks by subscribing " \
|
38
|
-
"to `order_recalculated` and/or `order_finalized` events instead, depending " \
|
39
|
-
" on when OrderUpdater#run_hooks was called.", caller(1)
|
40
|
-
update_hooks.each { |hook| order.send hook }
|
41
|
-
end
|
42
|
-
|
43
34
|
# Updates the +shipment_state+ attribute according to the following logic:
|
44
35
|
#
|
45
36
|
# shipped when all Shipments are in the "shipped" state
|
@@ -186,7 +177,7 @@ module Spree
|
|
186
177
|
end
|
187
178
|
|
188
179
|
def persist_totals
|
189
|
-
order.save!
|
180
|
+
order.save!
|
190
181
|
end
|
191
182
|
|
192
183
|
def log_state_change(name)
|
@@ -26,16 +26,10 @@ module Spree
|
|
26
26
|
# @param payment [Spree::Payment] - the payment that should be canceled
|
27
27
|
#
|
28
28
|
def cancel(payment)
|
29
|
-
|
30
|
-
|
31
|
-
if response = payment.payment_method.try_void(payment)
|
32
|
-
payment.handle_void_response(response)
|
33
|
-
else
|
34
|
-
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason, perform_after_create: false).perform!
|
35
|
-
end
|
29
|
+
if response = payment.payment_method.try_void(payment)
|
30
|
+
payment.handle_void_response(response)
|
36
31
|
else
|
37
|
-
|
38
|
-
deprecated_behavior(payment)
|
32
|
+
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason).perform!
|
39
33
|
end
|
40
34
|
end
|
41
35
|
|
@@ -44,19 +38,6 @@ module Spree
|
|
44
38
|
def refund_reason
|
45
39
|
Spree::RefundReason.where(name: reason).first_or_create
|
46
40
|
end
|
47
|
-
|
48
|
-
def try_void_available?(payment_method)
|
49
|
-
payment_method.respond_to?(:try_void) &&
|
50
|
-
payment_method.method(:try_void).owner != Spree::PaymentMethod
|
51
|
-
end
|
52
|
-
|
53
|
-
def deprecated_behavior(payment)
|
54
|
-
Spree::Deprecation.warn "#{payment.payment_method.class.name}#cancel is deprecated and will be removed. " \
|
55
|
-
'Please implement a `try_void` method instead that returns a response object if void succeeds ' \
|
56
|
-
'or `false|nil` if not. Solidus will refund the payment then.'
|
57
|
-
response = payment.payment_method.cancel(payment.response_code)
|
58
|
-
payment.handle_void_response(response)
|
59
|
-
end
|
60
41
|
end
|
61
42
|
end
|
62
43
|
end
|
data/app/models/spree/payment.rb
CHANGED
@@ -8,9 +8,6 @@ module Spree
|
|
8
8
|
class Payment < Spree::Base
|
9
9
|
include Spree::Payment::Processing
|
10
10
|
|
11
|
-
alias_attribute :identifier, :number
|
12
|
-
deprecate :identifier, :identifier=, deprecator: Spree::Deprecation
|
13
|
-
|
14
11
|
IDENTIFIER_CHARS = (('A'..'Z').to_a + ('0'..'9').to_a - %w(0 1 I O)).freeze
|
15
12
|
NON_RISKY_AVS_CODES = ['B', 'D', 'H', 'J', 'M', 'Q', 'T', 'V', 'X', 'Y'].freeze
|
16
13
|
RISKY_AVS_CODES = ['A', 'C', 'E', 'F', 'G', 'I', 'K', 'L', 'N', 'O', 'P', 'R', 'S', 'U', 'W', 'Z'].freeze
|
@@ -7,7 +7,6 @@ module Spree
|
|
7
7
|
# @param attributes [Hash,ActionController::Parameters] attributes which are assigned to the new payment
|
8
8
|
# * :payment_method_id Id of payment method used for this payment
|
9
9
|
# * :source_attributes Attributes used to build the source of this payment. Usually a {CreditCard}
|
10
|
-
# * :existing_card_id (Integer) Deprecated: The id of an existing {CreditCard} object to use
|
11
10
|
# * :wallet_payment_source_id (Integer): The id of a {WalletPaymentSource} to use
|
12
11
|
# @param request_env [Hash] rack env of user creating the payment
|
13
12
|
# @param payment [Payment] Internal use only. Instead of making a new payment, change the attributes for an existing one.
|
@@ -29,13 +28,7 @@ module Spree
|
|
29
28
|
@payment.request_env = @request_env if @request_env
|
30
29
|
@payment.attributes = @attributes
|
31
30
|
|
32
|
-
if source_attributes[:
|
33
|
-
Spree::Deprecation.warn(
|
34
|
-
"Passing existing_card_id to PaymentCreate is deprecated. Use wallet_payment_source_id instead.",
|
35
|
-
caller,
|
36
|
-
)
|
37
|
-
build_existing_card
|
38
|
-
elsif source_attributes[:wallet_payment_source_id].present?
|
31
|
+
if source_attributes[:wallet_payment_source_id].present?
|
39
32
|
build_from_wallet_payment_source
|
40
33
|
else
|
41
34
|
build_source
|
@@ -67,11 +60,6 @@ module Spree
|
|
67
60
|
build_from_payment_source(wallet_payment_source.payment_source)
|
68
61
|
end
|
69
62
|
|
70
|
-
def build_existing_card
|
71
|
-
credit_card = available_cards.find(source_attributes[:existing_card_id])
|
72
|
-
build_from_payment_source(credit_card)
|
73
|
-
end
|
74
|
-
|
75
63
|
def build_from_payment_source(payment_source)
|
76
64
|
# FIXME: does this work?
|
77
65
|
if source_attributes[:verification_value]
|
@@ -9,10 +9,6 @@ module Spree
|
|
9
9
|
|
10
10
|
VALID_CCS = ['1', TEST_VISA, TEST_MC, TEST_AMEX, TEST_DISC].flatten
|
11
11
|
|
12
|
-
AUTHORIZATION_CODE = '12345'
|
13
|
-
FAILURE_MESSAGE = 'Bogus Gateway: Forced failure'
|
14
|
-
SUCCESS_MESSAGE = 'Bogus Gateway: Forced success'
|
15
|
-
|
16
12
|
attr_accessor :test
|
17
13
|
|
18
14
|
def gateway_class
|
@@ -30,40 +26,40 @@ module Spree
|
|
30
26
|
def authorize(_money, credit_card, _options = {})
|
31
27
|
profile_id = credit_card.gateway_customer_profile_id
|
32
28
|
if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-'))
|
33
|
-
ActiveMerchant::Billing::Response.new(true,
|
29
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345', avs_result: { code: 'D' })
|
34
30
|
else
|
35
|
-
ActiveMerchant::Billing::Response.new(false,
|
31
|
+
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', { message: 'Bogus Gateway: Forced failure' }, test: true)
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
35
|
def purchase(_money, credit_card, _options = {})
|
40
36
|
profile_id = credit_card.gateway_customer_profile_id
|
41
37
|
if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-'))
|
42
|
-
ActiveMerchant::Billing::Response.new(true,
|
38
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345', avs_result: { code: 'M' })
|
43
39
|
else
|
44
|
-
ActiveMerchant::Billing::Response.new(false,
|
40
|
+
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', message: 'Bogus Gateway: Forced failure', test: true)
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
44
|
def credit(_money, _credit_card, _response_code, _options = {})
|
49
|
-
ActiveMerchant::Billing::Response.new(true,
|
45
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345')
|
50
46
|
end
|
51
47
|
|
52
48
|
def capture(_money, authorization, _gateway_options)
|
53
49
|
if authorization == '12345'
|
54
|
-
ActiveMerchant::Billing::Response.new(true,
|
50
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true)
|
55
51
|
else
|
56
|
-
ActiveMerchant::Billing::Response.new(false,
|
52
|
+
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', error: 'Bogus Gateway: Forced failure', test: true)
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
56
|
def void(_response_code, _credit_card, _options = {})
|
61
|
-
ActiveMerchant::Billing::Response.new(true,
|
57
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345')
|
62
58
|
end
|
63
59
|
|
64
60
|
# @see Spree::PaymentMethod#try_void
|
65
61
|
def try_void(_payment)
|
66
|
-
ActiveMerchant::Billing::Response.new(true,
|
62
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345')
|
67
63
|
end
|
68
64
|
|
69
65
|
def test?
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def partial_name
|
17
|
-
|
17
|
+
'gateway'
|
18
18
|
end
|
19
19
|
|
20
20
|
def supports?(source)
|
@@ -27,8 +27,6 @@ module Spree
|
|
27
27
|
source_ids = order.payments.where(payment_method_id: id).pluck(:source_id).uniq
|
28
28
|
payment_source_class.where(id: source_ids).select(&:reusable?)
|
29
29
|
end
|
30
|
-
alias_method :sources_by_order, :reusable_sources_by_order
|
31
|
-
deprecate sources_by_order: :reusable_sources_by_order, deprecator: Spree::Deprecation
|
32
30
|
|
33
31
|
def reusable_sources(order)
|
34
32
|
if order.completed?
|
@@ -9,17 +9,17 @@ module Spree
|
|
9
9
|
|
10
10
|
def authorize(_money, credit_card, _options = {})
|
11
11
|
if VALID_CCS.include? credit_card.number
|
12
|
-
ActiveMerchant::Billing::Response.new(true,
|
12
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345', avs_result: { code: 'A' })
|
13
13
|
else
|
14
|
-
ActiveMerchant::Billing::Response.new(false,
|
14
|
+
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', { message: 'Bogus Gateway: Forced failure' }, test: true)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def purchase(_money, credit_card, _options = {})
|
19
19
|
if VALID_CCS.include? credit_card.number
|
20
|
-
ActiveMerchant::Billing::Response.new(true,
|
20
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, test: true, authorization: '12345', avs_result: { code: 'A' })
|
21
21
|
else
|
22
|
-
ActiveMerchant::Billing::Response.new(false,
|
22
|
+
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', message: 'Bogus Gateway: Forced failure', test: true)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|