gocardless_pro 2.21.0 → 2.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +25 -43
- data/Gemfile +7 -0
- data/gocardless_pro.gemspec +2 -2
- data/lib/gocardless_pro.rb +6 -0
- data/lib/gocardless_pro/api_service.rb +1 -1
- data/lib/gocardless_pro/client.rb +11 -1
- data/lib/gocardless_pro/resources/event.rb +12 -0
- data/lib/gocardless_pro/resources/payer_authorisation.rb +119 -0
- data/lib/gocardless_pro/resources/payout.rb +2 -0
- data/lib/gocardless_pro/resources/payout_item.rb +6 -0
- data/lib/gocardless_pro/resources/tax_rate.rb +51 -0
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +0 -10
- data/lib/gocardless_pro/services/base_service.rb +11 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +0 -10
- data/lib/gocardless_pro/services/creditors_service.rb +0 -10
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +0 -10
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +0 -10
- data/lib/gocardless_pro/services/customer_notifications_service.rb +0 -10
- data/lib/gocardless_pro/services/customers_service.rb +0 -10
- data/lib/gocardless_pro/services/events_service.rb +0 -10
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +0 -10
- data/lib/gocardless_pro/services/mandate_import_entries_service.rb +0 -10
- data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -10
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +0 -10
- data/lib/gocardless_pro/services/mandates_service.rb +0 -10
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +208 -0
- data/lib/gocardless_pro/services/payments_service.rb +0 -10
- data/lib/gocardless_pro/services/payout_items_service.rb +0 -10
- data/lib/gocardless_pro/services/payouts_service.rb +0 -10
- data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -10
- data/lib/gocardless_pro/services/refunds_service.rb +6 -11
- data/lib/gocardless_pro/services/subscriptions_service.rb +1 -11
- data/lib/gocardless_pro/services/tax_rates_service.rb +74 -0
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/resources/payer_authorisation_spec.rb +418 -0
- data/spec/resources/payout_item_spec.rb +5 -0
- data/spec/resources/payout_spec.rb +8 -0
- data/spec/resources/tax_rate_spec.rb +198 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +1 -1
- data/spec/services/customer_bank_accounts_service_spec.rb +1 -1
- data/spec/services/customer_notifications_service_spec.rb +1 -1
- data/spec/services/customers_service_spec.rb +1 -1
- data/spec/services/instalment_schedules_service_spec.rb +1 -1
- data/spec/services/mandate_imports_service_spec.rb +2 -2
- data/spec/services/mandates_service_spec.rb +2 -2
- data/spec/services/payer_authorisations_service_spec.rb +572 -0
- data/spec/services/payments_service_spec.rb +2 -2
- data/spec/services/payout_items_service_spec.rb +9 -0
- data/spec/services/payouts_service_spec.rb +12 -0
- data/spec/services/redirect_flows_service_spec.rb +1 -1
- data/spec/services/subscriptions_service_spec.rb +3 -3
- data/spec/services/tax_rates_service_spec.rb +381 -0
- metadata +19 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1d21b1955fd8db168185745bd1afbd46fd7c3fa434006abf5c0e838cd7507e
|
4
|
+
data.tar.gz: ef057338fc37aa2e791ef3dcd7536a50ff55711e7d8fa5762a51d6797395cab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c1daafd49f92798ff81c407809ecf888429f2c723801c42b49dfe4d7d7351ae818925c46d897784f798c7d4ee2c7089959594cec38ab0fc6df3472f481d0207
|
7
|
+
data.tar.gz: 78eb4cd3154aa14fe50e445cd94605fe39f91893564650948717e84356fb7d374357ecbfad08784be2c21221fc096530e85407c8a1a3eb794b2ab5d40d0024d1
|
data/.circleci/config.yml
CHANGED
@@ -1,50 +1,32 @@
|
|
1
|
-
version: 2
|
2
|
-
|
3
|
-
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
test: &test
|
4
5
|
parallelism: 1
|
6
|
+
parameters:
|
7
|
+
faraday-version: { type: string }
|
8
|
+
ruby-version: { type: string }
|
9
|
+
docker:
|
10
|
+
- image: ruby:<<parameters.ruby-version>>
|
11
|
+
environment:
|
12
|
+
- FARADAY_VERSION=<<parameters.faraday-version>>
|
5
13
|
steps:
|
6
14
|
- checkout
|
7
|
-
- run:
|
8
|
-
bundle install
|
9
|
-
bundle exec rspec
|
10
|
-
jobs:
|
11
|
-
test_ruby_2_5:
|
12
|
-
<<: *test_library
|
13
|
-
docker:
|
14
|
-
- image: ruby:2.5
|
15
|
-
|
16
|
-
test_ruby_2_4:
|
17
|
-
<<: *test_library
|
18
|
-
docker:
|
19
|
-
- image: ruby:2.4
|
20
|
-
|
21
|
-
test_ruby_2_3:
|
22
|
-
<<: *test_library
|
23
|
-
docker:
|
24
|
-
- image: ruby:2.3
|
25
|
-
|
26
|
-
test_ruby_2_2:
|
27
|
-
<<: *test_library
|
28
|
-
docker:
|
29
|
-
- image: ruby:2.2
|
30
|
-
|
31
|
-
test_ruby_2_1:
|
32
|
-
<<: *test_library
|
33
|
-
docker:
|
34
|
-
- image: ruby:2.1
|
35
|
-
|
36
|
-
test_ruby_2_0:
|
37
|
-
<<: *test_library
|
38
|
-
docker:
|
39
|
-
- image: ruby:2.0
|
15
|
+
- run: bundle install && bundle exec rspec
|
40
16
|
|
41
17
|
workflows:
|
42
18
|
version: 2
|
43
|
-
|
19
|
+
tests:
|
44
20
|
jobs:
|
45
|
-
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
21
|
+
- test:
|
22
|
+
matrix:
|
23
|
+
parameters:
|
24
|
+
faraday-version: ["0.9.2", "1.0"]
|
25
|
+
ruby-version: ["2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]
|
26
|
+
exclude:
|
27
|
+
- faraday-version: "1.0"
|
28
|
+
ruby-version: "2.0"
|
29
|
+
- faraday-version: "1.0"
|
30
|
+
ruby-version: "2.1"
|
31
|
+
- faraday-version: "1.0"
|
32
|
+
ruby-version: "2.2"
|
data/Gemfile
CHANGED
@@ -1,2 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
|
+
|
4
|
+
# We support both pre-1.x and post-1.x Faraday versions, but to ensure compatibility we
|
5
|
+
# pin this gem against each in separate runs of CI, using the FARADAY_VERSION env var. For
|
6
|
+
# more details on the values, see .circleci/config.yml.
|
7
|
+
if ENV.key?("FARADAY_VERSION")
|
8
|
+
gem 'faraday', "~> #{ENV["FARADAY_VERSION"]}"
|
9
|
+
end
|
data/gocardless_pro.gemspec
CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_dependency 'faraday', ['>= 0.9.2', '<
|
20
|
+
spec.add_dependency 'faraday', ['>= 0.9.2', '< 2']
|
21
21
|
|
22
22
|
spec.add_development_dependency 'rspec', '~> 3.7.0'
|
23
|
-
spec.add_development_dependency 'webmock', '~>
|
23
|
+
spec.add_development_dependency 'webmock', '~> 3.8.3'
|
24
24
|
spec.add_development_dependency 'rubocop', '~> 0.49.1'
|
25
25
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
26
26
|
|
data/lib/gocardless_pro.rb
CHANGED
@@ -77,6 +77,9 @@ require_relative 'gocardless_pro/services/mandate_import_entries_service'
|
|
77
77
|
require_relative 'gocardless_pro/resources/mandate_pdf'
|
78
78
|
require_relative 'gocardless_pro/services/mandate_pdfs_service'
|
79
79
|
|
80
|
+
require_relative 'gocardless_pro/resources/payer_authorisation'
|
81
|
+
require_relative 'gocardless_pro/services/payer_authorisations_service'
|
82
|
+
|
80
83
|
require_relative 'gocardless_pro/resources/payment'
|
81
84
|
require_relative 'gocardless_pro/services/payments_service'
|
82
85
|
|
@@ -95,4 +98,7 @@ require_relative 'gocardless_pro/services/refunds_service'
|
|
95
98
|
require_relative 'gocardless_pro/resources/subscription'
|
96
99
|
require_relative 'gocardless_pro/services/subscriptions_service'
|
97
100
|
|
101
|
+
require_relative 'gocardless_pro/resources/tax_rate'
|
102
|
+
require_relative 'gocardless_pro/services/tax_rates_service'
|
103
|
+
|
98
104
|
require_relative 'gocardless_pro/client.rb'
|
@@ -23,7 +23,7 @@ module GoCardlessPro
|
|
23
23
|
@url = url
|
24
24
|
root_url, @path_prefix = unpack_url(url)
|
25
25
|
http_adapter = options[:http_adapter] || [:net_http]
|
26
|
-
connection_options = options
|
26
|
+
connection_options = options.fetch(:connection_options, {})
|
27
27
|
|
28
28
|
@connection = Faraday.new(root_url, connection_options) do |faraday|
|
29
29
|
faraday.response :raise_gocardless_errors
|
@@ -68,6 +68,11 @@ module GoCardlessPro
|
|
68
68
|
@mandate_pdfs ||= Services::MandatePdfsService.new(@api_service)
|
69
69
|
end
|
70
70
|
|
71
|
+
# Access to the service for payer_authorisation to make API calls
|
72
|
+
def payer_authorisations
|
73
|
+
@payer_authorisations ||= Services::PayerAuthorisationsService.new(@api_service)
|
74
|
+
end
|
75
|
+
|
71
76
|
# Access to the service for payment to make API calls
|
72
77
|
def payments
|
73
78
|
@payments ||= Services::PaymentsService.new(@api_service)
|
@@ -98,6 +103,11 @@ module GoCardlessPro
|
|
98
103
|
@subscriptions ||= Services::SubscriptionsService.new(@api_service)
|
99
104
|
end
|
100
105
|
|
106
|
+
# Access to the service for tax_rate to make API calls
|
107
|
+
def tax_rates
|
108
|
+
@tax_rates ||= Services::TaxRatesService.new(@api_service)
|
109
|
+
end
|
110
|
+
|
101
111
|
# Get a Client configured to use HTTP Basic authentication with the GC Api
|
102
112
|
#
|
103
113
|
# @param options [Hash<Symbol,String>] configuration for creating the client
|
@@ -148,7 +158,7 @@ module GoCardlessPro
|
|
148
158
|
'User-Agent' => user_agent.to_s,
|
149
159
|
'Content-Type' => 'application/json',
|
150
160
|
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
|
151
|
-
'GoCardless-Client-Version' => '2.
|
161
|
+
'GoCardless-Client-Version' => '2.25.0',
|
152
162
|
},
|
153
163
|
}
|
154
164
|
end
|
@@ -64,6 +64,14 @@ module GoCardlessPro
|
|
64
64
|
@links['creditor']
|
65
65
|
end
|
66
66
|
|
67
|
+
def customer
|
68
|
+
@links['customer']
|
69
|
+
end
|
70
|
+
|
71
|
+
def customer_bank_account
|
72
|
+
@links['customer_bank_account']
|
73
|
+
end
|
74
|
+
|
67
75
|
def instalment_schedule
|
68
76
|
@links['instalment_schedule']
|
69
77
|
end
|
@@ -88,6 +96,10 @@ module GoCardlessPro
|
|
88
96
|
@links['parent_event']
|
89
97
|
end
|
90
98
|
|
99
|
+
def payer_authorisation
|
100
|
+
@links['payer_authorisation']
|
101
|
+
end
|
102
|
+
|
91
103
|
def payment
|
92
104
|
@links['payment']
|
93
105
|
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
#
|
4
|
+
# This client is automatically generated from a template and JSON schema definition.
|
5
|
+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'uri'
|
9
|
+
|
10
|
+
module GoCardlessPro
|
11
|
+
# A module containing classes for each of the resources in the GC Api
|
12
|
+
module Resources
|
13
|
+
# Represents an instance of a payer_authorisation resource returned from the API
|
14
|
+
|
15
|
+
# Payer Authorisation resource acts as a wrapper for creating customer, bank
|
16
|
+
# account and mandate details in a single request.
|
17
|
+
# PayerAuthorisation API enables the integrators to build their own custom
|
18
|
+
# payment pages.
|
19
|
+
#
|
20
|
+
# The process to use the Payer Authorisation API is as follows:
|
21
|
+
#
|
22
|
+
# 1. Create a Payer Authorisation, either empty or with already available
|
23
|
+
# information
|
24
|
+
# 2. Update the authorisation with additional information or fix any
|
25
|
+
# mistakes
|
26
|
+
# 3. Submit the authorisation, after the payer has reviewed their
|
27
|
+
# information
|
28
|
+
# 4. [coming soon] Redirect the payer to the verification mechanisms from
|
29
|
+
# the response of the Submit request (this will be introduced as a
|
30
|
+
# non-breaking change)
|
31
|
+
# 5. Confirm the authorisation to indicate that the resources can be
|
32
|
+
# created
|
33
|
+
#
|
34
|
+
# After the Payer Authorisation is confirmed, resources will eventually be
|
35
|
+
# created as it's an asynchronous process.
|
36
|
+
#
|
37
|
+
# To retrieve the status and ID of the linked resources you can do one of
|
38
|
+
# the following:
|
39
|
+
# <ol>
|
40
|
+
# <li> Listen to <code> payer_authorisation_completed </code> <a
|
41
|
+
# href="#appendix-webhooks"> webhook</a> (recommended)</li>
|
42
|
+
# <li> Poll the GET <a
|
43
|
+
# href="#payer-authorisations-get-a-single-payer-authorisation">
|
44
|
+
# endpoint</a></li>
|
45
|
+
# <li> Poll the GET events API
|
46
|
+
# <code>https://api.gocardless.com/events?payer_authorisation={id}&action=completed</code>
|
47
|
+
# </li>
|
48
|
+
# </ol>
|
49
|
+
#
|
50
|
+
# <p class="notice">
|
51
|
+
# Note that the `create` and `update` endpoints behave differently than
|
52
|
+
# other existing `create` and `update` endpoints. The Payer Authorisation
|
53
|
+
# is still saved if incomplete data is provided.
|
54
|
+
# We return the list of incomplete data in the `incomplete_fields` along
|
55
|
+
# with the resources in the body of the response.
|
56
|
+
# <br><br>
|
57
|
+
# The API is designed to be flexible and allows you to collect information
|
58
|
+
# in multiple steps without storing any sensitive data in the browser or in
|
59
|
+
# your servers.
|
60
|
+
# </p>
|
61
|
+
class PayerAuthorisation
|
62
|
+
attr_reader :bank_account
|
63
|
+
attr_reader :created_at
|
64
|
+
attr_reader :customer
|
65
|
+
attr_reader :id
|
66
|
+
attr_reader :incomplete_fields
|
67
|
+
attr_reader :mandate
|
68
|
+
attr_reader :status
|
69
|
+
|
70
|
+
# Initialize a payer_authorisation resource instance
|
71
|
+
# @param object [Hash] an object returned from the API
|
72
|
+
def initialize(object, response = nil)
|
73
|
+
@object = object
|
74
|
+
|
75
|
+
@bank_account = object['bank_account']
|
76
|
+
@created_at = object['created_at']
|
77
|
+
@customer = object['customer']
|
78
|
+
@id = object['id']
|
79
|
+
@incomplete_fields = object['incomplete_fields']
|
80
|
+
@links = object['links']
|
81
|
+
@mandate = object['mandate']
|
82
|
+
@status = object['status']
|
83
|
+
@response = response
|
84
|
+
end
|
85
|
+
|
86
|
+
def api_response
|
87
|
+
ApiResponse.new(@response)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Return the links that the resource has
|
91
|
+
def links
|
92
|
+
@payer_authorisation_links ||= Links.new(@links)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Provides the payer_authorisation resource as a hash of all its readable attributes
|
96
|
+
def to_h
|
97
|
+
@object
|
98
|
+
end
|
99
|
+
|
100
|
+
class Links
|
101
|
+
def initialize(links)
|
102
|
+
@links = links || {}
|
103
|
+
end
|
104
|
+
|
105
|
+
def bank_account
|
106
|
+
@links['bank_account']
|
107
|
+
end
|
108
|
+
|
109
|
+
def customer
|
110
|
+
@links['customer']
|
111
|
+
end
|
112
|
+
|
113
|
+
def mandate
|
114
|
+
@links['mandate']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -30,6 +30,7 @@ module GoCardlessPro
|
|
30
30
|
attr_reader :payout_type
|
31
31
|
attr_reader :reference
|
32
32
|
attr_reader :status
|
33
|
+
attr_reader :tax_currency
|
33
34
|
|
34
35
|
# Initialize a payout resource instance
|
35
36
|
# @param object [Hash] an object returned from the API
|
@@ -48,6 +49,7 @@ module GoCardlessPro
|
|
48
49
|
@payout_type = object['payout_type']
|
49
50
|
@reference = object['reference']
|
50
51
|
@status = object['status']
|
52
|
+
@tax_currency = object['tax_currency']
|
51
53
|
@response = response
|
52
54
|
end
|
53
55
|
|
@@ -32,6 +32,7 @@ module GoCardlessPro
|
|
32
32
|
#
|
33
33
|
class PayoutItem
|
34
34
|
attr_reader :amount
|
35
|
+
attr_reader :taxes
|
35
36
|
attr_reader :type
|
36
37
|
|
37
38
|
# Initialize a payout_item resource instance
|
@@ -41,6 +42,7 @@ module GoCardlessPro
|
|
41
42
|
|
42
43
|
@amount = object['amount']
|
43
44
|
@links = object['links']
|
45
|
+
@taxes = object['taxes']
|
44
46
|
@type = object['type']
|
45
47
|
@response = response
|
46
48
|
end
|
@@ -71,6 +73,10 @@ module GoCardlessPro
|
|
71
73
|
def payment
|
72
74
|
@links['payment']
|
73
75
|
end
|
76
|
+
|
77
|
+
def refund
|
78
|
+
@links['refund']
|
79
|
+
end
|
74
80
|
end
|
75
81
|
end
|
76
82
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
#
|
4
|
+
# This client is automatically generated from a template and JSON schema definition.
|
5
|
+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'uri'
|
9
|
+
|
10
|
+
module GoCardlessPro
|
11
|
+
# A module containing classes for each of the resources in the GC Api
|
12
|
+
module Resources
|
13
|
+
# Represents an instance of a tax_rate resource returned from the API
|
14
|
+
|
15
|
+
# Tax rates from tax authority.
|
16
|
+
#
|
17
|
+
# We also maintain a [static list of the tax rates for each
|
18
|
+
# jurisdiction](#appendix-tax-rates).
|
19
|
+
class TaxRate
|
20
|
+
attr_reader :end_date
|
21
|
+
attr_reader :id
|
22
|
+
attr_reader :jurisdiction
|
23
|
+
attr_reader :percentage
|
24
|
+
attr_reader :start_date
|
25
|
+
attr_reader :type
|
26
|
+
|
27
|
+
# Initialize a tax_rate resource instance
|
28
|
+
# @param object [Hash] an object returned from the API
|
29
|
+
def initialize(object, response = nil)
|
30
|
+
@object = object
|
31
|
+
|
32
|
+
@end_date = object['end_date']
|
33
|
+
@id = object['id']
|
34
|
+
@jurisdiction = object['jurisdiction']
|
35
|
+
@percentage = object['percentage']
|
36
|
+
@start_date = object['start_date']
|
37
|
+
@type = object['type']
|
38
|
+
@response = response
|
39
|
+
end
|
40
|
+
|
41
|
+
def api_response
|
42
|
+
ApiResponse.new(@response)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Provides the tax_rate resource as a hash of all its readable attributes
|
46
|
+
def to_h
|
47
|
+
@object
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative './base_service'
|
2
|
-
require 'uri'
|
3
2
|
|
4
3
|
# encoding: utf-8
|
5
4
|
#
|
@@ -59,15 +58,6 @@ module GoCardlessPro
|
|
59
58
|
def envelope_key
|
60
59
|
'bank_details_lookups'
|
61
60
|
end
|
62
|
-
|
63
|
-
# take a URL with placeholder params and substitute them out for the actual value
|
64
|
-
# @param url [String] the URL with placeholders in
|
65
|
-
# @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
|
66
|
-
def sub_url(url, param_map)
|
67
|
-
param_map.reduce(url) do |new_url, (param, value)|
|
68
|
-
new_url.gsub(":#{param}", URI.escape(value))
|
69
|
-
end
|
70
|
-
end
|
71
61
|
end
|
72
62
|
end
|
73
63
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module GoCardlessPro
|
2
4
|
# Module that contains all services for making requests to the API.
|
3
5
|
module Services
|
@@ -23,6 +25,15 @@ module GoCardlessPro
|
|
23
25
|
def envelope_key
|
24
26
|
raise NotImplementedError
|
25
27
|
end
|
28
|
+
|
29
|
+
# take a URL with placeholder params and substitute them out for the actual value
|
30
|
+
# @param url [String] the URL with placeholders in
|
31
|
+
# @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
|
32
|
+
def sub_url(url, param_map)
|
33
|
+
param_map.reduce(url) do |new_url, (param, value)|
|
34
|
+
new_url.gsub(":#{param}", CGI.escape(value))
|
35
|
+
end
|
36
|
+
end
|
26
37
|
end
|
27
38
|
end
|
28
39
|
end
|