Coder Social home page Coder Social logo

payex-ruby's Introduction

Build Status

Installation

This is a rudimentary Ruby binding for the PayEx API. You can install it using RubyGems.

gem install payex

Usage

This library only implements the "credit card redirect" method.

Here's how a basic credit card transaction works:

require 'payex'

PayEx.account_number = 123456789
PayEx.encryption_key = 'e4939be3910ebu194'
PayEx.default_currency = 'SEK'
#PayEx.base_url = PayEx::TEST_URL # (use this for testing)

# (an arbitrary string you can use to identify this transaction)
my_order_id = 'c704acc45a4bec4c8cd50b73fb01a7c7'

payment_url = PayEx::CreditCardRedirect.initialize_transaction!
  order_id: my_order_id,
  product_number: '123456',
  product_description: 'Brief product description',
  price: 14900, # (in cents)
  customer_ip: '12.34.56.78',
  return_url: 'http://example.com/payex-return',
  cancel_url: 'http://example.com/payex-cancel'

After redirecting the customer to payment_url, they'll enter their payment details and then PayEx will redirect them back to return_url with a parameter called orderRef appended to the query string.

The PayEx::CreditCardRedirect.complete_transaction! method takes this orderRef string as input and returns your order ID as output.

order_id, error, raw_response =
  PayEx.complete_transaction! '9b4031c19960da92d'
case error
when nil
  # The transaction succeeded (use `order_id` to proceed).
when PayEx::Error::CardDeclined
  # The transaction was declined by the credit card company.
else
  # The transaction failed (look at `raw_response` for details).
end

payex-ruby's People

Contributors

dbrock avatar oleander avatar ziaahmad avatar

Watchers

 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.