Class: Vpago::Vattanac::Base
- Inherits:
-
Object
- Object
- Vpago::Vattanac::Base
show all
- Defined in:
- lib/vpago/vattanac/base.rb
Constant Summary
collapse
- CONTENT_TYPE_JSON =
'application/json'.freeze
Instance Method Summary
collapse
Constructor Details
#initialize(payment) ⇒ Base
Returns a new instance of Base.
8
9
10
|
# File 'lib/vpago/vattanac/base.rb', line 8
def initialize(payment)
@payment = payment
end
|
Instance Method Details
#access_token ⇒ Object
32
33
34
|
# File 'lib/vpago/vattanac/base.rb', line 32
def access_token
@access_token ||= fetch_access_token
end
|
#access_token_url ⇒ Object
20
21
22
|
# File 'lib/vpago/vattanac/base.rb', line 20
def access_token_url
payment_method.preferred_access_token_url
end
|
#amount ⇒ Object
52
53
54
|
# File 'lib/vpago/vattanac/base.rb', line 52
def amount
@payment.amount
end
|
#check_transaction_url ⇒ Object
28
29
30
|
# File 'lib/vpago/vattanac/base.rb', line 28
def check_transaction_url
payment_method.preferred_check_transaction_url
end
|
#currency ⇒ Object
56
57
58
|
# File 'lib/vpago/vattanac/base.rb', line 56
def currency
'USD'
end
|
60
61
62
|
# File 'lib/vpago/vattanac/base.rb', line 60
def
{ 'Authorization' => "Bearer #{access_token}", 'Content-Type' => CONTENT_TYPE_JSON }
end
|
#generate_payment_url ⇒ Object
24
25
26
|
# File 'lib/vpago/vattanac/base.rb', line 24
def generate_payment_url
payment_method.preferred_generate_payment_url
end
|
#merchant_id ⇒ Object
48
49
50
|
# File 'lib/vpago/vattanac/base.rb', line 48
def merchant_id
payment_method.preferred_merchant_id
end
|
#parse_json(body) ⇒ Object
64
65
66
67
68
|
# File 'lib/vpago/vattanac/base.rb', line 64
def parse_json(body)
JSON.parse(body)
rescue JSON::ParserError
{}
end
|
#password ⇒ Object
16
17
18
|
# File 'lib/vpago/vattanac/base.rb', line 16
def password
payment_method.preferred_password
end
|
#payment_method ⇒ Object
36
37
38
|
# File 'lib/vpago/vattanac/base.rb', line 36
def payment_method
@payment.payment_method
end
|
#payment_number ⇒ Object
40
41
42
|
# File 'lib/vpago/vattanac/base.rb', line 40
def payment_number
@payment.number
end
|
#payment_type ⇒ Object
44
45
46
|
# File 'lib/vpago/vattanac/base.rb', line 44
def payment_type
payment_method.preferred_payment_type
end
|
#username ⇒ Object
12
13
14
|
# File 'lib/vpago/vattanac/base.rb', line 12
def username
payment_method.preferred_username
end
|