Module: Unit::Payment

Defined in:
lib/unit/models/payment/payment.rb,
lib/unit/models/payment/get_request.rb,
lib/unit/models/payment/list_payment_params.rb,
lib/unit/models/payment/bulk_payment_request.rb,
lib/unit/models/payment/patch_ach_payment_request.rb,
lib/unit/models/payment/patch_book_payment_request.rb,
lib/unit/models/payment/create_book_payment_request.rb,
lib/unit/models/payment/create_wire_payment_request.rb,
lib/unit/models/payment/create_batch_release_request.rb,
lib/unit/models/payment/batch_release_request_builder.rb,
lib/unit/models/payment/create_payment_linked_request.rb,
lib/unit/models/payment/create_with_plaid_token_request.rb,
lib/unit/models/payment/create_ach_payment_inline_request.rb

Defined Under Namespace

Classes: BatchReleaseRequestBuilder, BulkPaymentRequest, CreateAchPaymentInlineRequest, CreateBatchReleaseRequest, CreateBookPaymentRequest, CreatePaymentLinkedRequest, CreateWirePaymentRequest, CreateWithPlaidTokenRequest, GetRequest, ListPaymentParams, PatchAchPaymentRequest, PatchBookPaymentRequest

Constant Summary collapse

PAYMENT_LIMIT =
100
PAYMENT_OFFSET =
0

Class Method Summary collapse

Class Method Details

.cancel_payment(payment_id:) ⇒ Object

Cancel a payment by calling Unit’s API

Parameters:

  • payment_id (String)

See Also:



124
125
126
# File 'lib/unit/models/payment/payment.rb', line 124

def cancel_payment(payment_id:)
  Unit::Resource::PaymentResource.cancel_payment(payment_id)
end

.create_ach_payment_inline(account_id:, amount:, direction:, counterparty:, description:, addenda: nil, idempotency_key: nil, tags: nil, same_day: nil, sec_code: nil) ⇒ Object

Create a new ach payment to inline counterparty by calling Unit’s API

