moneytree-rails 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +29 -6
- data/Rakefile +30 -4
- data/app/assets/config/moneytree_manifest.js +1 -0
- data/app/assets/stylesheets/moneytree/application.css +15 -0
- data/app/controllers/moneytree/application_controller.rb +9 -0
- data/app/controllers/moneytree/oauth/square_controller.rb +14 -0
- data/app/controllers/moneytree/oauth/stripe_controller.rb +43 -0
- data/app/controllers/moneytree/webhooks/square_controller.rb +9 -0
- data/app/controllers/moneytree/webhooks/stripe_controller.rb +9 -0
- data/app/helpers/moneytree/application_helper.rb +4 -0
- data/app/helpers/moneytree/oauth/stripe_helper.rb +6 -0
- data/app/jobs/moneytree/application_job.rb +4 -0
- data/app/mailers/moneytree/application_mailer.rb +6 -0
- data/app/models/moneytree/application_record.rb +5 -0
- data/app/models/moneytree/payment_gateway.rb +52 -0
- data/app/views/layouts/moneytree/application.html.erb +15 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20200914151648_create_moneytree_payment_gateways.rb +11 -0
- data/lib/moneytree.rb +9 -16
- data/lib/moneytree/account.rb +3 -34
- data/lib/moneytree/engine.rb +5 -0
- data/lib/moneytree/payment_provider/base.rb +5 -2
- data/lib/moneytree/payment_provider/stripe.rb +34 -0
- data/lib/moneytree/version.rb +1 -1
- data/lib/tasks/moneytree_tasks.rake +4 -0
- metadata +39 -32
- data/.github/workflows/ruby.yml +0 -33
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.travis.yml +0 -6
- data/CHANGELOG.md +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -248
- data/Guardfile +0 -70
- data/LICENSE.txt +0 -21
- data/app/controllers/moneytree/oauth_controller.rb +0 -18
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/config.ru +0 -9
- data/lib/generators/moneytree/activerecord_generator.rb +0 -41
- data/lib/generators/moneytree/base_generator.rb +0 -13
- data/lib/generators/moneytree/install_generator.rb +0 -43
- data/lib/generators/moneytree/templates/active_record_event_model.rb.tt +0 -10
- data/lib/generators/moneytree/templates/active_record_migration.rb.tt +0 -62
- data/lib/generators/moneytree/templates/active_record_visit_model.rb.tt +0 -6
- data/lib/generators/moneytree/templates/base_store_initializer.rb.tt +0 -20
- data/lib/generators/moneytree/templates/moneytree_initializer.rb.tt +0 -15
- data/lib/moneytree/transaction.rb +0 -9
- data/moneytree.gemspec +0 -29
data/Guardfile
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
## Uncomment and set this to only include directories you want to watch
|
5
|
-
# directories %w(app lib config test spec features) \
|
6
|
-
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
-
|
8
|
-
## Note: if you are using the `directories` clause above and you are not
|
9
|
-
## watching the project directory ('.'), then you will want to move
|
10
|
-
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
-
#
|
12
|
-
# $ mkdir config
|
13
|
-
# $ mv Guardfile config/
|
14
|
-
# $ ln -s config/Guardfile .
|
15
|
-
#
|
16
|
-
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
-
|
18
|
-
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
-
# rspec may be run, below are examples of the most common uses.
|
20
|
-
# * bundler: 'bundle exec rspec'
|
21
|
-
# * bundler binstubs: 'bin/rspec'
|
22
|
-
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
-
# installed the spring binstubs per the docs)
|
24
|
-
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
-
# * 'just' rspec: 'rspec'
|
26
|
-
|
27
|
-
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
-
require "guard/rspec/dsl"
|
29
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
-
|
31
|
-
# Feel free to open issues for suggestions and improvements
|
32
|
-
|
33
|
-
# RSpec files
|
34
|
-
rspec = dsl.rspec
|
35
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
-
watch(rspec.spec_files)
|
38
|
-
|
39
|
-
# Ruby files
|
40
|
-
ruby = dsl.ruby
|
41
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
-
|
43
|
-
# Rails files
|
44
|
-
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
-
dsl.watch_spec_files_for(rails.app_files)
|
46
|
-
dsl.watch_spec_files_for(rails.views)
|
47
|
-
|
48
|
-
watch(rails.controllers) do |m|
|
49
|
-
[
|
50
|
-
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
-
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
-
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
-
]
|
54
|
-
end
|
55
|
-
|
56
|
-
# Rails config changes
|
57
|
-
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
-
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
-
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
-
|
61
|
-
# Capybara features specs
|
62
|
-
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
-
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
-
|
65
|
-
# Turnip features and steps
|
66
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
-
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
-
end
|
70
|
-
end
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 Kieran Klaassen
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Moneytree
|
2
|
-
class OauthController < ApplicationController
|
3
|
-
def new
|
4
|
-
redirect_to current_account.oauth_link
|
5
|
-
end
|
6
|
-
|
7
|
-
def create
|
8
|
-
current_account.oauth_callback(params)
|
9
|
-
render text: 'Boom'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def current_account
|
16
|
-
send(Moneytree.current_account)
|
17
|
-
end
|
18
|
-
end
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "moneytree"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/config.ru
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'rails/generators/active_record'
|
2
|
-
|
3
|
-
module Moneytree
|
4
|
-
module Generators
|
5
|
-
class ActiverecordGenerator < Rails::Generators::Base
|
6
|
-
include ActiveRecord::Generators::Migration
|
7
|
-
source_root File.join(__dir__, 'templates')
|
8
|
-
|
9
|
-
class_option :database, type: :string, aliases: '-d'
|
10
|
-
|
11
|
-
def copy_templates
|
12
|
-
template 'moneytree_initializer.rb', 'config/initializers/moneytree.rb'
|
13
|
-
# template 'active_record_visit_model.rb', 'app/models/moneytree/visit.rb'
|
14
|
-
# template 'active_record_event_model.rb', 'app/models/moneytree/event.rb'
|
15
|
-
migration_template 'active_record_migration.rb', 'db/migrate/create_moneytree_visits_and_events.rb', migration_version: migration_version
|
16
|
-
puts "\nAlmost set! Last, run:\n\n rails db:migrate"
|
17
|
-
end
|
18
|
-
|
19
|
-
def properties_type
|
20
|
-
# use connection_config instead of connection.adapter
|
21
|
-
# so database connection isn't needed
|
22
|
-
case ActiveRecord::Base.connection_config[:adapter].to_s
|
23
|
-
when /postg/i # postgres, postgis
|
24
|
-
'jsonb'
|
25
|
-
when /mysql/i
|
26
|
-
'json'
|
27
|
-
else
|
28
|
-
'text'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def rails52?
|
33
|
-
ActiveRecord::VERSION::STRING >= '5.2'
|
34
|
-
end
|
35
|
-
|
36
|
-
def migration_version
|
37
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Moneytree
|
4
|
-
module Generators
|
5
|
-
class BaseGenerator < Rails::Generators::Base
|
6
|
-
source_root File.join(__dir__, 'templates')
|
7
|
-
|
8
|
-
def copy_templates
|
9
|
-
template 'base_store_initializer.rb', 'config/initializers/moneytree.rb'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Moneytree
|
4
|
-
module Generators
|
5
|
-
class InstallGenerator < Rails::Generators::Base
|
6
|
-
source_root File.join(__dir__, 'templates')
|
7
|
-
|
8
|
-
def copy_templates
|
9
|
-
activerecord = defined?(ActiveRecord)
|
10
|
-
|
11
|
-
selection =
|
12
|
-
if activerecord
|
13
|
-
puts <<~MSG
|
14
|
-
|
15
|
-
Which data store would you like to use?
|
16
|
-
1. ActiveRecord (default)
|
17
|
-
2. Mongoid
|
18
|
-
3. Neither
|
19
|
-
MSG
|
20
|
-
|
21
|
-
ask('>')
|
22
|
-
elsif activerecord
|
23
|
-
'1'
|
24
|
-
elsif mongoid
|
25
|
-
'2'
|
26
|
-
else
|
27
|
-
'3'
|
28
|
-
end
|
29
|
-
|
30
|
-
case selection
|
31
|
-
when '', '1'
|
32
|
-
invoke 'moneytree:activerecord'
|
33
|
-
when '2'
|
34
|
-
invoke 'moneytree:mongoid'
|
35
|
-
when '3'
|
36
|
-
invoke 'moneytree:base'
|
37
|
-
else
|
38
|
-
abort 'Error: must enter a number [1-3]'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
|
2
|
-
def change
|
3
|
-
create_table :Moneytree_visits do |t|
|
4
|
-
t.string :visit_token
|
5
|
-
t.string :visitor_token
|
6
|
-
|
7
|
-
# the rest are recommended but optional
|
8
|
-
# simply remove any you don't want
|
9
|
-
|
10
|
-
# user
|
11
|
-
t.references :user
|
12
|
-
|
13
|
-
# standard
|
14
|
-
t.string :ip
|
15
|
-
t.text :user_agent
|
16
|
-
t.text :referrer
|
17
|
-
t.string :referring_domain
|
18
|
-
t.text :landing_page
|
19
|
-
|
20
|
-
# technology
|
21
|
-
t.string :browser
|
22
|
-
t.string :os
|
23
|
-
t.string :device_type
|
24
|
-
|
25
|
-
# location
|
26
|
-
t.string :country
|
27
|
-
t.string :region
|
28
|
-
t.string :city
|
29
|
-
t.float :latitude
|
30
|
-
t.float :longitude
|
31
|
-
|
32
|
-
# utm parameters
|
33
|
-
t.string :utm_source
|
34
|
-
t.string :utm_medium
|
35
|
-
t.string :utm_term
|
36
|
-
t.string :utm_content
|
37
|
-
t.string :utm_campaign
|
38
|
-
|
39
|
-
# native apps
|
40
|
-
t.string :app_version
|
41
|
-
t.string :os_version
|
42
|
-
t.string :platform
|
43
|
-
|
44
|
-
t.timestamp :started_at
|
45
|
-
end
|
46
|
-
|
47
|
-
add_index :Moneytree_visits, :visit_token, unique: true
|
48
|
-
|
49
|
-
create_table :Moneytree_events do |t|
|
50
|
-
t.references :visit
|
51
|
-
t.references :user
|
52
|
-
|
53
|
-
t.string :name
|
54
|
-
t.<%= properties_type %> :properties
|
55
|
-
t.timestamp :time
|
56
|
-
end
|
57
|
-
|
58
|
-
add_index :Moneytree_events, [:name, :time]<% if properties_type == "jsonb" %><% if rails52? %>
|
59
|
-
add_index :Moneytree_events, :properties, using: :gin, opclass: :jsonb_path_ops<% else %>
|
60
|
-
add_index :Moneytree_events, "properties jsonb_path_ops", using: "gin"<% end %><% end %>
|
61
|
-
end
|
62
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class Moneytree::Store < Moneytree::BaseStore
|
2
|
-
def track_visit(data)
|
3
|
-
# do
|
4
|
-
end
|
5
|
-
|
6
|
-
def track_event(data)
|
7
|
-
# something
|
8
|
-
end
|
9
|
-
|
10
|
-
def geocode(data)
|
11
|
-
# amazing
|
12
|
-
end
|
13
|
-
|
14
|
-
def authenticate(data)
|
15
|
-
# !!!
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# set to true for JavaScript tracking
|
20
|
-
Moneytree.api = false
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Moneytree.setup do |config|
|
2
|
-
config.enabled_psps = %i[square stripe braintree]
|
3
|
-
|
4
|
-
# Account, merchant, team, Payee etc.
|
5
|
-
config.account_class = 'Account'
|
6
|
-
config.account_table = 'accounts'
|
7
|
-
|
8
|
-
# Order
|
9
|
-
config.order_class = 'Order'
|
10
|
-
config.order_table = 'orders'
|
11
|
-
|
12
|
-
# Transaction
|
13
|
-
config.transaction_class = 'Transaction'
|
14
|
-
config.transaction_table = 'transactions'
|
15
|
-
end
|
data/moneytree.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative 'lib/moneytree/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'moneytree-rails'
|
5
|
-
spec.version = Moneytree::VERSION
|
6
|
-
spec.authors = ['Kieran Klaassen']
|
7
|
-
spec.email = ['kieranklaassen@gmail.com']
|
8
|
-
|
9
|
-
spec.summary = 'A payments engine for rails centered aorund transactional payments and orders.'
|
10
|
-
spec.description = spec.summary
|
11
|
-
spec.homepage = 'https://github.com/kieranklaassen/moneytree'
|
12
|
-
spec.license = 'MIT'
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
|
-
|
15
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
16
|
-
spec.metadata['source_code_uri'] = 'https://github.com/kieranklaassen/moneytree'
|
17
|
-
spec.metadata['changelog_uri'] = 'https://github.com/kieranklaassen/moneytree/blob/master/CHANGELOG.md'
|
18
|
-
|
19
|
-
# Specify which files should be added to the gem when it is released.
|
20
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
-
end
|
24
|
-
spec.bindir = 'exe'
|
25
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
-
spec.require_paths = ['lib']
|
27
|
-
|
28
|
-
spec.add_dependency 'rails', '>= 4.2'
|
29
|
-
end
|