Skip to content

SystemPay is a gem to ease credit card payment with Natixis Paiements / CyberplusPaiement (Credit du Nord) bank system. It's a Ruby on Rails port of the connexion kits published by the bank.

Notifications You must be signed in to change notification settings

brunto/system_pay

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This fork is for a ruby version 1.8.6 and for a Rails version < 3

SystemPay

SystemPay is a gem to ease credit card payment with Natixis Paiements / CyberplusPaiement (Banque Populaire) bank system. It's a Ruby on Rails port of the connexion kits published by the bank.

  • Gem Homepage : site
  • Cyberplus SystemPay documentation : site

INSTALL

In vendor/plugins git clone git://github.com/brunto/system_pay.git

USAGE

in environment.rb :

Add 'system_pay' in config.plugins

And add this :

# Your vads_site_id
SystemPay.vads_site_id = '654927625'
if ENV['RAILS_ENV'] == 'production'
  # Your production certificat
  SystemPay.certificat = '7193156219823756'
  # Set the production mode
  SystemPay.vads_ctx_mode = 'PRODUCTION'
else
  # Your test certificat
  SystemPay.certificat = '9123456299120752'
end

in order controller :

helper :'system_pay/form'
@system_pay = SystemPay.new(:amount => @order.amount_in_cents, :trans_id => @order.id)

in order view :

= form_tag @system_pay.target_url do
  = system_pay_hidden_fields(@system_pay)
  = submit_tag "Access to the bank website"

in a controller for call back from the bank :

class OrderTransactionsController < ApplicationController

  protect_from_forgery :except => [:bank_callback]

  def bank_callback
    @system_pay = SystemPay.new(params)
    if @system_pay.valid_signature?(params[:signature])

      order_transaction = OrderTransaction.find_by_reference params[:reference], :last
      order = order_transaction.order

      return_code = params['vads_result']

      if return_code == "Annulation"
        order.cancel!
        order.update_attribute :description, "Paiement refusé par la banque."

      elsif return_code == "payetest"
        order.pay!
        order.update_attribute :description, "TEST accepté par la banque."
        order_transaction.update_attribute :test, true

      elsif return_code == "00"
        order.pay!
        order.update_attribute :description, "Paiement accepté par la banque."
        order_transaction.update_attribute :test, false
      end

      order_transaction.update_attribute :success, true

      receipt = "0"
    else
      order.transaction_declined!
      order.update_attribute :description, "Document Falsifie."
      order_transaction.update_attribute :success, false

      receipt = "1\n#{PaiementCic.mac_string}"
    end
    render :text => "Pragma: no-cache\nContent-type: text/plain\n\nversion=2\ncdr=#{receipt}"
  end

Thanks

This gem is inspired by Novelys paiement_cic, many thanks to the team.

License

Copyright (c) 2012 iMenlo Team, released under the MIT license

About

SystemPay is a gem to ease credit card payment with Natixis Paiements / CyberplusPaiement (Credit du Nord) bank system. It's a Ruby on Rails port of the connexion kits published by the bank.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%