class ProcessingKz::CompleteTransaction

Attributes

customer_reference[R]
goods_list[R]
merchant_id[R]
override_amount[R]
success[R]
transaction_success[R]

Public Class Methods

new(args= {}) click to toggle source
# File lib/processing_kz/complete_transaction.rb, line 12
def initialize(args= {})
  @merchant_id = args[:merchant_id] || Config.merchant_id
  @customer_reference = args[:customer_reference]
  @transaction_success = args[:transaction_success]
  @override_amount = args[:override_amount]
  @goods_list = args[:goods_list]
  request!
end

Public Instance Methods

hashed_goods_list() click to toggle source
# File lib/processing_kz/complete_transaction.rb, line 30
def hashed_goods_list
  hash = []
  goods_list.each do |good|
    hash << good.to_hash
  end
  hash
end
request!() click to toggle source
# File lib/processing_kz/complete_transaction.rb, line 38
def request!
  client = Savon.client(wsdl: Config.wsdl, endpoint: Config.host)
  response = client.call(:complete_transaction, message: { 
    merchant_id: merchant_id,
    reference_nr: customer_reference,
    transaction_success: transaction_success,
    override_amount: override_amount,
    goods_list: goods_list
    }
  )
  response(response.body[:complete_transaction_response][:return])
end
response(success) click to toggle source
# File lib/processing_kz/complete_transaction.rb, line 51
def response(success)
  @success = success
end
total_amount() click to toggle source
# File lib/processing_kz/complete_transaction.rb, line 21
def total_amount
  raise NoGoodsError unless goods_list
  total = 0
  goods_list.each do |good|
    total += good.amount
  end
  total
end