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::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, 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
52
# 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)
  add_user_data(post, options)

  commit(:authorization, post)
end

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



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

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

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



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

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)
  add_user_data(post, options)

  commit(:credit, post)
end

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



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

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)
  add_user_data(post, options)

  commit(:purchase, post)
end

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



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

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

#scrub(transcript) ⇒ Object



115
116
117
118
119
120
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 115

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((&?card_number=)[^&]*), '\1[FILTERED]').
    gsub(%r((&?card_cvv2=)[^&]*), '\1[FILTERED]')
end

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



97
98
99
100
101
102
103
104
105
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 97

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

#supports_scrubbingObject



111
112
113
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 111

def supports_scrubbing
  true
end

#test?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 107

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

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



91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 91

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