Class: ActiveMerchant::Billing::AuthorizeNetGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::AuthorizeNetGateway
show all
- Includes:
- Empty
- Defined in:
- lib/active_merchant/billing/gateways/authorize_net.rb
Constant Summary
collapse
- TRANSACTION_ALREADY_ACTIONED =
%w(310 311)
- CARD_CODE_ERRORS =
%w(N S)
- AVS_ERRORS =
%w(A E N R W Z)
- AVS_REASON_CODES =
%w(27 45)
- TRACKS =
{
1 => /^%(?<format_code>.)(?<pan>[\d]{1,19}+)\^(?<name>.{2,26})\^(?<expiration>[\d]{0,4}|\^)(?<service_code>[\d]{0,3}|\^)(?<discretionary_data>.*)\?\Z/,
2 => /\A;(?<pan>[\d]{1,19}+)=(?<expiration>[\d]{0,4}|=)(?<service_code>[\d]{0,3}|=)(?<discretionary_data>.*)\?\Z/
}.freeze
- APPLE_PAY_DATA_DESCRIPTOR =
"COMMON.APPLE.INAPP.PAYMENT"
Constants inherited
from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
#options
Instance Method Summary
collapse
-
#authorize(amount, payment, options = {}) ⇒ Object
-
#capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ AuthorizeNetGateway
constructor
A new instance of AuthorizeNetGateway.
-
#purchase(amount, payment, options = {}) ⇒ Object
-
#refund(amount, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, non_fractional_currency?, #supported_countries, supported_countries, supported_countries=, supports?, #test?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of AuthorizeNetGateway.
35
36
37
38
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 35
def initialize(options={})
requires!(options, :login, :password)
super
end
|
Instance Method Details
#authorize(amount, payment, options = {}) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 57
def authorize(amount, payment, options={})
commit("AUTH_ONLY") do |xml|
add_order_id(xml, options)
xml.transactionRequest do
xml.transactionType('authOnlyTransaction')
xml.amount(amount(amount))
add_payment_source(xml, payment)
add_invoice(xml, options)
add_customer_data(xml, payment, options)
add_settings(xml, payment, options)
add_user_fields(xml, amount, options)
end
end
end
|
#capture(amount, authorization, options = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 73
def capture(amount, authorization, options={})
commit("PRIOR_AUTH_CAPTURE") do |xml|
add_order_id(xml, options)
xml.transactionRequest do
xml.transactionType('priorAuthCaptureTransaction')
xml.amount(amount(amount))
xml.refTransId(split_authorization(authorization)[0])
add_invoice(xml, options)
add_user_fields(xml, amount, options)
end
end
end
|
#purchase(amount, payment, options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 40
def purchase(amount, payment, options = {})
commit("AUTH_CAPTURE") do |xml|
add_order_id(xml, options)
xml.transactionRequest do
xml.transactionType('authCaptureTransaction')
xml.amount(amount(amount))
add_payment_source(xml, payment)
add_invoice(xml, options)
add_customer_data(xml, payment, options)
add_retail_data(xml, payment)
add_settings(xml, payment, options)
add_user_fields(xml, amount, options)
end
end
end
|
#refund(amount, authorization, options = {}) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 87
def refund(amount, authorization, options={})
transaction_id, card_number = split_authorization(authorization)
commit("CREDIT") do |xml|
xml.transactionRequest do
xml.transactionType('refundTransaction')
xml.amount(amount.nil? ? 0 : amount(amount))
xml.payment do
xml.creditCard do
xml.cardNumber(card_number || options[:card_number])
xml.expirationDate('XXXX')
end
end
xml.refTransId(transaction_id)
add_customer_data(xml, nil, options)
add_user_fields(xml, amount, options)
end
end
end
|
#scrub(transcript) ⇒ Object
130
131
132
133
134
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 130
def scrub(transcript)
transcript.
gsub(%r((<cardNumber>).+(</cardNumber>)), '\1[FILTERED]\2').
gsub(%r((<cardCode>).+(</cardCode>)), '\1[FILTERED]\2')
end
|
#supports_scrubbing? ⇒ Boolean
126
127
128
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 126
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
119
120
121
122
123
124
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 119
def verify(credit_card, options = {})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(100, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
|
#void(authorization, options = {}) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 107
def void(authorization, options={})
commit("VOID") do |xml|
add_order_id(xml, options)
xml.transactionRequest do
xml.transactionType('voidTransaction')
xml.refTransId(split_authorization(authorization)[0])
add_user_fields(xml, nil, options)
end
end
end
|