moneytree-rails 0.1.4 β†’ 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 779e0ff0793ee2a7c983a518fddc541d947789a1389e272348b011de846fa6ef
4
- data.tar.gz: d6a4598c886d4f650aef78f1bfb44d0e1d6372f887e6610d219c9e0a9bd16d4e
3
+ metadata.gz: '079364d1a5759325bd0978da80070be3054ca7833db677991a779b9cf60f40d1'
4
+ data.tar.gz: 75dda268ddb18e96f8570ef591b5bb5687743e764a066f0196c8a435b364511d
5
5
  SHA512:
6
- metadata.gz: 871ff1ec60cc065d4508e2a8e3aa3fd82b9cac5abb955975ecdfdfd79619520317daab2ee69df13f6b122861181e516dcc192bf55f0bd5049c5166249715911c
7
- data.tar.gz: bd4a338cec1216e8e6cfad8a861d0b21344cfc5fa2d14eb34baeccf109b6569493a002fa19fa31e38632bbf3d3c7419b4417f3d2093eaed91d6b0b036910a197
6
+ metadata.gz: d934abaf84e4eb8136807226535cd3659da2cd9ed71b4f8d684c7cf0730aa90cbca25c771203686dce76598961c025c289124dbabb177e2e0c60ad418f979c78
7
+ data.tar.gz: 7db374f8ed29d853755e362d60e0ea3fad3ea86d19a846153fb6109dacd787d2a27c8279fc119dc90df98797587334d4e71ff6677b16af7819279ea1e26d500e
data/README.md CHANGED
@@ -13,7 +13,7 @@ functionality with almost no work on your end:
13
13
  - πŸ’΅πŸ’ΆπŸ’·πŸ’΄ Multi-currency
14
14
  - πŸ”‘ OAuth to link your PSP account
15
15
  - πŸ‘©β€πŸ’» PSP account creation, (with commission)
16
- - βš™οΈ ~~Webhooks~~ comming soon
16
+ - βš™οΈ Webhooks
17
17
  - πŸ’³ ~~PCI compliance with Javascript libraries~~ comming soon
18
18
  - 🧲 Platform fees a.k.a. Market Places
19
19
 
@@ -95,6 +95,11 @@ class Merchant < ApplicationRecord
95
95
  def website
96
96
  'https://www.boomtown.com'
97
97
  end
98
+
99
+ # Optional, will be called by Moneytree after authenticating with the PSP
100
+ def moneytree_oauth_callback
101
+ puts "Hurray, I just got associated with a Moneytree gateway!"
102
+ end
98
103
  end
