Module: EffectiveOrders
- Defined in:
- lib/generators/effective_orders/upgrade_price_column_generator.rb,
lib/effective_orders.rb,
lib/effective_orders/engine.rb,
lib/effective_orders/version.rb,
lib/effective_orders/app_checkout_service.rb,
lib/generators/effective_orders/install_generator.rb,
lib/generators/effective_orders/upgrade_from1x_generator.rb,
lib/generators/effective_orders/upgrade_from03x_generator.rb
Overview
bundle exec rails generate effective_orders:upgrade_price_column TABLE COLUMN
Defined Under Namespace
Modules: Generators Classes: AlreadyPurchasedException, AppCheckoutService, Engine, SoldOutException
Constant Summary collapse
- PURCHASED =
'purchased'- DECLINED =
'declined'- PENDING =
'pending'- VERSION =
'2.1.5'.freeze
Class Method Summary collapse
- .authorized?(controller, action, resource) ⇒ Boolean
- .minimum_charge ⇒ Object
- .other_payment_providers ⇒ Object
-
.payment_providers ⇒ Object
The Effective::Order.payment_provider value must be in this collection.
- .permitted_params ⇒ Object
- .setup {|_self| ... } ⇒ Object
- .single_payment_processor? ⇒ Boolean
- .tax_rate_method=(*args) ⇒ Object
- .use_active_admin? ⇒ Boolean
Class Method Details
.authorized?(controller, action, resource) ⇒ Boolean
99 100 101 102 103 104 |
# File 'lib/effective_orders.rb', line 99 def self.(controller, action, resource) if .respond_to?(:call) || .kind_of?(Symbol) raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &) end true end |
.minimum_charge ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/effective_orders.rb', line 106 def self.minimum_charge if @@minimum_charge.nil? || @@minimum_charge.kind_of?(Integer) @@minimum_charge else ActiveSupport::Deprecation.warn('EffectiveOrders.minimum_charge config option is a non-integer. It should be an Integer representing the number of cents. Continuing with (price * 100.0).round(0).to_i conversion') unless EffectiveOrders.silence_deprecation_warnings ((@@minimum_charge * 100.0).round(0).to_i rescue nil) end end |
.other_payment_providers ⇒ Object
155 156 157 |
# File 'lib/effective_orders.rb', line 155 def self.other_payment_providers ['credit card', 'none', 'other'] end |
.payment_providers ⇒ Object
The Effective::Order.payment_provider value must be in this collection
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/effective_orders.rb', line 141 def self.payment_providers @payment_providers ||= [ ('app_checkout' if app_checkout_enabled), ('ccbill' if ccbill_enabled), ('cheque' if cheque_enabled), ('free' if allow_free_orders), ('moneris' if moneris_enabled), ('paypal' if paypal_enabled), ('pretend' if (allow_pretend_purchase_in_production && Rails.env.production?) || (allow_pretend_purchase_in_development && !Rails.env.production?)), ('stripe' if stripe_enabled), ('stripe_connect' if stripe_connect_enabled) ].compact end |
.permitted_params ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'lib/effective_orders.rb', line 119 def self.permitted_params [ :note, :save_billing_address, :save_shipping_address, :shipping_address_same_as_billing, :terms_and_conditions, billing_address: [:full_name, :address1, :address2, :city, :country_code, :state_code, :postal_code], shipping_address: [:full_name, :address1, :address2, :city, :country_code, :state_code, :postal_code], user_attributes: (EffectiveOrders.collect_user_fields || []), order_items_attributes: [:stripe_coupon_id, :class, :id] ] end |
.setup {|_self| ... } ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/effective_orders.rb', line 85 def self.setup yield self if EffectiveOrders.stripe_enabled begin require 'stripe' rescue Exception raise "unable to load stripe. Plese add gem 'stripe' to your Gemfile and then 'bundle install'" end ::Stripe.api_key = stripe[:secret_key] end end |
.single_payment_processor? ⇒ Boolean
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/effective_orders.rb', line 129 def self.single_payment_processor? [ moneris_enabled, paypal_enabled, stripe_enabled, cheque_enabled, ccbill_enabled, app_checkout_enabled ].select { |enabled| enabled }.length == 1 end |
.tax_rate_method=(*args) ⇒ Object
159 160 161 |
# File 'lib/effective_orders.rb', line 159 def self.tax_rate_method=(*args) raise 'EffectiveOrders.tax_rate_method has been removed and renamed to EffectiveOrders.order_tax_rate_method. Its expected value is now different too. Return 5.25 for 5.25% tax. Please refer to the readme for more info.' end |
.use_active_admin? ⇒ Boolean
115 116 117 |
# File 'lib/effective_orders.rb', line 115 def self.use_active_admin? use_active_admin && defined?(ActiveAdmin) end |