Class: Onpay::PayController
- Inherits:
-
Object
- Object
- Onpay::PayController
show all
- Includes:
- Onpay
- Defined in:
- lib/onpay.rb
Instance Method Summary
collapse
Methods included from Onpay
#gen_md5, #gen_request_md5, #gen_request_pay_md5, #gen_respond_md5, #gen_respond_pay_md5
Instance Method Details
#check_req(p) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/onpay.rb', line 39
def check_req p
req_md5 = gen_md5(gen_request_md5("check", @request_hash))
if req_md5 == p[:md5] &&
@lambda_hash[:check_payment].call(@request_hash[:pay_for])
@result[:code] = "0"
@respond_hash[:code] = "0"
md5 = gen_respond_md5("check",@respond_hash)
md5 = gen_md5(md5)
@result[:md5] = md5
return @result.to_xml(:root => 'result',:dasherize => false )
else
@respond_hash[:code] = "0"
md5 = gen_respond_md5("check",@respond_hash)
md5 = gen_md5(md5)
@result[:code] = "2"
@result[:comment] = "Внутренняя ошибка."
@result[:md5] = md5
return @result.to_xml(:root => 'result',:dasherize => false )
end
end
|
#pay_req(p) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/onpay.rb', line 68
def pay_req p
@request_hash[:onpay_id] = p[:onpay_id]
@respond_hash[:onpay_id] = p[:onpay_id]
req_md5 = gen_md5(gen_request_pay_md5("pay", @request_hash))
if req_md5 == p[:md5] &&
@lambda_hash[:onpay].call(@request_hash[:pay_for])
@result[:code] = "0"
@respond_hash[:code] = "0"
md5 = gen_respond_pay_md5("pay",@respond_hash)
md5 = gen_md5(md5)
@result[:md5] = md5
return @result.to_xml(:root => 'result',:dasherize => false )
else
@respond_hash[:code] = "2"
md5 = gen_respond_pay_md5("pay", @respond_hash)
md5 = gen_md5(md5)
@result[:code] = "2"
@result[:comment] = "Внутренняя ошибка."
@result[:md5] = md5
return @result.to_xml(:root => 'result',:dasherize => false )
end
end
|
#process(p, secret, lambda_hash) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/onpay.rb', line 9
def process p, secret, lambda_hash
@lambda_hash = lambda_hash
p_for = p[:pay_for]
o_a = p[:order_amount]
o_c = p[:order_currency]
@respond_hash = { :pay_for=>p_for,
:order_amount=>o_a,
:order_currency=>o_c,
:secret => secret,
:code => "0"
}
@request_hash = { :pay_for=>p_for,
:order_amount=>o_a,
:order_currency=>o_c.upcase,
:secret => secret
}
@result = {'pay_for'=>p_for, :comment=>"OK"}
case p[:type]
when "check" then
return check_req p
when "pay" then
return pay_req p
end
end
|