Class: ActiveMerchant::Billing::QuickbooksGateway

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

Constant Summary collapse

ENDPOINT =
'/quickbooks/v4/payments/charges'
OAUTH_ENDPOINTS =
{
  site: 'https://oauth.intuit.com',
  request_token_path: '/oauth/v1/get_request_token',
  authorize_url: 'https://appcenter.intuit.com/Connect/Begin',
  access_token_path: '/oauth/v1/get_access_token'
}
STANDARD_ERROR_CODE_MAPPING =
{
  # Fraud Warnings
  'PMT-1000' => STANDARD_ERROR_CODE[:processing_error],   # payment was accepted, but refund was unsuccessful
  'PMT-1001' => STANDARD_ERROR_CODE[:invalid_cvc],        # payment processed, but cvc was invalid
  'PMT-1002' => STANDARD_ERROR_CODE[:incorrect_address],  # payment processed, incorrect address info
  'PMT-1003' => STANDARD_ERROR_CODE[:processing_error],   # payment processed, address info couldn't be validated

  # Fraud Errors
  'PMT-2000' => STANDARD_ERROR_CODE[:incorrect_cvc],      # Incorrect CVC
  'PMT-2001' => STANDARD_ERROR_CODE[:invalid_cvc],        # CVC check unavaliable
  'PMT-2002' => STANDARD_ERROR_CODE[:incorrect_address],  # Incorrect address
  'PMT-2003' => STANDARD_ERROR_CODE[:incorrect_address],  # Address info unavailable

  'PMT-3000' => STANDARD_ERROR_CODE[:processing_error],   # Merchant account could not be validated

  # Invalid Request
  'PMT-4000' => STANDARD_ERROR_CODE[:processing_error],   # Object is invalid
  'PMT-4001' => STANDARD_ERROR_CODE[:processing_error],   # Object not found
  'PMT-4002' => STANDARD_ERROR_CODE[:processing_error],   # Object is required

  # Transaction Declined
  'PMT-5000' => STANDARD_ERROR_CODE[:card_declined],      # Request was declined
  'PMT-5001' => STANDARD_ERROR_CODE[:card_declined],      # Merchant does not support given payment method

  # System Error
  'PMT-6000' => STANDARD_ERROR_CODE[:processing_error],   # A temporary Issue prevented this request from being processed.
}
FRAUD_WARNING_CODES =
['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

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?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ QuickbooksGateway

Returns a new instance of QuickbooksGateway.



53
54
55
56
57
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 53

def initialize(options = {})
  requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm)
  @options = options
  super
end

Instance Method Details

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



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

def authorize(money, payment, options = {})
  post = {}
  add_amount(post, money, options)
  add_charge_data(post, payment, options)
  post[:capture] = 'false'

  commit(ENDPOINT, post)
end

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



77
78
79
80
81
82
83
84
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 77

def capture(money, authorization, options = {})
  post = {}
  capture_uri = "#{ENDPOINT}/#{CGI.escape(authorization)}/capture"
  post[:amount] = localized_amount(money, currency(money))
  add_context(post, options)

  commit(capture_uri, post)
end

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



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

def purchase(money, payment, options = {})
  post = {}
  add_amount(post, money, options)
  add_charge_data(post, payment, options)
  post[:capture] = 'true'

  commit(ENDPOINT, post)
end

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



86
87
88
89
90
91
92
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 86

def refund(money, authorization, options = {})
  post = {}
  post[:amount] = localized_amount(money, currency(money))
  add_context(post, options)

  commit(refund_uri(authorization), post)
end

#scrub(transcript) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 102

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+)\d{16}), '\1[FILTERED]').
    gsub(%r((cvc\D+)\d{3}), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 98

def supports_scrubbing?
  true
end

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



94
95
96
# File 'lib/active_merchant/billing/gateways/quickbooks.rb', line 94

def verify(credit_card, options = {})
  authorize(1.00, credit_card, options)
end