gocardless_pro 4.2.0 → 4.4.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/README.md +16 -12
- data/lib/gocardless_pro/client.rb +33 -3
- data/lib/gocardless_pro/error.rb +3 -3
- data/lib/gocardless_pro/list_response.rb +2 -2
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +11 -3
- data/lib/gocardless_pro/paginator.rb +3 -2
- data/lib/gocardless_pro/resources/balance.rb +4 -1
- data/lib/gocardless_pro/resources/bank_account_detail.rb +5 -1
- data/lib/gocardless_pro/resources/bank_account_holder_verification.rb +44 -0
- data/lib/gocardless_pro/resources/bank_authorisation.rb +9 -2
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +3 -1
- data/lib/gocardless_pro/resources/billing_request.rb +24 -10
- data/lib/gocardless_pro/resources/billing_request_flow.rb +18 -2
- data/lib/gocardless_pro/resources/billing_request_template.rb +18 -2
- data/lib/gocardless_pro/resources/billing_request_with_action.rb +6 -5
- data/lib/gocardless_pro/resources/block.rb +12 -8
- data/lib/gocardless_pro/resources/creditor.rb +26 -6
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +17 -7
- data/lib/gocardless_pro/resources/currency_exchange_rate.rb +4 -1
- data/lib/gocardless_pro/resources/customer.rb +22 -5
- data/lib/gocardless_pro/resources/customer_bank_account.rb +24 -10
- data/lib/gocardless_pro/resources/customer_notification.rb +8 -5
- data/lib/gocardless_pro/resources/event.rb +31 -4
- data/lib/gocardless_pro/resources/export.rb +7 -1
- data/lib/gocardless_pro/resources/funds_availability.rb +38 -0
- data/lib/gocardless_pro/resources/instalment_schedule.rb +8 -2
- data/lib/gocardless_pro/resources/institution.rb +11 -4
- data/lib/gocardless_pro/resources/logo.rb +2 -1
- data/lib/gocardless_pro/resources/mandate.rb +21 -6
- data/lib/gocardless_pro/resources/mandate_import.rb +29 -22
- data/lib/gocardless_pro/resources/mandate_import_entry.rb +16 -17
- data/lib/gocardless_pro/resources/mandate_pdf.rb +5 -4
- data/lib/gocardless_pro/resources/negative_balance_limit.rb +4 -2
- data/lib/gocardless_pro/resources/outbound_payment.rb +33 -12
- data/lib/gocardless_pro/resources/outbound_payment_import.rb +81 -0
- data/lib/gocardless_pro/resources/outbound_payment_import_entry.rb +77 -0
- data/lib/gocardless_pro/resources/payer_authorisation.rb +34 -32
- data/lib/gocardless_pro/resources/payment.rb +24 -8
- data/lib/gocardless_pro/resources/payment_account.rb +64 -0
- data/lib/gocardless_pro/resources/payment_account_transaction.rb +79 -0
- data/lib/gocardless_pro/resources/payout.rb +19 -8
- data/lib/gocardless_pro/resources/payout_item.rb +4 -3
- data/lib/gocardless_pro/resources/redirect_flow.rb +44 -25
- data/lib/gocardless_pro/resources/refund.rb +16 -7
- data/lib/gocardless_pro/resources/scheme_identifier.rb +18 -3
- data/lib/gocardless_pro/resources/subscription.rb +37 -16
- data/lib/gocardless_pro/resources/tax_rate.rb +8 -3
- data/lib/gocardless_pro/resources/transferred_mandate.rb +3 -1
- data/lib/gocardless_pro/resources/verification_detail.rb +19 -8
- data/lib/gocardless_pro/resources/webhook.rb +13 -2
- data/lib/gocardless_pro/services/balances_service.rb +11 -3
- data/lib/gocardless_pro/services/bank_account_details_service.rb +14 -3
- data/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb +92 -0
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +9 -3
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +14 -6
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +8 -2
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +14 -7
- data/lib/gocardless_pro/services/billing_request_with_actions_service.rb +7 -1
- data/lib/gocardless_pro/services/billing_requests_service.rb +38 -33
- data/lib/gocardless_pro/services/blocks_service.rb +17 -10
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +14 -7
- data/lib/gocardless_pro/services/creditors_service.rb +13 -6
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +10 -3
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +25 -15
- data/lib/gocardless_pro/services/customer_notifications_service.rb +8 -3
- data/lib/gocardless_pro/services/customers_service.rb +15 -9
- data/lib/gocardless_pro/services/events_service.rb +16 -4
- data/lib/gocardless_pro/services/exports_service.rb +8 -2
- data/lib/gocardless_pro/services/funds_availabilities_service.rb +56 -0
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -13
- data/lib/gocardless_pro/services/institutions_service.rb +8 -2
- data/lib/gocardless_pro/services/logos_service.rb +9 -3
- data/lib/gocardless_pro/services/mandate_import_entries_service.rb +10 -4
- data/lib/gocardless_pro/services/mandate_imports_service.rb +16 -8
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +11 -5
- data/lib/gocardless_pro/services/mandates_service.rb +23 -16
- data/lib/gocardless_pro/services/negative_balance_limits_service.rb +10 -3
- data/lib/gocardless_pro/services/outbound_payment_import_entries_service.rb +64 -0
- data/lib/gocardless_pro/services/outbound_payment_imports_service.rb +118 -0
- data/lib/gocardless_pro/services/outbound_payments_service.rb +34 -12
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +18 -15
- data/lib/gocardless_pro/services/payer_themes_service.rb +7 -1
- data/lib/gocardless_pro/services/payment_account_transactions_service.rb +93 -0
- data/lib/gocardless_pro/services/payment_accounts_service.rb +83 -0
- data/lib/gocardless_pro/services/payments_service.rb +29 -21
- data/lib/gocardless_pro/services/payout_items_service.rb +12 -7
- data/lib/gocardless_pro/services/payouts_service.rb +14 -7
- data/lib/gocardless_pro/services/redirect_flows_service.rb +19 -9
- data/lib/gocardless_pro/services/refunds_service.rb +18 -13
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +90 -81
- data/lib/gocardless_pro/services/scheme_identifiers_service.rb +15 -9
- data/lib/gocardless_pro/services/subscriptions_service.rb +57 -47
- data/lib/gocardless_pro/services/tax_rates_service.rb +11 -4
- data/lib/gocardless_pro/services/transferred_mandates_service.rb +8 -2
- data/lib/gocardless_pro/services/verification_details_service.rb +7 -1
- data/lib/gocardless_pro/services/webhooks_service.rb +13 -6
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro/webhook.rb +45 -0
- data/lib/gocardless_pro.rb +18 -0
- metadata +38 -16
|
@@ -10,12 +10,13 @@ module GoCardlessPro
|
|
|
10
10
|
module Services
|
|
11
11
|
# Service for making requests to the Payment endpoints
|
|
12
12
|
class PaymentsService < BaseService
|
|
13
|
-
#
|
|
13
|
+
# Creates a new payment object.
|
|
14
14
|
#
|
|
15
|
-
# This fails with a `mandate_is_inactive` error if the linked
|
|
16
|
-
#
|
|
17
|
-
# be created against mandates with status
|
|
18
|
-
# `pending_submission`, `submitted`, and
|
|
15
|
+
# This fails with a `mandate_is_inactive` error if the linked mandate
|
|
16
|
+
# (https://developer.gocardless.com/api-reference/#core-endpoints-mandates) is
|
|
17
|
+
# cancelled or has failed. Payments can be created against mandates with status
|
|
18
|
+
# of: `pending_customer_approval`, `pending_submission`, `submitted`, and
|
|
19
|
+
# `active`.
|
|
19
20
|
# Example URL: /payments
|
|
20
21
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
21
22
|
def create(options = {})
|
|
@@ -36,7 +37,7 @@ module GoCardlessPro
|
|
|
36
37
|
if e.idempotent_creation_conflict?
|
|
37
38
|
case @api_service.on_idempotency_conflict
|
|
38
39
|
when :raise
|
|
39
|
-
raise IdempotencyConflict
|
|
40
|
+
raise IdempotencyConflict.new(e.error)
|
|
40
41
|
when :fetch
|
|
41
42
|
return get(e.conflicting_resource_id)
|
|
42
43
|
end
|
|
@@ -50,8 +51,9 @@ module GoCardlessPro
|
|
|
50
51
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
# Returns a
|
|
54
|
-
#
|
|
54
|
+
# Returns a cursor-paginated
|
|
55
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
56
|
+
# list of your payments.
|
|
55
57
|
# Example URL: /payments
|
|
56
58
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
57
59
|
def list(options = {})
|
|
@@ -86,7 +88,7 @@ module GoCardlessPro
|
|
|
86
88
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
87
89
|
def get(identity, options = {})
|
|
88
90
|
path = sub_url('/payments/:identity', {
|
|
89
|
-
'identity' => identity
|
|
91
|
+
'identity' => identity,
|
|
90
92
|
})
|
|
91
93
|
|
|
92
94
|
options[:retry_failures] = true
|
|
@@ -105,7 +107,7 @@ module GoCardlessPro
|
|
|
105
107
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
106
108
|
def update(identity, options = {})
|
|
107
109
|
path = sub_url('/payments/:identity', {
|
|
108
|
-
'identity' => identity
|
|
110
|
+
'identity' => identity,
|
|
109
111
|
})
|
|
110
112
|
|
|
111
113
|
params = options.delete(:params) || {}
|
|
@@ -133,7 +135,7 @@ module GoCardlessPro
|
|
|
133
135
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
134
136
|
def cancel(identity, options = {})
|
|
135
137
|
path = sub_url('/payments/:identity/actions/cancel', {
|
|
136
|
-
'identity' => identity
|
|
138
|
+
'identity' => identity,
|
|
137
139
|
})
|
|
138
140
|
|
|
139
141
|
params = options.delete(:params) || {}
|
|
@@ -151,7 +153,7 @@ module GoCardlessPro
|
|
|
151
153
|
if e.idempotent_creation_conflict?
|
|
152
154
|
case @api_service.on_idempotency_conflict
|
|
153
155
|
when :raise
|
|
154
|
-
raise IdempotencyConflict
|
|
156
|
+
raise IdempotencyConflict.new(e.error)
|
|
155
157
|
when :fetch
|
|
156
158
|
return get(e.conflicting_resource_id)
|
|
157
159
|
end
|
|
@@ -165,12 +167,12 @@ module GoCardlessPro
|
|
|
165
167
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
|
166
168
|
end
|
|
167
169
|
|
|
168
|
-
#
|
|
169
|
-
#
|
|
170
|
-
#
|
|
171
|
-
#
|
|
172
|
-
#
|
|
173
|
-
#
|
|
170
|
+
# Retries a failed payment if the underlying mandate is active. You will receive
|
|
171
|
+
# a `resubmission_requested` webhook, but after that retrying the payment
|
|
172
|
+
# follows the same process as its initial creation, so you will receive a
|
|
173
|
+
# `submitted` webhook, followed by a `confirmed` or `failed` event. Any metadata
|
|
174
|
+
# supplied to this endpoint will be stored against the payment submission event
|
|
175
|
+
# it causes.
|
|
174
176
|
#
|
|
175
177
|
# This will return a `retry_failed` error if the payment has not failed.
|
|
176
178
|
#
|
|
@@ -181,7 +183,7 @@ module GoCardlessPro
|
|
|
181
183
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
182
184
|
def retry(identity, options = {})
|
|
183
185
|
path = sub_url('/payments/:identity/actions/retry', {
|
|
184
|
-
'identity' => identity
|
|
186
|
+
'identity' => identity,
|
|
185
187
|
})
|
|
186
188
|
|
|
187
189
|
params = options.delete(:params) || {}
|
|
@@ -199,7 +201,7 @@ module GoCardlessPro
|
|
|
199
201
|
if e.idempotent_creation_conflict?
|
|
200
202
|
case @api_service.on_idempotency_conflict
|
|
201
203
|
when :raise
|
|
202
|
-
raise IdempotencyConflict
|
|
204
|
+
raise IdempotencyConflict.new(e.error)
|
|
203
205
|
when :fetch
|
|
204
206
|
return get(e.conflicting_resource_id)
|
|
205
207
|
end
|
|
@@ -219,7 +221,13 @@ module GoCardlessPro
|
|
|
219
221
|
#
|
|
220
222
|
# @param body [Hash]
|
|
221
223
|
def unenvelope_body(body)
|
|
222
|
-
body
|
|
224
|
+
if body.key?(envelope_key)
|
|
225
|
+
body[envelope_key]
|
|
226
|
+
elsif body.key?('data')
|
|
227
|
+
body['data']
|
|
228
|
+
else
|
|
229
|
+
body
|
|
230
|
+
end
|
|
223
231
|
end
|
|
224
232
|
|
|
225
233
|
# return the key which API responses will envelope data under
|
|
@@ -10,13 +10,12 @@ module GoCardlessPro
|
|
|
10
10
|
module Services
|
|
11
11
|
# Service for making requests to the PayoutItem endpoints
|
|
12
12
|
class PayoutItemsService < BaseService
|
|
13
|
-
# Returns a
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
# <strong>This endpoint only serves requests for payouts created in the last 6
|
|
17
|
-
# months. Requests for older payouts will return an HTTP status <code>410
|
|
18
|
-
# Gone</code>.</strong>
|
|
13
|
+
# Returns a cursor-paginated
|
|
14
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
15
|
+
# list of items in the payout.
|
|
19
16
|
#
|
|
17
|
+
# This endpoint only serves requests for payouts created in the last 6 months.
|
|
18
|
+
# Requests for older payouts will return an HTTP status 410 Gone.
|
|
20
19
|
# Example URL: /payout_items
|
|
21
20
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
22
21
|
def list(options = {})
|
|
@@ -50,7 +49,13 @@ module GoCardlessPro
|
|
|
50
49
|
#
|
|
51
50
|
# @param body [Hash]
|
|
52
51
|
def unenvelope_body(body)
|
|
53
|
-
body
|
|
52
|
+
if body.key?(envelope_key)
|
|
53
|
+
body[envelope_key]
|
|
54
|
+
elsif body.key?('data')
|
|
55
|
+
body['data']
|
|
56
|
+
else
|
|
57
|
+
body
|
|
58
|
+
end
|
|
54
59
|
end
|
|
55
60
|
|
|
56
61
|
# return the key which API responses will envelope data under
|
|
@@ -10,8 +10,9 @@ module GoCardlessPro
|
|
|
10
10
|
module Services
|
|
11
11
|
# Service for making requests to the Payout endpoints
|
|
12
12
|
class PayoutsService < BaseService
|
|
13
|
-
# Returns a
|
|
14
|
-
#
|
|
13
|
+
# Returns a cursor-paginated
|
|
14
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
15
|
+
# list of your payouts.
|
|
15
16
|
# Example URL: /payouts
|
|
16
17
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
17
18
|
def list(options = {})
|
|
@@ -40,15 +41,15 @@ module GoCardlessPro
|
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
# Retrieves the details of a single payout. For an example of how to reconcile
|
|
43
|
-
# the transactions in a payout, see
|
|
44
|
-
#
|
|
44
|
+
# the transactions in a payout, see this guide
|
|
45
|
+
# (https://developer.gocardless.com/api-reference/#events-reconciling-payouts-with-events).
|
|
45
46
|
# Example URL: /payouts/:identity
|
|
46
47
|
#
|
|
47
48
|
# @param identity # Unique identifier, beginning with "PO".
|
|
48
49
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
49
50
|
def get(identity, options = {})
|
|
50
51
|
path = sub_url('/payouts/:identity', {
|
|
51
|
-
'identity' => identity
|
|
52
|
+
'identity' => identity,
|
|
52
53
|
})
|
|
53
54
|
|
|
54
55
|
options[:retry_failures] = true
|
|
@@ -67,7 +68,7 @@ module GoCardlessPro
|
|
|
67
68
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
68
69
|
def update(identity, options = {})
|
|
69
70
|
path = sub_url('/payouts/:identity', {
|
|
70
|
-
'identity' => identity
|
|
71
|
+
'identity' => identity,
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
params = options.delete(:params) || {}
|
|
@@ -89,7 +90,13 @@ module GoCardlessPro
|
|
|
89
90
|
#
|
|
90
91
|
# @param body [Hash]
|
|
91
92
|
def unenvelope_body(body)
|
|
92
|
-
body
|
|
93
|
+
if body.key?(envelope_key)
|
|
94
|
+
body[envelope_key]
|
|
95
|
+
elsif body.key?('data')
|
|
96
|
+
body['data']
|
|
97
|
+
else
|
|
98
|
+
body
|
|
99
|
+
end
|
|
93
100
|
end
|
|
94
101
|
|
|
95
102
|
# return the key which API responses will envelope data under
|
|
@@ -32,7 +32,7 @@ module GoCardlessPro
|
|
|
32
32
|
if e.idempotent_creation_conflict?
|
|
33
33
|
case @api_service.on_idempotency_conflict
|
|
34
34
|
when :raise
|
|
35
|
-
raise IdempotencyConflict
|
|
35
|
+
raise IdempotencyConflict.new(e.error)
|
|
36
36
|
when :fetch
|
|
37
37
|
return get(e.conflicting_resource_id)
|
|
38
38
|
end
|
|
@@ -53,7 +53,7 @@ module GoCardlessPro
|
|
|
53
53
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
54
54
|
def get(identity, options = {})
|
|
55
55
|
path = sub_url('/redirect_flows/:identity', {
|
|
56
|
-
'identity' => identity
|
|
56
|
+
'identity' => identity,
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
options[:retry_failures] = true
|
|
@@ -65,10 +65,14 @@ module GoCardlessPro
|
|
|
65
65
|
Resources::RedirectFlow.new(unenvelope_body(response.body), response)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
# This creates a
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
# customer
|
|
68
|
+
# This creates a customer
|
|
69
|
+
# (https://developer.gocardless.com/api-reference/#core-endpoints-customers),
|
|
70
|
+
# customer bank account
|
|
71
|
+
# (https://developer.gocardless.com/api-reference/#core-endpoints-customer-bank-accounts),
|
|
72
|
+
# and mandate
|
|
73
|
+
# (https://developer.gocardless.com/api-reference/#core-endpoints-mandates)
|
|
74
|
+
# using the details supplied by your customer and returns the ID of the created
|
|
75
|
+
# mandate.
|
|
72
76
|
#
|
|
73
77
|
# This will return a `redirect_flow_incomplete` error if your customer has not
|
|
74
78
|
# yet been redirected back to your site, and a `redirect_flow_already_completed`
|
|
@@ -81,7 +85,7 @@ module GoCardlessPro
|
|
|
81
85
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
82
86
|
def complete(identity, options = {})
|
|
83
87
|
path = sub_url('/redirect_flows/:identity/actions/complete', {
|
|
84
|
-
'identity' => identity
|
|
88
|
+
'identity' => identity,
|
|
85
89
|
})
|
|
86
90
|
|
|
87
91
|
params = options.delete(:params) || {}
|
|
@@ -99,7 +103,7 @@ module GoCardlessPro
|
|
|
99
103
|
if e.idempotent_creation_conflict?
|
|
100
104
|
case @api_service.on_idempotency_conflict
|
|
101
105
|
when :raise
|
|
102
|
-
raise IdempotencyConflict
|
|
106
|
+
raise IdempotencyConflict.new(e.error)
|
|
103
107
|
when :fetch
|
|
104
108
|
return get(e.conflicting_resource_id)
|
|
105
109
|
end
|
|
@@ -119,7 +123,13 @@ module GoCardlessPro
|
|
|
119
123
|
#
|
|
120
124
|
# @param body [Hash]
|
|
121
125
|
def unenvelope_body(body)
|
|
122
|
-
body
|
|
126
|
+
if body.key?(envelope_key)
|
|
127
|
+
body[envelope_key]
|
|
128
|
+
elsif body.key?('data')
|
|
129
|
+
body['data']
|
|
130
|
+
else
|
|
131
|
+
body
|
|
132
|
+
end
|
|
123
133
|
end
|
|
124
134
|
|
|
125
135
|
# return the key which API responses will envelope data under
|
|
@@ -12,18 +12,16 @@ module GoCardlessPro
|
|
|
12
12
|
class RefundsService < BaseService
|
|
13
13
|
# Creates a new refund object.
|
|
14
14
|
#
|
|
15
|
-
# This fails with
|
|
16
|
-
# name="number_of_refunds_exceeded"></a><a
|
|
17
|
-
# name="available_refund_amount_insufficient"></a>
|
|
15
|
+
# This fails with:
|
|
18
16
|
#
|
|
19
|
-
# -
|
|
17
|
+
# -
|
|
18
|
+
# `total_amount_confirmation_invalid` if the confirmation amount doesn't match
|
|
20
19
|
# the total amount refunded for the payment. This safeguard is there to prevent
|
|
21
20
|
# two processes from creating refunds without awareness of each other.
|
|
22
|
-
#
|
|
23
|
-
#
|
|
21
|
+
# -
|
|
22
|
+
# `available_refund_amount_insufficient` if the creditor does not have
|
|
24
23
|
# sufficient balance for refunds available to cover the cost of the requested
|
|
25
24
|
# refund.
|
|
26
|
-
#
|
|
27
25
|
# Example URL: /refunds
|
|
28
26
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
29
27
|
def create(options = {})
|
|
@@ -44,7 +42,7 @@ module GoCardlessPro
|
|
|
44
42
|
if e.idempotent_creation_conflict?
|
|
45
43
|
case @api_service.on_idempotency_conflict
|
|
46
44
|
when :raise
|
|
47
|
-
raise IdempotencyConflict
|
|
45
|
+
raise IdempotencyConflict.new(e.error)
|
|
48
46
|
when :fetch
|
|
49
47
|
return get(e.conflicting_resource_id)
|
|
50
48
|
end
|
|
@@ -58,8 +56,9 @@ module GoCardlessPro
|
|
|
58
56
|
Resources::Refund.new(unenvelope_body(response.body), response)
|
|
59
57
|
end
|
|
60
58
|
|
|
61
|
-
# Returns a
|
|
62
|
-
#
|
|
59
|
+
# Returns a cursor-paginated
|
|
60
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
61
|
+
# list of your refunds.
|
|
63
62
|
# Example URL: /refunds
|
|
64
63
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
65
64
|
def list(options = {})
|
|
@@ -94,7 +93,7 @@ module GoCardlessPro
|
|
|
94
93
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
95
94
|
def get(identity, options = {})
|
|
96
95
|
path = sub_url('/refunds/:identity', {
|
|
97
|
-
'identity' => identity
|
|
96
|
+
'identity' => identity,
|
|
98
97
|
})
|
|
99
98
|
|
|
100
99
|
options[:retry_failures] = true
|
|
@@ -113,7 +112,7 @@ module GoCardlessPro
|
|
|
113
112
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
114
113
|
def update(identity, options = {})
|
|
115
114
|
path = sub_url('/refunds/:identity', {
|
|
116
|
-
'identity' => identity
|
|
115
|
+
'identity' => identity,
|
|
117
116
|
})
|
|
118
117
|
|
|
119
118
|
params = options.delete(:params) || {}
|
|
@@ -135,7 +134,13 @@ module GoCardlessPro
|
|
|
135
134
|
#
|
|
136
135
|
# @param body [Hash]
|
|
137
136
|
def unenvelope_body(body)
|
|
138
|
-
body
|
|
137
|
+
if body.key?(envelope_key)
|
|
138
|
+
body[envelope_key]
|
|
139
|
+
elsif body.key?('data')
|
|
140
|
+
body['data']
|
|
141
|
+
else
|
|
142
|
+
body
|
|
143
|
+
end
|
|
139
144
|
end
|
|
140
145
|
|
|
141
146
|
# return the key which API responses will envelope data under
|
|
@@ -15,133 +15,136 @@ module GoCardlessPro
|
|
|
15
15
|
#
|
|
16
16
|
# @param identity # The unique identifier of the simulator, used to initiate simulations.
|
|
17
17
|
# One of:
|
|
18
|
-
#
|
|
19
|
-
#
|
|
18
|
+
#
|
|
19
|
+
# - `creditor_verification_status_action_required`: Sets a creditor's
|
|
20
20
|
# `verification status` to `action required`, meaning that the creditor
|
|
21
21
|
# must provide further information to GoCardless in order to verify their
|
|
22
|
-
# account to receive payouts
|
|
23
|
-
#
|
|
22
|
+
# account to receive payouts.
|
|
23
|
+
# - `creditor_verification_status_in_review`: Sets a creditor's
|
|
24
24
|
# `verification status` to `in review`, meaning that the creditor has
|
|
25
25
|
# provided all of the information requested by GoCardless to verify their
|
|
26
|
-
# account, and is now awaiting review
|
|
27
|
-
#
|
|
26
|
+
# account, and is now awaiting review.
|
|
27
|
+
# - `creditor_verification_status_successful`: Sets a creditor's
|
|
28
28
|
# `verification status` to `successful`, meaning that the creditor is
|
|
29
|
-
# fully verified and can receive payouts
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# their mandates are submitted with their first payment)
|
|
35
|
-
#
|
|
29
|
+
# fully verified and can receive payouts.
|
|
30
|
+
# - `payment_confirmed`: Transitions a payment through to `confirmed`. It
|
|
31
|
+
# must start in the `pending_submission` state, and its mandate must be in
|
|
32
|
+
# the `activated` state (unless it is a payment for ACH, BECS, BECS_NZ or
|
|
33
|
+
# SEPA, in which cases the mandate may be `pending_submission`, since
|
|
34
|
+
# their mandates are submitted with their first payment).
|
|
35
|
+
# - `payment_paid_out`: Transitions a payment through to `paid_out`,
|
|
36
36
|
# having been collected successfully and paid out to you. It must start in
|
|
37
37
|
# the `pending_submission` state, and its mandate must be in the
|
|
38
38
|
# `activated` state (unless it is a payment for ACH, BECS, BECS_NZ or
|
|
39
39
|
# SEPA, in which cases the mandate may be `pending_submission`, since
|
|
40
|
-
# their mandates are submitted with their first payment)
|
|
41
|
-
#
|
|
40
|
+
# their mandates are submitted with their first payment).
|
|
41
|
+
# - `payment_failed`: Transitions a payment through to `failed`. It must
|
|
42
42
|
# start in the `pending_submission` state, and its mandate must be in the
|
|
43
43
|
# `activated` state (unless it is a payment for ACH, BECS, BECS_NZ or
|
|
44
44
|
# SEPA, in which cases the mandate may be `pending_submission`, since
|
|
45
|
-
# their mandates are submitted with their first payment)
|
|
46
|
-
#
|
|
45
|
+
# their mandates are submitted with their first payment).
|
|
46
|
+
# - `payment_charged_back`: Behaves the same as the `payout_paid_out`
|
|
47
47
|
# simulator, except that the payment is transitioned to `charged_back`
|
|
48
|
-
# after it is paid out, having been charged back by the customer
|
|
49
|
-
#
|
|
48
|
+
# after it is paid out, having been charged back by the customer.
|
|
49
|
+
# - `payment_chargeback_settled`: Behaves the same as the
|
|
50
50
|
# `payment_charged_back` simulator, except that the charged back payment
|
|
51
51
|
# is additionally included as a debit item in a payout, thereby settling
|
|
52
|
-
# the charged back payment
|
|
53
|
-
#
|
|
52
|
+
# the charged back payment.
|
|
53
|
+
# - `payment_late_failure`: Transitions a payment through to
|
|
54
54
|
# `late_failure`, having been apparently collected successfully
|
|
55
55
|
# beforehand. It must start in either the `pending_submission` or
|
|
56
56
|
# `paid_out` state, and its mandate must be in the `activated` state
|
|
57
57
|
# (unless it is a payment for ACH, BECS, BECS_NZ or SEPA, in which cases
|
|
58
58
|
# the mandate may be `pending_submission`, since their mandates are
|
|
59
59
|
# submitted with their first payment). Not compatible with Autogiro
|
|
60
|
-
# mandates
|
|
61
|
-
#
|
|
60
|
+
# mandates.
|
|
61
|
+
# - `payment_late_failure_settled`: Behaves the same as the
|
|
62
62
|
# `payment_late_failure` simulator, except that the late failure is
|
|
63
63
|
# additionally included as a debit item in a payout, thereby settling the
|
|
64
|
-
# late failure
|
|
65
|
-
#
|
|
66
|
-
# proceeding any further. It must start in the `pending_submission`
|
|
67
|
-
#
|
|
68
|
-
# <li>`mandate_activated`: Transitions a mandate through to `activated`,
|
|
64
|
+
# late failure.
|
|
65
|
+
# - `payment_submitted`: Transitions a payment to `submitted`, without
|
|
66
|
+
# proceeding any further. It must start in the `pending_submission` state.
|
|
67
|
+
# - `mandate_activated`: Transitions a mandate through to `activated`,
|
|
69
68
|
# having been submitted to the banks and set up successfully. It must
|
|
70
69
|
# start in the `pending_submission` state. Not compatible with ACH, BECS,
|
|
71
70
|
# BECS_NZ and SEPA mandates, which are submitted and activated with their
|
|
72
|
-
# first payment
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
71
|
+
# first payment.
|
|
72
|
+
# - `mandate_customer_approval_granted`: Transitions a mandate through to
|
|
73
|
+
# `pending_submission`, as if the customer approved the mandate creation.
|
|
74
|
+
# It must start in the `pending_customer_approval` state. Compatible only
|
|
75
|
+
# with Bacs and SEPA mandates, which support customer signatures on the
|
|
76
|
+
# mandate. All payments associated with the mandate will be transitioned
|
|
77
|
+
# to `pending_submission`. All subscriptions associated with the mandate
|
|
78
|
+
# will become `active`.
|
|
79
|
+
# - `mandate_customer_approval_skipped`: Transitions a mandate through to
|
|
80
|
+
# `pending_submission`, as if the customer skipped the mandate approval
|
|
82
81
|
# during the mandate creation process. It must start in the
|
|
83
82
|
# `pending_customer_approval` state. Compatible only with Bacs and SEPA
|
|
84
83
|
# mandates, which support customer signatures on the mandate. All payments
|
|
85
84
|
# associated with the mandate will be transitioned to
|
|
86
85
|
# `pending_submission`. All subscriptions associated with the mandate will
|
|
87
|
-
# become `active
|
|
88
|
-
#
|
|
86
|
+
# become `active`.
|
|
87
|
+
# - `mandate_failed`: Transitions a mandate through to `failed`, having
|
|
89
88
|
# been submitted to the banks but found to be invalid (for example due to
|
|
90
89
|
# invalid bank details). It must start in the `pending_submission` or
|
|
91
90
|
# `submitted` states. Not compatible with SEPA mandates, which are
|
|
92
|
-
# submitted with their first payment
|
|
93
|
-
#
|
|
94
|
-
#
|
|
91
|
+
# submitted with their first payment.
|
|
92
|
+
# - `mandate_expired`: Transitions a mandate through to `expired`, having
|
|
93
|
+
# been submitted to the banks, set up successfully and then expired
|
|
95
94
|
# because no collection attempts were made against it for longer than the
|
|
96
95
|
# scheme's dormancy period (13 months for Bacs, 3 years for SEPA, 15
|
|
97
96
|
# months for ACH, Betalingsservice, and BECS). It must start in the
|
|
98
97
|
# `pending_submission` state. Not compatible with Autogiro, BECS NZ, and
|
|
99
|
-
# PAD mandates, which do not expire
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
# `
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
# `
|
|
110
|
-
# <li>`mandate_suspended_by_payer`: Transitions a mandate to
|
|
98
|
+
# PAD mandates, which do not expire.
|
|
99
|
+
# - `mandate_transferred`: Transitions a mandate through to `transferred`,
|
|
100
|
+
# having been submitted to the banks, set up successfully and then moved
|
|
101
|
+
# to a new bank account due. It must start in the `pending_submission`
|
|
102
|
+
# state. Only compatible with Bacs and SEPA mandates.
|
|
103
|
+
# - `mandate_transferred_with_resubmission`: Transitions a mandate through
|
|
104
|
+
# `transferred` and resubmits it to the banks, can be caused be the UK's
|
|
105
|
+
# Current Account Switching Service (CASS) or when a customer contacts
|
|
106
|
+
# GoCardless to change their bank details. It must start in the
|
|
107
|
+
# `pending_submission` state. Only compatible with Bacs mandates.
|
|
108
|
+
# - `mandate_suspended_by_payer`: Transitions a mandate to
|
|
111
109
|
# `suspended_by_payer`, as if payer has suspended the mandate after it has
|
|
112
110
|
# been setup successfully. It must start in the `activated` state. Only
|
|
113
|
-
# compatible with PAY_TO mandates
|
|
114
|
-
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
# `
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
123
|
-
# refund must start in `pending_submission
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
# with all actions completed except for `bank_authorisation`. Only billing
|
|
129
|
-
# requests with a `payment_request` are supported.</li>
|
|
130
|
-
# <li>`billing_request_fulfilled_and_payment_failed`: Authorises the
|
|
131
|
-
# billing request, fulfils it, and moves the associated payment to
|
|
132
|
-
# `failed`. The billing request must be in the `pending` state, with all
|
|
111
|
+
# compatible with PAY_TO mandates.
|
|
112
|
+
# - `refund_paid`: Transitions a refund to `paid`. It must start in either
|
|
113
|
+
# the `pending_submission` or `submitted` state.
|
|
114
|
+
# - `refund_settled`: Transitions a refund to `paid`, if it's not already,
|
|
115
|
+
# then generates a payout that includes the refund, thereby settling the
|
|
116
|
+
# funds. It must start in one of `pending_submission`, `submitted` or
|
|
117
|
+
# `paid` states.
|
|
118
|
+
# - `refund_bounced`: Transitions a refund to `bounced`. It must start in
|
|
119
|
+
# either the `pending_submission`, `submitted`, or `paid` state.
|
|
120
|
+
# - `refund_returned`: Transitions a refund to `refund_returned`. The
|
|
121
|
+
# refund must start in `pending_submission`.
|
|
122
|
+
# - `payout_bounced`: Transitions a payout to `bounced`. It must start in
|
|
123
|
+
# the `paid` state.
|
|
124
|
+
# - `billing_request_fulfilled`: Authorises the billing request, and then
|
|
125
|
+
# fulfils it. The billing request must be in the `pending` state, with all
|
|
133
126
|
# actions completed except for `bank_authorisation`. Only billing requests
|
|
134
|
-
# with a `payment_request` are supported
|
|
135
|
-
#
|
|
127
|
+
# with a `payment_request` are supported.
|
|
128
|
+
# - `billing_request_fulfilled_and_payment_failed`: Authorises the billing
|
|
129
|
+
# request, fulfils it, and moves the associated payment to `failed`. The
|
|
130
|
+
# billing request must be in the `pending` state, with all actions
|
|
131
|
+
# completed except for `bank_authorisation`. Only billing requests with a
|
|
132
|
+
# `payment_request` are supported.
|
|
133
|
+
# - `billing_request_fulfilled_and_payment_confirmed_to_failed`:
|
|
134
|
+
# Authorises the billing request, fulfils it, moves the associated payment
|
|
135
|
+
# to `confirmed` and then moves it to `failed`. The billing request must
|
|
136
|
+
# be in the `pending` state, with all actions completed except for
|
|
137
|
+
# `bank_authorisation`. Only billing requests with a `payment_request` are
|
|
138
|
+
# supported.
|
|
139
|
+
# - `billing_request_fulfilled_and_payment_paid_out`: Authorises the
|
|
136
140
|
# billing request, fulfils it, and moves the associated payment to
|
|
137
141
|
# `paid_out`. The billing request must be in the `pending` state, with all
|
|
138
142
|
# actions completed except for `bank_authorisation`. Only billing requests
|
|
139
|
-
# with a `payment_request` are supported
|
|
140
|
-
# </ul>
|
|
143
|
+
# with a `payment_request` are supported.
|
|
141
144
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
142
145
|
def run(identity, options = {})
|
|
143
146
|
path = sub_url('/scenario_simulators/:identity/actions/run', {
|
|
144
|
-
'identity' => identity
|
|
147
|
+
'identity' => identity,
|
|
145
148
|
})
|
|
146
149
|
|
|
147
150
|
params = options.delete(:params) || {}
|
|
@@ -163,7 +166,13 @@ module GoCardlessPro
|
|
|
163
166
|
#
|
|
164
167
|
# @param body [Hash]
|
|
165
168
|
def unenvelope_body(body)
|
|
166
|
-
body
|
|
169
|
+
if body.key?(envelope_key)
|
|
170
|
+
body[envelope_key]
|
|
171
|
+
elsif body.key?('data')
|
|
172
|
+
body['data']
|
|
173
|
+
else
|
|
174
|
+
body
|
|
175
|
+
end
|
|
167
176
|
end
|
|
168
177
|
|
|
169
178
|
# return the key which API responses will envelope data under
|