Class: Focas::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/focas/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lidm: nil, purch_amt: nil, currency_note: '訂單金額說明', auth_res_url: nil) ⇒ Payment

Returns a new instance of Payment.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/focas/payment.rb', line 15

def initialize(
  # 必填參數
  lidm: nil,
  purch_amt: nil,

  # 參數
  currency_note: '訂單金額說明',

  # 客製回傳網址(同一個站有不同接收的 route 時使用)
  auth_res_url: nil
)
  unless lidm && purch_amt
    raise Focas::PaymentArgumentError,
      '請確認以下參數皆有填寫:
      - lidm 訂單編號
      - purch_amt 金額
    '
  end

  @lidm = lidm
  @purch_amt = purch_amt
  @currency_note = currency_note

  # 回傳網址
  @auth_res_url = auth_res_url

  set_trade_info
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



13
14
15
# File 'lib/focas/payment.rb', line 13

def response
  @response
end

#trade_infoObject

Returns the value of attribute trade_info.



12
13
14
# File 'lib/focas/payment.rb', line 12

def trade_info
  @trade_info
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


44
45
46
47
# File 'lib/focas/payment.rb', line 44

def success?
  return if @response.nil?
  @response['Status'] == 'SUCCESS'
end