Class: ActiveMerchant::Billing::QuickbooksGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::QuickbooksGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/quickbooks.rb
Constant Summary
collapse
- REFRESH_URI =
'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'
- STANDARD_ERROR_CODE_MAPPING =
{
'PMT-1000' => STANDARD_ERROR_CODE[:processing_error], 'PMT-1001' => STANDARD_ERROR_CODE[:invalid_cvc], 'PMT-1002' => STANDARD_ERROR_CODE[:incorrect_address], 'PMT-1003' => STANDARD_ERROR_CODE[:processing_error],
'PMT-2000' => STANDARD_ERROR_CODE[:incorrect_cvc], 'PMT-2001' => STANDARD_ERROR_CODE[:invalid_cvc], 'PMT-2002' => STANDARD_ERROR_CODE[:incorrect_address], 'PMT-2003' => STANDARD_ERROR_CODE[:incorrect_address],
'PMT-3000' => STANDARD_ERROR_CODE[:processing_error],
'PMT-4000' => STANDARD_ERROR_CODE[:processing_error], 'PMT-4001' => STANDARD_ERROR_CODE[:processing_error], 'PMT-4002' => STANDARD_ERROR_CODE[:processing_error],
'PMT-5000' => STANDARD_ERROR_CODE[:card_declined], 'PMT-5001' => STANDARD_ERROR_CODE[:card_declined],
'PMT-6000' => STANDARD_ERROR_CODE[:processing_error] }
- FRAUD_WARNING_CODES =
%w(PMT-1000 PMT-1001 PMT-1002 PMT-1003)
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
-
#base_path ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#endpoint ⇒ Object
-
#initialize(options = {}) ⇒ QuickbooksGateway
constructor
A new instance of QuickbooksGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refresh ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
-
#void_endpoint ⇒ 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?
#fetch_version, included
#expdate, #format, #strftime_yyyymm, #strftime_yyyymmdd_last_day
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of QuickbooksGateway.
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 59
def initialize(options = {})
if options[:refresh_token]
requires!(options, :client_id, :client_secret, :access_token, :refresh_token)
else
requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm)
end
@options = options
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 83
def authorize(money, payment, options = {})
post = {}
add_amount(post, money, options)
add_charge_data(post, payment, options)
post[:capture] = 'false'
response = commit(endpoint, post)
check_token_response(response, endpoint, post, options)
end
|
#base_path ⇒ Object
14
15
16
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 14
def base_path
"/quickbooks/#{fetch_version}/payments"
end
|
#capture(money, authorization, options = {}) ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 93
def capture(money, authorization, options = {})
post = {}
authorization, = split_authorization(authorization)
post[:amount] = localized_amount(money, currency(money))
add_context(post, options)
response = commit(capture_uri(authorization), post)
check_token_response(response, capture_uri(authorization), post, options)
end
|
#endpoint ⇒ Object
18
19
20
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 18
def endpoint
"#{base_path}/charges"
end
|
#purchase(money, payment, options = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 73
def purchase(money, payment, options = {})
post = {}
add_amount(post, money, options)
add_charge_data(post, payment, options)
post[:capture] = 'true'
response = commit(endpoint, post)
check_token_response(response, endpoint, post, options)
end
|
#refresh ⇒ Object
124
125
126
127
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 124
def refresh
response = refresh_access_token
response_object(response)
end
|
#refund(money, authorization, options = {}) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 103
def refund(money, authorization, options = {})
post = {}
post[:amount] = localized_amount(money, currency(money))
add_context(post, options)
authorization, = split_authorization(authorization)
response = commit(refund_uri(authorization), post)
check_token_response(response, refund_uri(authorization), post, options)
end
|
#scrub(transcript) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 133
def scrub(transcript)
transcript.
gsub(%r((realm=\")\w+), '\1[FILTERED]').
gsub(%r((oauth_consumer_key=\")\w+), '\1[FILTERED]').
gsub(%r((oauth_nonce=\")\w+), '\1[FILTERED]').
gsub(%r((oauth_signature=\")[a-zA-Z%0-9]+), '\1[FILTERED]').
gsub(%r((oauth_token=\")\w+), '\1[FILTERED]').
gsub(%r((number\\\":\\\")\d+), '\1[FILTERED]').
gsub(%r((cvc\\\":\\\")\d+), '\1[FILTERED]').
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(%r((access_token\\?":\\?")[\w\-\.]+)i, '\1[FILTERED]').
gsub(%r((refresh_token\\?":\\?")\w+), '\1[FILTERED]').
gsub(%r((refresh_token=)\w+), '\1[FILTERED]').
gsub(%r((Authorization: Bearer )[\w\-\.]+)i, '\1[FILTERED]\2')
end
|
#supports_scrubbing? ⇒ Boolean
129
130
131
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 129
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
120
121
122
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 120
def verify(credit_card, options = {})
authorize(1.00, credit_card, options)
end
|
#void(authorization, options = {}) ⇒ Object
113
114
115
116
117
118
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 113
def void(authorization, options = {})
_, request_id = split_authorization(authorization)
response = commit(void_uri(request_id))
check_token_response(response, void_uri(request_id), {}, options)
end
|
#void_endpoint ⇒ Object
22
23
24
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 22
def void_endpoint
"#{base_path}/txn-requests"
end
|