Class: ActiveMerchant::Billing::NetbillingGateway

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

Overview

To perform PCI Compliant Repeat Billing

 Ensure that PCI Compliant Repeat Billing is enabled on your merchant account:
  "Enable PCI Compliant Repeat Billing, Up-selling and Cross-selling" in Step 6 of the Credit Cards setup page

Instead of passing a credit_card to authorize or purchase, pass the transaction id (res.authorization)
of a past Netbilling transaction

To store billing information without performing an operation, use the 'store' method which invokes the tran_type 'Q' (Quasi) operation and returns a transaction id to use in future Repeat Billing operations

Constant Summary collapse

TRANSACTIONS =
{
  :authorization => 'A',
  :purchase      => 'S',
  :refund        => 'R',
  :credit        => 'C',
  :capture       => 'D',
  :void          => 'U',
  :quasi         => 'Q'
}
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, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

card_brand, #card_brand, #generate_unique_id, inherited, non_fractional_currency?, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ NetbillingGateway

Returns a new instance of NetbillingGateway



37
38
39
40
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 37

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

Instance Method Details

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



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

def authorize(money, payment_source, options = {})
  post = {}
  add_amount(post, money)
  add_invoice(post, options)
  add_payment_source(post, payment_source)
  add_address(post, payment_source, options)
  add_customer_data(post, options)

  commit(:authorization, post)
end

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



64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 64

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

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



77
78
79
80
81
82
83
84
85
86
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 77

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, payment_source, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 53

def purchase(money, payment_source, options = {})
  post = {}
  add_amount(post, money)
  add_invoice(post, options)
  add_payment_source(post, payment_source)
  add_address(post, payment_source, options)
  add_customer_data(post, options)

  commit(:purchase, post)
end

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



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

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

#store(credit_card, options = {}) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 94

def store(credit_card, options = {})
  post = {}
  add_amount(post, 0)
  add_payment_source(post, credit_card)
  add_address(post, credit_card, options)
  add_customer_data(post, options)

  commit(:quasi, post)
end

#test?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 104

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

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



88
89
90
91
92
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 88

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