Class: ProcessingKz::GetTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/processing_kz/get_transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ GetTransaction

Returns a new instance of GetTransaction.



21
22
23
24
25
# File 'lib/processing_kz/get_transaction.rb', line 21

def initialize(args= {})
  @merchant_id = args[:merchant_id] || Config.merchant_id
  @customer_reference = args[:customer_reference]
  request!
end

Instance Attribute Details

#amount_authorizedObject (readonly)

Returns the value of attribute amount_authorized.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def amount_authorized
  @amount_authorized
end

#amount_refundedObject (readonly)

Returns the value of attribute amount_refunded.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def amount_refunded
  @amount_refunded
end

#amount_requestedObject (readonly)

Returns the value of attribute amount_requested.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def amount_requested
  @amount_requested
end

#auth_codeObject (readonly)

Returns the value of attribute auth_code.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def auth_code
  @auth_code
end

#customer_referenceObject (readonly)

Returns the value of attribute customer_reference.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def customer_reference
  @customer_reference
end

#goodsObject

Returns the value of attribute goods.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def goods
  @goods
end

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def merchant_id
  @merchant_id
end

#merchant_local_date_timeObject (readonly)

Returns the value of attribute merchant_local_date_time.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def merchant_local_date_time
  @merchant_local_date_time
end

#merchant_online_addressObject (readonly)

Returns the value of attribute merchant_online_address.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def merchant_online_address
  @merchant_online_address
end

#purchaser_emailObject (readonly)

Returns the value of attribute purchaser_email.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def purchaser_email
  @purchaser_email
end

#purchaser_nameObject (readonly)

Returns the value of attribute purchaser_name.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def purchaser_name
  @purchaser_name
end

#purchaser_phoneObject (readonly)

Returns the value of attribute purchaser_phone.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def purchaser_phone
  @purchaser_phone
end

#transaction_currency_codeObject (readonly)

Returns the value of attribute transaction_currency_code.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def transaction_currency_code
  @transaction_currency_code
end

#transaction_statusObject (readonly)

Returns the value of attribute transaction_status.



6
7
8
# File 'lib/processing_kz/get_transaction.rb', line 6

def transaction_status
  @transaction_status
end

Instance Method Details

#hashed_goods_listObject



45
46
47
48
49
50
51
# File 'lib/processing_kz/get_transaction.rb', line 45

def hashed_goods_list
  hash = []
  goods_list.each do |good|
    hash << good.to_hash
  end
  hash
end

#request!Object



53
54
55
56
57
58
59
60
61
# File 'lib/processing_kz/get_transaction.rb', line 53

def request!
  client = Savon.client(wsdl: Config.wsdl, endpoint: Config.host)
  response = client.call(:get_transaction_status, message: { 
    merchant_id: merchant_id,
    reference_nr: customer_reference
    }
  )
  response(response.body[:get_transaction_status_response][:return])
end

#response(args = {}) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/processing_kz/get_transaction.rb', line 63

def response(args = {})
  @transaction_status = args[:transaction_status]
  @transaction_currency_code = args[:currency_code] || Config.currency_code
  @amount_requested = args[:amount_requested]
  @amount_authorized = args[:amount_authorized]
  @amount_refunded = args[:amount_refunded]
  @auth_code = args[:auth_code]
  @purchaser_name = args[:purchaser_name]
  @purchaser_email = args[:purchaser_email]
  @purchaser_phone = args[:purchaser_phone]
  @merchant_online_address = args[:merchant_online_address]
  @merchant_local_date_time = args[:merchant_local_date_time] || Time.now
  self.goods = args[:goods_list]
end

#statusObject



27
28
29
# File 'lib/processing_kz/get_transaction.rb', line 27

def status
  @transaction_status
end

#total_amountObject

Raises:



36
37
38
39
40
41
42
43
# File 'lib/processing_kz/get_transaction.rb', line 36

def total_amount
  raise NoGoodsError unless goods_list
  total = 0
  goods_list.each do |good|
    total += good.amount
  end
  total
end