Sha256: d6869ae66656dc7ab04f90d9aeab1621e74a44031497ebb4b78aaff595803f53

Contents?: true

Size: 605 Bytes

Versions: 2

Compression:

Stored size: 605 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.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

2 entries across 2 versions & 1 rubygems

Version Path
opay-1.0.0 lib/opay/payable.rb
opay-1.0.0.beta lib/opay/payable.rb