Class: Moneytree::PaymentProvider::Square
- Inherits:
-
Base
- Object
- Base
- Moneytree::PaymentProvider::Square
show all
- Defined in:
- lib/moneytree/payment_provider/square.rb
Constant Summary
collapse
- PERMISSIONS =
The permissions we request from Square OAuth, we store them in the database
%i[
merchant_profile_read
payments_write
payments_read
customers_write
payments_write_additional_recipients
].freeze
Instance Attribute Summary
Attributes inherited from Base
#account, #payment_gateway
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#client ⇒ Object
39
40
41
42
43
44
|
# File 'lib/moneytree/payment_provider/square.rb', line 39
def client
@client ||= Square::Client.new(
access_token: @account.psp_credentials.square_access_token,
environment: credentitals[:environment]
)
end
|
#oauth_callback(_params) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/moneytree/payment_provider/square.rb', line 17
def oauth_callback(_params)
{
scope: PERMISSIONS,
access_token: '123',
refresh_token: '567',
expires_at: '',
token_type: 'bearer',
merchant_id: 'safsf'
}
end
|
#oauth_link ⇒ Object
13
14
15
|
# File 'lib/moneytree/payment_provider/square.rb', line 13
def oauth_link
"#{credentitals[:oauth_domain]}/oauth2/authorize?client_id=#{credentitals[:app_id]}&scope=#{PERMISSIONS.join('+').upcase}"
end
|
#scope_correct? ⇒ Boolean
35
36
37
|
# File 'lib/moneytree/payment_provider/square.rb', line 35
def scope_correct?
@account.psp_credentials.scope.sort == PERMISSIONS.sort
end
|
#test_credentials ⇒ Object
29
30
31
32
33
|
# File 'lib/moneytree/payment_provider/square.rb', line 29
def test_credentials
client.sdfsdf
rescue StandardError
raise 'Not working'
end
|