Class: Bambora::V1::BatchPaymentResource

Inherits:
Object
  • Object
show all
Defined in:
lib/bambora/v1/batch_payment_resource.rb

Overview

Bank Electronic Funds Transfer (CAD) and Automatic Clearing House (USD)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, api_key:) ⇒ BatchPaymentResource

Returns a new instance of BatchPaymentResource.



9
10
11
12
13
# File 'lib/bambora/v1/batch_payment_resource.rb', line 9

def initialize(client:, api_key:)
  @client = client
  @api_key = api_key
  @sub_path = '/v1/batchpayments'
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/bambora/v1/batch_payment_resource.rb', line 7

def api_key
  @api_key
end

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/bambora/v1/batch_payment_resource.rb', line 7

def client
  @client
end

#sub_pathObject (readonly)

Returns the value of attribute sub_path.



7
8
9
# File 'lib/bambora/v1/batch_payment_resource.rb', line 7

def sub_path
  @sub_path
end

Instance Method Details

#create(transactions, opts = { process_now: 1 }) ⇒ Object

Post batch payment data. Transaction objects must have keys that match the order of the columns defined in the Bambora documentation.dev.na.bambora.com/docs/references/batch_payment/#format-of-data-in-file The values of each object are used to create one row of a CSV.

Examples:

batch_payment_resource.create(
  [{
    super_type: 'E',
    transaction_type: 'D',
    institution_number: 12345,
    transit_number: 123,
    account_number: 1223456789,
    amount: 10000,
    reference_nubmer: 1234,
    reccipient_name: 'Hup Podling',
    customer_code: '02355E2e58Bf488EAB4EaFAD7083dB6A',
    dynamic_description: 'The Skeksis',
  }],
)

Parameters:

  • transactions (Array)

    of hashes with payment data.

  • opts (:process_now) (defaults to: { process_now: 1 })
    Integer

    optional. Defaults to 1.

  • opts (:process_date) (defaults to: { process_now: 1 })
    String

    optional. Must exclude process_now or pass { process_now: 0 }

See Also:



42
43
44
45
46
47
48
49
# File 'lib/bambora/v1/batch_payment_resource.rb', line 42

def create(transactions, opts = { process_now: 1 })
  client.post(
    path: sub_path,
    file_contents: Bambora::Builders::BatchPaymentCSV.build(transactions),
    options: opts.merge(sub_merchant_id: client.sub_merchant_id),
    api_key: api_key,
  )
end