Skip to content

Commit

Permalink
fix for issue #9 - Can't connect to both Sandbox and Live Endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mcohen01 committed Feb 9, 2015
1 parent b0a3237 commit ce65f36
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ function QuickBooks(consumerKey, consumerSecret, token, tokenSecret, realmId, us
this.realmId = eval(prefix + 'realmId')
this.useSandbox = eval(prefix + 'useSandbox')
this.debug = eval(prefix + 'debug')
if (! this.useSandbox) {
QuickBooks.V3_ENDPOINT_BASE_URL = QuickBooks.V3_ENDPOINT_BASE_URL.replace('sandbox-', '')
QuickBooks.PAYMENTS_API_BASE_URL = QuickBooks.PAYMENTS_API_BASE_URL.replace('sandbox.', '')
}
this.endpoint = this.useSandbox ? QuickBooks.V3_ENDPOINT_BASE_URL : QuickBooks.V3_ENDPOINT_BASE_URL.replace('sandbox-', '')
this.paymentEndpoint = this.useSandbox ? QuickBooks.PAYMENTS_API_BASE_URL : QuickBooks.PAYMENTS_API_BASE_URL.replace('sandbox.', '')
}

/**
Expand Down Expand Up @@ -1712,8 +1710,8 @@ QuickBooks.prototype.reportClassSales = function(options, callback) {

module.request = function(context, verb, options, entity, callback) {
var isPayment = options.url.match(/^\/(charge|tokens)/),
url = isPayment ? QuickBooks.PAYMENTS_API_BASE_URL + options.url :
QuickBooks.V3_ENDPOINT_BASE_URL + context.realmId + options.url,
url = isPayment ? context.paymentEndpoint + options.url :
context.endpoint + context.realmId + options.url,
opts = {
url: url,
qs: options.qs || {},
Expand Down

0 comments on commit ce65f36

Please sign in to comment.