This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Rails Integration
cesario edited this page Aug 13, 2010
·
4 revisions
Payme isn’t dependent of rails. It integrates well with it though (both 2.3 and 3).
Here’s how I’ve integrated it in my case.
Create a new initializer config/initializers/payme.rb
With the following :
Payme::Config.set_config('config/payme.yml', Rails.env)
(Rails >= 2.3.6 syntax)
It’ll load your payme’s config file when the application starts (you must restart your server every time you change that configuration).
Create your config file config/payme.yml
test:
merchant_id: '014213245611111'
bin_path: <%= Rails.root %>/lib/payme
pathfile: <%= Rails.root %>/lib/payme/param/pathfile
development:
merchant_id: '014213245611111'
bin_path: <%= Rails.root %>/lib/payme
pathfile: <%= Rails.root %>/lib/payme/param/pathfile
production:
merchant_id: 'provided_by_your_bank'
bin_path: <%= Rails.root %>/lib/payme
pathfile: <%= Rails.root %>/lib/payme/param/pathfile
Then create a new controller which will handle your payments. Mine looks like this :
class PaymentsController < ApplicationController
#
# Display the payment page
#
def new
@amount = 1500 # Replace this with the real amount
@request = Payme::Request.new(@amount).launch
end
#
# After the payment, the user is redirected here
#
def create
@response = Payme::Response.new(params[:DATA]).launch
end
end
And you have the request and response, which you can use in your views to display whatever you want !