Class: ActiveMerchant::Billing::NetbanxGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::NetbanxGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/netbanx.rb
Constant Summary
collapse
- AVS_CODE_CONVERTER =
{
'MATCH' => 'X',
'MATCH_ADDRESS_ONLY' => 'A',
'MATCH_ZIP_ONLY' => 'Z',
'NO_MATCH' => 'N',
'NOT_PROCESSED' => 'U',
'UNKNOWN' => 'Q'
}
- CVV_CODE_CONVERTER =
{
'MATCH' => 'M',
'NO_MATCH' => 'N',
'NOT_PROCESSED' => 'P',
'UNKNOWN' => 'U'
}
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, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#get_settlement(authorization) ⇒ Object
-
#initialize(options = {}) ⇒ NetbanxGateway
constructor
A new instance of NetbanxGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
note: when passing options we only attempt to add the card to the profile_id passed as the options.
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(identification, options = {}) ⇒ Object
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, 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?, #test?
#format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of NetbanxGateway.
41
42
43
44
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 41
def initialize(options = {})
requires!(options, :account_number, :api_key)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 60
def authorize(money, payment, options = {})
verification_response = verify(payment, options)
return verification_response if verification_response.message != 'OK'
post = {}
add_invoice(post, money, options)
add_payment(post, payment, options)
add_customer_detail_data(post, options)
commit(:post, 'auths', post)
end
|
#capture(money, authorization, options = {}) ⇒ Object
73
74
75
76
77
78
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 73
def capture(money, authorization, options = {})
post = {}
add_invoice(post, money, options)
commit(:post, "auths/#{authorization}/settlements", post)
end
|
#get_settlement(authorization) ⇒ Object
102
103
104
105
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 102
def get_settlement(authorization)
post = {}
commit(:get, "settlements/#{authorization}", post)
end
|
#purchase(money, payment, options = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 46
def purchase(money, payment, options = {})
verification_response = verify(payment, options)
return verification_response if verification_response.message != 'OK'
post = {}
add_invoice(post, money, options)
add_settle_with_auth(post)
add_payment(post, payment, options)
add_customer_detail_data(post, options)
commit(:post, 'auths', post)
end
|
#refund(money, authorization, options = {}) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 80
def refund(money, authorization, options = {})
settlement_data = get_settlement(authorization)
return settlement_data if settlement_data.message != 'OK'
post = {}
if settlement_data.params['status'] == 'PENDING' && money == settlement_data.params['amount']
post[:status] = 'CANCELLED'
commit(:put, "settlements/#{authorization}", post)
elsif settlement_data.params['status'] == 'PENDING' && (money < settlement_data.params['amount'] || money > settlement_data.params['amount'])
return Response.new(false, 'Transaction not settled. Either do a full refund or try partial refund after settlement.')
else
add_invoice(post, money, options)
post[:merchantRefNum] = SecureRandom.uuid
commit(:post, "settlements/#{authorization}/refunds", post)
end
end
|
#scrub(transcript) ⇒ Object
150
151
152
153
154
155
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 150
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]
124
125
126
127
128
129
130
131
132
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 124
def store(credit_card, options = {})
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
146
147
148
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 146
def supports_scrubbing?
true
end
|
#unstore(identification, options = {}) ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 134
def unstore(identification, options = {})
customer_id, card_id = identification.split('|')
if card_id.nil?
commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}", nil)
else
commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil)
end
end
|
#verify(credit_card, options = {}) ⇒ Object
114
115
116
117
118
119
120
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 114
def verify(credit_card, options = {})
post = {}
add_payment(post, credit_card, options)
add_order_id(post, options)
commit(:post, 'verifications', post)
end
|
#void(authorization, options = {}) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/active_merchant/billing/gateways/netbanx.rb', line 107
def void(authorization, options = {})
post = {}
add_order_id(post, options)
commit(:post, "auths/#{authorization}/voidauths", post)
end
|