Sha256: d1195a1b7edaea77c812d45e264895a5f11f3f9ac5c9f094cb9814042d5b122a

Contents?: true

Size: 907 Bytes

Versions: 2

Compression:

Stored size: 907 Bytes

Contents

require 'active_record'
module WepayRails
  module Payments
    require 'helpers/controller_helpers'
    class Gateway
      include HTTParty
      base_uri Rails.env.production? ? "https://api.wepay.com" : "https://stage.wepay.com"

      attr_accessor :wepay_auth_code

      def initialize(*args)
        yml = Rails.root.join('config', 'wepay.yml').to_s
        @config = YAML.load_file(yml)[Rails.env].symbolize_keys
      end

      def wepay_auth_header
        {'Authorization' => "Bearer: #{@wepay_auth_code}"}
      end

      def wepay_user
        response = self.class.get("/v2/user", {:headers => wepay_auth_header})
        JSON.parse(response.body)
      end
    end

    include WepayRails::Helpers::ControllerHelpers
  end

  require 'helpers/model_helpers'
  def self.included(base)
    base.extend WepayRails::Helpers::ModelHelpers
  end
end
ActiveRecord::Base.send(:include, WepayRails)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wepay-rails-0.1.17 lib/wepay-rails.rb
wepay-rails-0.1.16 lib/wepay-rails.rb