gocardless_pro 4.3.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 -0
- data/lib/gocardless_pro/client.rb +11 -1
- data/lib/gocardless_pro/list_response.rb +2 -2
- data/lib/gocardless_pro/resources/billing_request.rb +7 -8
- data/lib/gocardless_pro/resources/billing_request_with_action.rb +4 -4
- data/lib/gocardless_pro/resources/block.rb +4 -6
- data/lib/gocardless_pro/resources/creditor.rb +6 -4
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +6 -5
- data/lib/gocardless_pro/resources/customer.rb +4 -3
- data/lib/gocardless_pro/resources/customer_bank_account.rb +13 -8
- data/lib/gocardless_pro/resources/customer_notification.rb +3 -4
- data/lib/gocardless_pro/resources/event.rb +13 -2
- data/lib/gocardless_pro/resources/export.rb +2 -0
- data/lib/gocardless_pro/resources/instalment_schedule.rb +0 -1
- data/lib/gocardless_pro/resources/institution.rb +3 -3
- data/lib/gocardless_pro/resources/logo.rb +2 -1
- data/lib/gocardless_pro/resources/mandate.rb +7 -4
- data/lib/gocardless_pro/resources/mandate_import.rb +25 -21
- data/lib/gocardless_pro/resources/mandate_import_entry.rb +13 -16
- data/lib/gocardless_pro/resources/mandate_pdf.rb +3 -3
- data/lib/gocardless_pro/resources/negative_balance_limit.rb +0 -1
- data/lib/gocardless_pro/resources/outbound_payment.rb +11 -4
- 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 +27 -31
- data/lib/gocardless_pro/resources/payment.rb +9 -6
- data/lib/gocardless_pro/resources/payment_account.rb +2 -1
- data/lib/gocardless_pro/resources/payment_account_transaction.rb +2 -1
- data/lib/gocardless_pro/resources/payout.rb +7 -6
- data/lib/gocardless_pro/resources/payout_item.rb +1 -2
- data/lib/gocardless_pro/resources/redirect_flow.rb +34 -23
- data/lib/gocardless_pro/resources/refund.rb +8 -6
- data/lib/gocardless_pro/resources/scheme_identifier.rb +0 -1
- data/lib/gocardless_pro/resources/subscription.rb +17 -14
- data/lib/gocardless_pro/resources/tax_rate.rb +2 -2
- data/lib/gocardless_pro/resources/verification_detail.rb +10 -6
- data/lib/gocardless_pro/services/balances_service.rb +11 -3
- data/lib/gocardless_pro/services/bank_account_details_service.rb +10 -4
- data/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb +7 -1
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +7 -1
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +14 -6
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +7 -1
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +10 -3
- data/lib/gocardless_pro/services/billing_request_with_actions_service.rb +7 -1
- data/lib/gocardless_pro/services/billing_requests_service.rb +18 -13
- data/lib/gocardless_pro/services/blocks_service.rb +10 -3
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +10 -3
- data/lib/gocardless_pro/services/creditors_service.rb +10 -3
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +10 -3
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +20 -10
- data/lib/gocardless_pro/services/customer_notifications_service.rb +7 -2
- data/lib/gocardless_pro/services/customers_service.rb +11 -5
- data/lib/gocardless_pro/services/events_service.rb +15 -3
- data/lib/gocardless_pro/services/exports_service.rb +7 -1
- data/lib/gocardless_pro/services/funds_availabilities_service.rb +7 -1
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +15 -7
- data/lib/gocardless_pro/services/institutions_service.rb +7 -1
- 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 +10 -2
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +11 -5
- data/lib/gocardless_pro/services/mandates_service.rb +16 -9
- 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 +11 -4
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +11 -8
- data/lib/gocardless_pro/services/payer_themes_service.rb +7 -1
- data/lib/gocardless_pro/services/payment_account_transactions_service.rb +34 -7
- data/lib/gocardless_pro/services/payment_accounts_service.rb +10 -3
- data/lib/gocardless_pro/services/payments_service.rb +22 -14
- data/lib/gocardless_pro/services/payout_items_service.rb +12 -7
- data/lib/gocardless_pro/services/payouts_service.rb +12 -5
- data/lib/gocardless_pro/services/redirect_flows_service.rb +15 -5
- data/lib/gocardless_pro/services/refunds_service.rb +15 -10
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +85 -82
- data/lib/gocardless_pro/services/scheme_identifiers_service.rb +13 -7
- data/lib/gocardless_pro/services/subscriptions_service.rb +48 -38
- data/lib/gocardless_pro/services/tax_rates_service.rb +10 -3
- data/lib/gocardless_pro/services/transferred_mandates_service.rb +7 -1
- data/lib/gocardless_pro/services/verification_details_service.rb +7 -1
- data/lib/gocardless_pro/services/webhooks_service.rb +10 -3
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro/webhook.rb +45 -0
- data/lib/gocardless_pro.rb +6 -0
- metadata +7 -7
|
@@ -15,135 +15,132 @@ 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`:
|
|
136
134
|
# Authorises the billing request, fulfils it, moves the associated payment
|
|
137
135
|
# to `confirmed` and then moves it to `failed`. The billing request must
|
|
138
136
|
# be in the `pending` state, with all actions completed except for
|
|
139
137
|
# `bank_authorisation`. Only billing requests with a `payment_request` are
|
|
140
|
-
# supported
|
|
141
|
-
#
|
|
138
|
+
# supported.
|
|
139
|
+
# - `billing_request_fulfilled_and_payment_paid_out`: Authorises the
|
|
142
140
|
# billing request, fulfils it, and moves the associated payment to
|
|
143
141
|
# `paid_out`. The billing request must be in the `pending` state, with all
|
|
144
142
|
# actions completed except for `bank_authorisation`. Only billing requests
|
|
145
|
-
# with a `payment_request` are supported
|
|
146
|
-
# </ul>
|
|
143
|
+
# with a `payment_request` are supported.
|
|
147
144
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
148
145
|
def run(identity, options = {})
|
|
149
146
|
path = sub_url('/scenario_simulators/:identity/actions/run', {
|
|
@@ -169,7 +166,13 @@ module GoCardlessPro
|
|
|
169
166
|
#
|
|
170
167
|
# @param body [Hash]
|
|
171
168
|
def unenvelope_body(body)
|
|
172
|
-
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
|
|
173
176
|
end
|
|
174
177
|
|
|
175
178
|
# return the key which API responses will envelope data under
|
|
@@ -20,7 +20,7 @@ module GoCardlessPro
|
|
|
20
20
|
# become active. On other schemes, including SEPA,
|
|
21
21
|
# this happens instantly.
|
|
22
22
|
#
|
|
23
|
-
#
|
|
23
|
+
# Scheme identifier name validations
|
|
24
24
|
#
|
|
25
25
|
# The `name` field of a scheme identifier can contain alphanumeric characters,
|
|
26
26
|
# spaces and
|
|
@@ -29,8 +29,8 @@ module GoCardlessPro
|
|
|
29
29
|
# Its maximum length and the special characters it supports depend on the
|
|
30
30
|
# scheme:
|
|
31
31
|
#
|
|
32
|
-
# |
|
|
33
|
-
#
|
|
32
|
+
# | scheme | maximum length | special characters allowed
|
|
33
|
+
# |
|
|
34
34
|
# | :---------------- | :----------------- |
|
|
35
35
|
# :-------------------------------------------------- |
|
|
36
36
|
# | `bacs` | 18 characters | `/` `.` `&` `-`
|
|
@@ -49,7 +49,6 @@ module GoCardlessPro
|
|
|
49
49
|
# You should ensure that the name you set matches the legal name or the trading
|
|
50
50
|
# name of
|
|
51
51
|
# the creditor, otherwise, there is an increased risk of chargeback.
|
|
52
|
-
#
|
|
53
52
|
# Example URL: /scheme_identifiers
|
|
54
53
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
55
54
|
def create(options = {})
|
|
@@ -84,8 +83,9 @@ module GoCardlessPro
|
|
|
84
83
|
Resources::SchemeIdentifier.new(unenvelope_body(response.body), response)
|
|
85
84
|
end
|
|
86
85
|
|
|
87
|
-
# Returns a
|
|
88
|
-
#
|
|
86
|
+
# Returns a cursor-paginated
|
|
87
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
88
|
+
# list of your scheme identifiers.
|
|
89
89
|
# Example URL: /scheme_identifiers
|
|
90
90
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
91
91
|
def list(options = {})
|
|
@@ -138,7 +138,13 @@ module GoCardlessPro
|
|
|
138
138
|
#
|
|
139
139
|
# @param body [Hash]
|
|
140
140
|
def unenvelope_body(body)
|
|
141
|
-
body
|
|
141
|
+
if body.key?(envelope_key)
|
|
142
|
+
body[envelope_key]
|
|
143
|
+
elsif body.key?('data')
|
|
144
|
+
body['data']
|
|
145
|
+
else
|
|
146
|
+
body
|
|
147
|
+
end
|
|
142
148
|
end
|
|
143
149
|
|
|
144
150
|
# return the key which API responses will envelope data under
|
|
@@ -45,9 +45,10 @@ module GoCardlessPro
|
|
|
45
45
|
Resources::Subscription.new(unenvelope_body(response.body), response)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
# Returns a
|
|
49
|
-
#
|
|
50
|
-
#
|
|
48
|
+
# Returns a cursor-paginated
|
|
49
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
50
|
+
# list of your subscriptions. Please note if the subscriptions are related to
|
|
51
|
+
# customers who have been removed, they will not be shown in the response.
|
|
51
52
|
# Example URL: /subscriptions
|
|
52
53
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
53
54
|
def list(options = {})
|
|
@@ -98,26 +99,26 @@ module GoCardlessPro
|
|
|
98
99
|
#
|
|
99
100
|
# This fails with:
|
|
100
101
|
#
|
|
101
|
-
# -
|
|
102
|
+
# -
|
|
103
|
+
# `validation_failed` if invalid data is provided when attempting to update a
|
|
102
104
|
# subscription.
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
#
|
|
105
|
+
# -
|
|
106
|
+
# `subscription_not_active` if the subscription is no longer active.
|
|
107
|
+
# -
|
|
108
|
+
# `subscription_already_ended` if the subscription has taken all payments.
|
|
109
|
+
# -
|
|
110
|
+
# `mandate_payments_require_approval` if the amount is being changed and the
|
|
109
111
|
# mandate requires approval.
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
#
|
|
113
|
-
#
|
|
114
|
-
#
|
|
112
|
+
# -
|
|
113
|
+
# `number_of_subscription_amendments_exceeded` error if the subscription amount
|
|
114
|
+
# has already been changed 10 times.
|
|
115
|
+
# -
|
|
116
|
+
# `forbidden` if the amount is being changed, and the subscription was created
|
|
115
117
|
# by an app and you are not authenticated as that app, or if the subscription
|
|
116
118
|
# was not created by an app and you are authenticated as an app
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
+
# -
|
|
120
|
+
# `resource_created_by_another_app` if the app fee is being changed, and the
|
|
119
121
|
# subscription was created by an app other than the app you are authenticated as
|
|
120
|
-
#
|
|
121
122
|
# Example URL: /subscriptions/:identity
|
|
122
123
|
#
|
|
123
124
|
# @param identity # Unique identifier, beginning with "SB".
|
|
@@ -148,8 +149,10 @@ module GoCardlessPro
|
|
|
148
149
|
# when they continue forever (created without `count` or `end_date`) or
|
|
149
150
|
# the subscription is already paused for a number of cycles.
|
|
150
151
|
#
|
|
151
|
-
# When `pause_cycles` is omitted the subscription is paused until the
|
|
152
|
-
# endpoint
|
|
152
|
+
# When `pause_cycles` is omitted the subscription is paused until the resume
|
|
153
|
+
# endpoint
|
|
154
|
+
# (https://developer.gocardless.com/api-reference/#subscriptions-resume-a-subscription)
|
|
155
|
+
# is called.
|
|
153
156
|
# If the subscription is collecting a fixed number of payments, `end_date` will
|
|
154
157
|
# be set to `null`.
|
|
155
158
|
# When paused indefinitely, `upcoming_payments` will be empty.
|
|
@@ -163,22 +166,23 @@ module GoCardlessPro
|
|
|
163
166
|
#
|
|
164
167
|
# This fails with:
|
|
165
168
|
#
|
|
166
|
-
# -
|
|
169
|
+
# -
|
|
170
|
+
# `forbidden` if the subscription was created by an app and you are not
|
|
167
171
|
# authenticated as that app, or if the subscription was not created by an app
|
|
168
172
|
# and you are authenticated as an app
|
|
169
|
-
#
|
|
170
|
-
#
|
|
173
|
+
# -
|
|
174
|
+
# `validation_failed` if invalid data is provided when attempting to pause a
|
|
171
175
|
# subscription.
|
|
172
|
-
#
|
|
173
|
-
#
|
|
176
|
+
# -
|
|
177
|
+
# `subscription_paused_cannot_update_cycles` if the subscription is already
|
|
174
178
|
# paused for a number of cycles and the request provides a value for
|
|
175
179
|
# `pause_cycle`.
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
179
|
-
#
|
|
180
|
-
#
|
|
181
|
-
#
|
|
180
|
+
# -
|
|
181
|
+
# `subscription_cannot_be_paused` if the subscription cannot be paused.
|
|
182
|
+
# -
|
|
183
|
+
# `subscription_already_ended` if the subscription has taken all payments.
|
|
184
|
+
# -
|
|
185
|
+
# `pause_cycles_must_be_greater_than_or_equal_to` if the provided value for
|
|
182
186
|
# `pause_cycles` cannot be satisfied.
|
|
183
187
|
# Example URL: /subscriptions/:identity/actions/pause
|
|
184
188
|
#
|
|
@@ -226,15 +230,15 @@ module GoCardlessPro
|
|
|
226
230
|
#
|
|
227
231
|
# This fails with:
|
|
228
232
|
#
|
|
229
|
-
# -
|
|
233
|
+
# -
|
|
234
|
+
# `forbidden` if the subscription was created by an app and you are not
|
|
230
235
|
# authenticated as that app, or if the subscription was not created by an app
|
|
231
236
|
# and you are authenticated as an app
|
|
232
|
-
#
|
|
233
|
-
#
|
|
237
|
+
# -
|
|
238
|
+
# `validation_failed` if invalid data is provided when attempting to resume a
|
|
234
239
|
# subscription.
|
|
235
|
-
#
|
|
236
|
-
#
|
|
237
|
-
#
|
|
240
|
+
# -
|
|
241
|
+
# `subscription_not_paused` if the subscription is not paused.
|
|
238
242
|
# Example URL: /subscriptions/:identity/actions/resume
|
|
239
243
|
#
|
|
240
244
|
# @param identity # Unique identifier, beginning with "SB".
|
|
@@ -323,7 +327,13 @@ module GoCardlessPro
|
|
|
323
327
|
#
|
|
324
328
|
# @param body [Hash]
|
|
325
329
|
def unenvelope_body(body)
|
|
326
|
-
body
|
|
330
|
+
if body.key?(envelope_key)
|
|
331
|
+
body[envelope_key]
|
|
332
|
+
elsif body.key?('data')
|
|
333
|
+
body['data']
|
|
334
|
+
else
|
|
335
|
+
body
|
|
336
|
+
end
|
|
327
337
|
end
|
|
328
338
|
|
|
329
339
|
# 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 TaxRate endpoints
|
|
12
12
|
class TaxRatesService < BaseService
|
|
13
|
-
# Returns a
|
|
14
|
-
#
|
|
13
|
+
# Returns a cursor-paginated
|
|
14
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
15
|
+
# list of all tax rates.
|
|
15
16
|
# Example URL: /tax_rates
|
|
16
17
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
17
18
|
def list(options = {})
|
|
@@ -64,7 +65,13 @@ module GoCardlessPro
|
|
|
64
65
|
#
|
|
65
66
|
# @param body [Hash]
|
|
66
67
|
def unenvelope_body(body)
|
|
67
|
-
body
|
|
68
|
+
if body.key?(envelope_key)
|
|
69
|
+
body[envelope_key]
|
|
70
|
+
elsif body.key?('data')
|
|
71
|
+
body['data']
|
|
72
|
+
else
|
|
73
|
+
body
|
|
74
|
+
end
|
|
68
75
|
end
|
|
69
76
|
|
|
70
77
|
# return the key which API responses will envelope data under
|
|
@@ -37,7 +37,13 @@ module GoCardlessPro
|
|
|
37
37
|
#
|
|
38
38
|
# @param body [Hash]
|
|
39
39
|
def unenvelope_body(body)
|
|
40
|
-
body
|
|
40
|
+
if body.key?(envelope_key)
|
|
41
|
+
body[envelope_key]
|
|
42
|
+
elsif body.key?('data')
|
|
43
|
+
body['data']
|
|
44
|
+
else
|
|
45
|
+
body
|
|
46
|
+
end
|
|
41
47
|
end
|
|
42
48
|
|
|
43
49
|
# return the key which API responses will envelope data under
|
|
@@ -63,7 +63,13 @@ module GoCardlessPro
|
|
|
63
63
|
#
|
|
64
64
|
# @param body [Hash]
|
|
65
65
|
def unenvelope_body(body)
|
|
66
|
-
body
|
|
66
|
+
if body.key?(envelope_key)
|
|
67
|
+
body[envelope_key]
|
|
68
|
+
elsif body.key?('data')
|
|
69
|
+
body['data']
|
|
70
|
+
else
|
|
71
|
+
body
|
|
72
|
+
end
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
# 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 Webhook endpoints
|
|
12
12
|
class WebhooksService < 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 webhooks.
|
|
15
16
|
# Example URL: /webhooks
|
|
16
17
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
17
18
|
def list(options = {})
|
|
@@ -103,7 +104,13 @@ module GoCardlessPro
|
|
|
103
104
|
#
|
|
104
105
|
# @param body [Hash]
|
|
105
106
|
def unenvelope_body(body)
|
|
106
|
-
body
|
|
107
|
+
if body.key?(envelope_key)
|
|
108
|
+
body[envelope_key]
|
|
109
|
+
elsif body.key?('data')
|
|
110
|
+
body['data']
|
|
111
|
+
else
|
|
112
|
+
body
|
|
113
|
+
end
|
|
107
114
|
end
|
|
108
115
|
|
|
109
116
|
# return the key which API responses will envelope data under
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
require 'openssl'
|
|
2
2
|
|
|
3
3
|
module GoCardlessPro
|
|
4
|
+
# Represents the result of parsing a webhook, containing both the events
|
|
5
|
+
# and the webhook metadata.
|
|
6
|
+
class WebhookParseResult
|
|
7
|
+
attr_reader :events
|
|
8
|
+
attr_reader :webhook_id
|
|
9
|
+
|
|
10
|
+
def initialize(events, webhook_id)
|
|
11
|
+
@events = events
|
|
12
|
+
@webhook_id = webhook_id
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
4
16
|
class Webhook
|
|
5
17
|
class InvalidSignatureError < StandardError; end
|
|
6
18
|
|
|
@@ -38,6 +50,39 @@ module GoCardlessPro
|
|
|
38
50
|
events.map { |event| Resources::Event.new(event) }
|
|
39
51
|
end
|
|
40
52
|
|
|
53
|
+
# Validates that a webhook was genuinely sent by GoCardless using
|
|
54
|
+
# `.signature_valid?`, and then parses it into a WebhookParseResult containing
|
|
55
|
+
# both the events and the webhook ID from the meta field
|
|
56
|
+
#
|
|
57
|
+
# @option options [String] :request_body the request body
|
|
58
|
+
# @option options [String] :signature_header the signature included in the request,
|
|
59
|
+
# found in the `Webhook-Signature` header
|
|
60
|
+
# @option options [String] :webhook_endpoint_secret the webhook endpoint secret for
|
|
61
|
+
# your webhook endpoint, as configured in your GoCardless Dashboard
|
|
62
|
+
# @return [WebhookParseResult] containing the events and webhook ID
|
|
63
|
+
# @raise [InvalidSignatureError] if the signature header specified does not match
|
|
64
|
+
# the signature computed using the request body and webhook endpoint secret
|
|
65
|
+
# @raise [ArgumentError] if a required keyword argument is not provided or is not
|
|
66
|
+
# of the required type
|
|
67
|
+
def parse_with_meta(options = {})
|
|
68
|
+
validate_options!(options)
|
|
69
|
+
|
|
70
|
+
unless signature_valid?(request_body: options[:request_body],
|
|
71
|
+
signature_header: options[:signature_header],
|
|
72
|
+
webhook_endpoint_secret: options[:webhook_endpoint_secret])
|
|
73
|
+
raise InvalidSignatureError, "This webhook doesn't appear to be a genuine " \
|
|
74
|
+
'webhook from GoCardless, because the signature ' \
|
|
75
|
+
"header doesn't match the signature computed" \
|
|
76
|
+
' with your webhook endpoint secret.'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
parsed = JSON.parse(options[:request_body])
|
|
80
|
+
events = parsed['events'].map { |event| Resources::Event.new(event) }
|
|
81
|
+
webhook_id = parsed.dig('meta', 'webhook_id')
|
|
82
|
+
|
|
83
|
+
WebhookParseResult.new(events, webhook_id)
|
|
84
|
+
end
|
|
85
|
+
|
|
41
86
|
# Validates that a webhook was genuinely sent by GoCardless by computing its
|
|
42
87
|
# signature using the body and your webhook endpoint secret, and comparing that with
|
|
43
88
|
# the signature included in the `Webhook-Signature` header
|
data/lib/gocardless_pro.rb
CHANGED
|
@@ -123,6 +123,12 @@ require_relative 'gocardless_pro/services/negative_balance_limits_service'
|
|
|
123
123
|
require_relative 'gocardless_pro/resources/outbound_payment'
|
|
124
124
|
require_relative 'gocardless_pro/services/outbound_payments_service'
|
|
125
125
|
|
|
126
|
+
require_relative 'gocardless_pro/resources/outbound_payment_import'
|
|
127
|
+
require_relative 'gocardless_pro/services/outbound_payment_imports_service'
|
|
128
|
+
|
|
129
|
+
require_relative 'gocardless_pro/resources/outbound_payment_import_entry'
|
|
130
|
+
require_relative 'gocardless_pro/services/outbound_payment_import_entries_service'
|
|
131
|
+
|
|
126
132
|
require_relative 'gocardless_pro/resources/payer_authorisation'
|
|
127
133
|
require_relative 'gocardless_pro/services/payer_authorisations_service'
|
|
128
134
|
|