Skip to content
This repository has been archived by the owner on Dec 2, 2018. It is now read-only.

pepijn/omni_kassa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Easier Rabobank OmniKassa payments

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages