 		@_getOrderFormIdFromCookie() or @_getOrderFormIdFromURL() or ''
 
 	_getOrderFormIdFromCookie: =>
-		cookie = _.readCookie(@COOKIE_NAME)
-		unless cookie is undefined or cookie is ''
-			return _.getCookieValue(cookie, @COOKIE_ORDER_FORM_ID_KEY)
-		return undefined
+		COOKIE_NAME = 'checkout.vtex.com'
+		COOKIE_ORDER_FORM_ID_KEY = '__ofid'
+		cookie = readCookie(COOKIE_NAME)
+		return undefined if cookie is undefined or cookie is ''
+		return readSubcookie(cookie, COOKIE_ORDER_FORM_ID_KEY)
 
 	_getOrderFormIdFromURL: =>
-		$.url().param('orderFormId')
+		urlParam('orderFormId')
 
 	_getOrderFormURL: =>
 		@HOST_ORDER_FORM_URL + @_getOrderFormId()

	# @param serializedAttachment stringified serializedAttachment
	# @param expectedOrderFormSections
	sendAttachment: (attachmentId, serializedAttachment, expectedOrderFormSections = @expectedFormSections(), options = {}) =>
		orderAttachmentRequest =
			expectedOrderFormSections: expectedOrderFormSections

		if attachmentId is undefined or serializedAttachment is undefined
			d = $.Deferred()
			d.reject("Invalid arguments")
			return d.promise()

		## TODO alterar chamadas para não mandar stringified
		_.extend(orderAttachmentRequest, JSON.parse(serializedAttachment))

		if options.cache and options.currentStateHash
			requestHash = _.hash(attachmentId + JSON.stringify(orderAttachmentRequest))
			stateRequestHash = options.currentStateHash.toString() + ':' +  requestHash.toString()

			if @stateRequestHashToResponseMap[stateRequestHash]
				deferred = $.Deferred()

class CheckoutAPI
	constructor: (@ajax = $.ajaxQueue) ->
		@CHECKOUT_ID = 'checkout'
		@HOST_URL = 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
