Project

tenpay

0.01
No commit activity in last 3 years
No release in over 3 years
A Ruby wrapper of Tenpay(财付通) Payment API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies
 Project Readme
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