Skip to content
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,22 @@ class WebhooksController < ApplicationController
end
```

#### Accessing the webhook ID

If you need to access the webhook ID for debugging purposes, you can use `parse_with_meta` instead:

```ruby
result = GoCardlessPro::Webhook.parse_with_meta(
request_body: request.raw_post,
signature_header: request.headers['Webhook-Signature'],
webhook_endpoint_secret: webhook_endpoint_secret
)
events = result.events
webhook_id = result.webhook_id # e.g. "WB123" - useful for debugging
```

Note: The webhook ID is intended for debugging and logging purposes only. It should not be used for deduplication - instead, use the event IDs to deduplicate, as each event has a unique ID that remains consistent if the same event is sent multiple times.

For more details on working with webhooks, see our ["Getting started" guide](https://developer.gocardless.com/getting-started/api/introduction/?lang=ruby).

### Using the OAuth API
Expand Down
6 changes: 6 additions & 0 deletions lib/gocardless_pro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ module GoCardlessPro
require_relative 'gocardless_pro/resources/outbound_payment'
require_relative 'gocardless_pro/services/outbound_payments_service'

require_relative 'gocardless_pro/resources/outbound_payment_import'
require_relative 'gocardless_pro/services/outbound_payment_imports_service'

require_relative 'gocardless_pro/resources/outbound_payment_import_entry'
require_relative 'gocardless_pro/services/outbound_payment_import_entries_service'

require_relative 'gocardless_pro/resources/payer_authorisation'
require_relative 'gocardless_pro/services/payer_authorisations_service'

Expand Down
10 changes: 10 additions & 0 deletions lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ def outbound_payments
@outbound_payments ||= Services::OutboundPaymentsService.new(@api_service)
end

# Access to the service for outbound_payment_import to make API calls
def outbound_payment_imports
@outbound_payment_imports ||= Services::OutboundPaymentImportsService.new(@api_service)
end

# Access to the service for outbound_payment_import_entry to make API calls
def outbound_payment_import_entries
@outbound_payment_import_entries ||= Services::OutboundPaymentImportEntriesService.new(@api_service)
end

# Access to the service for payer_authorisation to make API calls
def payer_authorisations
@payer_authorisations ||= Services::PayerAuthorisationsService.new(@api_service)
Expand Down
4 changes: 2 additions & 2 deletions lib/gocardless_pro/list_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def api_response

# return the before cursor for paginating
def before
@response.body['meta']['cursors']['before']
@response.body.dig('meta', 'cursors', 'before')
end

# return the after cursor for paginating
def after
@response.body['meta']['cursors']['after']
@response.body.dig('meta', 'cursors', 'after')
end
end
end
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/customer_bank_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CustomerBankAccount
attr_reader :enabled
attr_reader :id
attr_reader :metadata
attr_reader :trusted_recipient

# Initialize a customer_bank_account resource instance
# @param object [Hash] an object returned from the API
Expand All @@ -57,6 +58,7 @@ def initialize(object, response = nil)
@id = object['id']
@links = object['links']
@metadata = object['metadata']
@trusted_recipient = object['trusted_recipient']
@response = response
end

Expand Down
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Export
attr_reader :created_at
attr_reader :currency
attr_reader :download_url
attr_reader :error_message
attr_reader :export_type
attr_reader :id

Expand All @@ -26,6 +27,7 @@ def initialize(object, response = nil)
@created_at = object['created_at']
@currency = object['currency']
@download_url = object['download_url']
@error_message = object['error_message']
@export_type = object['export_type']
@id = object['id']
@response = response
Expand Down
81 changes: 81 additions & 0 deletions lib/gocardless_pro/resources/outbound_payment_import.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

require 'uri'

module GoCardlessPro
# A module containing classes for each of the resources in the GC Api
module Resources
# Represents an instance of a outbound_payment_import resource returned from the API

# Outbound Payment Imports allow you to create multiple payments via a
# single API call.
#
# The Workflow:
# 1. Create the outbound payment import.
# 2. Retrieve an authorisation link from the response.
# 3. Redirect the user to the link to authorise the import.
# 4. Once the user authorises the import, the individual outbound payments
# are automatically submitted.
#
# Import entries are not processed as actual payments until they are
# reviewed and authorised in GoCardless Dashboard.
# Upon approval, a unique outbound payment is generated for every entry in
# the import.
#
# <p class="notice">Outbound Payment Imports are capped at 1000 entries. If
# you expect to exceed this limit, please create multiple smaller
# imports.</p>
class OutboundPaymentImport
attr_reader :amount_sum
attr_reader :authorisation_url
attr_reader :created_at
attr_reader :currency
attr_reader :entry_counts
attr_reader :id
attr_reader :status

# Initialize a outbound_payment_import resource instance
# @param object [Hash] an object returned from the API
def initialize(object, response = nil)
@object = object

@amount_sum = object['amount_sum']
@authorisation_url = object['authorisation_url']
@created_at = object['created_at']
@currency = object['currency']
@entry_counts = object['entry_counts']
@id = object['id']
@links = object['links']
@status = object['status']
@response = response
end

def api_response
ApiResponse.new(@response)
end

# Return the links that the resource has
def links
@outbound_payment_import_links ||= Links.new(@links)
end

# Provides the outbound_payment_import resource as a hash of all its readable attributes
def to_h
@object
end

class Links
def initialize(links)
@links = links || {}
end

def creditor
@links['creditor']
end
end
end
end
end
77 changes: 77 additions & 0 deletions lib/gocardless_pro/resources/outbound_payment_import_entry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

require 'uri'

module GoCardlessPro
# A module containing classes for each of the resources in the GC Api
module Resources
# Represents an instance of a outbound_payment_import_entry resource returned from the API

# Import Entries are the individual rows of an outbound payment import,
# representing each payment to be created.
class OutboundPaymentImportEntry
attr_reader :amount
attr_reader :created_at
attr_reader :id
attr_reader :metadata
attr_reader :processed_at
attr_reader :reference
attr_reader :scheme
attr_reader :validation_errors
attr_reader :verification_result

# Initialize a outbound_payment_import_entry resource instance
# @param object [Hash] an object returned from the API
def initialize(object, response = nil)
@object = object

@amount = object['amount']
@created_at = object['created_at']
@id = object['id']
@links = object['links']
@metadata = object['metadata']
@processed_at = object['processed_at']
@reference = object['reference']
@scheme = object['scheme']
@validation_errors = object['validation_errors']
@verification_result = object['verification_result']
@response = response
end

def api_response
ApiResponse.new(@response)
end

# Return the links that the resource has
def links
@outbound_payment_import_entry_links ||= Links.new(@links)
end

# Provides the outbound_payment_import_entry resource as a hash of all its readable attributes
def to_h
@object
end

class Links
def initialize(links)
@links = links || {}
end

def outbound_payment
@links['outbound_payment']
end

def outbound_payment_import
@links['outbound_payment_import']
end

def recipient_bank_account
@links['recipient_bank_account']
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def initialise(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down
18 changes: 9 additions & 9 deletions lib/gocardless_pro/services/billing_requests_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def collect_customer_details(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -129,7 +129,7 @@ def collect_bank_account(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -170,7 +170,7 @@ def confirm_payer_details(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -210,7 +210,7 @@ def fulfil(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -250,7 +250,7 @@ def cancel(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -342,7 +342,7 @@ def notify(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -382,7 +382,7 @@ def fallback(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -427,7 +427,7 @@ def choose_currency(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -466,7 +466,7 @@ def select_institution(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down
6 changes: 3 additions & 3 deletions lib/gocardless_pro/services/blocks_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def disable(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -144,7 +144,7 @@ def enable(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down Expand Up @@ -182,7 +182,7 @@ def block_by_ref(options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def disable(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def disable(identity, options = {})

params = options.delete(:params) || {}
options[:params] = {}
options[:params]['data'] = params
options[:params][envelope_key] = params

options[:retry_failures] = false

Expand Down
Loading