Coder Social home page Coder Social logo

omni_kassa's Introduction

OmniKassa

Gem Version Build Status Dependency Status Code Climate

Easier Rabobank OmniKassa payments. 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
  url: 'https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet',
  transaction_reference: lambda { |order_id| "omnikassatest#{Time.now.to_i}" },
  customer_language: :nl
)

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.payed = true
      @order.save

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

omni_kassa's People

Contributors

koenpunt avatar pepijn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.