Class: Vpago::Acleda::TransactionStatus
- Inherits:
-
Base
- Object
- Base
- Vpago::Acleda::TransactionStatus
show all
- Defined in:
- lib/vpago/acleda/transaction_status.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#acleda_company_name, #acleda_payment_card, #action_url, #app_checkout, #app_checkout?, #error_url, #expiry_time, #host, #initialize, #login_id, #merchant_id, #merchant_name, #order_number, #other_url, #password, #payment_number, #purchase_date, #signature, #success_url
#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/acleda/transaction_status.rb', line 6
def error_message
@error_message
end
|
#result ⇒ Object
Returns the value of attribute result.
6
7
8
|
# File 'lib/vpago/acleda/transaction_status.rb', line 6
def result
@result
end
|
Instance Method Details
#call ⇒ Object
8
9
10
11
|
# File 'lib/vpago/acleda/transaction_status.rb', line 8
def call
prepare
process
end
|
#check_acleda_payment_status ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/vpago/acleda/transaction_status.rb', line 45
def check_acleda_payment_status
con = Faraday::Connection.new(url: host)
con.post(check_status_path) do |request|
request.['Content-Type'] = 'application/json'
request.body = request_payload.to_json
end
end
|
#check_status_path ⇒ Object
54
55
56
|
# File 'lib/vpago/acleda/transaction_status.rb', line 54
def check_status_path
ENV.fetch('ACLEDA_CHECK_STATUS_PATH', nil)
end
|
#fail!(message) ⇒ Object
62
63
64
|
# File 'lib/vpago/acleda/transaction_status.rb', line 62
def fail!(message)
@error_message = message
end
|
#json_response ⇒ Object
58
59
60
|
# File 'lib/vpago/acleda/transaction_status.rb', line 58
def json_response
@json_response ||= JSON.parse(@response.body)
end
|
#prepare ⇒ Object
13
14
15
16
|
# File 'lib/vpago/acleda/transaction_status.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/acleda/transaction_status.rb', line 18
def process
@response = check_acleda_payment_status
if @response.status == 200
if (json_response['result']['code']).zero?
@result = json_response
else
fail!(json_response['result']['errorDetails'])
end
else
fail!(@response.body)
end
end
|
#request_payload ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/vpago/acleda/transaction_status.rb', line 32
def request_payload
payment_token_id = @payment.source.transaction_id
{
loginId: login_id,
password: password,
merchantName: merchant_name,
signature: signature,
merchantId: merchant_id,
paymentTokenid: payment_token_id
}
end
|
#success? ⇒ Boolean
66
67
68
|
# File 'lib/vpago/acleda/transaction_status.rb', line 66
def success?
@error_message.nil?
end
|