GithubHelp home page GithubHelp logo

judo-ruby's Introduction

Judopay Ruby gem Build Status

The JudoPay gem provides you with ability to integrate card payments into your Ruby and Rails projects. Judo's SDK enables a faster, simpler and more secure payment experience within your app.

***Due to industry-wide security updates, versions below 2.0 of this SDK will no longer be supported after 1st Oct 2016. For more information regarding these updates, please read our blog here.***

Requirements

The Judopay gem supports Ruby 1.9.3 and above (including 2.0.x and 2.1.x).

Getting started

1. Integration

Add this line to your application's Gemfile:

gem 'judopay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install judopay
2. Setup

To start using the gem, you need to pass block with your API credentials:

	Judopay.configure do |config|
	  config.judo_id = 'your-judo-id'
	  config.api_token = 'your-token'
	  config.api_secret = 'your-secret'
	  config.use_production = false    # set to true on production, defaults to false which is the sandbox
	end
3. Make a payment

To make a new payment with full card details:

payment = Judopay::CardPayment.new(
  :judoId => 'your_judo_id',
  :your_consumer_reference => 'xxxxxxxx',
  :your_payment_reference => 'xxxxxxxx',
  :amount => 5.01,
  :currency => 'GBP',
  :card_number => '4976000000003436',
  :expiry_date => '12/20',
  :cv2 => '452',
  :card_address => {
    :line1 => '32 Edward Street',
    :town => 'Camborne',
    :postcode => 'TR14 8PA'
  },
  :consumer_location => {
    :latitude => 51.5033630,
    :longitude => -0.1276250
  }
)

You can check on the required fields and the format of each field in the Judopay REST API reference.

To send the request to the API, call:

    payment_response = payment.create
4. Check the payment result

If the payment is successful, you'll payment_response variable will contain Mash like this (see full response here):

{
  "receipt_id"=>"xxxxxxx",
  "type"=>"Payment",
  "created_at"=>"2016-09-23T09:28:47.1207+01:00",
  "result"=>"Success",
  ...
  "amount"=>"5.01",
  "currency"=>"GBP",
  ...
}

So your check code might look like this:

    if result_payment.result == 'Success'
        puts 'Payment successful'
    else
        puts 'There were some problems while processing your payment'
    end

Also important to handle different exceptions in your code. See more details in our error handling section.

Next steps

The Judopay gem supports a range of customization options. For more information on using judo see our wiki documentation.

License

See the LICENSE file for license rights and limitations (MIT).

judo-ruby's People

Contributors

bluefuton avatar ofetisov avatar jamesgoodwin avatar akakjs avatar mikehancock avatar ryanharkins avatar yonahforst avatar

Watchers

Albert Mata 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.