This repository has been archived by the owner on Mar 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
52 lines (37 loc) · 1.58 KB
/
README
1
2
3
4
5
6
7
8
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Tenpay
======
A Ruby on Rails plugin for Tenpay (Online pay solution from Tencent).
Install
=======
$ script/plugin install git://github.com/yzhang/tenpay.git
Charge
=======
1. After you installing the plugin, there should be a tenpay.yml
in your RAILS_ENV/config dir, you should edit that file and set
your spid and key you got from Tencent.
2. To start a transaction, you will need create a new Tenpay::Request
instance, for example:
@request = Tenpay::Request.new('test product', # Product name
1, # Order id, should be unique
4500, # Product price, in cent
'http://return', # Url user will return after the transaction, support Get/Post
request.remote_ip, # Use for ip validation, ignored in development mode.
'attach data') # Attach data, will be pass to the return url.
redirect_to @request.url
This will redirect user to pay page.
3. After user finishing the paying, the return url will be called, below
code will demo if the request is legal and user finish the paying.
@response = Tenpay::Response.new(params)
if @response.successful?
# paying is successful
else
# it's failed
end
Query
========
If you want to query if user has paid for an order, use below interface:
@query = Tenpay::Query.new(1, # Order id
Time.now) # Order date
@query.response.successful? # true => paid, false => unpaid.
It's all, feedbacks are always welcome, feel free to contact me at zhangyuanyi@gmail.com
Copyright (c) 2009 Yuanyi Zhang, released under the MIT license