 #
 # Offers convenient methods for using the Checkout API in JS.
 class Checkout
+
+	HOST_URL = window.location.origin
+
 	# Instantiate the SDK.
 	#
+	# @param hostURL [String] (default = window.location.origin) the base URL for API calls, without the trailing slash, e.g. "http://example.vtexcommerce.com.br".
 	# @param ajax [Function] (default = $.ajax) an AJAX function that must follow the convention, i.e., accept an object of options such as 'url', 'type' and 'data', and return a promise.
-	# @param HostURL [String] (default = window.location.origin) the base URL for API calls, without the trailing slash, e.g. "http://example.vtexcommerce.com.br"
+	# @param promise [Function] (default = $.when) a promise function that must follow the Promises/A+ specification.
 	# @return [VTEX] the SDK
-	constructor: (ajax = $.ajax, hostURL) ->
-		@ajax = AjaxQueue(ajax)
+	# @note hostURL configures a static variable. This means you can't have two different instances looking at different host URLs.
+	constructor: (hostURL, ajax = $.ajax, promise = $.when) ->
+		@ajax = (if window.AjaxQueue then window.AjaxQueue(ajax) else ajax)
+		@promise = promise
+		HOST_URL = hostURL if hostURL
 		@CHECKOUT_ID = 'checkout'
-		@HOST_URL = hostURL || window.location.origin
-		@HOST_ORDER_FORM_URL = @HOST_URL + '/api/checkout/pub/orderForm/'
-		@POSTALCODE_URL = @HOST_URL + '/api/checkout/pub/postal-code/'
-		@GATEWAY_CALLBACK_URL = @HOST_URL + '/checkout/gatewayCallback/{0}/{1}/{2}'
-		@requestingItem = undefined
-		@stateRequestHashToResponseMap = {}
-		@subjectToJqXHRMap = {}
-
-		@allOrderFormSections =
+		@orderForm = undefined
+		@orderFormId = undefined
+		@_requestingItem = undefined
+		@_subjectToJqXHRMap = {}
+		@_allOrderFormSections =
 			[
 				'items'
 				'totalizers'


	# @nodoc
	_getOrderFormId: =>
		@_getOrderFormIdFromCookie() or @_getOrderFormIdFromURL() or ''

	# @nodoc
	_getOrderFormIdFromCookie: =>

		urlParam('orderFormId')

	# @nodoc
	_getBaseOrderFormURL: ->
		HOST_URL + '/api/checkout/pub/orderForm'

	# @nodoc
	_getOrderFormURL: =>
		id = @_getOrderFormId()
		if id is ''
			throw new Error "This method requires an OrderForm. Use getOrderForm beforehand."
		@HOST_ORDER_FORM_URL + id

	# @nodoc
	_getSaveAttachmentURL: (attachmentId) =>
