UltraCart REST Checkout API
This is Version 1 of the UltraCart REST API. It is now legacy. It will remain forever, but no new development will be done.
Please see Version 2 for new development. Version 2 contains language specific SDKs, more functionality, and reduced API call counts.
Version 2 Main Documentation
Version 2 Supplemental Documentation
Additional Note, August 2020:
To prevent anyone from using this code in a new installation, several key samples have been removed. These samples referred to php scripts that are no longer compatible with the UltraCart engine. You should not be using this javascript anymore. This documentation exists only for a reference for old legacy implementations.
- 1 Changes
- 2 Introduction (Things you'll wish you read first)
- 3 Reference Implementations
- 4 Object Model
- 4.1 Cart Objects
- 4.2 CartCoupon Objects
- 4.3 CartItem Objects
- 4.4 CartItemOption Objects
- 4.5 CartItemMultimedia Objects
- 4.6 CartKitComponentOption Objects
- 4.7 CheckoutTerms Objects
- 4.8 CheckoutRequest Objects
- 4.9 CheckoutResponse
- 4.10 CityStateZip
- 4.11 CustomerProfile
- 4.12 CustomerProfileAddress
- 4.13 CustomerProfileCreditCard
- 4.14 FinalizeOrderRequest
- 4.15 FinalizeOrderResult
- 4.16 FinalizeOrderOptions
- 4.17 Distance
- 4.18 Gift Settings
- 4.19 Gift Wrap
- 4.20 Item
- 4.21 ItemAttribute
- 4.22 ItemMultimedia
- 4.23 ItemMultimediaThumbnail
- 4.24 ItemOption
- 4.25 ItemOptionValue
- 4.26 Order
- 4.26.1 Order Labels
- 4.27 ShippingEstimate
- 4.28 Weight
- 5 Cart REST API
- 5.1 /rest/cart
- 5.2 /rest/cart/estimateShipping
- 5.3 /rest/cart/checkout (this is NOT the last step)
- 5.4 /rest/cart/finalizeOrder
- 5.5 /rest/cart/validate
- 5.6 /rest/cart/setFinalizeAfter
- 5.7 /rest/cart/clearFinalizeAfter
- 5.8 /rest/cart/subscribeToAutoResponder
- 5.9 /rest/cart/login
- 5.10 /rest/cart/logout
- 5.11 /rest/cart/register
- 5.12 /rest/cart/resetPassword
- 5.13 /rest/cart/checkoutTerms
- 5.14 /rest/cart/relatedItems
- 5.15 /rest/cart/relatedItems/{itemId}
- 5.16 /rest/cart/taxCounties
- 5.17 /rest/cart/giftSettings
- 5.18 /rest/cart/validateGiftCertificate
- 5.19 /rest/cart/hostLink
- 5.20 /rest/cart/cityState
- 5.21 /rest/cart/share/email
- 6 Server Side Logging
Changes
(this list was started Aug 2014)
August 2014
Added localization to support non US currencies. There are two ways to set the currency of the shopping cart.
1. Updating the cart with cart.currencyCode will cause the localized fields to display in that currency.
2. Adding an item to the cart which has the item cost in a different currency will set the cart to that currency. Only the first item added alters the currency of the cart.
You will now see additional fields on the Cart and CartItem ending with "Localized" and "LocalizedFormatted". The localized fields contain currency amounts in the local currency. The formatted fields are strings containing currency symbols for easy use in templates and mark up.
Introduction (Things you'll wish you read first)
The UltraCart REST API aims to be a lightweight protocol for tying a checkout page(s) to the UltraCart back end.
Merchant ID Required
Every call needs a merchant id (our merchant id is DEMO). We need to know who you are. There are three ways to provide the merchant id to the server:
Query Parameter:
_mid=DEMOHTTP Header:
'X-UC-Merchant-Id': 'DEMO'Cookie named
UltraCartMerchantID
Most of the examples below use the http header since it's easy to use with jQuery. If you wished to do it for all your ajax calls, you could execute this javascript:
jQuery.ajaxSetup({ cache: false, headers: {'X-UC-Merchant-Id': 'DEMO', "cache-control": "no-cache"});
However, that makes each call less atomic (and jQuery doesn't recommend it). Still, it's an option and may work well with your site.
If you receive an error "Missing Merchant ID", you've forgotten to do one of the above.
Now, in case you're wondering why the three methods use different names...
We made the query parameter as short as possible to keep the urls as short as possible. We used an underscore to denote "meta data" to the call.
We follow common practices for naming custom http headers. While the X- prefix is officially out of vogue, we still think it looks cool.
The cookie 'UltraCartMerchantID' is used in hundred of existing UltraCart checkout pages. So it made sense to stick with that cookie name.
Where are the errors?
When something doesn't work or you get an error, open your browser console and view the headers. Look for the error.
then fix it.
Can't? Then get on github.com. Ask for help here.
Note Regarding Support for API
API troubleshooting
UltraCart's free support does not cover API development questions or troubleshooting of custom checkout pages.
Please post your questions to the "Issues" section of the github.com API reponsitories, which are monitored and responded to by the API developers. Please allow 24-48 hours for a reply.
Additional API support and troubleshooting services can be purchased at $100/hr (1 hour minimum) via UltraCart Professional Services.
(Scheduling of paid for support will be determined by Professional Services personnel.)
/rest/cart/checkout is not the end
/rest/cart/checkout is NOT THE END! It's the beginning of the end. If the response from checkout has no errors, you must redirect the browser to the url found in checkoutResonse.redirectToUrl. That finishes the order. Any errors during that phase (card declined) will send the browser back to checkoutRequest.redirectOnErrorUrl, which is usually set to your checkout page. It's a circle, one that handles shipping companies and payment gateway timeouts without timing out the browser. It also handles any upsell gauntlets. So make sure you follow the redirect!
// incompatible code. this code was removed.