0.0
No commit activity in last 3 years
No release in over 3 years
Shoppe module for handling Paytrail integration
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0

Runtime

< 2, > 1
 Project Readme

Paytrail module for Shoppe

Build Status Code Climate Test Coverage Gem Version

Integrate Paytrail to your Shoppe application, with ease.

Installation

Add this line to your application's Gemfile:

gem 'shoppe-paytrail'

And then execute:

$ bundle install

Example Payment handling

class PaymentsController < ApplicationController
  before_action(only: [:paytrail, :paytrail_ok, :paytrail_error, :paytrail_notification]) { Shoppe::Paytrail.configure }

  def paytrail
    redirect_to current_order.redirect_to_paytrail(payments_paytrail_ok_url, payments_paytrail_error_url, payments_paytrail_notification_url)
  end

  def paytrail_ok
    redirect_to root_path and return unless current_order.confirming?

    paytrail_order = Shoppe::Order.find(params['ORDER_NUMBER'])
    paytrail_order.handle_paytrail_payment(params, false)
    paytrail_order.confirm!

    clear_current_order

    respond_to do |wants|
      wants.html { redirect_to root_path, notice: 'Your order has now been completed!' }
    end
  rescue => e
    redirect_to root_path, alert: 'There was an error while completing the payment'
  end

  def paytrail_error
    redirect_to root_path, alert: 'The payment process was aborted'
  end

  def paytrail_notification
    paytrail_order = Shoppe::Order.find(params['ORDER_NUMBER'])
    paytrail_order.handle_paytrail_payment(params, true)
    render :text => ""
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/anakinj/shoppe-paytrail.

License

The gem is available as open source under the terms of the MIT License.