Class: BuckarooClient::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/buckaroo_client/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Transaction

Returns a new instance of Transaction.



6
7
8
9
10
11
12
13
14
15
# File 'lib/buckaroo_client/transaction.rb', line 6

def initialize(args = {})
  @websitekey = args[:websitekey]
  @amount = args[:amount]
  @culture = args.fetch(:culture, 'nl-NL')
  @currency = args.fetch(:currency, 'EUR')
  @description = args[:description]
  @invoicenumber = args[:invoicenumber]
  @service = args[:service]
  @additional_services = args.fetch(:additional_services, [])
end

Instance Attribute Details

#additional_servicesObject

Returns the value of attribute additional_services.



4
5
6
# File 'lib/buckaroo_client/transaction.rb', line 4

def additional_services
  @additional_services
end

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/buckaroo_client/transaction.rb', line 3

def amount
  @amount
end

#cultureObject

Returns the value of attribute culture.



3
4
5
# File 'lib/buckaroo_client/transaction.rb', line 3

def culture
  @culture
end

#currencyObject

Returns the value of attribute currency.



3
4
5
# File 'lib/buckaroo_client/transaction.rb', line 3

def currency
  @currency
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/buckaroo_client/transaction.rb', line 3

def description
  @description
end

#invoicenumberObject

Returns the value of attribute invoicenumber.



3
4
5
# File 'lib/buckaroo_client/transaction.rb', line 3

def invoicenumber
  @invoicenumber
end

#serviceObject

Returns the value of attribute service.



4
5
6
# File 'lib/buckaroo_client/transaction.rb', line 4

def service
  @service
end

#websitekeyObject

Returns the value of attribute websitekey.



3
4
5
# File 'lib/buckaroo_client/transaction.rb', line 3

def websitekey
  @websitekey
end

Instance Method Details

#gateway_attributesObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/buckaroo_client/transaction.rb', line 17

def gateway_attributes
  output = {
    'websitekey' => websitekey,
    'amount' => amount,
    'culture' => culture,
    'currency' => currency,
    'description' => description,
    'invoicenumber' => invoicenumber,
  }
  if service
    output['service'] = service.servicecode
    output.merge!(service.gateway_attributes)
  end
  if additional_services.count > 0
    output['additional_service'] = additional_services.map(&:servicecode).join(',')
    additional_services.each do |a|
      output.merge!(a.gateway_attributes)
    end
  end
  output
end