index.rb |
|
---|---|
ePayThe |
|
Installation |
|
Just install the gem: |
gem install epay |
or add to your Gemfile: |
gem 'epay' |
Setup |
|
Require the epay gem in your code and set your merchant number: |
require 'epay'
Epay.merchant_number = 88776655 |
If you’ve entered an API password in the ePay administration interface, set it as well: |
Epay.password = 'my_pass' |
If can set a default currency to avoid having to explicitly pass |
Epay.default_currency = :DKK |
TransactionsThe gem gives you access to the |
|
Authorize a new transaction using card data |
|
Use |
@transaction = Epay::Transaction.create(
:card_no => '3330333333333000',
:exp_year => 14,
:exp_month => 10,
:cvc => '999',
:amount => 150.0,
:order_no => 'AWESOME-INC-12346', |
Optional parameters : |
:description => 'My awesome transaction',
:group => 'Awesome transactions',
:cardholder => 'Jack Doe'
)
=> #<Epay::Transaction id: 1234, ...> |
The transaction object gives you various details about the transaction: |
@transaction.success?
=> true
@transaction.amount
=> 150.0 |
Find transaction |
|
Use |
@transaction = Epay::Transaction.find(1234567)
=> #<Epay::Transaction id: 1234567, ...> |
Capture a transaction |
|
Just call |
@transaction.capture
=> true
@transaction.captured?
=> true |
Delete transaction |
|
Use |
@transaction.delete
=> true
@transaction.deleted?
=> true |
Credit a transaction |
|
Use |
@transaction.credit(10)
=> true
@transaction.credited_amount
=> 10.0 |
Credit the remaining part of transaction: |
@transaction.credit
=> true |