Class: ActiveMerchant::Billing::NmiGateway

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

Constant Summary collapse

DUP_WINDOW_DEPRECATION_MESSAGE =
'The class-level duplicate_window variable is deprecated. Please use the :dup_seconds transaction option instead.'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ NmiGateway

Returns a new instance of NmiGateway.



25
26
27
28
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 25

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

Class Method Details

.duplicate_windowObject



21
22
23
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 21

def self.duplicate_window
  instance_variable_defined?(:@dup_seconds) ? @dup_seconds : nil
end

.duplicate_window=(seconds) ⇒ Object



16
17
18
19
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 16

def self.duplicate_window=(seconds)
  ActiveMerchant.deprecated(DUP_WINDOW_DEPRECATION_MESSAGE)
  @dup_seconds = seconds
end

Instance Method Details

#authorize(amount, payment_method, options = {}) ⇒ Object



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

def authorize(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method, options)
  add_customer_data(post, options)
  add_vendor_data(post, options)
  add_merchant_defined_fields(post, options)

  commit('auth', post)
end

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



52
53
54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 52

def capture(amount, authorization, options={})
  post = {}
  add_invoice(post, amount, options)
  add_reference(post, authorization)
  add_merchant_defined_fields(post, options)

  commit('capture', post)
end

#credit(amount, payment_method, options = {}) ⇒ Object



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

def credit(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method, options)
  add_customer_data(post, options)
  add_vendor_data(post, options)

  commit('credit', post)
end

#purchase(amount, payment_method, options = {}) ⇒ Object



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

def purchase(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method, options)
  add_customer_data(post, options)
  add_vendor_data(post, options)
  add_merchant_defined_fields(post, options)

  commit('sale', post)
end

#refund(amount, authorization, options = {}) ⇒ Object



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

def refund(amount, authorization, options={})
  post = {}
  add_invoice(post, amount, options)
  add_reference(post, authorization)
  add_payment_type(post, authorization)

  commit('refund', post)
end

#scrub(transcript) ⇒ Object



118
119
120
121
122
123
124
125
126
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 118

def scrub(transcript)
  transcript.
    gsub(%r((password=)\w+), '\1[FILTERED]').
    gsub(%r((ccnumber=)\d+), '\1[FILTERED]').
    gsub(%r((cvv=)\d+), '\1[FILTERED]').
    gsub(%r((checkaba=)\d+), '\1[FILTERED]').
    gsub(%r((checkaccount=)\d+), '\1[FILTERED]').
    gsub(%r((cryptogram=)[^&]+(&?)), '\1[FILTERED]\2')
end

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



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

def store(payment_method, options = {})
  post = {}
  add_invoice(post, nil, options)
  add_payment_method(post, payment_method, options)
  add_customer_data(post, options)
  add_vendor_data(post, options)
  add_merchant_defined_fields(post, options)

  commit('add_customer', post)
end

#supports_network_tokenization?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 128

def supports_network_tokenization?
  true
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 114

def supports_scrubbing?
  true
end

#verify(payment_method, options = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 88

def verify(payment_method, options={})
  post = {}
  add_payment_method(post, payment_method, options)
  add_customer_data(post, options)
  add_vendor_data(post, options)
  add_merchant_defined_fields(post, options)

  commit('validate', post)
end

#verify_credentialsObject



109
110
111
112
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 109

def verify_credentials
  response = void('0')
  response.message != 'Authentication Failed'
end

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



61
62
63
64
65
66
67
# File 'lib/active_merchant/billing/gateways/nmi.rb', line 61

def void(authorization, options={})
  post = {}
  add_reference(post, authorization)
  add_payment_type(post, authorization)

  commit('void', post)
end