Sha256: 4ca2cd91ddb73c4409beb2785e7e8d26b8ddb28783c68c5510ad822c87d83788

Contents?: true

Size: 703 Bytes

Versions: 5

Compression:

Stored size: 703 Bytes

Contents

module Spree
  class Recurring < Spree::Base
    include RestrictiveDestroyer

    acts_as_restrictive_destroyer

    preference :secret_key, :string
    preference :public_key, :string

    has_many :plans
    attr_readonly :type
    validates :type, :name, presence: true
    validates :type, uniqueness: { message: 'of provider recurring already exists' }

    scope :active, -> { undeleted.where(active: true) }

    def self.display_name
      name.gsub(%r{.+:}, '')
    end

    def visible?
      active? && !is_destroyed?
    end

    def default_plan
      plans.default
    end

    def has_preferred_keys?
      preferred_secret_key.present? && preferred_public_key.present?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_account_recurring-2.0.0 app/models/spree/recurring.rb
spree_account_recurring-1.3.1 app/models/spree/recurring.rb
spree_account_recurring-1.2.1 app/models/spree/recurring.rb
spree_account_recurring-1.3.0 app/models/spree/recurring.rb
spree_account_recurring-1.2.0 app/models/spree/recurring.rb