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
- BASE =
'/quickbooks/v4/payments'
- ENDPOINT =
"#{BASE}/charges"
- VOID_ENDPOINT =
"#{BASE}/txn-requests"
- 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
-
#capture(money, authorization, options = {}) ⇒ 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
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?
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of QuickbooksGateway.
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 50
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
74
75
76
77
78
79
80
81
82
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 74
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
|
#capture(money, authorization, options = {}) ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 84
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
|
#purchase(money, payment, options = {}) ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 64
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
115
116
117
118
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 115
def refresh
response = refresh_access_token
response_object(response)
end
|
#refund(money, authorization, options = {}) ⇒ Object
94
95
96
97
98
99
100
101
102
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 94
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 124
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
120
121
122
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 120
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
111
112
113
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 111
def verify(credit_card, options = {})
authorize(1.00, credit_card, options)
end
|
#void(authorization, options = {}) ⇒ Object
104
105
106
107
108
109
|
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 104
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
|