lib/pay/billable.rb in pay-2.6.3 vs lib/pay/billable.rb in pay-2.6.4
- old
+ new
@@ -22,10 +22,13 @@
has_many :subscriptions, class_name: Pay.subscription_class, foreign_key: :owner_id, inverse_of: :owner, as: :owner
attribute :plan, :string
attribute :quantity, :integer
attribute :card_token, :string
+ attribute :pay_fake_processor_allowed, :boolean, default: false
+
+ validate :pay_fake_processor_is_allowed, if: :processor_changed?
end
def payment_processor
@payment_processor ||= payment_processor_for(processor).new(self)
end
@@ -152,8 +155,13 @@
private
def default_generic_trial?(name, plan)
# Generic trials don't have plans or custom names
plan.nil? && name == "default" && on_generic_trial?
+ end
+
+ def pay_fake_processor_is_allowed
+ return unless processor == "fake_processor"
+ errors.add(:processor, "must be a valid payment processor") unless pay_fake_processor_allowed?
end
end
end