Class: BanorteTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/banorte_payworks/banorte_transaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_original_postObject

Returns the value of attribute _original_post.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def _original_post
  @_original_post
end

#amountObject

Returns the value of attribute amount.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def amount
  @amount
end

#authnumObject

Returns the value of attribute authnum.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def authnum
  @authnum
end

#card_numberObject

Returns the value of attribute card_number.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def card_number
  @card_number
end

#card_typeObject

Returns the value of attribute card_type.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def card_type
  @card_type
end

#cvvObject

Returns the value of attribute cvv.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def cvv
  @cvv
end

#eObject

Returns the value of attribute e.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def e
  @e
end

#error_codeObject

Returns the value of attribute error_code.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def error_code
  @error_code
end

#exp_dateObject

Returns the value of attribute exp_date.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def exp_date
  @exp_date
end

#issuing_bankObject

Returns the value of attribute issuing_bank.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def issuing_bank
  @issuing_bank
end

#messageObject

Returns the value of attribute message.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def message
  @message
end

#order_idObject

Returns the value of attribute order_id.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def order_id
  @order_id
end

#time_inObject

Returns the value of attribute time_in.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def time_in
  @time_in
end

#time_outObject

Returns the value of attribute time_out.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def time_out
  @time_out
end

#transaction_statusObject

Returns the value of attribute transaction_status.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def transaction_status
  @transaction_status
end

#transaction_typeObject

Returns the value of attribute transaction_type.



2
3
4
# File 'lib/banorte_payworks/banorte_transaction.rb', line 2

def transaction_type
  @transaction_type
end

Class Method Details

.from_post(post) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/banorte_payworks/banorte_transaction.rb', line 7

def self.from_post(post)
  #TODO this big huge method needs to be abstracted to an a class and we need to cas the proper primitive types
  parsed_post = CGI::parse(post)
  create_with_properties self do |transaction|
    transaction._original_post = post
    transaction.error_code = parsed_post['CcErrCode'][0]
    transaction.message = parsed_post['Text'][0]
    transaction.authnum = parsed_post['AuthCode'][0]
    transaction.order_id = parsed_post['OrderId'][0]
    transaction.amount = parsed_post['Total'][0]
    transaction.time_in = parsed_post['TimeIn'][0]
    transaction.time_out = parsed_post['TimeOut'][0]

    transaction.e = [parsed_post['E1'][0],
                  parsed_post['E2'][0],
                  parsed_post['E3'][0]]

    transaction.card_type = parsed_post['CardType'][0]
    transaction.issuing_bank = parsed_post['IssuingBank'][0]
    transaction.transaction_type = parsed_post['TransType'][0]
    transaction.transaction_status = parsed_post['TransStat'][0]

    transaction.card_number = parsed_post['Number'][0]
  end
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/banorte_payworks/banorte_transaction.rb', line 33

def valid?
  error_code.eql? '1'
end

#validate!Object

Raises:



37
38
39
# File 'lib/banorte_payworks/banorte_transaction.rb', line 37

def validate!
  raise BpayworksException.new("Error::#{error_code}: #{message}") unless valid?
end