moneytree-rails 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac0effde5b67728b209c237fcd5eb32f1bfaf682396d6dd65b3bbef29614c880
4
+ data.tar.gz: 48b468a83dfd1a2099a04c3d137538d90444be660e281cbcf9fbb502469b28e7
5
+ SHA512:
6
+ metadata.gz: f07412f98d4783a4e6b64316c1fe10300e0c47f6f008a9479b8df592e23a01c2d72697de61b53d5d495e504a64bdfdb79529bddc71af205ff1fa968a3742b420
7
+ data.tar.gz: c04082cfb750538aa4ae3f9500c2d3b9fcae56ad546a81e326ae5994e7045c781ff4ac408b99b71492fef642dccd60d2c5ac851f17b55b957ed04ca780fb30d3
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: build
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ /spec/internal/db/combustion_test.sqlite
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,7 @@
1
+ ## Master
2
+
3
+ -
4
+
5
+ ## 0.1.0 (2020-06-07)
6
+
7
+ -
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kieranklaassen@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in moneytree.gemspec
4
+ gemspec
5
+
6
+ # Dev dependencies
7
+ gem "rails", "~> 6.0"
8
+ gem "rake", "~> 12.0"
9
+ gem 'rspec-rails', '~> 3.4'
10
+ gem "rubocop", "~> 0.89.1"
11
+ gem "combustion", "~> 1.3"
12
+ gem "sqlite3", "~> 1.4"
13
+ gem 'guard-rspec', require: false
14
+ gem 'square.rb', '~> 6.3'
15
+ gem "pry", "~> 0.13.1"
@@ -0,0 +1,248 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ moneytree-rails (0.1.0)
5
+ rails (>= 4.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.0.3.2)
11
+ actionpack (= 6.0.3.2)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.3.2)
15
+ actionpack (= 6.0.3.2)
16
+ activejob (= 6.0.3.2)
17
+ activerecord (= 6.0.3.2)
18
+ activestorage (= 6.0.3.2)
19
+ activesupport (= 6.0.3.2)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.3.2)
22
+ actionpack (= 6.0.3.2)
23
+ actionview (= 6.0.3.2)
24
+ activejob (= 6.0.3.2)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (6.0.3.2)
28
+ actionview (= 6.0.3.2)
29
+ activesupport (= 6.0.3.2)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.3.2)
35
+ actionpack (= 6.0.3.2)
36
+ activerecord (= 6.0.3.2)
37
+ activestorage (= 6.0.3.2)
38
+ activesupport (= 6.0.3.2)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.3.2)
41
+ activesupport (= 6.0.3.2)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.3.2)
47
+ activesupport (= 6.0.3.2)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.3.2)
50
+ activesupport (= 6.0.3.2)
51
+ activerecord (6.0.3.2)
52
+ activemodel (= 6.0.3.2)
53
+ activesupport (= 6.0.3.2)
54
+ activestorage (6.0.3.2)
55
+ actionpack (= 6.0.3.2)
56
+ activejob (= 6.0.3.2)
57
+ activerecord (= 6.0.3.2)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.3.2)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 2.2, >= 2.2.2)
65
+ ast (2.4.1)
66
+ builder (3.2.4)
67
+ certifi (2018.01.18)
68
+ coderay (1.1.3)
69
+ combustion (1.3.0)
70
+ activesupport (>= 3.0.0)
71
+ railties (>= 3.0.0)
72
+ thor (>= 0.14.6)
73
+ concurrent-ruby (1.1.7)
74
+ crass (1.0.6)
75
+ diff-lcs (1.4.4)
76
+ erubi (1.9.0)
77
+ faraday (0.17.3)
78
+ multipart-post (>= 1.2, < 3)
79
+ faraday-http-cache (2.2.0)
80
+ faraday (>= 0.8)
81
+ faraday_middleware (0.14.0)
82
+ faraday (>= 0.7.4, < 1.0)
83
+ ffi (1.13.1)
84
+ formatador (0.2.5)
85
+ globalid (0.4.2)
86
+ activesupport (>= 4.2.0)
87
+ guard (2.16.2)
88
+ formatador (>= 0.2.4)
89
+ listen (>= 2.7, < 4.0)
90
+ lumberjack (>= 1.0.12, < 2.0)
91
+ nenv (~> 0.1)
92
+ notiffany (~> 0.0)
93
+ pry (>= 0.9.12)
94
+ shellany (~> 0.0)
95
+ thor (>= 0.18.1)
96
+ guard-compat (1.2.1)
97
+ guard-rspec (4.7.3)
98
+ guard (~> 2.1)
99
+ guard-compat (~> 1.1)
100
+ rspec (>= 2.99.0, < 4.0)
101
+ i18n (1.8.5)
102
+ concurrent-ruby (~> 1.0)
103
+ listen (3.2.1)
104
+ rb-fsevent (~> 0.10, >= 0.10.3)
105
+ rb-inotify (~> 0.9, >= 0.9.10)
106
+ little-plugger (1.1.4)
107
+ logging (2.3.0)
108
+ little-plugger (~> 1.1)
109
+ multi_json (~> 1.14)
110
+ loofah (2.6.0)
111
+ crass (~> 1.0.2)
112
+ nokogiri (>= 1.5.9)
113
+ lumberjack (1.2.7)
114
+ mail (2.7.1)
115
+ mini_mime (>= 0.1.1)
116
+ marcel (0.3.3)
117
+ mimemagic (~> 0.3.2)
118
+ method_source (1.0.0)
119
+ mimemagic (0.3.5)
120
+ mini_mime (1.0.2)
121
+ mini_portile2 (2.4.0)
122
+ minitest (5.14.1)
123
+ multi_json (1.15.0)
124
+ multipart-post (2.1.1)
125
+ nenv (0.3.0)
126
+ nio4r (2.5.2)
127
+ nokogiri (1.10.10)
128
+ mini_portile2 (~> 2.4.0)
129
+ notiffany (0.1.3)
130
+ nenv (~> 0.1)
131
+ shellany (~> 0.0)
132
+ parallel (1.19.2)
133
+ parser (2.7.1.4)
134
+ ast (~> 2.4.1)
135
+ pry (0.13.1)
136
+ coderay (~> 1.1)
137
+ method_source (~> 1.0)
138
+ rack (2.2.3)
139
+ rack-test (1.1.0)
140
+ rack (>= 1.0, < 3)
141
+ rails (6.0.3.2)
142
+ actioncable (= 6.0.3.2)
143
+ actionmailbox (= 6.0.3.2)
144
+ actionmailer (= 6.0.3.2)
145
+ actionpack (= 6.0.3.2)
146
+ actiontext (= 6.0.3.2)
147
+ actionview (= 6.0.3.2)
148
+ activejob (= 6.0.3.2)
149
+ activemodel (= 6.0.3.2)
150
+ activerecord (= 6.0.3.2)
151
+ activestorage (= 6.0.3.2)
152
+ activesupport (= 6.0.3.2)
153
+ bundler (>= 1.3.0)
154
+ railties (= 6.0.3.2)
155
+ sprockets-rails (>= 2.0.0)
156
+ rails-dom-testing (2.0.3)
157
+ activesupport (>= 4.2.0)
158
+ nokogiri (>= 1.6)
159
+ rails-html-sanitizer (1.3.0)
160
+ loofah (~> 2.3)
161
+ railties (6.0.3.2)
162
+ actionpack (= 6.0.3.2)
163
+ activesupport (= 6.0.3.2)
164
+ method_source
165
+ rake (>= 0.8.7)
166
+ thor (>= 0.20.3, < 2.0)
167
+ rainbow (3.0.0)
168
+ rake (12.3.3)
169
+ rb-fsevent (0.10.4)
170
+ rb-inotify (0.10.1)
171
+ ffi (~> 1.0)
172
+ regexp_parser (1.7.1)
173
+ rexml (3.2.4)
174
+ rspec (3.9.0)
175
+ rspec-core (~> 3.9.0)
176
+ rspec-expectations (~> 3.9.0)
177
+ rspec-mocks (~> 3.9.0)
178
+ rspec-core (3.9.2)
179
+ rspec-support (~> 3.9.3)
180
+ rspec-expectations (3.9.2)
181
+ diff-lcs (>= 1.2.0, < 2.0)
182
+ rspec-support (~> 3.9.0)
183
+ rspec-mocks (3.9.1)
184
+ diff-lcs (>= 1.2.0, < 2.0)
185
+ rspec-support (~> 3.9.0)
186
+ rspec-rails (3.9.1)
187
+ actionpack (>= 3.0)
188
+ activesupport (>= 3.0)
189
+ railties (>= 3.0)
190
+ rspec-core (~> 3.9.0)
191
+ rspec-expectations (~> 3.9.0)
192
+ rspec-mocks (~> 3.9.0)
193
+ rspec-support (~> 3.9.0)
194
+ rspec-support (3.9.3)
195
+ rubocop (0.89.1)
196
+ parallel (~> 1.10)
197
+ parser (>= 2.7.1.1)
198
+ rainbow (>= 2.2.2, < 4.0)
199
+ regexp_parser (>= 1.7)
200
+ rexml
201
+ rubocop-ast (>= 0.3.0, < 1.0)
202
+ ruby-progressbar (~> 1.7)
203
+ unicode-display_width (>= 1.4.0, < 2.0)
204
+ rubocop-ast (0.3.0)
205
+ parser (>= 2.7.1.4)
206
+ ruby-progressbar (1.10.1)
207
+ shellany (0.0.1)
208
+ sprockets (4.0.2)
209
+ concurrent-ruby (~> 1.0)
210
+ rack (> 1, < 3)
211
+ sprockets-rails (3.2.1)
212
+ actionpack (>= 4.0)
213
+ activesupport (>= 4.0)
214
+ sprockets (>= 3.0.0)
215
+ sqlite3 (1.4.2)
216
+ square.rb (6.3.0.20200826)
217
+ certifi (~> 2018.1)
218
+ faraday (~> 0.15)
219
+ faraday-http-cache (~> 2.0)
220
+ faraday_middleware (~> 0.13)
221
+ logging (~> 2.2)
222
+ thor (1.0.1)
223
+ thread_safe (0.3.6)
224
+ tzinfo (1.2.7)
225
+ thread_safe (~> 0.1)
226
+ unicode-display_width (1.7.0)
227
+ websocket-driver (0.7.3)
228
+ websocket-extensions (>= 0.1.0)
229
+ websocket-extensions (0.1.5)
230
+ zeitwerk (2.4.0)
231
+
232
+ PLATFORMS
233
+ ruby
234
+
235
+ DEPENDENCIES
236
+ combustion (~> 1.3)
237
+ guard-rspec
238
+ moneytree-rails!
239
+ pry (~> 0.13.1)
240
+ rails (~> 6.0)
241
+ rake (~> 12.0)
242
+ rspec-rails (~> 3.4)
243
+ rubocop (~> 0.89.1)
244
+ sqlite3 (~> 1.4)
245
+ square.rb (~> 6.3)
246
+
247
+ BUNDLED WITH
248
+ 2.2.0.rc.1
@@ -0,0 +1,70 @@
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
@@ -0,0 +1,21 @@
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.
@@ -0,0 +1,113 @@
1
+ # 🚧 WORK IN PROGRESS 🚧
2
+
3
+ - [ ] OAuth
4
+ - [ ] Cards
5
+ - [ ] Customers
6
+ - [ ] Payments
7
+ - [ ] Refunds
8
+ - [ ] Notifications
9
+
10
+ # Moneytree 💵 🌴
11
+
12
+ [![Actions Status](https://github.com/kieranklaassen/moneytree/workflows/build/badge.svg)](https://github.com/kieranklaassen/moneytree/actions)
13
+ [![Gem Version](https://badge.fury.io/rb/moneytree.svg)](https://badge.fury.io/rb/moneytree)
14
+
15
+ 🔥 A powerful, simple, and extendable payment engine for rails, centered around transactional payments. 💵 🌴
16
+
17
+ Moneytree is a rails engine to add multi-PSP payments to your app by extending your own models. It brings the following
18
+ functionality with almost no work on your end:
19
+
20
+ - 💵💶💷💴 Multi-currency
21
+ - 🔑 OAuth to link your PSP account
22
+ - 👩‍💻PSP account creation, (with commission)
23
+ - ⚙️ Webhooks
24
+ - 💳 PCI compliance with Javascript libraries
25
+ - 🧲 Platform fees
26
+
27
+ Currently we support the following PSP's:
28
+
29
+ - Square
30
+ - Stripe
31
+ - Braintree
32
+
33
+ But if you want to add more PSP's, we make it easy to do so. Read our
34
+ [Contributing](https://github.com/kieranklaassen/moneytree#contributing) section to learn more.
35
+
36
+ ## Installation
37
+
38
+ ### Easy Installation
39
+
40
+ Run our installer script:
41
+
42
+ ```bash
43
+ rails app:template LOCATION='https://railsbytes.com/script/Xg8sOv'
44
+ ```
45
+
46
+ ### Manual Installation
47
+
48
+ Add the latest version of Moneytree to your gem Gemfile by running:
49
+
50
+ ```bash
51
+ $ bundle add moneytree
52
+ $ bundle install
53
+ $ bundle exec moneytree init
54
+ ```
55
+
56
+ Or your can use environment variables:
57
+
58
+ FIXME: add
59
+
60
+ ## Configuration
61
+
62
+ Do you need to make some changes to how Moneytree is used? You can create an initializer
63
+ `config/initializers/moneytree.rb`
64
+
65
+ ```ruby
66
+ Moneytree.setup do |config|
67
+ config.enabled_psps = [:square, :stripe, :braintree]
68
+ config.account_class = 'Account'
69
+ config.order_class = 'Order'
70
+ config.transaction_class = 'Transaction'
71
+
72
+ config.square_credentials = {
73
+ app_id: ENV['SQUARE_APP_ID'],
74
+ app_secret: ENV['SQUARE_APP_SECRET'],
75
+ environment: Rails.env.production? : 'production' : 'sandbox',
76
+ oauth_domain: Rails.env.production? ? 'https://connect.squareup.com' : 'https://connect.squareupsandbox.com'
77
+ }
78
+ end
79
+ ```
80
+
81
+ ## Usage
82
+
83
+ ### The Primitives
84
+
85
+ Before you start using the Gem, it is good to understand the models and what they do. This Gem is made for people that
86
+ need payments for transactional orders. Think, an account holder that sells products. When an order is made there is a
87
+ transaction attached for the payment. You can name these models however you want yourself.
88
+
89
+ ### The API
90
+
91
+ ## Development
92
+
93
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
94
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
95
+
96
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
97
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
98
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
99
+
100
+ ## Contributing
101
+
102
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kieranklaassen/moneytree. This project is
103
+ intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
104
+ [code of conduct](https://github.com/kieranklaassen/moneytree/blob/master/CODE_OF_CONDUCT.md).
105
+
106
+ ## License
107
+
108
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
109
+
110
+ ## Code of Conduct
111
+
112
+ Everyone interacting in the Moneytree project's codebases, issue trackers, chat rooms and mailing lists is expected to
113
+ follow the [code of conduct](https://github.com/kieranklaassen/moneytree/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,14 @@
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize! :all
9
+ run Combustion::Application
@@ -0,0 +1,41 @@
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
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,43 @@
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
@@ -0,0 +1,10 @@
1
+ class Moneytree::Event < ApplicationRecord
2
+ include Moneytree::QueryMethods
3
+
4
+ self.table_name = "Moneytree_events"
5
+
6
+ belongs_to :visit
7
+ belongs_to :user, optional: true<% if properties_type == "text" %>
8
+
9
+ serialize :properties, JSON<% end %>
10
+ end
@@ -0,0 +1,62 @@
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
@@ -0,0 +1,6 @@
1
+ class Moneytree::Visit < ApplicationRecord
2
+ self.table_name = "Moneytree_visits"
3
+
4
+ has_many :events, class_name: "Moneytree::Event"
5
+ belongs_to :user, optional: true
6
+ end
@@ -0,0 +1,20 @@
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
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,49 @@
1
+ # dependencies
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+
5
+ # modules
6
+ # FIXME: autoload instead? https :/ / github.com / excid3 / noticed / blob / master / lib / noticed.rb
7
+ require 'moneytree/version'
8
+ require 'moneytree/account'
9
+ require 'moneytree/transaction'
10
+ require 'moneytree/payment_provider/square'
11
+
12
+ require "'moneytree/engine" if defined?(Rails)
13
+
14
+ module Moneytree
15
+ PSPS = %i[square stripe braintree].freeze
16
+
17
+ mattr_accessor :enabled_psps
18
+ mattr_accessor :account_class
19
+ mattr_accessor :order_class
20
+ mattr_accessor :transaction_class
21
+ mattr_accessor :square_credentials
22
+ mattr_accessor :current_account
23
+
24
+ @@enabled_psps = PSPS
25
+ @@account_class = 'Account'
26
+ @@order_class = 'Order'
27
+ @@transaction_class = 'Transaction'
28
+ @@current_account = 'current_account'
29
+
30
+ def self.setup
31
+ yield self
32
+ end
33
+
34
+ # Errors FIXME: see examples at https://github.com/pay-rails/pay/blob/master/lib/pay.rb#L119
35
+ class Error < StandardError; end
36
+ end
37
+
38
+ # FIXME: See if we need this, example: https://github.com/ankane/ahoy/blob/master/lib/ahoy/model.rb
39
+ ActiveSupport.on_load(:action_controller) do
40
+ # include Moneytree::Controller
41
+ end
42
+
43
+ ActiveSupport.on_load(:active_record) do
44
+ # extend Moneytree::Model
45
+ end
46
+
47
+ ActiveSupport.on_load(:action_view) do
48
+ # include Moneytree::Helper
49
+ end
@@ -0,0 +1,42 @@
1
+ module Moneytree
2
+ module Account
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ enum moneytree_psp: Moneytree::PSPS
7
+ serialize :psp_credentials
8
+ # encrypts :psp_credentials
9
+ # FIXME: enable https://github.com/ankane/lockbox
10
+ delegate :client, :oauth_link, to: :psp
11
+ end
12
+
13
+ def oauth_callback(params)
14
+ update! psp_credentials: psp.oauth_callback(params)
15
+ end
16
+
17
+ def psp_connected?
18
+ false
19
+ # moneytree_psp && psp_credentials
20
+ end
21
+
22
+ def needs_oauth?
23
+ true
24
+ end
25
+
26
+ def charge; end
27
+
28
+ def refund; end
29
+
30
+ private
31
+
32
+ def psp
33
+ @psp ||=
34
+ case moneytree_psp
35
+ when 'square'
36
+ Moneytree::PaymentProvider::Square.new(self)
37
+ else
38
+ raise 'BOOM'
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ module Moneytree
2
+ module PaymentProvider
3
+ class Base
4
+ def initialize(account)
5
+ @account = account
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,53 @@
1
+ module Moneytree
2
+ module PaymentProvider
3
+ class Square < Base
4
+ # The permissions we request from Square OAuth, we store them in the database
5
+ PERMISSIONS = %i[
6
+ merchant_profile_read
7
+ payments_write
8
+ payments_read
9
+ customers_write
10
+ payments_write_additional_recipients
11
+ ].freeze
12
+
13
+ def oauth_link
14
+ "#{credentitals[:oauth_domain]}/oauth2/authorize?client_id=#{credentitals[:app_id]}&scope=#{PERMISSIONS.join('+').upcase}"
15
+ end
16
+
17
+ def oauth_callback(_params)
18
+ # https://developer.squareup.com/docs/oauth-api/walkthrough
19
+ {
20
+ scope: PERMISSIONS,
21
+ access_token: '123',
22
+ refresh_token: '567',
23
+ expires_at: '',
24
+ token_type: 'bearer',
25
+ merchant_id: 'safsf'
26
+ }
27
+ end
28
+
29
+ def test_credentials
30
+ client.sdfsdf
31
+ rescue StandardError
32
+ raise 'Not working'
33
+ end
34
+
35
+ def scope_correct?
36
+ @account.psp_credentials.scope.sort == PERMISSIONS.sort
37
+ end
38
+
39
+ def client
40
+ @client ||= Square::Client.new(
41
+ access_token: @account.psp_credentials.square_access_token,
42
+ environment: credentitals[:environment]
43
+ )
44
+ end
45
+
46
+ private
47
+
48
+ def credentitals
49
+ Moneytree.square_credentials
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,9 @@
1
+ module Moneytree
2
+ module Transaction
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ enum type: %i[payment refund]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Moneytree
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,29 @@
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
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moneytree-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kieran Klaassen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ description: A payments engine for rails centered aorund transactional payments and
28
+ orders.
29
+ email:
30
+ - kieranklaassen@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".github/workflows/ruby.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".travis.yml"
39
+ - CHANGELOG.md
40
+ - CODE_OF_CONDUCT.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - Guardfile
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - app/controllers/moneytree/oauth_controller.rb
48
+ - bin/console
49
+ - bin/setup
50
+ - config.ru
51
+ - lib/generators/moneytree/activerecord_generator.rb
52
+ - lib/generators/moneytree/base_generator.rb
53
+ - lib/generators/moneytree/install_generator.rb
54
+ - lib/generators/moneytree/templates/active_record_event_model.rb.tt
55
+ - lib/generators/moneytree/templates/active_record_migration.rb.tt
56
+ - lib/generators/moneytree/templates/active_record_visit_model.rb.tt
57
+ - lib/generators/moneytree/templates/base_store_initializer.rb.tt
58
+ - lib/generators/moneytree/templates/moneytree_initializer.rb.tt
59
+ - lib/moneytree.rb
60
+ - lib/moneytree/account.rb
61
+ - lib/moneytree/payment_provider/base.rb
62
+ - lib/moneytree/payment_provider/square.rb
63
+ - lib/moneytree/transaction.rb
64
+ - lib/moneytree/version.rb
65
+ - moneytree.gemspec
66
+ homepage: https://github.com/kieranklaassen/moneytree
67
+ licenses:
68
+ - MIT
69
+ metadata:
70
+ homepage_uri: https://github.com/kieranklaassen/moneytree
71
+ source_code_uri: https://github.com/kieranklaassen/moneytree
72
+ changelog_uri: https://github.com/kieranklaassen/moneytree/blob/master/CHANGELOG.md
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 2.3.0
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.1.2
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A payments engine for rails centered aorund transactional payments and orders.
92
+ test_files: []