Class: ActiveMerchant::Billing::NetbillingGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::NetbillingGateway
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::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
#options
Instance Method Summary
collapse
-
#authorize(money, payment_source, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, credit_card, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ NetbillingGateway
constructor
A new instance of NetbillingGateway.
-
#purchase(money, payment_source, options = {}) ⇒ Object
-
#refund(money, source, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
-
#supports_scrubbing ⇒ Object
-
#test? ⇒ Boolean
-
#void(source, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of NetbillingGateway.
36
37
38
39
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 36
def initialize(options = {})
requires!(options, :login)
super
end
|
Instance Method Details
#authorize(money, payment_source, options = {}) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 41
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
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 65
def capture(money, authorization, options = {})
post = {}
add_reference(post, authorization)
commit(:capture, post)
end
|
#credit(money, credit_card, options = {}) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 78
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
53
54
55
56
57
58
59
60
61
62
63
|
# 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)
add_user_data(post, options)
commit(:purchase, post)
end
|
#refund(money, source, options = {}) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 71
def refund(money, source, options = {})
post = {}
add_amount(post, money)
add_reference(post, source)
commit(:refund, post)
end
|
#scrub(transcript) ⇒ Object
114
115
116
117
118
119
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 114
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
96
97
98
99
100
101
102
103
104
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 96
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_scrubbing ⇒ Object
110
111
112
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 110
def supports_scrubbing
true
end
|
#test? ⇒ Boolean
106
107
108
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 106
def test?
(@options[:login] == TEST_LOGIN || super)
end
|
#void(source, options = {}) ⇒ Object
90
91
92
93
94
|
# File 'lib/active_merchant/billing/gateways/netbilling.rb', line 90
def void(source, options = {})
post = {}
add_reference(post, source)
commit(:void, post)
end
|