0.0
No commit activity in last 3 years
No release in over 3 years
Payment strategy for Alipay(https://alipay.com) base on Midpay Middleware.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

>= 0
 Project Readme

Midpay::Alipay

Code Climate

Payment strategy for Alipay(支付宝 https://alipay.com) base on Midpay Middleware.

Installation

Add this line to your application's Gemfile:

gem 'midpay_alipay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install midpay-alipay

Usage

In your application initialize

  require 'midpay_alipay'
  use Midpay::Strategies::Alipay, APPID, APPSECRET, :request_params_proc => {|params| 
    order = Order.find(params['order_id'])
    order.to_alipay_params
  }

In your routes:

  map '/midpay/alipay/callback' => 'payment#callback' 

Type following URL in your browser

  http://DOMAIN.COM/midpay/alipay?order_id=123

And your broswer will navigate to Alipay Casher page,

Then, handle the callback phase in your controller

  def callback
    strategy = request.env['midpay.strategy']
    callback_data = request.env['midpay.callback'] # A Midpay::PaymentInfo object
    if callback_data.success?
      order = Order.find(callback_data.raw_data[:out_trade_no])
      order.paid!
    end

    p callback_data.to_hash
    p callback_data.to_json
    # ....
  end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request