Class: ActiveMerchant::Billing::UsaEpayTransactionGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/usa_epay_transaction.rb

Constant Summary collapse

TRANSACTIONS =
{
  :authorization  => 'cc:authonly',
  :purchase       => 'cc:sale',
  :capture        => 'cc:capture',
  :refund         => 'cc:refund',
  :void           => 'cc:void'
}

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ UsaEpayTransactionGateway

Returns a new instance of UsaEpayTransactionGateway.



21
22
23
24
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 21

def initialize(options = {})
  requires!(options, :login)
  super
end

Instance Method Details

#authorize(money, credit_card, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 26

def authorize(money, credit_card, options = {})
  post = {}

  add_amount(post, money)
  add_invoice(post, options)
  add_credit_card(post, credit_card)
  add_address(post, credit_card, options)
  add_customer_data(post, options)
  add_split_payments(post, options)

  commit(:authorization, post)
end

#capture(money, authorization, options = {}) ⇒ Object



52
53
54
55
56
57
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 52

def capture(money, authorization, options = {})
  post = { :refNum => authorization }

  add_amount(post, money)
  commit(:capture, post)
end

#purchase(money, credit_card, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 39

def purchase(money, credit_card, options = {})
  post = {}

  add_amount(post, money)
  add_invoice(post, options)
  add_credit_card(post, credit_card)
  add_address(post, credit_card, options)
  add_customer_data(post, options)
  add_split_payments(post, options)

  commit(:purchase, post)
end

#refund(money, authorization, options = {}) ⇒ Object



59
60
61
62
63
64
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 59

def refund(money, authorization, options = {})
  post = { :refNum => authorization }

  add_amount(post, money)
  commit(:refund, post)
end

#verify(creditcard, options = {}) ⇒ Object



66
67
68
69
70
71
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 66

def verify(creditcard, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(1, creditcard, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object



73
74
75
76
# File 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb', line 73

def void(authorization, options = {})
  post = { :refNum => authorization }
  commit(:void, post)
end