Class: Sisow::Api::TransactionRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/sisow/api/request/transaction_request.rb

Constant Summary

Constants inherited from Request

Request::BASE_URI

Instance Attribute Summary

Attributes inherited from Request

#merchant_id, #merchant_key

Instance Method Summary collapse

Methods inherited from Request

#default_params, #perform, perform

Constructor Details

#initialize(payment) ⇒ TransactionRequest

Returns a new instance of TransactionRequest.



5
6
7
# File 'lib/sisow/api/request/transaction_request.rb', line 5

def initialize(payment)
  @payment = payment
end

Instance Method Details

#clean(response) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/sisow/api/request/transaction_request.rb', line 17

def clean(response)
  check_validity!(response)

  if response.transactionrequest? && response.transactionrequest.transaction?
    response.transactionrequest.transaction
  end
end

#methodObject



9
10
11
# File 'lib/sisow/api/request/transaction_request.rb', line 9

def method
  'TransactionRequest'
end

#paramsObject



13
14
15
# File 'lib/sisow/api/request/transaction_request.rb', line 13

def params
  default_params.merge!(transaction_params)
end

#sha1Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sisow/api/request/transaction_request.rb', line 29

def sha1
  string = [
    payment.purchase_id,
    payment.entrance_code,
    payment.amount,
    merchant_id,
    merchant_key
  ].join

  Digest::SHA1.hexdigest(string)
end

#validate!Object

Raises:



25
26
27
# File 'lib/sisow/api/request/transaction_request.rb', line 25

def validate!
  raise Sisow::Exception, 'One of your payment parameters is missing or invalid' unless @payment.valid?
end