32
33
34
35
36
37
38
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
67
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 'app/controllers/gateway/onpay_controller.rb', line 32
def api
@out = Hash.new
@out["pay_for"] = params["pay_for"]
if params["type"] == "check" then
if params["md5"] == Digest::MD5.hexdigest([params["type"],
params["pay_for"],
params["order_amount"],
params["order_currency"],
@gateway.options[:priv_code]].join(';')).upcase
if @gateway.options[:test_mode] then
tst_valid_check(params["pay_for"],params["order_amount"],params["order_currency"]) ? (0,"All,OK") : (3,"Error on parameters check")
else
valid_check(params["pay_for"],params["order_amount"],params["order_currency"]) ? (0,"All,OK") : (3,"Error on parameters check")
end
@out["md5"] = create_check_md5(params["type"],params["pay_for"],params["order_amount"],
params["order_currency"],@out["code"],@gateway.options[:priv_code])
render :action => "check"
else
(7,"MD5 signature wrong")
@out["md5"] = create_check_md5(params["type"],params["pay_for"],params["order_amount"],
params["order_currency"],@out["code"],@gateway.options[:priv_code])
render :action => "check"
end
end
if params["type"] == "pay" then
if params["md5"] == Digest::MD5.hexdigest([params["type"],
params["pay_for"],
params["onpay_id"],
params["order_amount"],
params["order_currency"],
@gateway.options[:priv_code]].join(';')).upcase
@out["onpay_id"] = params["onpay_id"]
if @gateway.options[:test_mode] then
if tst_valid_check(params["pay_for"],params["order_amount"],params["order_currency"]) then
create_payment(params["order_amount"].to_f)
(0,"OK")
else
(3,"Error on parameters check")
end
else
if valid_check(params["pay_for"],params["order_amount"],params["order_currency"]) then
create_payment(params["order_amount"].to_f)
(0,"OK")
else
(3,"Error on parameters check")
end
end
@out["md5"] = create_pay_md5(params["type"],params["pay_for"],params["onpay_id"],params["pay_for"],params["order_amount"],
params["order_currency"],@out["code"],@gateway.options[:priv_code])
render :action => "pay"
else
(7,"MD5 signature wrong")
@out["onpay_id"] = params["onpay_id"]
@out["md5"] = create_pay_md5(params["type"],params["pay_for"],params["onpay_id"],params["pay_for"],params["order_amount"],
params["order_currency"],@out["code"],@gateway.options[:priv_code])
render :action => "pay"
end
end
end
|