Sha256: 0a2f0143f30d07ef1e094a55af257abafa792196e182fdc9ba99eb7a95e92aad

Contents?: true

Size: 625 Bytes

Versions: 5

Compression:

Stored size: 625 Bytes

Contents

module Opay
  module Payable
    extend ActiveSupport::Concern
    extend ActiveModel::Callbacks

    included do
      has_one :payment, as: :payable, class_name: 'Opay::Payment'
      define_model_callbacks :payment, only: :after
    end

    def finished?
      payment.present? && payment.finished?
    end

    def finish
      run_callbacks :payment do
        payment.update_attribute(:finished, true)
      end
    end

    def payment_session_id
      raise 'Resource must be saved before payment' if id.nil?
      Digest::MD5.hexdigest(self.class.name + id.to_s)
    end

    module ClassMethods
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opay-1.0.6 lib/opay/payable.rb
opay-1.0.5 lib/opay/payable.rb
opay-1.0.4 lib/opay/payable.rb
opay-1.0.3 lib/opay/payable.rb
opay-1.0.1 lib/opay/payable.rb