Class: Spree::CashOnDelivery::PaymentMethod
- Inherits:
-
PaymentMethod
- Object
- PaymentMethod
- Spree::CashOnDelivery::PaymentMethod
- Defined in:
- app/models/spree/cash_on_delivery/payment_method.rb
Instance Method Summary collapse
- #actions ⇒ Object
- #authorize(*args) ⇒ Object
- #auto_capture? ⇒ Boolean
- #can_capture?(payment) ⇒ Boolean
- #can_void?(payment) ⇒ Boolean
- #capture(payment, source, gateway_options) ⇒ Object
- #create_adjustment(payment) ⇒ Object
- #method_type ⇒ Object
- #payment_profiles_supported? ⇒ Boolean
-
#payment_source_class ⇒ Object
def provider_class self.class end.
- #source_required? ⇒ Boolean
- #void(*args) ⇒ Object
Instance Method Details
#actions ⇒ Object
46 47 48 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 46 def actions %w{capture void} end |
#authorize(*args) ⇒ Object
34 35 36 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 34 def (*args) ActiveMerchant::Billing::Response.new(true, "", {}, {}) end |
#auto_capture? ⇒ Boolean
74 75 76 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 74 def auto_capture? true end |
#can_capture?(payment) ⇒ Boolean
50 51 52 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 50 def can_capture?(payment) payment.state == 'pending' || payment.state == 'checkout' end |
#can_void?(payment) ⇒ Boolean
54 55 56 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 54 def can_void?(payment) payment.state != 'void' end |
#capture(payment, source, gateway_options) ⇒ Object
38 39 40 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 38 def capture(payment, source, ) ActiveMerchant::Billing::Response.new(true, "", {}, {}) end |
#create_adjustment(payment) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 13 def create_adjustment(payment) adjustment = Spree::Adjustment.create( amount: Spree::CashOnDelivery::Config.charge.to_f, order: payment.order, adjustable: payment.order, source: self, :mandatory => true, :included => true, label: "Cash On Delivery Fee" ) payment.order.adjustments << adjustment payment.update_attribute(:amount, payment.amount + Spree::CashOnDelivery::Config.charge.to_f) payment.order.updater.update_adjustment_total payment.order.updater.update_order_total payment.order.persist_totals # end end |
#method_type ⇒ Object
70 71 72 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 70 def method_type 'cash_on_delivery' end |
#payment_profiles_supported? ⇒ Boolean
8 9 10 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 8 def payment_profiles_supported? false # we want to show the confirm step. end |
#payment_source_class ⇒ Object
def provider_class
self.class
end
66 67 68 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 66 def payment_source_class nil end |
#source_required? ⇒ Boolean
58 59 60 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 58 def source_required? false end |
#void(*args) ⇒ Object
42 43 44 |
# File 'app/models/spree/cash_on_delivery/payment_method.rb', line 42 def void(*args) ActiveMerchant::Billing::Response.new(true, "", {}, {}) end |