onpay-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/onpay.rb +152 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTFkODA4NWFiN2M3YjJhYmVmYTIxMDEyNWQ0NzcxNjRlYjgxYTgyYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWY5NWRmZjhhZjViOGI2N2VmMTZiZDE3NTY2MTljOTY3OTdhODQ0Nw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjlmYTU1NTQ1NTdhNmUzNTQ3MDAwOTgxZDUzYmQ0YmU5ODM2ZWI3NjJjZTA5
|
10
|
+
ZjkwN2ZiM2ZjNDMxZDdjZGU0MWJjOTRjYjNiMWUxZDY1NDc5OWQ4ZTBiNTc1
|
11
|
+
ZGFjOWIzODViZTFmZWE1MmMzNjJiZTM5YWIzNGE4MTA3YmEyMjE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2ZlMzJlNTZjOTYwZTlmMGZjMGQ1ODk1Zjc2Mjk2NDM1MDNiMWQ3YzIwNTUw
|
14
|
+
ZTc5NjUwZGU1ZjFjOGY3OGQ3YTUyNWNjNThhMzFhYjYwZTFhYTU4OWEzMzhl
|
15
|
+
YmRkNzRiM2RkYTQ5NzBlMDQ0YWY4YWU4MTA2NTVjZDdmYmJiYTA=
|
data/lib/onpay.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
require 'digest'
|
3
|
+
|
4
|
+
module Onpay
|
5
|
+
class PayController
|
6
|
+
|
7
|
+
include Onpay
|
8
|
+
|
9
|
+
def process p, secret, lambda_hash
|
10
|
+
@lambda_hash = lambda_hash
|
11
|
+
|
12
|
+
p_for = p[:pay_for]
|
13
|
+
o_a = p[:order_amount]
|
14
|
+
o_c = p[:order_currency]
|
15
|
+
|
16
|
+
@respond_hash = { :pay_for=>p_for,
|
17
|
+
:order_amount=>o_a,
|
18
|
+
:order_currency=>o_c,
|
19
|
+
:secret => secret,
|
20
|
+
:code => "0"
|
21
|
+
}
|
22
|
+
|
23
|
+
@request_hash = { :pay_for=>p_for,
|
24
|
+
:order_amount=>o_a,
|
25
|
+
:order_currency=>o_c.upcase,
|
26
|
+
:secret => secret
|
27
|
+
}
|
28
|
+
|
29
|
+
@result = {'pay_for'=>p_for, :comment=>"OK"}
|
30
|
+
|
31
|
+
case p[:type]
|
32
|
+
when "check" then
|
33
|
+
return check_req p
|
34
|
+
when "pay" then
|
35
|
+
return pay_req p
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_req p
|
40
|
+
req_md5 = gen_md5(gen_request_md5("check", @request_hash))
|
41
|
+
|
42
|
+
if req_md5 == p[:md5] &&
|
43
|
+
@lambda_hash[:check_payment].call(@request_hash[:pay_for])
|
44
|
+
|
45
|
+
@result[:code] = "0"
|
46
|
+
@respond_hash[:code] = "0"
|
47
|
+
|
48
|
+
md5 = gen_respond_md5("check",@respond_hash)
|
49
|
+
md5 = gen_md5(md5)
|
50
|
+
|
51
|
+
@result[:md5] = md5
|
52
|
+
|
53
|
+
return @result.to_xml(:root => 'result',:dasherize => false )
|
54
|
+
else
|
55
|
+
@respond_hash[:code] = "0"
|
56
|
+
md5 = gen_respond_md5("check",@respond_hash)
|
57
|
+
md5 = gen_md5(md5)
|
58
|
+
|
59
|
+
@result[:code] = "2"
|
60
|
+
@result[:comment] = "Внутренняя ошибка."
|
61
|
+
@result[:md5] = md5
|
62
|
+
return @result.to_xml(:root => 'result',:dasherize => false )
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def pay_req p
|
69
|
+
@request_hash[:onpay_id] = p[:onpay_id]
|
70
|
+
@respond_hash[:onpay_id] = p[:onpay_id]
|
71
|
+
|
72
|
+
req_md5 = gen_md5(gen_request_pay_md5("pay", @request_hash))
|
73
|
+
|
74
|
+
if req_md5 == p[:md5] &&
|
75
|
+
@lambda_hash[:onpay].call(@request_hash[:pay_for])
|
76
|
+
|
77
|
+
@result[:code] = "0"
|
78
|
+
@respond_hash[:code] = "0"
|
79
|
+
|
80
|
+
md5 = gen_respond_pay_md5("pay",@respond_hash)
|
81
|
+
md5 = gen_md5(md5)
|
82
|
+
|
83
|
+
@result[:md5] = md5
|
84
|
+
|
85
|
+
return @result.to_xml(:root => 'result',:dasherize => false )
|
86
|
+
else
|
87
|
+
@respond_hash[:code] = "2"
|
88
|
+
|
89
|
+
md5 = gen_respond_pay_md5("pay", @respond_hash)
|
90
|
+
md5 = gen_md5(md5)
|
91
|
+
|
92
|
+
@result[:code] = "2"
|
93
|
+
@result[:comment] = "Внутренняя ошибка."
|
94
|
+
@result[:md5] = md5
|
95
|
+
return @result.to_xml(:root => 'result',:dasherize => false )
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
def gen_request_pay_md5 t, p
|
102
|
+
str_md5 = "type;pay_for;onpay_id;order_amount;order_currency;secret_key_for_api_in"
|
103
|
+
str_md5.gsub!(/type/,t)
|
104
|
+
str_md5.gsub!(/onpay_id/,p[:onpay_id])
|
105
|
+
str_md5.gsub!(/pay_for/, p[:pay_for])
|
106
|
+
str_md5.gsub!(/order_amount/, p[:order_amount])
|
107
|
+
str_md5.gsub!(/order_currency/, p[:order_currency])
|
108
|
+
str_md5.gsub!(/secret_key_for_api_in/,p[:secret])
|
109
|
+
return str_md5
|
110
|
+
end
|
111
|
+
|
112
|
+
def gen_respond_pay_md5 t, p
|
113
|
+
str_md5 = "type;pay_for;onpay_id;order_id;order_amount;order_currency;code;secret_key_api_in"
|
114
|
+
str_md5.gsub!(/order_id/, "")
|
115
|
+
str_md5.gsub!(/type/, t)
|
116
|
+
str_md5.gsub!(/onpay_id/,p[:onpay_id])
|
117
|
+
str_md5.gsub!(/pay_for/, p[:pay_for])
|
118
|
+
str_md5.gsub!(/order_amount/, p[:order_amount])
|
119
|
+
str_md5.gsub!(/order_currency/, p[:order_currency])
|
120
|
+
str_md5.gsub!(/code/, p[:code])
|
121
|
+
str_md5.gsub!(/secret_key_api_in/, p[:secret])
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
def gen_request_md5 t, p
|
126
|
+
str_md5 ="type;pay_for;order_amount;order_currency;secret_key_for_api_in"
|
127
|
+
|
128
|
+
str_md5.gsub!(/type/,t)
|
129
|
+
str_md5.gsub!(/pay_for/, p[:pay_for])
|
130
|
+
str_md5.gsub!(/order_amount/, p[:order_amount])
|
131
|
+
str_md5.gsub!(/order_currency/, p[:order_currency])
|
132
|
+
str_md5.gsub!(/secret_key_for_api_in/,p[:secret])
|
133
|
+
|
134
|
+
return str_md5
|
135
|
+
end
|
136
|
+
|
137
|
+
def gen_respond_md5 t, p
|
138
|
+
str_md5 = "type;pay_for;order_amount;order_currency;code;secret_key_api_in"
|
139
|
+
str_md5.gsub!(/type/, t)
|
140
|
+
str_md5.gsub!(/pay_for/, p[:pay_for])
|
141
|
+
str_md5.gsub!(/order_amount/, p[:order_amount])
|
142
|
+
str_md5.gsub!(/order_currency/, p[:order_currency])
|
143
|
+
str_md5.gsub!(/code/, p[:code])
|
144
|
+
str_md5.gsub!(/secret_key_api_in/, p[:secret])
|
145
|
+
return str_md5
|
146
|
+
end
|
147
|
+
|
148
|
+
def gen_md5(p)
|
149
|
+
Digest::MD5.hexdigest(p).upcase
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onpay-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Presnyakov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Payment method for onpay.ru
|
14
|
+
email: alex@pixella.ru
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/onpay.rb
|
20
|
+
homepage: http://rubygems.org/gems/onpay-rails
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.9.3
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Onpay-rails
|
43
|
+
test_files: []
|