This fork is for a ruby version 1.8.6 and for a Rails version < 3
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.
In vendor/plugins git clone git://github.com/brunto/system_pay.git
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
helper :'system_pay/form'
@system_pay = SystemPay.new(:amount => @order.amount_in_cents, :trans_id => @order.id)
= form_tag @system_pay.target_url do
= system_pay_hidden_fields(@system_pay)
= submit_tag "Access to the bank website"
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
This gem is inspired by Novelys paiement_cic, many thanks to the team.
Copyright (c) 2012 iMenlo Team, released under the MIT license