solidus_core 2.11.1 → 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/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.rb +7 -162
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +1 -12
- data/app/models/spree/calculator.rb +4 -11
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- 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.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 +3 -136
- data/app/models/spree/order/payments.rb +2 -2
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_merger.rb +1 -1
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment.rb +10 -6
- data/app/models/spree/payment/cancellation.rb +3 -22
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method.rb +2 -103
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_source.rb +2 -2
- data/app/models/spree/product.rb +8 -41
- data/app/models/spree/product/scopes.rb +0 -28
- data/app/models/spree/promotion.rb +2 -6
- 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_action.rb +2 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/refund.rb +3 -47
- 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 +1 -26
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/state.rb +0 -4
- data/app/models/spree/stock/availability_validator.rb +2 -2
- data/app/models/spree/stock/inventory_validator.rb +2 -2
- data/app/models/spree/stock/simple_coordinator.rb +0 -14
- 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_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.rb +0 -11
- data/app/models/spree/taxon/active_storage_attachment.rb +0 -6
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -4
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/variant.rb +1 -45
- data/config/locales/en.yml +0 -8
- data/db/migrate/20210122110141_add_name_to_spree_addresses.rb +13 -0
- data/lib/generators/solidus/install/install_generator.rb +12 -1
- 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 +6 -1
- data/lib/spree/app_configuration.rb +7 -66
- data/lib/spree/core.rb +10 -12
- 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 +6 -42
- 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/version.rb +1 -1
- data/lib/spree/event.rb +0 -31
- 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/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +2 -53
- data/lib/spree/testing_support.rb +31 -0
- 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.rb +10 -16
- data/lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb +4 -0
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/factories.rb +8 -4
- data/lib/spree/testing_support/factories/address_factory.rb +6 -2
- data/lib/spree/testing_support/factories/adjustment_factory.rb +10 -5
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/calculator_factory.rb +5 -0
- data/lib/spree/testing_support/factories/carton_factory.rb +7 -2
- data/lib/spree/testing_support/factories/country_factory.rb +5 -0
- data/lib/spree/testing_support/factories/credit_card_factory.rb +5 -0
- data/lib/spree/testing_support/factories/customer_return_factory.rb +8 -3
- data/lib/spree/testing_support/factories/image_factory.rb +5 -0
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +9 -4
- data/lib/spree/testing_support/factories/line_item_factory.rb +7 -2
- data/lib/spree/testing_support/factories/option_type_factory.rb +8 -0
- data/lib/spree/testing_support/factories/option_value_factory.rb +5 -0
- data/lib/spree/testing_support/factories/order_factory.rb +11 -7
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +7 -2
- data/lib/spree/testing_support/factories/payment_factory.rb +9 -4
- data/lib/spree/testing_support/factories/payment_method_factory.rb +5 -0
- data/lib/spree/testing_support/factories/price_factory.rb +6 -1
- data/lib/spree/testing_support/factories/product_factory.rb +10 -5
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +7 -2
- data/lib/spree/testing_support/factories/product_property_factory.rb +7 -2
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +5 -0
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +7 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +7 -2
- data/lib/spree/testing_support/factories/property_factory.rb +5 -0
- data/lib/spree/testing_support/factories/refund_factory.rb +7 -3
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +6 -1
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +5 -0
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +8 -3
- data/lib/spree/testing_support/factories/return_item_factory.rb +8 -3
- data/lib/spree/testing_support/factories/return_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/role_factory.rb +5 -0
- data/lib/spree/testing_support/factories/shipment_factory.rb +9 -3
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +5 -0
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +8 -3
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +7 -2
- data/lib/spree/testing_support/factories/state_factory.rb +7 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +7 -2
- data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -3
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +6 -1
- data/lib/spree/testing_support/factories/stock_package_factory.rb +7 -2
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +7 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +8 -3
- data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_factory.rb +6 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +7 -1
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +8 -3
- data/lib/spree/testing_support/factories/taxon_factory.rb +6 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +5 -0
- data/lib/spree/testing_support/factories/user_factory.rb +8 -3
- data/lib/spree/testing_support/factories/variant_factory.rb +9 -4
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +7 -2
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +8 -3
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +7 -2
- data/lib/spree/testing_support/factories/zone_factory.rb +7 -2
- data/lib/spree/testing_support/factory_bot.rb +68 -0
- data/lib/spree/testing_support/order_walkthrough.rb +10 -13
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support/sequences.rb +4 -1
- data/{app/models → lib}/spree/user_class_handle.rb +0 -0
- data/lib/tasks/migrations/migrate_address_names.rake +158 -0
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +38 -0
- data/lib/tasks/upgrade.rake +13 -0
- data/solidus_core.gemspec +3 -4
- metadata +32 -63
- 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 -21
- data/app/models/spree/calculator/percent_per_item.rb +0 -49
- data/app/models/spree/calculator/price_sack.rb +0 -27
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- 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/awesome_nested_set_override.rb +0 -44
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -11
- 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
@@ -37,14 +37,14 @@ module Spree
|
|
37
37
|
|
38
38
|
private
|
39
39
|
|
40
|
-
def process_payments_with(
|
40
|
+
def process_payments_with(method_name)
|
41
41
|
# Don't run if there is nothing to pay.
|
42
42
|
return true if payment_total >= total
|
43
43
|
|
44
44
|
unprocessed_payments.each do |payment|
|
45
45
|
break if payment_total >= total
|
46
46
|
|
47
|
-
payment.public_send(
|
47
|
+
payment.public_send(method_name)
|
48
48
|
end
|
49
49
|
rescue Core::GatewayError => error
|
50
50
|
result = !!Spree::Config[:allow_checkout_on_gateway_error]
|
@@ -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,
|
@@ -128,7 +128,7 @@ module Spree
|
|
128
128
|
# @param [Spree::LineItem] line_item The line item which could not be saved
|
129
129
|
# @return [void]
|
130
130
|
def handle_error(line_item)
|
131
|
-
order.errors
|
131
|
+
order.errors.add(:base, line_item.errors.full_messages)
|
132
132
|
end
|
133
133
|
|
134
134
|
# Save the order totals after merge
|
@@ -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)
|
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
|
@@ -168,9 +165,16 @@ module Spree
|
|
168
165
|
|
169
166
|
def validate_source
|
170
167
|
if source && !source.valid?
|
171
|
-
|
172
|
-
|
173
|
-
|
168
|
+
if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
|
169
|
+
source.errors.each do |error|
|
170
|
+
field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{error.attribute}")
|
171
|
+
errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error.message}")
|
172
|
+
end
|
173
|
+
else
|
174
|
+
source.errors.each do |field, error|
|
175
|
+
field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{field}")
|
176
|
+
errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error}")
|
177
|
+
end
|
174
178
|
end
|
175
179
|
end
|
176
180
|
if errors.any?
|
@@ -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
|
@@ -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]
|
@@ -18,19 +18,6 @@ module Spree
|
|
18
18
|
|
19
19
|
acts_as_list
|
20
20
|
|
21
|
-
# @private
|
22
|
-
def self.const_missing(name)
|
23
|
-
if name == :DISPLAY
|
24
|
-
Spree::Deprecation.warn(
|
25
|
-
"#{self}::DISPLAY has been deprecated and will be removed in Solidus v3.",
|
26
|
-
caller
|
27
|
-
)
|
28
|
-
const_set(:DISPLAY, [:both, :front_end, :back_end])
|
29
|
-
else
|
30
|
-
super
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
21
|
validates :name, :type, presence: true
|
35
22
|
|
36
23
|
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
@@ -67,51 +54,9 @@ module Spree
|
|
67
54
|
end
|
68
55
|
|
69
56
|
class << self
|
70
|
-
# @deprecated Use Spree::Config.environment.payment_methods instead
|
71
|
-
def providers
|
72
|
-
Spree::Deprecation.warn 'Spree::PaymentMethod.providers is deprecated and will be deleted in Solidus 3.0. ' \
|
73
|
-
'Please use Rails.application.config.spree.payment_methods instead'
|
74
|
-
Spree::Config.environment.payment_methods
|
75
|
-
end
|
76
|
-
|
77
|
-
# @deprecated Use {.active}, {.available_to_users}, and {.available_to_admin} scopes instead.
|
78
|
-
def available(display_on = nil, store: nil)
|
79
|
-
Spree::Deprecation.warn "Spree::PaymentMethod.available is deprecated."\
|
80
|
-
"Please use .active, .available_to_users, and .available_to_admin scopes instead."\
|
81
|
-
"For payment methods associated with a specific store, use Spree::PaymentMethod.available_to_store(your_store)"\
|
82
|
-
" as the base applying any further filtering"
|
83
|
-
|
84
|
-
display_on = display_on.to_s
|
85
|
-
|
86
|
-
available_payment_methods =
|
87
|
-
case display_on
|
88
|
-
when 'front_end'
|
89
|
-
active.available_to_users
|
90
|
-
when 'back_end'
|
91
|
-
active.available_to_admin
|
92
|
-
else
|
93
|
-
active.available_to_users.available_to_admin
|
94
|
-
end
|
95
|
-
available_payment_methods.select do |payment|
|
96
|
-
store.nil? || store.payment_methods.empty? || store.payment_methods.include?(payment)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
57
|
def model_name
|
101
58
|
ModelName.new(self, Spree)
|
102
59
|
end
|
103
|
-
|
104
|
-
# @deprecated Use .active.any? instead
|
105
|
-
def active?
|
106
|
-
Spree::Deprecation.warn "#{self}.active? is deprecated. Use #{self}.active.any? instead"
|
107
|
-
where(type: to_s, active: true).count > 0
|
108
|
-
end
|
109
|
-
|
110
|
-
# @deprecated Use .with_discarded.find instead
|
111
|
-
def find_with_destroyed(*args)
|
112
|
-
Spree::Deprecation.warn "#{self}.find_with_destroyed is deprecated. Use #{self}.with_discarded.find instead"
|
113
|
-
unscoped { find(*args) }
|
114
|
-
end
|
115
60
|
end
|
116
61
|
|
117
62
|
# Represents the gateway of this payment method
|
@@ -138,8 +83,6 @@ module Spree
|
|
138
83
|
|
139
84
|
@gateway ||= gateway_class.new(gateway_options)
|
140
85
|
end
|
141
|
-
alias_method :provider, :gateway
|
142
|
-
deprecate provider: :gateway, deprecator: Spree::Deprecation
|
143
86
|
|
144
87
|
# Represents all preferences as a Hash
|
145
88
|
#
|
@@ -159,29 +102,6 @@ module Spree
|
|
159
102
|
raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
|
160
103
|
end
|
161
104
|
|
162
|
-
# @deprecated Use {Spree::PaymentMethod#available_to_users=} and {Spree::PaymentMethod#available_to_admin=} instead
|
163
|
-
def display_on=(value)
|
164
|
-
Spree::Deprecation.warn "Spree::PaymentMethod#display_on= is deprecated."\
|
165
|
-
"Please use #available_to_users= and #available_to_admin= instead."
|
166
|
-
self.available_to_users = value.blank? || value == 'front_end'
|
167
|
-
self.available_to_admin = value.blank? || value == 'back_end'
|
168
|
-
end
|
169
|
-
|
170
|
-
# @deprecated Use {Spree::PaymentMethod#available_to_users} and {Spree::PaymentMethod#available_to_admin} instead
|
171
|
-
def display_on
|
172
|
-
Spree::Deprecation.warn "Spree::PaymentMethod#display_on is deprecated."\
|
173
|
-
"Please use #available_to_users and #available_to_admin instead."
|
174
|
-
if available_to_users? && available_to_admin?
|
175
|
-
''
|
176
|
-
elsif available_to_users?
|
177
|
-
'front_end'
|
178
|
-
elsif available_to_admin?
|
179
|
-
'back_end'
|
180
|
-
else
|
181
|
-
'none'
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
105
|
# Used as partial name for your payment method
|
186
106
|
#
|
187
107
|
# Currently your payment method needs to provide these partials:
|
@@ -202,21 +122,7 @@ module Spree
|
|
202
122
|
# The view that represents your payment method on orders through the api
|
203
123
|
#
|
204
124
|
def partial_name
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
# :nodoc:
|
209
|
-
# If method_type has been overridden, call it and return the value, otherwise return nil
|
210
|
-
def deprecated_method_type_override
|
211
|
-
if method(:method_type).owner != Spree::PaymentMethod
|
212
|
-
Spree::Deprecation.warn "#{method(:method_type).owner} is overriding PaymentMethod#method_type. This is deprecated and will be removed from Solidus 3.0 (override partial_name instead).", caller[1..-1]
|
213
|
-
method_type
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def method_type
|
218
|
-
Spree::Deprecation.warn "method_type is deprecated and will be removed from Solidus 3.0 (use partial_name instead)", caller
|
219
|
-
partial_name
|
125
|
+
type.demodulize.underscore
|
220
126
|
end
|
221
127
|
|
222
128
|
def payment_profiles_supported?
|
@@ -274,14 +180,7 @@ module Spree
|
|
274
180
|
# Represents the gateway class of this payment method
|
275
181
|
#
|
276
182
|
def gateway_class
|
277
|
-
|
278
|
-
Spree::Deprecation.warn \
|
279
|
-
"provider_class is deprecated and will be removed from Solidus 3.0 " \
|
280
|
-
"(use gateway_class instead)"
|
281
|
-
public_send :provider_class
|
282
|
-
else
|
283
|
-
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
284
|
-
end
|
183
|
+
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
285
184
|
end
|
286
185
|
end
|
287
186
|
end
|
@@ -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?
|
@@ -23,9 +23,9 @@ module Spree
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# @param payment [Spree::Payment] the payment we want to know if can be voided
|
26
|
-
# @return [Boolean] true when the payment is not failed or
|
26
|
+
# @return [Boolean] true when the payment is not failed, voided or invalid
|
27
27
|
def can_void?(payment)
|
28
|
-
|
28
|
+
payment.can_void?
|
29
29
|
end
|
30
30
|
|
31
31
|
# Indicates whether its possible to credit the payment. Note that most
|
data/app/models/spree/product.rb
CHANGED
@@ -5,10 +5,6 @@ module Spree
|
|
5
5
|
# variations, called variants. Product properties include description,
|
6
6
|
# permalink, availability, shipping category, etc. that do not change by
|
7
7
|
# variant.
|
8
|
-
#
|
9
|
-
# @note this model uses {https://github.com/radar/paranoia paranoia}.
|
10
|
-
# +#destroy+ will only soft-destroy records and the default scope hides
|
11
|
-
# soft-destroyed records using +WHERE deleted_at IS NULL+.
|
12
8
|
class Product < Spree::Base
|
13
9
|
extend FriendlyId
|
14
10
|
friendly_id :slug_candidates, use: :history
|
@@ -89,7 +85,6 @@ module Spree
|
|
89
85
|
:has_default_price?,
|
90
86
|
:images,
|
91
87
|
:price_for,
|
92
|
-
:price_in,
|
93
88
|
:rebuild_vat_prices=,
|
94
89
|
to: :find_or_build_master
|
95
90
|
|
@@ -186,19 +181,6 @@ module Spree
|
|
186
181
|
!!discontinue_on&.past?
|
187
182
|
end
|
188
183
|
|
189
|
-
# Groups variants by the specified option type.
|
190
|
-
#
|
191
|
-
# @deprecated This method is not called in the Solidus codebase
|
192
|
-
# @param opt_type [String] the name of the option type to group by
|
193
|
-
# @param pricing_options [Spree::Config.pricing_options_class] the pricing options to search
|
194
|
-
# for, default: the default pricing options
|
195
|
-
# @return [Hash] option_type as keys, array of variants as values.
|
196
|
-
def categorise_variants_from_option(opt_type, pricing_options = Spree::Config.default_pricing_options)
|
197
|
-
return {} unless option_types.include?(opt_type)
|
198
|
-
variants.with_prices(pricing_options).group_by { |variant| variant.option_values.detect { |option| option.option_type == opt_type } }
|
199
|
-
end
|
200
|
-
deprecate :categorise_variants_from_option, deprecator: Spree::Deprecation
|
201
|
-
|
202
184
|
# Poor man's full text search.
|
203
185
|
#
|
204
186
|
# Filters products to those which have any of the strings in +values+ in
|
@@ -214,17 +196,6 @@ module Spree
|
|
214
196
|
where conditions.inject(:or)
|
215
197
|
end
|
216
198
|
|
217
|
-
# @param current_currency [String] currency to filter variants by; defaults to Spree's default
|
218
|
-
# @deprecated This method can only handle prices for currencies
|
219
|
-
# @return [Array<Spree::Variant>] all variants with at least one option value
|
220
|
-
def variants_and_option_values(current_currency = nil)
|
221
|
-
variants.includes(:option_values).active(current_currency).select do |variant|
|
222
|
-
variant.option_values.any?
|
223
|
-
end
|
224
|
-
end
|
225
|
-
deprecate variants_and_option_values: :variants_and_option_values_for,
|
226
|
-
deprecator: Spree::Deprecation
|
227
|
-
|
228
199
|
# @param pricing_options [Spree::Variant::PricingOptions] the pricing options to search
|
229
200
|
# for, default: the default pricing options
|
230
201
|
# @return [Array<Spree::Variant>] all variants with at least one option value
|
@@ -296,16 +267,6 @@ module Spree
|
|
296
267
|
end
|
297
268
|
end
|
298
269
|
|
299
|
-
# Image that can be used for the product.
|
300
|
-
#
|
301
|
-
# Will first search for images on the product, then those belonging to the
|
302
|
-
# variants. If all else fails, will return a new image object.
|
303
|
-
# @return [Spree::Image] the image to display
|
304
|
-
def display_image
|
305
|
-
Spree::Deprecation.warn('Spree::Product#display_image is DEPRECATED. Choose an image from Spree::Product#gallery instead.')
|
306
|
-
images.first || variant_images.first || Spree::Image.new
|
307
|
-
end
|
308
|
-
|
309
270
|
# Finds the variant property rule that matches the provided option value ids.
|
310
271
|
#
|
311
272
|
# @param option_value_ids [Array<Integer>] list of option value ids
|
@@ -366,8 +327,14 @@ module Spree
|
|
366
327
|
# If the master is invalid, the Product object will be assigned its errors
|
367
328
|
def validate_master
|
368
329
|
unless master.valid?
|
369
|
-
|
370
|
-
errors.
|
330
|
+
if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
|
331
|
+
master.errors.each do |error|
|
332
|
+
errors.add(error.attribute, error.message)
|
333
|
+
end
|
334
|
+
else
|
335
|
+
master.errors.each do |att, error|
|
336
|
+
errors.add(att, error)
|
337
|
+
end
|
371
338
|
end
|
372
339
|
end
|
373
340
|
end
|