99
104
  ```
100
105
 
@@ -1,6 +1,6 @@
1
1
  module Moneytree
2
2
  module Oauth
3
- class SquareController < ApplicationController
3
+ class SquareController < Moneytree::ApplicationController
4
4
  def new
5
5
  redirect_to current_account.oauth_link
6
6
  end
@@ -1,12 +1,13 @@
1
1
  module Moneytree
2
2
  module Oauth
3
- class StripeController < ApplicationController
3
+ class StripeController < Moneytree::ApplicationController
4
4
  def new
5
5
  redirect_to stripe_oauth_url
6
6
  end
7
7
 
8
8
  def callback
9
- payment_gateway = PaymentGateway.create!(psp: 'stripe', account: current_account)
9
+ # TODO: Remove this module prefix once we figure out how to properly autoload this.
10
+ payment_gateway = Moneytree::PaymentGateway.create!(psp: 'stripe', account: current_account)
10
11
  payment_gateway.oauth_callback(payment_gateway_params)
11
12
  redirect_to Moneytree.oauth_redirect, notice: 'Connected to Stripe'
12
13
  end
@@ -26,7 +27,7 @@ module Moneytree
26
27
  query: {
27
28
  response_type: :code,
28
29
  client_id: Moneytree.stripe_credentials[:client_id],
29
- scope: PaymentProvider::Stripe::PERMISSION,
30
+ scope: Moneytree::PaymentProvider::Stripe::PERMISSION,
30
31
  redirect_uri: oauth_stripe_callback_url,
31
32
  'stripe_user[email]': current_account.email,
32
33
  'stripe_user[url]': current_account.website,
@@ -1,6 +1,6 @@
1
1
  module Moneytree
2
2
  module Webhooks
3
- class SquareController < ApplicationController
3
+ class SquareController < Moneytree::ApplicationController
4
4
  def create
5
5
  # Do some callback magic here
6
6
  end
@@ -1,6 +1,6 @@
1
1
  module Moneytree
2
2
  module Webhooks
3
- class StripeController < ApplicationController
3
+ class StripeController < Moneytree::ApplicationController
4
4
  skip_before_action :verify_authenticity_token
5
5
 
6
6
  def create
@@ -29,7 +29,7 @@ module Moneytree
29
29
  return if transaction.completed?
30
30
 
31
31
  transaction.process_response(
32
- TransactionResponse.new(:success, '', { charge_id: stripe_object.id })
32
+ Moneytree::TransactionResponse.new(:success, '', { charge_id: stripe_object.id })
33
33
  )
34
34
 
35
35
  if Moneytree.order_status_trigger_method
@@ -47,7 +47,7 @@ module Moneytree
47
47
  next if refund.completed?
48
48
 
49
49
  refund.process_response(
50
- TransactionResponse.new(:success, '')
50
+ Moneytree::TransactionResponse.new(:success, '')
51
51
  )
52
52
  if Moneytree.order_status_trigger_method
53
53
  transaction.order.send(Moneytree.order_status_trigger_method, transaction)
@@ -56,7 +56,7 @@ module Moneytree
56
56
  end
57
57
 
58
58
  def transaction
59
- @transaction ||= Transaction.find(stripe_object.metadata[:moneytree_transaction_id])
59
+ @transaction ||= Moneytree::Transaction.find(stripe_object.metadata[:moneytree_transaction_id])
60
60
  end
61
61
 
62
62
  def stripe_object
@@ -1,6 +1,6 @@
1
1
  module Moneytree
2
- class Payment < Transaction
3
- has_many :refunds, class_name: 'Refund'
2
+ class Payment < Moneytree::Transaction
3
+ has_many :refunds, class_name: 'Moneytree::Refund'
4
4
 
5
5
  validates_absence_of :payment_id
6
6
 
@@ -8,13 +8,11 @@ module Moneytree
8
8
  # FIXME: enable https://github.com/ankane/lockbox
9
9
  delegate :oauth_link, :scope_correct?, :charge, :refund, to: :payment_provider
10
10
 
11
- # has_many :orders
12
- # has_many :transactions
13
- # has_many :customers
14
- # has_many :cards
11
+ has_many :transactions
15
12
 
16
13
  def oauth_callback(params)
17
14
  update! psp_credentials: payment_provider.get_access_token(params)
15
+ account.send(:moneytree_oauth_callback) if account.respond_to?(:moneytree_oauth_callback, true)
18
16
  end
19
17
 
20
18
  def psp_connected?
@@ -1,5 +1,5 @@
1
1
  module Moneytree
2
- class Refund < Transaction
2
+ class Refund < Moneytree::Transaction
3
3
  belongs_to :payment, class_name: 'Moneytree::Payment'
4
4
 
5
5
  before_validation :set_order, :set_payment_gateway
@@ -1,5 +1,5 @@
1
1
  module Moneytree
2
- class Transaction < ApplicationRecord
2
+ class Transaction < Moneytree::ApplicationRecord
3
3
  belongs_to :payment_gateway
4
4
  belongs_to :order, polymorphic: true
5
5
 
@@ -9,7 +9,9 @@ module Moneytree
9
9
  end
10
10
 
11
11
  def new_payment(*args)
12
- moneytree_transactions << Payment.new(*args)
12
+ payment = Payment.new(*args)
13
+ moneytree_transactions << payment
14
+ payment
13
15
  end
14
16
  end
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module Moneytree
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moneytree-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kieran Klaassen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.1.2
100
+ rubygems_version: 3.1.4
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: A payments engine for rails centered aorund transactional payments and orders.