magpie 0.8.8 → 0.8.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/Rakefile +1 -1
- data/doc/Magpie.html +360 -0
- data/doc/Magpie/Alipay.html +257 -0
- data/doc/Magpie/AlipayModel.html +1770 -0
- data/doc/Magpie/Chinabank.html +257 -0
- data/doc/Magpie/ChinabankModel.html +1030 -0
- data/doc/Magpie/Dung.html +673 -0
- data/doc/Magpie/Goose.html +420 -0
- data/doc/Magpie/Goose/ClassMethods.html +467 -0
- data/doc/Magpie/Mothlog.html +239 -0
- data/doc/Magpie/Mouse.html +363 -0
- data/doc/Magpie/Mouse/ClassMethods.html +225 -0
- data/doc/Magpie/Mouse/MouseError.html +100 -0
- data/doc/Magpie/Rubber.html +160 -0
- data/doc/Magpie/Server.html +253 -0
- data/doc/Magpie/Server/Options.html +261 -0
- data/doc/Magpie/Snake.html +744 -0
- data/doc/Magpie/Tenpay.html +259 -0
- data/doc/Magpie/TenpayModel.html +1542 -0
- data/doc/Magpie/Utils.html +888 -0
- data/doc/_index.html +295 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +307 -0
- data/doc/file.README.html +239 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +239 -0
- data/doc/js/app.js +202 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +154 -0
- data/doc/method_list.html +1003 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/apps.rb +1 -1
- data/lib/magpie.rb +1 -1
- data/lib/magpie/server.rb +2 -0
- data/magpie.gemspec +43 -1
- data/static/images/error.gif +0 -0
- data/static/images/q2.gif +0 -0
- data/test/test.log +2182 -0
- metadata +39 -3
@@ -0,0 +1,239 @@
|
|
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>Documentation by YARD 0.6.1</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="_index.html" title="Index">Index</a> »
|
27
|
+
<span class="title">File: README</span>
|
28
|
+
|
29
|
+
|
30
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div id="search">
|
34
|
+
<a id="class_list_link" href="#">Class List</a>
|
35
|
+
<a id="method_list_link" href="#">Method List</a>
|
36
|
+
<a id ="file_list_link" href="#">File List</a>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="clear"></div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<iframe id="search_frame"></iframe>
|
43
|
+
|
44
|
+
<div id="content"><div id='filecontents'><h1>Magpie用于模拟支付平台的沙盒功能</h1>
|
45
|
+
|
46
|
+
<p><strong>Git</strong>: <a href="http://github.com/baya/magpie">http://github.com/baya/magpie</a></p>
|
47
|
+
|
48
|
+
<p><strong>Author</strong>: Guimin Jiang</p>
|
49
|
+
|
50
|
+
<p><strong>Copyright</strong>: 2010</p>
|
51
|
+
|
52
|
+
<p><strong>License</strong>: MIT License</p>
|
53
|
+
|
54
|
+
<p><strong>Latest Version</strong>: 0.8.8</p>
|
55
|
+
|
56
|
+
<p><strong>Release Date</strong>: 2010-11-03</p>
|
57
|
+
|
58
|
+
<h2>快搭</h2>
|
59
|
+
|
60
|
+
<pre class="code"><span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='magpie identifier id'>magpie</span>
|
61
|
+
</pre>
|
62
|
+
|
63
|
+
<p>打开终端,输入:</p>
|
64
|
+
|
65
|
+
<pre class="code">$ <span class='mag identifier id'>mag</span> <span class='magpie identifier id'>magpie</span><span class='dot token'>.</span><span class='yml identifier id'>yml</span>
|
66
|
+
</pre>
|
67
|
+
|
68
|
+
<p>magpie.yml文件用来配置你的商号信息, 假设你在支付宝(alipay)有个账号:123456, key是:aaabbb, 网银在线(chinabank)
|
69
|
+
有个账号:789789, key是:cccddd, 财付通(tenpay)有个账号:888666, key是:dddggg, 那么你在magpie.yml中这样写,</p>
|
70
|
+
|
71
|
+
<pre class="code"><span class='alipay identifier id'>alipay</span><span class='colon op'>:</span>
|
72
|
+
<span class='minus op'>-</span> <span class='lbrack token'>[</span><span class='string val'>"123456"</span><span class='comma token'>,</span> <span class='string val'>"aaabbb"</span><span class='rbrack token'>]</span>
|
73
|
+
|
74
|
+
<span class='chinabank identifier id'>chinabank</span><span class='colon op'>:</span>
|
75
|
+
<span class='minus op'>-</span> <span class='lbrack token'>[</span><span class='string val'>"789789"</span><span class='comma token'>,</span> <span class='string val'>"cccddd"</span><span class='rbrack token'>]</span>
|
76
|
+
|
77
|
+
<span class='tenpay identifier id'>tenpay</span><span class='colon op'>:</span>
|
78
|
+
<span class='minus op'>-</span> <span class='lbrack token'>[</span><span class='string val'>"888666"</span><span class='comma token'>,</span> <span class='string val'>"dddggg"</span><span class='rbrack token'>]</span>
|
79
|
+
</pre>
|
80
|
+
|
81
|
+
<p><strong>注意!</strong> 如果你输入mag命令报错, 那可能是因为你的电脑缺少一些magpie需要的gem包, 试着使用下面的命令:</p>
|
82
|
+
|
83
|
+
<pre class="code">$ <span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='rack identifier id'>rack</span>
|
84
|
+
$ <span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='hpricot identifier id'>hpricot</span>
|
85
|
+
</pre>
|
86
|
+
|
87
|
+
<p>mag命令默认会在本地9292端口启动http服务, 你可以用-p选项指定端口</p>
|
88
|
+
|
89
|
+
<pre class="code"><span class='mag identifier id'>mag</span> <span class='minus op'>-</span><span class='p identifier id'>p</span> <span class='integer val'>2010</span> <span class='magpie identifier id'>magpie</span><span class='dot token'>.</span><span class='yml identifier id'>yml</span>
|
90
|
+
</pre>
|
91
|
+
|
92
|
+
<p>mag命令的更多选项可以通过<code>mag -h</code>查看</p>
|
93
|
+
|
94
|
+
<h2>使用示例</h2>
|
95
|
+
|
96
|
+
<p>假设你正在实现支付宝支付的相关代码, 首先启动magpie服务</p>
|
97
|
+
|
98
|
+
<pre class="code">$ <span class='mag identifier id'>mag</span> <span class='magpie identifier id'>magpie</span><span class='dot token'>.</span><span class='yml identifier id'>yml</span>
|
99
|
+
</pre>
|
100
|
+
|
101
|
+
<p>上面命令的意思是:用Mongrel启动magpie服务, 服务的mode是snake, 日志文件是magpie.log, 服务的端口是9292</p>
|
102
|
+
|
103
|
+
<p>完整的命令是: mag -s mongrel -M snake -L magpie.log -p 9292 magpie.yml</p>
|
104
|
+
|
105
|
+
<p>然后在你开发的商户系统中将支付网关由支付宝的网关<code>https://www.alipay.com/cooperate/gateway.do</code></p>
|
106
|
+
|
107
|
+
<p>更改为magpie的网关<code>http://127.0.0.1:9292/alipay</code></p>
|
108
|
+
|
109
|
+
<p>如果你请求的参数出现错误, 你可以通过magpie的日志查看到详细的出错信息, 或者在浏览器上查看出错信息</p>
|
110
|
+
|
111
|
+
<p>如果你的支付请求成功, magpie将会显示一个成功订单的页面, 然后你点击购买就可以给你自己的商户系统发送</p>
|
112
|
+
|
113
|
+
<p>购买成功的通知了, 你需要确保你商户系统的<code>notify_url</code>是可用的,magpie将通过这个<code>notify_url</code>将支付</p>
|
114
|
+
|
115
|
+
<p>成功的通知发到你的商户系统中, 这样你就可以避免去支付宝的页面进行真实的支付.</p>
|
116
|
+
|
117
|
+
<p>对于网银在线(chinabank), 将支付网关由网银在线的网关<code>https://pay3.chinabank.com.cn/PayGate</code>更改为</p>
|
118
|
+
|
119
|
+
<p>magpie的网关<code>http://127.0.0.1:9292/chinabank</code></p>
|
120
|
+
|
121
|
+
<p>对于财付通(tenpay), 将支付网关由财付通的网关<code>http://service.tenpay.com/cgi-bin/v3.0/payservice.cgi</code></p>
|
122
|
+
|
123
|
+
<p>更改为magpie的网关<code>http://127.0.0.1:9292/tenpay</code></p>
|
124
|
+
|
125
|
+
<h2>Magpie启动模式</h2>
|
126
|
+
|
127
|
+
<p><strong>1. bird mode</strong></p>
|
128
|
+
|
129
|
+
<p> $ mag -M bird magpie.yml</p>
|
130
|
+
|
131
|
+
<p>写ruby代码的人一般都是测试控, 这个bird模式主要是为他们提供.以支付宝(alipay)为例, 开发者将支付</p>
|
132
|
+
|
133
|
+
<p>参数提交到http://127.0.0.1:9292/alipay, 出错信息将以xml格式反馈给开发者,如果提交成功, 成功</p>
|
134
|
+
|
135
|
+
<p>信息同样以xml格式反馈给开发者, 同时magpie会自动将购买成功的消息通知到开发者的商户系统中,并返回</p>
|
136
|
+
|
137
|
+
<p>商户系统的处理结果.</p>
|
138
|
+
|
139
|
+
<p>在bird模式下,开发者需要确保magpie.yml中的商号信息是真实有效的,也就是在alipay上实际注册过的,因为</p>
|
140
|
+
|
141
|
+
<p>magpie在bird模式下会将开发者提交的支付参数往alipay的实际网关<code>https://www.alipay.com/cooperate/gateway.do</code></p>
|
142
|
+
|
143
|
+
<p>发送一次.</p>
|
144
|
+
|
145
|
+
<p>网银在线(chinabank), 财付通(tenpay)的模拟情况与之类似.</p>
|
146
|
+
|
147
|
+
<p><strong>2. snake mode</strong></p>
|
148
|
+
|
149
|
+
<p> $ mag -M snake</p>
|
150
|
+
|
151
|
+
<p>这是magpie默认的启动模式,以支付宝(alipay)为例, 开发者将支付参数提交到http://127.0.0.1:9292/alipay</p>
|
152
|
+
|
153
|
+
<p>出错信息以普通html页面显示,如果提交成功, 开发者将看到订单的详细信息, 然后开发者可以点击支付按钮进行支付</p>
|
154
|
+
|
155
|
+
<p>测试, 最终magpie将返回开发者商户系统的处理结果.</p>
|
156
|
+
|
157
|
+
<p>网银在线(chinabank), 财付通(tenpay)的模拟情况与之类似</p>
|
158
|
+
|
159
|
+
<h2>其他语言开发者</h2>
|
160
|
+
|
161
|
+
<p>如果你使用其他开发语言, 比如php, java等,需要使用magpie, 必须首先搭建ruby执行环境才能运行mapgie.</p>
|
162
|
+
|
163
|
+
<p>你可以看看这篇资料<a href="http://www.javaeye.com/topic/43228">http://www.javaeye.com/topic/43228</a></p>
|
164
|
+
|
165
|
+
<p>在这篇资料,你看到"然后就可以安装rails了,"这里就可以停止了, 然后开始搭建ruby执行环境. 我鼓励你能</p>
|
166
|
+
|
167
|
+
<p>把整篇资料看完, 搭建好ruby on rails开发环境, 这样你就可以用rails开发项目了.</p>
|
168
|
+
|
169
|
+
<h2>支持的支付平台</h2>
|
170
|
+
|
171
|
+
<ul>
|
172
|
+
<li>支付宝(alipay)</li>
|
173
|
+
<li>网银在线(chinabank)</li>
|
174
|
+
<li>财付通(tenpay)</li>
|
175
|
+
</ul>
|
176
|
+
|
177
|
+
|
178
|
+
<h2>使用的项目</h2>
|
179
|
+
|
180
|
+
<ul>
|
181
|
+
<li><a href="http://piao.fantong.com">饭票</a></li>
|
182
|
+
<li><a href="http://tuan.fantong.com">饭团</a></li>
|
183
|
+
</ul>
|
184
|
+
|
185
|
+
|
186
|
+
<h2>感谢</h2>
|
187
|
+
|
188
|
+
<ul>
|
189
|
+
<li>potian <a href="http://www.javaeye.com/topic/605707">Rack编程</a>的作者</li>
|
190
|
+
<li>liuzihua liuzihua8@gmail.com</li>
|
191
|
+
</ul>
|
192
|
+
|
193
|
+
|
194
|
+
<h2>Changelog</h2>
|
195
|
+
|
196
|
+
<ul>
|
197
|
+
<li><p><strong>2010-10-20</strong>: 0.8.6.1 release</p>
|
198
|
+
|
199
|
+
<ul>
|
200
|
+
<li>支持网银在线</li>
|
201
|
+
</ul>
|
202
|
+
</li>
|
203
|
+
<li><p><strong>2010-10-20</strong>: 0.8.6.2 release</p>
|
204
|
+
|
205
|
+
<ul>
|
206
|
+
<li>改善README.md的可阅读性</li>
|
207
|
+
</ul>
|
208
|
+
</li>
|
209
|
+
<li><p><strong>2010-11-03</strong>: 0.8.8 release</p>
|
210
|
+
|
211
|
+
<ul>
|
212
|
+
<li>增加财付通的支持</li>
|
213
|
+
<li>增加snake, bird两个启动模式</li>
|
214
|
+
<li>增加日志功能</li>
|
215
|
+
</ul>
|
216
|
+
</li>
|
217
|
+
<li><p><strong>2010-11-08</strong>: 0.8.8.1 release</p>
|
218
|
+
|
219
|
+
<ul>
|
220
|
+
<li>修改一个紧急bug: 加载yml文件报无法找到YAML</li>
|
221
|
+
</ul>
|
222
|
+
</li>
|
223
|
+
</ul>
|
224
|
+
|
225
|
+
|
226
|
+
<h2>Copyright</h2>
|
227
|
+
|
228
|
+
<p>MAGPIE © 2007-2010 by <a href="mailto:kayak.jiang@gmail.com">Guimin Jiang</a>.
|
229
|
+
MAGPIE is licensed under the MIT license except for some files which come
|
230
|
+
from the RDoc/Ruby distributions. Please see the <a href="file.COPYING.html" title="COPYING">COPYING</a> documents for more information.</p></div></div>
|
231
|
+
|
232
|
+
<div id="footer">
|
233
|
+
Generated on Mon Nov 8 16:21:43 2010 by
|
234
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
235
|
+
0.6.1 (ruby-1.8.7).
|
236
|
+
</div>
|
237
|
+
|
238
|
+
</body>
|
239
|
+
</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,13 @@
|
|
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>Documentation by YARD 0.6.1</title>
|
8
|
+
</head>
|
9
|
+
<frameset cols="20%,*">
|
10
|
+
<frame name="list" src="class_list.html" />
|
11
|
+
<frame name="main" src="index.html" />
|
12
|
+
</frameset>
|
13
|
+
</html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,239 @@
|
|
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>Documentation by YARD 0.6.1</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="_index.html" title="Index">Index</a> »
|
27
|
+
<span class="title">File: README</span>
|
28
|
+
|
29
|
+
|
30
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div id="search">
|
34
|
+
<a id="class_list_link" href="#">Class List</a>
|
35
|
+
<a id="method_list_link" href="#">Method List</a>
|
36
|
+
<a id ="file_list_link" href="#">File List</a>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="clear"></div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<iframe id="search_frame"></iframe>
|
43
|
+
|
44
|
+
<div id="content"><div id='filecontents'><h1>Magpie用于模拟支付平台的沙盒功能</h1>
|
45
|
+
|
46
|
+
<p><strong>Git</strong>: <a href="http://github.com/baya/magpie">http://github.com/baya/magpie</a></p>
|
47
|
+
|
48
|
+
<p><strong>Author</strong>: Guimin Jiang</p>
|
49
|
+
|
50
|
+
<p><strong>Copyright</strong>: 2010</p>
|
51
|
+
|
52
|
+
<p><strong>License</strong>: MIT License</p>
|
53
|
+
|
54
|
+
<p><strong>Latest Version</strong>: 0.8.8</p>
|
55
|
+
|
56
|
+
<p><strong>Release Date</strong>: 2010-11-03</p>
|
57
|
+
|
58
|
+
<h2>快搭</h2>
|
59
|
+
|
60
|
+
<pre class="code"><span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='magpie identifier id'>magpie</span>
|
61
|
+
</pre>
|
62
|
+
|
63
|
+
<p>打开终端,输入:</p>
|
64
|
+
|
65
|
+
<pre class="code">$ <span class='mag identifier id'>mag</span> <span class='magpie identifier id'>magpie</span><span class='dot token'>.</span><span class='yml identifier id'>yml</span>
|
66
|
+
</pre>
|
67
|
+
|
68
|
+
<p>magpie.yml文件用来配置你的商号信息, 假设你在支付宝(alipay)有个账号:123456, key是:aaabbb, 网银在线(chinabank)
|
69
|
+
有个账号:789789, key是:cccddd, 财付通(tenpay)有个账号:888666, key是:dddggg, 那么你在magpie.yml中这样写,</p>
|
70
|
+
|
71
|
+
<pre class="code"><span class='alipay identifier id'>alipay</span><span class='colon op'>:</span>
|
72
|
+
<span class='minus op'>-</span> <span class='lbrack token'>[</span><span class='string val'>"123456"</span><span class='comma token'>,</span> <span class='string val'>"aaabbb"</span><span class='rbrack token'>]</span>
|
73
|
+
|
74
|
+
<span class='chinabank identifier id'>chinabank</span><span class='colon op'>:</span>
|
75
|
+
<span class='minus op'>-</span> <span class='lbrack token'>[</span><span class='string val'>"789789"</span><span class='comma token'>,</span> <span class='string val'>"cccddd"</span><span class='rbrack token'>]</span>
|
76
|
+
|
77
|
+
<span class='tenpay identifier id'>tenpay</span><span class='colon op'>:</span>
|
78
|
+
<span class='minus op'>-</span> <span class='lbrack token'>[</span><span class='string val'>"888666"</span><span class='comma token'>,</span> <span class='string val'>"dddggg"</span><span class='rbrack token'>]</span>
|
79
|
+
</pre>
|
80
|
+
|
81
|
+
<p><strong>注意!</strong> 如果你输入mag命令报错, 那可能是因为你的电脑缺少一些magpie需要的gem包, 试着使用下面的命令:</p>
|
82
|
+
|
83
|
+
<pre class="code">$ <span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='rack identifier id'>rack</span>
|
84
|
+
$ <span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='hpricot identifier id'>hpricot</span>
|
85
|
+
</pre>
|
86
|
+
|
87
|
+
<p>mag命令默认会在本地9292端口启动http服务, 你可以用-p选项指定端口</p>
|
88
|
+
|
89
|
+
<pre class="code"><span class='mag identifier id'>mag</span> <span class='minus op'>-</span><span class='p identifier id'>p</span> <span class='integer val'>2010</span> <span class='magpie identifier id'>magpie</span><span class='dot token'>.</span><span class='yml identifier id'>yml</span>
|
90
|
+
</pre>
|
91
|
+
|
92
|
+
<p>mag命令的更多选项可以通过<code>mag -h</code>查看</p>
|
93
|
+
|
94
|
+
<h2>使用示例</h2>
|
95
|
+
|
96
|
+
<p>假设你正在实现支付宝支付的相关代码, 首先启动magpie服务</p>
|
97
|
+
|
98
|
+
<pre class="code">$ <span class='mag identifier id'>mag</span> <span class='magpie identifier id'>magpie</span><span class='dot token'>.</span><span class='yml identifier id'>yml</span>
|
99
|
+
</pre>
|
100
|
+
|
101
|
+
<p>上面命令的意思是:用Mongrel启动magpie服务, 服务的mode是snake, 日志文件是magpie.log, 服务的端口是9292</p>
|
102
|
+
|
103
|
+
<p>完整的命令是: mag -s mongrel -M snake -L magpie.log -p 9292 magpie.yml</p>
|
104
|
+
|
105
|
+
<p>然后在你开发的商户系统中将支付网关由支付宝的网关<code>https://www.alipay.com/cooperate/gateway.do</code></p>
|
106
|
+
|
107
|
+
<p>更改为magpie的网关<code>http://127.0.0.1:9292/alipay</code></p>
|
108
|
+
|
109
|
+
<p>如果你请求的参数出现错误, 你可以通过magpie的日志查看到详细的出错信息, 或者在浏览器上查看出错信息</p>
|
110
|
+
|
111
|
+
<p>如果你的支付请求成功, magpie将会显示一个成功订单的页面, 然后你点击购买就可以给你自己的商户系统发送</p>
|
112
|
+
|
113
|
+
<p>购买成功的通知了, 你需要确保你商户系统的<code>notify_url</code>是可用的,magpie将通过这个<code>notify_url</code>将支付</p>
|
114
|
+
|
115
|
+
<p>成功的通知发到你的商户系统中, 这样你就可以避免去支付宝的页面进行真实的支付.</p>
|
116
|
+
|
117
|
+
<p>对于网银在线(chinabank), 将支付网关由网银在线的网关<code>https://pay3.chinabank.com.cn/PayGate</code>更改为</p>
|
118
|
+
|
119
|
+
<p>magpie的网关<code>http://127.0.0.1:9292/chinabank</code></p>
|
120
|
+
|
121
|
+
<p>对于财付通(tenpay), 将支付网关由财付通的网关<code>http://service.tenpay.com/cgi-bin/v3.0/payservice.cgi</code></p>
|
122
|
+
|
123
|
+
<p>更改为magpie的网关<code>http://127.0.0.1:9292/tenpay</code></p>
|
124
|
+
|
125
|
+
<h2>Magpie启动模式</h2>
|
126
|
+
|
127
|
+
<p><strong>1. bird mode</strong></p>
|
128
|
+
|
129
|
+
<p> $ mag -M bird magpie.yml</p>
|
130
|
+
|
131
|
+
<p>写ruby代码的人一般都是测试控, 这个bird模式主要是为他们提供.以支付宝(alipay)为例, 开发者将支付</p>
|
132
|
+
|
133
|
+
<p>参数提交到http://127.0.0.1:9292/alipay, 出错信息将以xml格式反馈给开发者,如果提交成功, 成功</p>
|
134
|
+
|
135
|
+
<p>信息同样以xml格式反馈给开发者, 同时magpie会自动将购买成功的消息通知到开发者的商户系统中,并返回</p>
|
136
|
+
|
137
|
+
<p>商户系统的处理结果.</p>
|
138
|
+
|
139
|
+
<p>在bird模式下,开发者需要确保magpie.yml中的商号信息是真实有效的,也就是在alipay上实际注册过的,因为</p>
|
140
|
+
|
141
|
+
<p>magpie在bird模式下会将开发者提交的支付参数往alipay的实际网关<code>https://www.alipay.com/cooperate/gateway.do</code></p>
|
142
|
+
|
143
|
+
<p>发送一次.</p>
|
144
|
+
|
145
|
+
<p>网银在线(chinabank), 财付通(tenpay)的模拟情况与之类似.</p>
|
146
|
+
|
147
|
+
<p><strong>2. snake mode</strong></p>
|
148
|
+
|
149
|
+
<p> $ mag -M snake</p>
|
150
|
+
|
151
|
+
<p>这是magpie默认的启动模式,以支付宝(alipay)为例, 开发者将支付参数提交到http://127.0.0.1:9292/alipay</p>
|
152
|
+
|
153
|
+
<p>出错信息以普通html页面显示,如果提交成功, 开发者将看到订单的详细信息, 然后开发者可以点击支付按钮进行支付</p>
|
154
|
+
|
155
|
+
<p>测试, 最终magpie将返回开发者商户系统的处理结果.</p>
|
156
|
+
|
157
|
+
<p>网银在线(chinabank), 财付通(tenpay)的模拟情况与之类似</p>
|
158
|
+
|
159
|
+
<h2>其他语言开发者</h2>
|
160
|
+
|
161
|
+
<p>如果你使用其他开发语言, 比如php, java等,需要使用magpie, 必须首先搭建ruby执行环境才能运行mapgie.</p>
|
162
|
+
|
163
|
+
<p>你可以看看这篇资料<a href="http://www.javaeye.com/topic/43228">http://www.javaeye.com/topic/43228</a></p>
|
164
|
+
|
165
|
+
<p>在这篇资料,你看到"然后就可以安装rails了,"这里就可以停止了, 然后开始搭建ruby执行环境. 我鼓励你能</p>
|
166
|
+
|
167
|
+
<p>把整篇资料看完, 搭建好ruby on rails开发环境, 这样你就可以用rails开发项目了.</p>
|
168
|
+
|
169
|
+
<h2>支持的支付平台</h2>
|
170
|
+
|
171
|
+
<ul>
|
172
|
+
<li>支付宝(alipay)</li>
|
173
|
+
<li>网银在线(chinabank)</li>
|
174
|
+
<li>财付通(tenpay)</li>
|
175
|
+
</ul>
|
176
|
+
|
177
|
+
|
178
|
+
<h2>使用的项目</h2>
|
179
|
+
|
180
|
+
<ul>
|
181
|
+
<li><a href="http://piao.fantong.com">饭票</a></li>
|
182
|
+
<li><a href="http://tuan.fantong.com">饭团</a></li>
|
183
|
+
</ul>
|
184
|
+
|
185
|
+
|
186
|
+
<h2>感谢</h2>
|
187
|
+
|
188
|
+
<ul>
|
189
|
+
<li>potian <a href="http://www.javaeye.com/topic/605707">Rack编程</a>的作者</li>
|
190
|
+
<li>liuzihua liuzihua8@gmail.com</li>
|
191
|
+
</ul>
|
192
|
+
|
193
|
+
|
194
|
+
<h2>Changelog</h2>
|
195
|
+
|
196
|
+
<ul>
|
197
|
+
<li><p><strong>2010-10-20</strong>: 0.8.6.1 release</p>
|
198
|
+
|
199
|
+
<ul>
|
200
|
+
<li>支持网银在线</li>
|
201
|
+
</ul>
|
202
|
+
</li>
|
203
|
+
<li><p><strong>2010-10-20</strong>: 0.8.6.2 release</p>
|
204
|
+
|
205
|
+
<ul>
|
206
|
+
<li>改善README.md的可阅读性</li>
|
207
|
+
</ul>
|
208
|
+
</li>
|
209
|
+
<li><p><strong>2010-11-03</strong>: 0.8.8 release</p>
|
210
|
+
|
211
|
+
<ul>
|
212
|
+
<li>增加财付通的支持</li>
|
213
|
+
<li>增加snake, bird两个启动模式</li>
|
214
|
+
<li>增加日志功能</li>
|
215
|
+
</ul>
|
216
|
+
</li>
|
217
|
+
<li><p><strong>2010-11-08</strong>: 0.8.8.1 release</p>
|
218
|
+
|
219
|
+
<ul>
|
220
|
+
<li>修改一个紧急bug: 加载yml文件报无法找到YAML</li>
|
221
|
+
</ul>
|
222
|
+
</li>
|
223
|
+
</ul>
|
224
|
+
|
225
|
+
|
226
|
+
<h2>Copyright</h2>
|
227
|
+
|
228
|
+
<p>MAGPIE © 2007-2010 by <a href="mailto:kayak.jiang@gmail.com">Guimin Jiang</a>.
|
229
|
+
MAGPIE is licensed under the MIT license except for some files which come
|
230
|
+
from the RDoc/Ruby distributions. Please see the <a href="file.COPYING.html" title="COPYING">COPYING</a> documents for more information.</p></div></div>
|
231
|
+
|
232
|
+
<div id="footer">
|
233
|
+
Generated on Mon Nov 8 16:21:43 2010 by
|
234
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
235
|
+
0.6.1 (ruby-1.8.7).
|
236
|
+
</div>
|
237
|
+
|
238
|
+
</body>
|
239
|
+
</html>
|