Project

omni_kassa

0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Easier Rabobank OmniKassa payments
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0.9.0
 Project Readme

OmniKassa

Gem Version Build Status Dependency Status Code Climate

Easier Rabobank OmniKassa payments. Once extracted from www.studysquare.nl. RDocs.

Installation

Supports Ruby 1.9.2, 1.9.3 and 2.0.0. Add to your Gemfile:

gem 'omni_kassa'

Run bundle and add your personal configuration. The example below is the official test configuration.

OmniKassa.config(
  secret_key:            '002020000000001_KEY1',
  merchant_id:           '002020000000001',
  key_version:           1,
  currency_code:         978, # Euro
  customer_language:     :nl,
  transaction_reference: lambda { |order_id| "omnikassatest#{Time.now.to_i}" },
  url: 'https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet'
)

Using Rails? Use different OmniKassa configurations by adding them in their respective config/environments/{development,test,production}.rb environment configuration files.

Usage

Request

The example below uses an OrdersController#create action to create an order from params[:order] and sets up the OmniKassa request.

class OrdersController
  def create
    # Save order in database
    @order = Order.create(params[:order])

    # OmniKassa preparation
    omnikassa                   = OmniKassa::Request.new
    omnikassa.order_id          = @order.id
    omnikassa.amount            = @order.amount
    omnikassa.normal_return_url = payments_url

    # Redirects user to OmniKassa
    render text: omnikassa.perform
  end
end

Response

class PaymentsController
  def create
    response = OmniKassa::Response.new(params)

    @order = Order.find(response.order_id)
    
    return if response.pending? # Payment is pending; serve an explanation to the customer

    if response.successful?
      @order.paid = true
      @order.save

      redirect_to root_url, success: "Payment succeeded"
    else
      redirect_to root_url, alert: "Payment failed"
    end
  end
end