Class: MerbMerchant::Billing::NetbillingGateway

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

Constant Summary collapse

URL =
'https://secure.netbilling.com:1402/gw/sas/direct3.1'
TRANSACTIONS =
{
  :authorization       => 'A',
  :purchase            => 'S',
  :referenced_credit   => 'R',
  :unreferenced_credit => 'C',
  :capture             => 'D'
}
SUCCESS_CODES =
[ '1', 'T' ]
SUCCESS_MESSAGE =
'The transaction was approved'
FAILURE_MESSAGE =
'The transaction failed'
TEST_LOGIN =
'104901072025'

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

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 Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #ssl_get, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ NetbillingGateway

Returns a new instance of NetbillingGateway.



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

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

Instance Method Details

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



30
31
32
33
34
35
36
37
38
39
# File 'lib/merb_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, money, post)
end

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



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

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

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



41
42
43
44
45
46
47
48
49
50
# File 'lib/merb_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, money, post)
end

#test?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/merb_merchant/billing/gateways/netbilling.rb', line 58

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