Giter Site home page Giter Site logo

realex's Introduction

RealEx library for interfacing with www.realexpayments.com

This is a Ruby library for interfacing with the RealEx API ( http://www.realexpayments.com )

Installation

gem install realex

Basic Usage

require 'realex'

RealEx::Config.shared_secret = 'YOUR SHARED SECRET'
RealEx::Config.merchant_id = 'YOUR MERCHANT ID'

card = RealEx::Card.new(:number => '4***************', :cvv => '509', :expiry_date => '0822', :cardholder_name => 'Paul Campbell', :type => 'VISA')

transaction = RealEx::Authorization.new(
:customer_number => 1234, :variable_reference => 1234,
:card => card, :amount => 500, :order_id => 12345, :currency => 'EUR', :autosettle => true)

transaction.comments << "Here's a comment"

transaction.to_xml

transaction.shipping_address = RealEx::Address.new(:type => 'shipping', :code => 'Postal Code', :country => 'Country')

transaction.billing_address = RealEx::Address.new(:type => 'billing', :code => 'Postal Code', :country => 'Country')

transaction.authorize!

Manual Request Type

transaction.manual = true
transaction.authcode = '12345'

transaction.authorize!

Recurring payments

payer = RealEx::Recurring::Payer.new(:type => 'Business', :reference => 'boom', :title => 'Mr.', :firstname => 'Paul', :lastname => 'Campbell', :company => 'Hyper Tiny')

payer.address = RealEx::Address.new(:street => '64 Dame Street', :city => 'Dublin', :county => 'Dublin', :post_code => 'Dublin 3', :country => 'Ireland', :country_code => 'IE', :phone_numbers => { :home => '1234', :work => '1234', :fax => '1234', :mobile => '1234'}, :email => '[email protected]')

payer.save!

recurring_card = RealEx::Recurring::Card.new(:payer => payer, :reference => 'paulcampbell')

recurring_card.card = card

recurring_card.save!

transaction = RealEx::Recurring::Authorization.new(:amount => 500, :payer => payer, :order_id => order_id, :reference => 'paulcampbell')

transaction.authorize!

Cancelling a recurring payment card

recurring_card = RealEx::Recurring::Card.new(:payer => payer, :reference => 'paulcampbell')

recurring_card.destroy!

realex's People

Contributors

brianewing avatar georgepalmer avatar paulca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

realex's Issues

Using a proxy

Hi I need to use a proxy address during connection with Realex, I buy a static ip address with Heroku to use otherwise Heroku provides different ip's all the time making them impossible to whitelist with Realex.

Iv'e forked the gem and the HTTP connection now looks like:

h = Net::HTTP.new('epage.payandshop.com', 443, 'http://54.75.227.164', 80)
h.use_ssl = true
response = h.request_post(url, xml)

However all I get from response is - Net::HTTPServerException: 403 "Forbidden" and when I remove use_ssl, repsonse hash is empty.

Any thoughts on this? Really stuck on it.

Add certificate verification

Hi,

In the project that I currently maintain the Realex code has been changed to support verification of the target certificated when using SSL.

Do you think this a good addition to Realex. I want to replace my local plugin with an official Realex gem, but need to address these local changes that were made.

Here is the change in client.rb:

      def call(url,xml)
        h = Net::HTTP.new('epage.payandshop.com', 443)
        h.use_ssl = true

        root_ca = File.join(File.dirname(__FILE__), 'cacert.pem')
        if File.exist?(root_ca)
          h.ca_file = root_ca
          h.verify_mode = OpenSSL::SSL::VERIFY_PEER
          h.verify_depth = 5
        else
          h.verify_mode = OpenSSL::SSL::VERIFY_NONE
          puts "Warning: no cacert.pem file found. Target host will be not checked."
        end
        response = h.request_post(url, xml)
        result = Nokogiri.XML(response.body)
        result
      end

The cacert.pem file is stated to be taken from:

cacert.pem taken from http://curl.haxx.se/docs/caextract.html
this source have been used by active_mechant https://github.com/Shopify/active_merchant/blob/master/lib/certs/cacert.pem

As I said, I'm migrating a Rails 3.1 project to 3.2 and want to replace the local plugins with gem versions, but because of these local changes and that this is related to the payment I'm more cautious.

Thank you for your time.

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.