Class: Vpago::WingSdk::TransactionStatusChecker
- Inherits:
-
Base
- Object
- Base
- Vpago::WingSdk::TransactionStatusChecker
show all
- Defined in:
- lib/vpago/wing_sdk/transaction_status_checker.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#action_url, #app_checkout, #app_checkout?, #biller_code, #host, #initialize, #merchant_name, #payment_number, #rest_api_key, #return_url, #sandbox, #username
#amount, #amount_with_fee, #transaction_fee, #transaction_fee_fix, #transaction_fee_percentage
Instance Attribute Details
#error_message ⇒ Object
Returns the value of attribute error_message.
6
7
8
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 6
def error_message
@error_message
end
|
#result ⇒ Object
Returns the value of attribute result.
6
7
8
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 6
def result
@result
end
|
Instance Method Details
#call ⇒ Object
8
9
10
11
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 8
def call
prepare
process
end
|
#check_remote_status ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 32
def check_remote_status
conn = Faraday::Connection.new do |faraday|
faraday.request :url_encoded
end
data = {
username: username,
rest_api_key: rest_api_key,
remark: payment_number,
sandbox: sandbox
}
conn.post(check_transaction_url, data)
end
|
#check_transaction_url ⇒ Object
59
60
61
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 59
def check_transaction_url
"#{host}inquiry"
end
|
#fail!(message) ⇒ Object
51
52
53
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 51
def fail!(message)
@error_message = message
end
|
#json_response ⇒ Object
47
48
49
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 47
def json_response
@json_response ||= JSON.parse(@response.body)
end
|
#prepare ⇒ Object
13
14
15
16
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 13
def prepare
@error_message = nil
@result = nil
end
|
#process ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 18
def process
@response = check_remote_status
if @response.status == 200
if json_response['errorCode'] == '200'
@result = json_response
else
fail!(json_response['errorText'])
end
else
fail!(@response.body)
end
end
|
#success? ⇒ Boolean
55
56
57
|
# File 'lib/vpago/wing_sdk/transaction_status_checker.rb', line 55
def success?
@error_message.nil?
end
|