payments-pl 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +94 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/doc/Payments/Pos.html +1283 -0
- data/doc/Payments/PosNotFound.html +100 -0
- data/doc/Payments/RequestFailed.html +100 -0
- data/doc/Payments/SignatureInvalid.html +100 -0
- data/doc/Payments/Transaction.html +332 -0
- data/doc/Payments/ViewHelpers.html +170 -0
- data/doc/Payments.html +433 -0
- data/doc/_index.html +170 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +50 -0
- data/doc/css/style.css +277 -0
- data/doc/file.README.html +170 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +14 -0
- data/doc/index.html +170 -0
- data/doc/js/app.js +138 -0
- data/doc/js/full_list.js +117 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +259 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/payments/pos.rb +115 -0
- data/lib/payments/transaction.rb +45 -0
- data/lib/payments/view_helpers.rb +18 -0
- data/lib/payments_pl.rb +84 -0
- data/payments-pl.gemspec +78 -0
- data/test/helper.rb +10 -0
- data/test/test_payments-pl.rb +7 -0
- metadata +117 -0
@@ -0,0 +1,170 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>payments-pl 0.1.0
|
7
|
+
</title>
|
8
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
<script type="text/javascript" charset="utf-8">
|
12
|
+
relpath = '';
|
13
|
+
if (relpath != '') relpath += '/';
|
14
|
+
</script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<script type="text/javascript" charset="utf-8">
|
21
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
22
|
+
</script>
|
23
|
+
|
24
|
+
<div id="header">
|
25
|
+
<div id="menu">
|
26
|
+
|
27
|
+
<a href="_index.html" title="Index">Index</a> »
|
28
|
+
<span class="title">File: README</span>
|
29
|
+
|
30
|
+
|
31
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div id="search">
|
35
|
+
<a id="class_list_link" href="#">Class List</a>
|
36
|
+
<a id="method_list_link" href="#">Method List</a>
|
37
|
+
<a id ="file_list_link" href="#">File List</a>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="clear"></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<iframe id="search_frame"></iframe>
|
44
|
+
|
45
|
+
<div id="content"><div id='filecontents'><h1>payments-pl</h1>
|
46
|
+
<p>
|
47
|
+
Simple library for handling payments via platnosci.pl
|
48
|
+
</p>
|
49
|
+
<h2>Features</h2>
|
50
|
+
<ul>
|
51
|
+
<li>Simple configuration (multiple POS-es)
|
52
|
+
|
53
|
+
</li>
|
54
|
+
<li>Transactions: create, get state, confirm, cancel
|
55
|
+
|
56
|
+
</li>
|
57
|
+
<li>View helper for generating payment form
|
58
|
+
|
59
|
+
</li>
|
60
|
+
</ul>
|
61
|
+
<h2>Installation</h2>
|
62
|
+
<p>
|
63
|
+
Install gem:
|
64
|
+
</p>
|
65
|
+
<pre class="code">
|
66
|
+
<span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='payments identifier id'>payments</span><span class='minus op'>-</span><span class='pl identifier id'>pl</span>
|
67
|
+
</pre>
|
68
|
+
<p>
|
69
|
+
And add it n your environment.rb file:
|
70
|
+
</p>
|
71
|
+
<pre class="code">
|
72
|
+
<span class='config identifier id'>config</span><span class='dot token'>.</span><span class='gem identifier id'>gem</span> <span class='string val'>'payments-pl'</span><span class='comma token'>,</span> <span class='symbol val'>:lib</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments_pl'</span>
|
73
|
+
</pre>
|
74
|
+
<h2>Configuration</h2>
|
75
|
+
<p>
|
76
|
+
First add POS informations in config/payments.yml file:
|
77
|
+
</p>
|
78
|
+
<pre class="code">
|
79
|
+
<span class='bank identifier id'>bank</span><span class='colon op'>:</span>
|
80
|
+
<span class='pos_id identifier id'>pos_id</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
81
|
+
<span class='pos_auth_key identifier id'>pos_auth_key</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
82
|
+
<span class='key1 identifier id'>key1</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
83
|
+
<span class='key2 identifier id'>key2</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
84
|
+
<span class='type identifier id'>type</span><span class='colon op'>:</span> <span class='express_gateway identifier id'>express_gateway</span>
|
85
|
+
|
86
|
+
<span class='sms identifier id'>sms</span><span class='colon op'>:</span>
|
87
|
+
<span class='pos_id identifier id'>pos_id</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
88
|
+
<span class='pos_auth_key identifier id'>pos_auth_key</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
89
|
+
<span class='key1 identifier id'>key1</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
90
|
+
<span class='key2 identifier id'>key2</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
91
|
+
<span class='type identifier id'>type</span><span class='colon op'>:</span> <span class='sms_premium identifier id'>sms_premium</span>
|
92
|
+
</pre>
|
93
|
+
<p>
|
94
|
+
Next add some routes so platnosci.pl can send messages to your application:
|
95
|
+
</p>
|
96
|
+
<pre class="code">
|
97
|
+
<span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/ok'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'ok'</span>
|
98
|
+
<span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/error'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'error'</span>
|
99
|
+
<span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/report'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'report'</span>
|
100
|
+
</pre>
|
101
|
+
<p>
|
102
|
+
These urls must be the same as those you entered on platnosci.pl site.
|
103
|
+
</p>
|
104
|
+
<h2>Usage</h2>
|
105
|
+
<p>
|
106
|
+
Creating new transaction in controller:
|
107
|
+
</p>
|
108
|
+
<pre class="code">
|
109
|
+
<span class='def def kw'>def</span> <span class='some_action identifier id'>some_action</span>
|
110
|
+
<span class='@transaction ivar id'>@transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='string val'>'bank'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='new_transaction identifier id'>new_transaction</span><span class='lparen token'>(</span><span class='symbol val'>:amount</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='integer val'>100</span><span class='comma token'>,</span> <span class='symbol val'>:desc</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'Abonament'</span><span class='comma token'>,</span> <span class='symbol val'>:client_ip</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='request identifier id'>request</span><span class='dot token'>.</span><span class='remote_addr identifier id'>remote_addr</span><span class='comma token'>,</span> <span class='symbol val'>:js</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'0'</span><span class='rparen token'>)</span>
|
111
|
+
<span class='end end kw'>end</span>
|
112
|
+
</pre>
|
113
|
+
<p>
|
114
|
+
Rendering payment form:
|
115
|
+
</p>
|
116
|
+
<pre class="code">
|
117
|
+
<span class='minus op'>-</span> <span class='form_tag identifier id'>form_tag</span> <span class='@transaction ivar id'>@transaction</span><span class='dot token'>.</span><span class='new_url identifier id'>new_url</span> <span class='do do kw'>do</span>
|
118
|
+
<span class='assign token'>=</span> <span class='transaction_hidden_fields identifier id'>transaction_hidden_fields</span> <span class='@transaction ivar id'>@transaction</span>
|
119
|
+
<span class='assign token'>=</span> <span class='submit_tag identifier id'>submit_tag</span> <span class='string val'>'Pay'</span>
|
120
|
+
</pre>
|
121
|
+
<p>
|
122
|
+
Controller for receiving messages from platnosci.pl:
|
123
|
+
</p>
|
124
|
+
<pre class="code">
|
125
|
+
<span class='class class kw'>class</span> <span class='PaymentsController constant id'>PaymentsController</span> <span class='lt op'><</span> <span class='ApplicationController constant id'>ApplicationController</span>
|
126
|
+
<span class='skip_before_filter identifier id'>skip_before_filter</span> <span class='symbol val'>:verify_authenticity_token</span>
|
127
|
+
|
128
|
+
<span class='def def kw'>def</span> <span class='error identifier id'>error</span>
|
129
|
+
<span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='Payments constant id'>Payments</span><span class='dot token'>.</span><span class='error_text identifier id'>error_text</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
|
130
|
+
<span class='end end kw'>end</span>
|
131
|
+
|
132
|
+
<span class='def def kw'>def</span> <span class='ok identifier id'>ok</span>
|
133
|
+
<span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'Payment OK'</span>
|
134
|
+
<span class='end end kw'>end</span>
|
135
|
+
|
136
|
+
<span class='def def kw'>def</span> <span class='report identifier id'>report</span>
|
137
|
+
<span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='get identifier id'>get</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
|
138
|
+
<span class='if if kw'>if</span> <span class='status identifier id'>status</span> <span class='eq op'>==</span> <span class='string val'>'OK'</span>
|
139
|
+
<span class='if if kw'>if</span> <span class='transaction identifier id'>transaction</span><span class='dot token'>.</span><span class='trans_status identifier id'>trans_status</span> <span class='eq op'>==</span> <span class='string val'>'99'</span>
|
140
|
+
<span class='comment val'># paid, money received</span>
|
141
|
+
<span class='else else kw'>else</span>
|
142
|
+
<span class='comment val'># other stuff</span>
|
143
|
+
<span class='end end kw'>end</span>
|
144
|
+
<span class='end end kw'>end</span>
|
145
|
+
<span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'OK'</span>
|
146
|
+
<span class='end end kw'>end</span>
|
147
|
+
<span class='end end kw'>end</span>
|
148
|
+
</pre>
|
149
|
+
<p>
|
150
|
+
Cancelling and confirming transaction is similar to getting transaction
|
151
|
+
state:
|
152
|
+
</p>
|
153
|
+
<pre class="code">
|
154
|
+
<span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='cancel identifier id'>cancel</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
|
155
|
+
<span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='confirm identifier id'>confirm</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
|
156
|
+
</pre>
|
157
|
+
<h2>Copyright</h2>
|
158
|
+
<p>
|
159
|
+
Copyright © 2010 Michał Młoźniak. See LICENSE for details.
|
160
|
+
</p>
|
161
|
+
</div></div>
|
162
|
+
|
163
|
+
<div id="footer">
|
164
|
+
Generated on Tue Aug 17 16:13:27 2010 by
|
165
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
166
|
+
0.5.8 (ruby-1.8.7).
|
167
|
+
</div>
|
168
|
+
|
169
|
+
</body>
|
170
|
+
</html>
|
data/doc/file_list.html
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
7
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
9
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
10
|
+
<base id="base_target" target="_parent" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<script type="text/javascript" charset="utf-8">
|
14
|
+
if (window.top.frames.main) {
|
15
|
+
document.getElementById('base_target').target = 'main';
|
16
|
+
document.body.className = 'frames';
|
17
|
+
}
|
18
|
+
</script>
|
19
|
+
<div id="content">
|
20
|
+
<h1 id="full_list_header">File List</h1>
|
21
|
+
<div id="nav">
|
22
|
+
<a target="_self" href="class_list.html">Classes</a> |
|
23
|
+
<a target="_self" href="method_list.html">Methods</a> |
|
24
|
+
<a target="_self" href="file_list.html">Files</a>
|
25
|
+
</div>
|
26
|
+
<div id="search">Search: <input type="text" /></div>
|
27
|
+
|
28
|
+
<ul id="full_list" class="files">
|
29
|
+
|
30
|
+
|
31
|
+
<li class="r1"><a href="index.html" title="README">README</a></li>
|
32
|
+
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
</div>
|
36
|
+
</body>
|
37
|
+
</html>
|
38
|
+
|
data/doc/frames.html
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
<title>payments-pl 0.1.0
|
8
|
+
</title>
|
9
|
+
</head>
|
10
|
+
<frameset cols="20%,*">
|
11
|
+
<frame name="list" src="class_list.html" />
|
12
|
+
<frame name="main" src="index.html" />
|
13
|
+
</frameset>
|
14
|
+
</html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>payments-pl 0.1.0
|
7
|
+
</title>
|
8
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
<script type="text/javascript" charset="utf-8">
|
12
|
+
relpath = '';
|
13
|
+
if (relpath != '') relpath += '/';
|
14
|
+
</script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<script type="text/javascript" charset="utf-8">
|
21
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
22
|
+
</script>
|
23
|
+
|
24
|
+
<div id="header">
|
25
|
+
<div id="menu">
|
26
|
+
|
27
|
+
<a href="_index.html" title="Index">Index</a> »
|
28
|
+
<span class="title">File: README</span>
|
29
|
+
|
30
|
+
|
31
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div id="search">
|
35
|
+
<a id="class_list_link" href="#">Class List</a>
|
36
|
+
<a id="method_list_link" href="#">Method List</a>
|
37
|
+
<a id ="file_list_link" href="#">File List</a>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="clear"></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<iframe id="search_frame"></iframe>
|
44
|
+
|
45
|
+
<div id="content"><div id='filecontents'><h1>payments-pl</h1>
|
46
|
+
<p>
|
47
|
+
Simple library for handling payments via platnosci.pl
|
48
|
+
</p>
|
49
|
+
<h2>Features</h2>
|
50
|
+
<ul>
|
51
|
+
<li>Simple configuration (multiple POS-es)
|
52
|
+
|
53
|
+
</li>
|
54
|
+
<li>Transactions: create, get state, confirm, cancel
|
55
|
+
|
56
|
+
</li>
|
57
|
+
<li>View helper for generating payment form
|
58
|
+
|
59
|
+
</li>
|
60
|
+
</ul>
|
61
|
+
<h2>Installation</h2>
|
62
|
+
<p>
|
63
|
+
Install gem:
|
64
|
+
</p>
|
65
|
+
<pre class="code">
|
66
|
+
<span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='payments identifier id'>payments</span><span class='minus op'>-</span><span class='pl identifier id'>pl</span>
|
67
|
+
</pre>
|
68
|
+
<p>
|
69
|
+
And add it n your environment.rb file:
|
70
|
+
</p>
|
71
|
+
<pre class="code">
|
72
|
+
<span class='config identifier id'>config</span><span class='dot token'>.</span><span class='gem identifier id'>gem</span> <span class='string val'>'payments-pl'</span><span class='comma token'>,</span> <span class='symbol val'>:lib</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments_pl'</span>
|
73
|
+
</pre>
|
74
|
+
<h2>Configuration</h2>
|
75
|
+
<p>
|
76
|
+
First add POS informations in config/payments.yml file:
|
77
|
+
</p>
|
78
|
+
<pre class="code">
|
79
|
+
<span class='bank identifier id'>bank</span><span class='colon op'>:</span>
|
80
|
+
<span class='pos_id identifier id'>pos_id</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
81
|
+
<span class='pos_auth_key identifier id'>pos_auth_key</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
82
|
+
<span class='key1 identifier id'>key1</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
83
|
+
<span class='key2 identifier id'>key2</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
84
|
+
<span class='type identifier id'>type</span><span class='colon op'>:</span> <span class='express_gateway identifier id'>express_gateway</span>
|
85
|
+
|
86
|
+
<span class='sms identifier id'>sms</span><span class='colon op'>:</span>
|
87
|
+
<span class='pos_id identifier id'>pos_id</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
88
|
+
<span class='pos_auth_key identifier id'>pos_auth_key</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
89
|
+
<span class='key1 identifier id'>key1</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
90
|
+
<span class='key2 identifier id'>key2</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
|
91
|
+
<span class='type identifier id'>type</span><span class='colon op'>:</span> <span class='sms_premium identifier id'>sms_premium</span>
|
92
|
+
</pre>
|
93
|
+
<p>
|
94
|
+
Next add some routes so platnosci.pl can send messages to your application:
|
95
|
+
</p>
|
96
|
+
<pre class="code">
|
97
|
+
<span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/ok'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'ok'</span>
|
98
|
+
<span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/error'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'error'</span>
|
99
|
+
<span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/report'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'report'</span>
|
100
|
+
</pre>
|
101
|
+
<p>
|
102
|
+
These urls must be the same as those you entered on platnosci.pl site.
|
103
|
+
</p>
|
104
|
+
<h2>Usage</h2>
|
105
|
+
<p>
|
106
|
+
Creating new transaction in controller:
|
107
|
+
</p>
|
108
|
+
<pre class="code">
|
109
|
+
<span class='def def kw'>def</span> <span class='some_action identifier id'>some_action</span>
|
110
|
+
<span class='@transaction ivar id'>@transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='string val'>'bank'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='new_transaction identifier id'>new_transaction</span><span class='lparen token'>(</span><span class='symbol val'>:amount</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='integer val'>100</span><span class='comma token'>,</span> <span class='symbol val'>:desc</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'Abonament'</span><span class='comma token'>,</span> <span class='symbol val'>:client_ip</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='request identifier id'>request</span><span class='dot token'>.</span><span class='remote_addr identifier id'>remote_addr</span><span class='comma token'>,</span> <span class='symbol val'>:js</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'0'</span><span class='rparen token'>)</span>
|
111
|
+
<span class='end end kw'>end</span>
|
112
|
+
</pre>
|
113
|
+
<p>
|
114
|
+
Rendering payment form:
|
115
|
+
</p>
|
116
|
+
<pre class="code">
|
117
|
+
<span class='minus op'>-</span> <span class='form_tag identifier id'>form_tag</span> <span class='@transaction ivar id'>@transaction</span><span class='dot token'>.</span><span class='new_url identifier id'>new_url</span> <span class='do do kw'>do</span>
|
118
|
+
<span class='assign token'>=</span> <span class='transaction_hidden_fields identifier id'>transaction_hidden_fields</span> <span class='@transaction ivar id'>@transaction</span>
|
119
|
+
<span class='assign token'>=</span> <span class='submit_tag identifier id'>submit_tag</span> <span class='string val'>'Pay'</span>
|
120
|
+
</pre>
|
121
|
+
<p>
|
122
|
+
Controller for receiving messages from platnosci.pl:
|
123
|
+
</p>
|
124
|
+
<pre class="code">
|
125
|
+
<span class='class class kw'>class</span> <span class='PaymentsController constant id'>PaymentsController</span> <span class='lt op'><</span> <span class='ApplicationController constant id'>ApplicationController</span>
|
126
|
+
<span class='skip_before_filter identifier id'>skip_before_filter</span> <span class='symbol val'>:verify_authenticity_token</span>
|
127
|
+
|
128
|
+
<span class='def def kw'>def</span> <span class='error identifier id'>error</span>
|
129
|
+
<span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='Payments constant id'>Payments</span><span class='dot token'>.</span><span class='error_text identifier id'>error_text</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
|
130
|
+
<span class='end end kw'>end</span>
|
131
|
+
|
132
|
+
<span class='def def kw'>def</span> <span class='ok identifier id'>ok</span>
|
133
|
+
<span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'Payment OK'</span>
|
134
|
+
<span class='end end kw'>end</span>
|
135
|
+
|
136
|
+
<span class='def def kw'>def</span> <span class='report identifier id'>report</span>
|
137
|
+
<span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='get identifier id'>get</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
|
138
|
+
<span class='if if kw'>if</span> <span class='status identifier id'>status</span> <span class='eq op'>==</span> <span class='string val'>'OK'</span>
|
139
|
+
<span class='if if kw'>if</span> <span class='transaction identifier id'>transaction</span><span class='dot token'>.</span><span class='trans_status identifier id'>trans_status</span> <span class='eq op'>==</span> <span class='string val'>'99'</span>
|
140
|
+
<span class='comment val'># paid, money received</span>
|
141
|
+
<span class='else else kw'>else</span>
|
142
|
+
<span class='comment val'># other stuff</span>
|
143
|
+
<span class='end end kw'>end</span>
|
144
|
+
<span class='end end kw'>end</span>
|
145
|
+
<span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>'OK'</span>
|
146
|
+
<span class='end end kw'>end</span>
|
147
|
+
<span class='end end kw'>end</span>
|
148
|
+
</pre>
|
149
|
+
<p>
|
150
|
+
Cancelling and confirming transaction is similar to getting transaction
|
151
|
+
state:
|
152
|
+
</p>
|
153
|
+
<pre class="code">
|
154
|
+
<span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='cancel identifier id'>cancel</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
|
155
|
+
<span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='confirm identifier id'>confirm</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
|
156
|
+
</pre>
|
157
|
+
<h2>Copyright</h2>
|
158
|
+
<p>
|
159
|
+
Copyright © 2010 Michał Młoźniak. See LICENSE for details.
|
160
|
+
</p>
|
161
|
+
</div></div>
|
162
|
+
|
163
|
+
<div id="footer">
|
164
|
+
Generated on Tue Aug 17 16:13:27 2010 by
|
165
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
166
|
+
0.5.8 (ruby-1.8.7).
|
167
|
+
</div>
|
168
|
+
|
169
|
+
</body>
|
170
|
+
</html>
|
data/doc/js/app.js
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
function createSourceLinks() {
|
2
|
+
$('.method_details_list .source_code').
|
3
|
+
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
|
4
|
+
$('.toggleSource').toggle(function() {
|
5
|
+
$(this).parent().next().slideDown(100);
|
6
|
+
$(this).text("Hide source");
|
7
|
+
},
|
8
|
+
function() {
|
9
|
+
$(this).parent().next().slideUp(100);
|
10
|
+
$(this).text("View source");
|
11
|
+
});
|
12
|
+
}
|
13
|
+
|
14
|
+
function createDefineLinks() {
|
15
|
+
var tHeight = 0;
|
16
|
+
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
|
17
|
+
$('.toggleDefines').toggle(function() {
|
18
|
+
tHeight = $(this).parent().prev().height();
|
19
|
+
$(this).prev().show();
|
20
|
+
$(this).parent().prev().height($(this).parent().height());
|
21
|
+
$(this).text("(less)");
|
22
|
+
},
|
23
|
+
function() {
|
24
|
+
$(this).prev().hide();
|
25
|
+
$(this).parent().prev().height(tHeight);
|
26
|
+
$(this).text("more...")
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
function createFullTreeLinks() {
|
31
|
+
var tHeight = 0;
|
32
|
+
$('.inheritanceTree').toggle(function() {
|
33
|
+
tHeight = $(this).parent().prev().height();
|
34
|
+
$(this).prev().prev().hide();
|
35
|
+
$(this).prev().show();
|
36
|
+
$(this).text("(hide)");
|
37
|
+
$(this).parent().prev().height($(this).parent().height());
|
38
|
+
},
|
39
|
+
function() {
|
40
|
+
$(this).prev().prev().show();
|
41
|
+
$(this).prev().hide();
|
42
|
+
$(this).parent().prev().height(tHeight);
|
43
|
+
$(this).text("show all")
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
function fixBoxInfoHeights() {
|
48
|
+
$('dl.box dd.r1, dl.box dd.r2').each(function() {
|
49
|
+
$(this).prev().height($(this).height());
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
function searchFrameLinks() {
|
54
|
+
$('#method_list_link').click(function() {
|
55
|
+
toggleSearchFrame(this, relpath + 'method_list.html');
|
56
|
+
});
|
57
|
+
|
58
|
+
$('#class_list_link').click(function() {
|
59
|
+
toggleSearchFrame(this, relpath + 'class_list.html');
|
60
|
+
});
|
61
|
+
|
62
|
+
$('#file_list_link').click(function() {
|
63
|
+
toggleSearchFrame(this, relpath + 'file_list.html');
|
64
|
+
});
|
65
|
+
}
|
66
|
+
|
67
|
+
function toggleSearchFrame(id, link) {
|
68
|
+
var frame = $('#search_frame');
|
69
|
+
$('#search a').removeClass('active').addClass('inactive');
|
70
|
+
if (frame.attr('src') == link && frame.css('display') != "none") {
|
71
|
+
frame.slideUp(100);
|
72
|
+
$('#search a').removeClass('active inactive');
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
$(id).addClass('active').removeClass('inactive');
|
76
|
+
frame.attr('src', link).slideDown(100);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
function linkSummaries() {
|
81
|
+
$('.summary_signature').click(function() {
|
82
|
+
document.location = $(this).find('a').attr('href');
|
83
|
+
});
|
84
|
+
}
|
85
|
+
|
86
|
+
function framesInit() {
|
87
|
+
if (window.top.frames.main) {
|
88
|
+
document.body.className = 'frames';
|
89
|
+
$('#menu .noframes a').attr('href', document.location);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
function keyboardShortcuts() {
|
94
|
+
if (window.top.frames.main) return;
|
95
|
+
$(document).keypress(function(evt) {
|
96
|
+
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
97
|
+
if (evt.originalTarget.nodeName == "INPUT" ||
|
98
|
+
evt.originalTarget.nodeName == "TEXTAREA") return;
|
99
|
+
switch (evt.charCode) {
|
100
|
+
case 67: case 99: $('#class_list_link').click(); break; // 'c'
|
101
|
+
case 77: case 109: $('#method_list_link').click(); break; // 'm'
|
102
|
+
case 70: case 102: $('#file_list_link').click(); break; // 'f'
|
103
|
+
}
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
function summaryToggle() {
|
108
|
+
$('.summary_toggle').click(function() {
|
109
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
110
|
+
var next = $(this).parent().parent().next();
|
111
|
+
if (next.hasClass('compact')) {
|
112
|
+
next.toggle();
|
113
|
+
next.next().toggle();
|
114
|
+
}
|
115
|
+
else if (next.hasClass('summary')) {
|
116
|
+
var list = $('<ul class="summary compact" />');
|
117
|
+
list.html(next.html());
|
118
|
+
list.find('.summary_desc, .note').remove();
|
119
|
+
list.find('a').each(function() {
|
120
|
+
$(this).html($(this).find('strong').html());
|
121
|
+
$(this).parent().html($(this)[0].outerHTML);
|
122
|
+
});
|
123
|
+
next.before(list);
|
124
|
+
next.toggle();
|
125
|
+
}
|
126
|
+
return false;
|
127
|
+
})
|
128
|
+
}
|
129
|
+
|
130
|
+
$(framesInit);
|
131
|
+
$(createSourceLinks);
|
132
|
+
$(createDefineLinks);
|
133
|
+
$(createFullTreeLinks);
|
134
|
+
$(fixBoxInfoHeights);
|
135
|
+
$(searchFrameLinks);
|
136
|
+
$(linkSummaries);
|
137
|
+
$(keyboardShortcuts);
|
138
|
+
$(summaryToggle);
|