Class: ActiveMerchant::Billing::NetbillingGateway

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

Constant Summary collapse

TRANSACTIONS =
{
  :authorization => 'A',
  :purchase      => 'S',
  :refund        => 'R',
  :credit        => 'C',
  :capture       => 'D',
  :void          => 'U'
}
SUCCESS_CODES =
[ '1', 'T' ]
SUCCESS_MESSAGE =
'The transaction was approved'
FAILURE_MESSAGE =
'The transaction failed'
TEST_LOGIN =
'104901072025'

Constants inherited from Gateway

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

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ NetbillingGateway

Returns a new instance of NetbillingGateway.



25
26
27
28
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 25

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

Instance Method Details

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



30
31
32
33
34
35
36
37
38
39
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 30

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)

  commit(:authorization, post)
end

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



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

def capture(money, authorization, options = {})
  post = {}
  add_reference(post, authorization)
  commit(:capture, post)
end

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



65
66
67
68
69
70
71
72
73
74
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 65

def credit(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)

  commit(:credit, post)
end

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



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

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)

  commit(:purchase, post)
end

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



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

def refund(money, source, options = {})
  post = {}
  add_amount(post, money)
  add_reference(post, source)
  commit(:refund, post)
end

#test?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 82

def test?
  (@options[:login] == TEST_LOGIN || super)
end

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



76
77
78
79
80
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 76

def void(source, options = {})
  post = {}
  add_reference(post, source)
  commit(:void, post)
end