Parameters:

  • account_id (String)
  • amount (Integer)
  • direction (String)
  • counterparty (Counterparty)
  • description (String)
  • addenda (String) (defaults to: nil)
    • optional

  • idempotency_key (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • same_day (Boolean) (defaults to: nil)
    • optional

  • sec_code (String) (defaults to: nil)
    • optional

See Also:



61
62
63
64
65
66
67
# File 'lib/unit/models/payment/payment.rb', line 61

def create_ach_payment_inline(account_id:, amount:, direction:, counterparty:,
                              description:, addenda: nil, idempotency_key: nil, tags: nil,
                              same_day: nil, sec_code: nil)
  request = Unit::Payment::CreateAchPaymentInlineRequest.new(account_id: , amount: amount, direction: direction, counterparty: counterparty, description: description, addenda: addenda, idempotency_key: idempotency_key,
                                                             tags: tags, same_day: same_day, sec_code: sec_code)
  Unit::Resource::PaymentResource.create_payment(request)
end

.create_ach_payment_linked(account_id:, counterparty_id:, amount:, direction:, description:, addenda: nil, idempotency_key: nil, tags: nil, verify_counterparty_balance: nil, same_day: nil, sec_code: nil) ⇒ Object

Create a new ach payment to linked counterparty by calling Unit’s API

Parameters:

  • account_id (String)
  • counterparty_id (String)
  • amount (Integer)
  • direction (String)
  • description (String)
  • addenda (String) (defaults to: nil)
    • optional

  • idempotency_key (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • verify_counterparty_balance (Boolean) (defaults to: nil)
    • optional

  • same_day (Boolean) (defaults to: nil)
    • optional

  • sec_code (String) (defaults to: nil)
    • optional

See Also:



82
83
84
85
86
87
88
# File 'lib/unit/models/payment/payment.rb', line 82

def create_ach_payment_linked(account_id:, counterparty_id:, amount:, direction:,
                              description:, addenda: nil, idempotency_key: nil, tags: nil,
                              verify_counterparty_balance: nil, same_day: nil, sec_code: nil)
  request = Unit::Payment::CreatePaymentLinkedRequest.new(account_id: , counterparty_id: counterparty_id, amount: amount, direction: direction, description: description, addenda: addenda, idempotency_key: idempotency_key,
                                                          tags: tags, verify_counterparty_balance: verify_counterparty_balance, same_day: same_day, sec_code: sec_code)
  Unit::Resource::PaymentResource.create_payment(request)
end

.create_ach_payment_with_plaid_token(account_id:, amount:, direction:, description:, plaid_processor_token:, addenda: nil, idempotency_key: nil, counterparty_name: nil, tags: nil, verify_counterparty_balance: nil, same_day: nil, sec_code: nil) ⇒ Object

Create a new ach payment with a plaid token by calling Unit’s API

Parameters:

  • account_id (String)
  • amount (Integer)
  • direction (String)
  • description (String)
  • plaid_processor_token (String)
  • addenda (String) (defaults to: nil)
    • optional

  • idempotency_key (String) (defaults to: nil)
    • optional

  • counterparty_name (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • verify_counterparty_balance (Boolean) (defaults to: nil)
    • optional

  • same_day (Boolean) (defaults to: nil)
    • optional

  • sec_code (String) (defaults to: nil)
    • optional

See Also:



104
105
106
107
108
109
110
# File 'lib/unit/models/payment/payment.rb', line 104

def create_ach_payment_with_plaid_token(account_id:, amount:, direction:, description:, plaid_processor_token:,
                                        addenda: nil, idempotency_key: nil, counterparty_name: nil, tags: nil,
                                        verify_counterparty_balance: nil, same_day: nil, sec_code: nil)
  request = Unit::Payment::CreateWithPlaidTokenRequest.new(account_id: , amount: amount, direction: direction, description: description, plaid_processor_token: plaid_processor_token, addenda: addenda, idempotency_key: idempotency_key,
                                                           counterparty_name: counterparty_name, tags: tags, verify_counterparty_balance: verify_counterparty_balance, same_day: same_day, sec_code: sec_code)
  Unit::Resource::PaymentResource.create_payment(request)
end

.create_batch_release(requests) ⇒ Object

Create a batch release

Parameters:

  • account_id (String)
  • amount (Integer)
  • description (String)
  • sender_name (String)
  • sender_address (Address)
  • sender_account_number (String)
  • tags (Hash)
    • optional

  • idempotency_key (String)
    • optional

See Also:



198
199
200
201
202
203
204
# File 'lib/unit/models/payment/payment.rb', line 198

def create_batch_release(requests)
  payload = BatchReleaseRequestBuilder.new
  requests.each do |req|
    payload.add_request(req[:account_id], req[:batch_account_id], req[:amount], req[:description], req[:sender_name], req[:sender_address], req[:sender_account_number], req[:tags], req[:idempotency_key])
  end
  Unit::Resource::PaymentResource.create_batch_release(payload.to_hash)
end

.create_book_payment(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil, idempotency_key: nil, tags: nil) ⇒ UnitResponse, UnitError

Create a new book payment by calling Unit’s API

Parameters:

  • amount (Integer)
  • description (String)
  • account_id (String)
  • counterparty_account_id (String)
  • transaction_summary_override (String) (defaults to: nil)
    • optional

  • idempotency_key (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

Returns:

See Also:



31
32
33
34
35
36
37
# File 'lib/unit/models/payment/payment.rb', line 31

def create_book_payment(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil,
                        idempotency_key: nil, tags: nil)
  request = Unit::Payment::CreateBookPaymentRequest.new(amount: amount, description: description, account_id: , counterparty_account_id: , transaction_summary_override: transaction_summary_override,
                                                        idempotency_key: idempotency_key, tags: tags)

  Unit::Resource::PaymentResource.create_payment(request)
end

.create_bulk_payment(requests:) ⇒ Object

Create a bulk payment by calling Unit’s API



183
184
185
186
# File 'lib/unit/models/payment/payment.rb', line 183

def create_bulk_payment(requests:)
  request = Unit::Payment::BulkPaymentRequest.serialize(requests)
  Unit::Resource::PaymentResource.create_bulk_payment(request)
end

.create_wire_payment(account_id:, amount:, description:, counterparty:, idempotency_key: nil, tags: nil) ⇒ Object

Create a wire payment by calling Unit’s API

Parameters:

  • account_id (String)
  • amount (Integer)
  • description (String)
  • counterparty (WireCounterparty)
  • idempotency_key (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

See Also:



136
137
138
139
# File 'lib/unit/models/payment/payment.rb', line 136

def create_wire_payment(account_id:, amount:, description:, counterparty:, idempotency_key: nil, tags: nil)
  request = Unit::Payment::CreateWirePaymentRequest.new(account_id: , amount: amount, description: description, counterparty: counterparty, idempotency_key: idempotency_key, tags: tags)
  Unit::Resource::PaymentResource.create_payment(request)
end

.get_payment(payment_id:, include: nil) ⇒ Object

Get a payment by calling Unit’s API

Parameters:

  • payment_id (String)
  • include (Array<String>) (defaults to: nil)
    • optional

See Also:



175
176
177
178
# File 'lib/unit/models/payment/payment.rb', line 175

def get_payment(payment_id:, include: nil)
  request = Unit::Payment::GetRequest.new(payment_id, include)
  Unit::Resource::PaymentResource.get_payment(request)
end

.list_payments(limit: PAYMENT_LIMIT, offset: PAYMENT_OFFSET, account_id: nil, customer_id: nil, counterparty_account_id: nil, tags: nil, status: nil, type: nil, direction: nil, since: nil, until_: nil, from_amount: nil, to_amount: nil, recurring_payment_id: nil, feature: nil, sort: nil, include: nil) ⇒ Object

List payments by calling Unit’s API

Parameters:

  • limit (Integer) (defaults to: PAYMENT_LIMIT)
    • optional

  • offset (Integer) (defaults to: PAYMENT_OFFSET)
    • optional

  • account_id (String) (defaults to: nil)
    • optional

  • customer_id (String) (defaults to: nil)
    • optional

  • counterparty_account_id (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • status (Array<String>) (defaults to: nil)
    • optional

  • type (Array<String>) (defaults to: nil)
    • optional

  • direction (Array<String>) (defaults to: nil)
    • optional

  • since (String) (defaults to: nil)
    • optional

  • _until (String)
    • optional

  • from_amount (Integer) (defaults to: nil)
    • optional

  • to_amount (Integer) (defaults to: nil)
    • optional

  • recurring_payment_id (String) (defaults to: nil)
    • optional

  • feature (Array<String>) (defaults to: nil)
    • optional

  • sort (String) (defaults to: nil)
    • optional

  • include (Array<String>) (defaults to: nil)
    • optional

See Also:



160
161
162
163
164
165
166
167
168
169
# File 'lib/unit/models/payment/payment.rb', line 160

def list_payments(limit: PAYMENT_LIMIT, offset: PAYMENT_OFFSET, account_id: nil, customer_id: nil,
                  counterparty_account_id: nil, tags: nil, status: nil,
                  type: nil, direction: nil, since: nil, until_: nil,
                  from_amount: nil, to_amount: nil, recurring_payment_id: nil,
                  feature: nil, sort: nil, include: nil)
  request = Unit::Payment::ListPaymentParams.new(limit, offset, , customer_id,
                                                 , tags, status, type, direction, since, until_,
                                                 from_amount, to_amount, recurring_payment_id, feature, sort, include)
  Unit::Resource::PaymentResource.list_payments(request)
end

.update_ach_payment(payment_id:, tags: nil) ⇒ Object

Update an ACH payment by calling Unit’s API

Parameters:

  • payment_id (String)
  • tags (Hash) (defaults to: nil)
    • optional

See Also:



116
117
118
119
# File 'lib/unit/models/payment/payment.rb', line 116

def update_ach_payment(payment_id:, tags: nil)
  request = Unit::Payment::PatchAchPaymentRequest.new(payment_id, tags)
  Unit::Resource::PaymentResource.update_payment(request)
end

.update_book_payment(payment_id:, tags: nil) ⇒ UnitResponse, UnitError

Update a book payment by calling Unit’s API

Parameters:

  • payment_id (String)
  • tags (Hash) (defaults to: nil)
    • optional

Returns:

See Also:



44
45
46
47
# File 'lib/unit/models/payment/payment.rb', line 44

def update_book_payment(payment_id:, tags: nil)
  request = Unit::Payment::PatchBookPaymentRequest.new(payment_id, tags)
  Unit::Resource::PaymentResource.update_payment(request)
end