GithubHelp home page GithubHelp logo

activemerchant-clickandbuy's Introduction

Active Merchant ClickandBuy gateway

This gem provides integration of ClickandBuy (http://www.clickandbuy.com) with Active Merchant (http://activemerchant.org).

Installation

Add this line to your application's Gemfile:

gem 'activemerchant-clickandbuy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activemerchant-clickandbuy

Usage

To use the gateway, you'll need to provide your merchant ID, project ID and secret key:

auth = {merchant_id: 'foo', project_id: 'bar', secret_key: 'baz'}
gateway = ActiveMerchant::Billing::ClickandBuyGateway.new(auth)

Now you can initiate a transaction at ClickandBuy:

amount = Money.new(1000, 'EUR')
options = {
  success_url: 'https://www.your-site.com/callback/success', # where to redirect the user on success
  failure_url: 'https://www.your-site.com/callback/failure', # where to redirect the user on failure
  order_id: 123,                                             # your unique order identifier
  ip: '1.2.3.4',                                             # user's IP address
  order_description: 'ACME Earthquake Pills',                # what the user is buying
  locale: 'en',                                              # user's locale ('en' or 'de')
  success_expiration: 1439                                   # (optional) how many minutes to wait for success
}
response = gateway.setup_purchase(amount, options)

The response hash will contain amongst other keys two important ones: transactionID and redirectURL. The transactionID identifies the transaction at ClickandBuy, make sure you store it together with your order. The redirectURL is where you redirect the user so that they can confirm the purchase.

After a user lands on success_url, you can check whether or not the transaction had been confirmed:

transaction = gateway.check_status(transaction_id)

The transaction variable is a hash containing the response details, amongst others a transactionStatus key.

Running specs

Copy spec/support/clickand_buy.yml.example to spec/support/clickand_buy.yml. Now run:

bundle exec rspec

By default, only "fast" specs will be running (the API will not be hit). In order to be able to execute remote specs, populate the clickand_buy.yml file with your staging account's authentication credentials. To run the remote specs, run the following:

bundle exec rspec --tag remote

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

activemerchant-clickandbuy's People

Contributors

exviva avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.