Class: ActiveMerchant::Billing::NetbanxGateway

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

Constant Summary

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?, #test?

Methods included from CreditCardFormatting

#format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ NetbanxGateway

Returns a new instance of NetbanxGateway


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

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

Instance Method Details

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


39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 39

def authorize(money, payment, options={})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment, options)

  commit(:post, 'auths', post)
end

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


47
48
49
50
51
52
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 47

def capture(money, authorization, options={})
  post = {}
  add_invoice(post, money, options)

  commit(:post, "auths/#{authorization}/settlements", post)
end

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


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

def purchase(money, payment, options={})
  post = {}
  add_invoice(post, money, options)
  add_settle_with_auth(post)
  add_payment(post, payment, options)

  commit(:post, 'auths', post)
end

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


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

def refund(money, authorization, options={})
  post = {}
  add_invoice(post, money, options)

  commit(:post, "settlements/#{authorization}/refunds", post)
end

#scrub(transcript) ⇒ Object


104
105
106
107
108
109
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 104

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r(("card\\?":{\\?"cardNum\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
end

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

note: when passing options we only attempt to add the

card to the profile_id passed as the options[:customer]

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

def store(credit_card, options={})
  # locale can only be one of en_US, fr_CA, en_GB
  requires!(options, :locale)
  post = {}
  add_credit_card(post, credit_card, options)
  add_customer_data(post, options)

  commit(:post, 'customervault/v1/profiles', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)

100
101
102
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 100

def supports_scrubbing?
  true
end

#unstore(identification, options = {}) ⇒ Object


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

def unstore(identification, options = {})
  customer_id, card_id = identification.split('|')

  if card_id.nil?
    # deleting the profile
    commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}", nil)
  else
    # deleting the card from the profile
    commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil)
  end
end

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


68
69
70
71
72
73
74
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 68

def verify(credit_card, options={})
  post = {}
  add_payment(post, credit_card)
  add_order_id(post, options)

  commit(:post, 'verifications', post)
end

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


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

def void(authorization, options={})
  post = {}
  add_order_id(post, options)

  commit(:post, "auths/#{authorization}/voidauths", post)
end