solidus_core 2.11.7 → 3.0.1
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.rb +2 -0
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -11
- 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 +8 -186
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +0 -35
- data/app/models/spree/calculator.rb +4 -7
- 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/image/active_storage_attachment.rb +10 -2
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- 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_cancellations.rb +4 -24
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method.rb +5 -103
- data/app/models/spree/payment_method/bogus_credit_card.rb +13 -9
- 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/product.rb +0 -39
- data/app/models/spree/product/scopes.rb +0 -27
- 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 +5 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_rule.rb +4 -0
- data/app/models/spree/refund.rb +0 -50
- 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 +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 -5
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
- 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/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 +14 -65
- data/lib/spree/core.rb +9 -8
- 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 -35
- 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/deprecation.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/preferences/persistable.rb +23 -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 +6 -14
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- 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/fixtures/file.txt +1 -0
- data/lib/spree/testing_support/order_walkthrough.rb +0 -3
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/tasks/upgrade.rake +7 -5
- data/solidus_core.gemspec +2 -5
- metadata +9 -48
- 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.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/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 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_address_names.rake +0 -158
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -38
- 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
@@ -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,
|
@@ -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
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
if response = payment.payment_method.try_void(payment)
|
30
30
|
payment.handle_void_response(response)
|
31
31
|
else
|
32
|
-
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason
|
32
|
+
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason).perform!
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -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]
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spree/preferences/persistable'
|
3
4
|
require 'spree/preferences/statically_configurable'
|
4
5
|
|
5
6
|
module Spree
|
@@ -11,6 +12,8 @@ module Spree
|
|
11
12
|
# This class is not meant to be instantiated. Please create instances of concrete payment methods.
|
12
13
|
#
|
13
14
|
class PaymentMethod < Spree::Base
|
15
|
+
include Spree::Preferences::Persistable
|
16
|
+
|
14
17
|
preference :server, :string, default: 'test'
|
15
18
|
preference :test_mode, :boolean, default: true
|
16
19
|
|
@@ -18,19 +21,6 @@ module Spree
|
|
18
21
|
|
19
22
|
acts_as_list
|
20
23
|
|
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
24
|
validates :name, :type, presence: true
|
35
25
|
|
36
26
|
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
@@ -67,51 +57,9 @@ module Spree
|
|
67
57
|
end
|
68
58
|
|
69
59
|
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
60
|
def model_name
|
101
61
|
ModelName.new(self, Spree)
|
102
62
|
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
63
|
end
|
116
64
|
|
117
65
|
# Represents the gateway of this payment method
|
@@ -138,8 +86,6 @@ module Spree
|
|
138
86
|
|
139
87
|
@gateway ||= gateway_class.new(gateway_options)
|
140
88
|
end
|
141
|
-
alias_method :provider, :gateway
|
142
|
-
deprecate provider: :gateway, deprecator: Spree::Deprecation
|
143
89
|
|
144
90
|
# Represents all preferences as a Hash
|
145
91
|
#
|
@@ -159,29 +105,6 @@ module Spree
|
|
159
105
|
raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
|
160
106
|
end
|
161
107
|
|
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
108
|
# Used as partial name for your payment method
|
186
109
|
#
|
187
110
|
# Currently your payment method needs to provide these partials:
|
@@ -202,21 +125,7 @@ module Spree
|
|
202
125
|
# The view that represents your payment method on orders through the api
|
203
126
|
#
|
204
127
|
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
|
128
|
+
type.demodulize.underscore
|
220
129
|
end
|
221
130
|
|
222
131
|
def payment_profiles_supported?
|
@@ -274,14 +183,7 @@ module Spree
|
|
274
183
|
# Represents the gateway class of this payment method
|
275
184
|
#
|
276
185
|
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
|
186
|
+
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
285
187
|
end
|
286
188
|
end
|
287
189
|
end
|
@@ -9,6 +9,10 @@ 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
|
+
|
12
16
|
attr_accessor :test
|
13
17
|
|
14
18
|
def gateway_class
|
@@ -26,40 +30,40 @@ module Spree
|
|
26
30
|
def authorize(_money, credit_card, _options = {})
|
27
31
|
profile_id = credit_card.gateway_customer_profile_id
|
28
32
|
if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-'))
|
29
|
-
ActiveMerchant::Billing::Response.new(true,
|
33
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'D' })
|
30
34
|
else
|
31
|
-
ActiveMerchant::Billing::Response.new(false,
|
35
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, { message: FAILURE_MESSAGE }, test: true)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def purchase(_money, credit_card, _options = {})
|
36
40
|
profile_id = credit_card.gateway_customer_profile_id
|
37
41
|
if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-'))
|
38
|
-
ActiveMerchant::Billing::Response.new(true,
|
42
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'M' })
|
39
43
|
else
|
40
|
-
ActiveMerchant::Billing::Response.new(false,
|
44
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, message: FAILURE_MESSAGE, test: true)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def credit(_money, _credit_card, _response_code, _options = {})
|
45
|
-
ActiveMerchant::Billing::Response.new(true,
|
49
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE)
|
46
50
|
end
|
47
51
|
|
48
52
|
def capture(_money, authorization, _gateway_options)
|
49
53
|
if authorization == '12345'
|
50
|
-
ActiveMerchant::Billing::Response.new(true,
|
54
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true)
|
51
55
|
else
|
52
|
-
ActiveMerchant::Billing::Response.new(false,
|
56
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, error: FAILURE_MESSAGE, test: true)
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
56
60
|
def void(_response_code, _credit_card, _options = {})
|
57
|
-
ActiveMerchant::Billing::Response.new(true,
|
61
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE)
|
58
62
|
end
|
59
63
|
|
60
64
|
# @see Spree::PaymentMethod#try_void
|
61
65
|
def try_void(_payment)
|
62
|
-
ActiveMerchant::Billing::Response.new(true,
|
66
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE)
|
63
67
|
end
|
64
68
|
|
65
69
|
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, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' })
|
13
13
|
else
|
14
|
-
ActiveMerchant::Billing::Response.new(false,
|
14
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, { message: FAILURE_MESSAGE }, 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, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' })
|
21
21
|
else
|
22
|
-
ActiveMerchant::Billing::Response.new(false,
|
22
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, message: FAILURE_MESSAGE, test: true)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
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
|