Sha256: 620c9b5c36bfddd5e76cb5f01026d127573247fb13a483c578b04e975dfe7692

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 Bytes

Contents

Spree::Order.class_eval do

  has_many :gtpay_transactions

  def gtpay_payment
    @gtpay_payment_method = Spree::Gateway::Gtpay.where(:environment => Rails.env).first
    payments.where("payment_method_id = #{@gtpay_payment_method.id} and state in ('checkout', 'processing', 'pending')").first if @gtpay_payment_method
  end

  def complete_and_finalize
    gtpay_payment.process_and_complete!

    update_attributes({:state => "complete", :completed_at => Time.current}, :without_protection => true)
    finalize!
  end

  def set_failure_for_payment
    gtpay_payment.started_processing!
    gtpay_payment.failure!
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_gtpay-1.0.2 app/models/spree/order_decorator.rb
spree_gtpay-1.0.1 app/models/spree/order_decorator.rb
spree_gtpay-1.0.0 app/models/spree/order_decorator.rb