Class: Sinopac::FunBiz::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/sinopac/funbiz/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ Result

Returns a new instance of Result.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sinopac/funbiz/result.rb', line 5

def initialize(result)
  @order_no = result[:OrderNo]
  @shop_no = result[:ShopNo]
  @transaction_no = result[:TSNo]
  @amount = result[:Amount] / 100
  @status = result[:Status]
  @description = result[:Description]
  @param1 = result[:Param1]
  @param2 = result[:Param2]
  @param3 = result[:Param3]

  case result[:PayType]
  when 'A'
    @pay_type = :atm
    @payment_params = result[:ATMParam]
  when 'C'
    @pay_type = :credit_card
    @payment_params = result[:CardParam]
  else
    @pay_type = :unknown
    @payment_params = {}
  end
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



3
4
5
# File 'lib/sinopac/funbiz/result.rb', line 3

def amount
  @amount
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/sinopac/funbiz/result.rb', line 3

def description
  @description
end

#order_noObject (readonly)

Returns the value of attribute order_no.



3
4
5
# File 'lib/sinopac/funbiz/result.rb', line 3

def order_no
  @order_no
end

#param1Object (readonly)

Returns the value of attribute param1.



4
5
6
# File 'lib/sinopac/funbiz/result.rb', line 4

def param1
  @param1
end

#param2Object (readonly)

Returns the value of attribute param2.



4
5
6
# File 'lib/sinopac/funbiz/result.rb', line 4

def param2
  @param2
end

#param3Object (readonly)

Returns the value of attribute param3.



4
5
6
# File 'lib/sinopac/funbiz/result.rb', line 4

def param3
  @param3
end

#pay_typeObject (readonly)

Returns the value of attribute pay_type.



4
5
6
# File 'lib/sinopac/funbiz/result.rb', line 4

def pay_type
  @pay_type
end

#payment_paramsObject (readonly)

Returns the value of attribute payment_params.



4
5
6
# File 'lib/sinopac/funbiz/result.rb', line 4

def payment_params
  @payment_params
end

#shop_noObject (readonly)

Returns the value of attribute shop_no.



3
4
5
# File 'lib/sinopac/funbiz/result.rb', line 3

def shop_no
  @shop_no
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/sinopac/funbiz/result.rb', line 3

def status
  @status
end

#transaction_noObject (readonly)

Returns the value of attribute transaction_no.



3
4
5
# File 'lib/sinopac/funbiz/result.rb', line 3

def transaction_no
  @transaction_no
end

Instance Method Details

#payment_urlObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/sinopac/funbiz/result.rb', line 33

def payment_url
  case @pay_type
  when :atm
    @payment_params[:WebAtmURL]
  when :credit_card
    @payment_params[:CardPayURL]
  else
    raise 'not supported'
  end
end

#success?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/sinopac/funbiz/result.rb', line 29

def success?
  @status == 'S'
end