/bigcharger

A lightweight Ruby library for interfacing with the eWAY Token Payments API.

Primary LanguageRubyApache License 2.0Apache-2.0

BigCharger - eWAY Token Payments Client

IMPORTANT NOTE: This repository is no longer actively maintained.

The idea of this project is to build a lightweight Ruby library for interfacing with the eWAY Token Payments API.

Documentation: http://www.rubydoc.info/gems/bigcharger

Installation

gem install bigcharger

Setup

client = BigCharger.new(
  '87654321', 
  'test@eway.com.au', 
  'test123'
)

Create a new customer

client.create_customer({
  'CustomerRef' => 'Test 123',
  'Title' => 'Mr.',
  'FirstName' => 'Jo',
  'LastName' => 'Smith',
  'Company' => 'company',
  'JobDesc' => 'Analyst',
  'Email' => 'test@eway.com.au',
  'Address' => '15 Dundas Court',
  'Suburb' => 'phillip',
  'State' => 'act',
  'PostCode' => '2606',
  'Country' => 'au',
  'Phone' => '02111111111',
  'Mobile' => '04111111111',
  'Fax' => '111122222',
  'URL' => 'http://eway.com.au',
  'Comments' => 'Comments',
  'CCNameOnCard' => 'Jo Smith',
  'CCNumber' => '444433XXXXXX1111',
  'CCExpiryMonth' => '08',
  'CCExpiryYear' => '15'
})
# => "9876543211000" (managedCustomerID of new customer)

Process a payment

client.process_payment(
  9876543211000,
  1000,
  'INV-80251',
  'Pants alteration'
)
# => {
#   'ewayTrxnError' => '00,Transaction Approved(Test Gateway)', 
#   'ewayTrxnStatus' => 'True', 
#   'ewayTrxnNumber' => '10498', 
#   'ewayReturnAmount' => '1000', 
#   'ewayAuthCode' => '123456'
# }

# Alternatively, improve security by requiring a CVN/CVV
client.process_payment_with_cvn(
  9876543211000,
  1000,
  '123',
  'INV-80251',
  'Pants alteration'
)

Find a customer

# Find a customer using the managed customer ID
client.query_customer(9876543211000)
# => {
#   'ManagedCustomerID' => '9876543211000', 
#   'CustomerRef' => 'Test 123', 
#   'CustomerTitle' => 'Mr.', 
#   'CustomerFirstName' => 'Jo', 
#   'CustomerLastName' => 'Smith', 
#   'CustomerCompany' => 'company', 
#   'CustomerJobDesc' => nil, 
#   'CustomerEmail' => 'test@eway.com.au', 
#   'CustomerAddress' => '15 Dundas Court', 
#   'CustomerSuburb' => 'phillip', 
#   'CustomerState' => 'act', 
#   'CustomerPostCode' => '2606', 
#   'CustomerCountry' => 'au', 
#   'CustomerPhone1' => '02111111111', 
#   'CustomerPhone2' => '04111111111', 
#   'CustomerFax' => '111122222', 
#   'CustomerURL' => 'http://eway.com.au', 
#   'CustomerComments' => 'Comments', 
#   'CCName' => 'Jo Smith', 
#   'CCNumber' => '444433XXXXXX1111', 
#   'CCExpiryMonth' => '08', 
#   'CCExpiryYear' => '15'
# }

# Find a customer using the reference you supplied when you created the
# customer
client.query_customer_by_reference('Test 123')

Get list of payments for a customer

client.query_payment(9876543211000)
# => [
#   {
#     'TotalAmount' => '1000', 
#     'Result' => '1', 
#     'ResponseText' => 'Approved', 
#     'TransactionDate' => '2012-02-20T00:00:00+11:00', 
#     'ewayTrxnNumber' => '1'
#   }, 
#   {
#     'TotalAmount' => '1008', 
#     'Result' => '1', 
#     'ResponseText' => 'Approved', 
#     'TransactionDate' => '2012-02-20T00:00:00+11:00', 
#     'ewayTrxnNumber' => '2'
#   }
# ]

Update a customer

client.update_customer(
  9876543211000,
  {
    'CCNameOnCard' => 'Jo Smith',
    'CCNumber' => '444433XXXXXX2222',
    'CCExpiryMonth' => '06',
    'CCExpiryYear' => '22'
  }
)
# => true