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
29
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 25

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

Instance Method Details

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



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

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



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

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

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



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

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



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

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



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

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

#test?Boolean

Returns:

  • (Boolean)


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

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

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



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

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