TrepStar.com HTTP Gateway API order automation documentation |
TrepStar HTTP Gateway API:
The TrepStar HTTP gateway API responds to http get/post requests initiated by your software/process. This is sometimes called a webhook. Currently, this API has two functions:
Function - SubmitProductOrder:
Summary:
The following section explains how to submit a product order for one or more products in any quantity.
Your software will initiate an http get or post request to a TrepStar HTTP Gateway URL (https://www.trepstar.com/custdata.asp). The response from the request will include either the text [SUCCESS] or [FAILURE].
ASP Sample: Code Sample Written in classic ASP (active server pages).
PHP Sample: Code Sample Written in PHP.
Python Sample: Code Sample Written in Python.
In the sections below, we define each field, and give you an example. We show you the correct URL format you would use to call our http gateway from some server to server process on your site or shopping cart (when your system is taking or processing order information). Many shopping cards can be configured to set up a http get/post call when an order is processed. If not, you can program (or hire someone) to program the http gateway call to our server.
The TrepStar HTTP Gateway URL for 'SubmitProductOrder' starts with https://www.trepstar.com/custdata.asp
Request Format - Field Definitions:
- productid This product id is specific to each project you have in your TrepStar.com account. The product (or project) ID is listed next to the title of each of your products. The exact TrepStar product ID is required to identify the project.
Single Order (single address), but with multiple products: There may be cases when you want to order multiple products to be shipped in the same box/package to the same address. For example: Suppose you wanted to order 3 different products each with a different quantity. First, string productid's together separating them with an x.- E.g. Customer Order with 3 products A, B, and C with TrepStar IDs 66750 and 66760 and 66770 respectively. The productid field would look like productid=66750x66760x66770.
- To specify quantity for each product, see the 'quantity' field below. (e.g. quantity=1x3x2)
- This multi product order will cause our server to manufacture, print and package these three products together in one box/package (in the quantity specified by the quantity field below).
- quantity Use a numeric value from 1 to 250. 1 is the default value. If you leave quantity blank or don't include it, 1 will be assumed. Quantity refers to how many of 'productid' product(s) will be shipped to the end user. If you need more than 250, submit two separate orders.
Single Order (single address), but with multiple products: There may be cases when you want to order multiple products to be shipped in the same box/package to the same address. For example:- You can specify a different quantity for multi-project orders. For example, if you have the productid=40350x40360x40370, you could set quantity=1x4x3
- This means we will make 1 of project 40350, 4 of project 40360, and 3 of project 40370, and they will all ship in the same box/package to the same address.
- quantity is positional. The first productid in the productid list will correspond to the first quantity in the quantity list.
- Invoice
- Invoice can be text up to 50 characters.
- If you plan to get order status via the API method getOrderStatusByInvoice you must include a unique invoice for ALL of your orders.
- You may leave Invoice blank but we highly discourage it. If it's blank then we use the 'email' field below instead. Email is the next best unique identifier for an order. The order will fail [FAILURE] and be considered a duplicate if the same email address is used on an order within 5 days (when no invoice was used). In other words, the same user (same email) can order this product again, but only after 5 days.
- Invoice is important because we want to make sure we are not accepting duplicate orders (and billing your for them). For example, if your system submitted 5 orders, each without invoice or email, we assume they are different orders since the software does not compare every single field for a match. We are trying to avoid submitting multiple duplicate orders sent to the same customer in the case where your system retries an order or is in an error loop. Therefore, if you supply a unique invoice, our system will correctly reject duplicate order requests if the same invoice is used. This is the primary reason why it's critical to have a unique invoice.
- Invoice must be unique for this productID. In other words, you can use the same invoice value again for a different product/project, but not for this project. However, we highly recommend you create a unique invoice for ALL of your orders, not just on a project by project basis, especially if you think you may use the getOrderStatusByInvoice function.
- typeMailMethod Values are standard, rtrackstandard, priority or express. rtrackstandard means standard + tracking.
- If your product is packaged in a sleeve or usb ecomailer, and it's a single quantity order, standard is the lower cost letter rate with no tracking.
- If your product is packaged in anything else, or it's to an INTL address, it's shipped as a parcel which includes tracking to most destinations and in these cases, is almost exactly like rtrackstandard. If you specified standard, but a package needs to be sent as a parcel, the order will still be accepted (will behave as if it was ordered using rtrackstandard).
- Priority is 2-3 days shipping time (plus 1 day production time). We try to get priority and express packages out as fast as possible. For a domestic address, Priority packages usually arrive 2-3 business days after the order has been paid and postage printed. Add a few more days for INTL addresses.
- Express is 1-2 days shipping time (plus 1 day production time). We try to get priority and express packages out as fast as possible. For a domestic address, Express packages almost always arrive 2 business days after the order has been paid and postage printed. Use this choice if you need to guarantee Amazon 2 day delivery for Prime members (domestic addresses only). Add a few more days for INTL addresses.
- For more information, open the order form for one of your products and read the help text in the shipping policy section near the bottom of the form.
- CoLoginEmail This is your TrepStar publisher account email (used to login to your TrepStar.com account). At this time, we don't have a separate API key or password so if you change your email or password, be sure to update your order automation software.
- CoLoginPassword This is your TrepStar publisher account password.
- mode Values are either test or prod. (e.g. mode=test)
- test mode orders will be accepted and will show up in the TrepStar dashboard (click the recent orders button). Use test mode when first testing this integration. You will receive the customer order notification email if you have that feature on. Test orders cannot be converted to prod orders. Test orders may be deleted from the dashboard.
- prod mode orders are live orders that will be billed to your account, and manufactured & shipped when they are paid for. Normally, your account does not have a positive balance when you are a new publisher. In other words, prod orders will be on hold unless you have a positive TrepStar account balance (a credit from a previous payment). 'hold' orders are not yet manufactured, so you may delete them from the dashboard (e.g. the recent orders list).
- email Customer's Email. Normally it would be the email address of your customer so they may receive our optional order notification and/or tracking information of you have that feature on.
- Email is used if you have Customer Email Notifications turned on within your publisher account settings (ON by default).
- Email is used only to send order related emails.
- This includes the order notification which contains an optional address modification link.
- A separate tracking link email is sent later, when postage is printed and a tracking number becomes available.
- Customer Email Notifications can be turned on/off by editing your TrepStar account settings.
- Customer Email Notifications are important if you want your customer to be able to modify his address in case they see errors. We send the order notification right away when the order is placed, which gives them time to modify their address before we actually print postage. The amount of time for this postage printing delay, and the use of the modify address setting can be found within your TrepStar Account settings.
- If you want email sent to customers in only certain cases, leave the notifications setting on, but for those customers where you don't want email sent, use one of your internal emails, or create a 'fake' email (e.g. internal@yourco.com or bogus@hotmail123.com). Or, look at the bSendOrderNotificationEmail section below.
- bSendOrderNotificationEmail (1 or 0) Optional: Send Order Notification Email to customer or not. This setting will override the Customer Email Notifications setting within your TrepStar Publisher Account. If you set bSendOrderNotificationEmail=1 we will send the Order Notification Email (and tracking email) to the email supplied on this order regardless of the TrepStar account setting. Setting bSendOrderNotificationEmail=0 means no emails will be sent even if you have the TrepStar Publisher Account setting set to Yes.
- nprice Optional. If you want an amount printed on the invoice we include with the package, set this value to a dollar amount. This goes on the printed invoice inside the package (e.g. You've already paid $xx.yy for this order...) If you use 0 (zero) for the price, the amount will not be mentioned in any customer receipt email notification, and will not be printed on the customer invoice.
- bUsePriceOnCustomsForm (1 or 0) Optional: This field has meaning for International orders only. VAT tax is determined by package value. Normally, we use $6.00. if you set bUsePriceOnCustomsForm=1 we use the price you set in the nPrice field (above). If you leave this field blank or 0, we use the $6.00 value.[more info].
- name Customer's full name. (e.g. John H. Smith)
- co Company name. (e.g. Capital Records or ATTN: John Smith, 3rd floor)
- addr Full street address. (e.g 123 some street, Apt123). If the address has 2 lines, put them together (concatenate) as a single line.
- city City
- st State or Province. Required for USA and Canada, and countries that have a state, but some countries do not have a state value so it can be left out in those cases. Use either the 2 letter state abbreviation or spell it out fully. (e.g. MN or Minnesota is acceptable separately but do not combine them twice. (e.g. MN Minnesota) is NOT acceptable).
- zip Zip Code, or postal code for international addresses.
- country Country.
- If blank, US (United States) is assumed and is the default value.
- If possible, use the standard 2 letter country code values like 'US' for United States, or 'UK' for united kingdom if possible (Google "2 letter country codes").
- You may also fully spell out country names. (e.g. UniTed KINGdom, or Great Britain).
- Our system is fairly well trained when accepting country names, and even common misspellings are handled most of the time. 'IT' or 'Italy' is acceptable, but do not combine too much data. (e.g. IT (Italy) will fail).
- If there are errors with the address, we normally catch this when printing postage later. The order submit status will be [SUCCESS] even if we have to correct the address manually. We don't do address verification on this order submit step. You will need to use the getOrderStatusByInvoice method to check status and get tracking codes.
- For bad addresses we may send an email to the customer using the email (field above) used when placing this order. We will ask the customer for corrections (since the end user customer knows best what their address is). If we can not contact them we send an email to your publisher email for clarification. See the send status list.
- SpecialText Use this information to give this customer specific instructions valid only for him/her such as a serial#, unlock code etc. If you specify any special text, it overrides the special text that you specified from within the project settings. Maximum 500 characters. No HTML.
- ordermethod=url (Value is always set equal to url). (e.g. ordermethod=url) This value never changes so always set as ordermethod=url . This tells us this is an http gateway call instead of an order from a different method such as a 3rd party shopping cart.
- source=cdfulfill (Value always set equal to cdfulfill). Use cdfulfill even if this is a DVD or USB order. (e.g. source=cdfulfill) This value never changes so always set source=cdfulfill . This tells us this is an http gateway call instead of an order from a different source such as our retail order buttons.
Server Response:
- [SUCCESS] The http gateway call to our server will return information about the order, including the word [SUCCESS] if the order was processed. There may be other summary information you can ignore in the response, but the word [SUCCESS] (case sensitive) will be displayed.
- [FAILURE] The http gateway call to our server will return information about the order, including the word [FAILURE] if the order was NOT processed. Duplicate orders are not processed and will be considered [FAILURE]. Duplicate orders are orders with the same invoice value. You are not allowed to order the same product with a previously used invoice. There may be other failure error messages. For example, if there is no customer name or address, an error message will be generated.
- The format of a failure will include an error code and error message in the following format:
[ERRORMSGBEGIN] ERRCODE#nnnnnn [FAILURE] Error Message Here [ERRORMSGEND]
Your process can scan the server response for the keyword [FAILURE] and/or parse out the area between [ERRORMSGBEGIN] and [ERRORMSGEND]. The ERRCODE always directly follows [ERRORMSGBEGIN], and the error message always follows the keyword [FAILURE].
Failure ERRCODEs and FAILURE messages:
- ERRCODE#000503 [FAILURE] http gateway URL Integration Call is Invalid. Source Mode Unknown. You must include your account email and password which must match your login to www.TrepStar.com. The field names you must add are CoLoginEmail and CoLoginPassword. Refer to http://www.trepstar.com/automate-integrate-ordering.asp
- ERRCODE#000101 [FAILURE] prod, productid, and eCommerceList were blank. For integration customers, you need to specify only the productid field. This should be the numeric value of your TrepStar project id (login and look for it)
- ERRCODE#003101 [FAILURE] The total quantity for this multi product order exceeded the maximum 250. The quantities you submitted were xxx which total yyy.Please click back, enter smaller quantities, or submit separate orders. The post office limits us to a total size and weight per package.
- ERRCODE#000601 [FAILURE] Your URL (http gateway) Integration Call does not have the correct CoLoginEmail and CoLoginPassword. You must provide your current www.trepstar.com login email and password on the http gateway URL integration call. CoLoginEmail and CoLoginPassword are the field names you must use. Either you have not specified them, or they are incorrect. Please refer to http://www.trepstar.com/automate-integrate-ordering.asp for more details.
- ERRCODE#000505 [FAILURE] Your http gateway URL Integration Call has the correct CoLoginEmail and CoLoginPassword, but the product you are trying to make (xxxyyy) is not from this account CompanyID='yyy' ParentID of Product='aaabbb'. You can only order for products within your account using this email and password .
- ERRCODE#000503 [FAILURE] http gateway URL Integration Call is Invalid. Source Mode Unknown. You must include your account email and password which must match your login to www.TrepStar.com. The field names you must add are CoLoginEmail and CoLoginPassword. Refer to http://www.trepstar.com/automate-integrate-ordering.asp
- ERRCODE#000002 [FAILURE] Invalid access or source variable value. If you are attempting to send data for TrepStar CD/DVD/USB fulfillment service, your GET or POST variables are malformed or you did not specify the right value for 'source' which should be cdfulfill. The value of source supplied by you was 'xxxx' .The List(s) at the top of this page shows the only readable form or querystring variables, we received, if any.
- ERRCODE#000010 [FAILURE] ProductID was blank
- ERRCODE#000013 [FAILURE] Name was blank
- ERRCODE#000035 [FAILURE] This is a duplicate Order. This order, taken by our server at [date/time] will not be filled because [some reason] Please login to your trepstar.com account, and click the 'reports' button to see the recent list of orders. If you do not see your customer listed, the order did not go through. To prevent our system from thinking an order is a duplicate, use a unique email or unique invoice# to prevent duplicate orders.
GET/POST Parameters:
- URL Encoding: Be sure to use proper URL encoding when sending text data. For example, the text "Thank you for ordering. Your unlock code is 123-23456. Email questions to help@somedomain.com" needs to be URL encoded. This text properly URL encoded would be sent to the server looking like "Thank+you+for+ordering%2E++Your+unlock+code+is+123%2D23456%2E++Email+questions+to+help%40somedomain%2Ecom".
WebHook to TrepStar:
Your software or server will call our server (sometimes known as a webhook) with specific customer data. Use your TrepStar productID number(s), and your TrepStar login email and password.Each TrepStar product has a unique productID assigned by our system. The following is just an example. When you create your own project, you will use the unique Product id assigned by our system used to identify your specific product.
Single Product Order Example. Webhook parameters to our server:
Example webhook URL to produce a single product order with quantity=1.
Multiple Product Order Example (with different quantities for each product).
In this example, there is a list of TrepStar productIDs and Quantities. The first product will have a quantity ordered of 4, 2nd product qty=2, and 3rd product qty=2.
Function - getOrderStatusByInvoice:
Summary:
The following section describes how to retrieve order status from a previously submitted order.
For the GetOrderStatusByInvoice function, your software will initiate an http get or post request (a webhook) to a TrepStar HTTP Gateway URL (https://www.trepstar.com/custdataXML.asp). The response will be in XML format.
The getOrderStatusByInvoice function will retrieve the status of a previously placed order. The response will contain delivery status, and a shipping tracking id if applicable. Each http call to the service results in a single XML response. Please do not abuse this service by calling our server too often. If you call this function over 1000 times in a 24 hour period, we charge 1 cent ($0.01) each time the function is called (we will bill your TrepStar account). Be careful to avoid frequent looping calls (or infinite loops). Any abuse of this service will be considered a denial of service attack and may result in us having to block your system and/or close your TrepStar account.
Input: Invoice you used when creating the order (the invoice you specified when ordering).
output: XML Response
Request Format:
Formulate an http get or post request to our server at this url https://www.trepstar.com/custdataXML.asp using 4 fields.
- function - Set to 'getOrderStatusByInvoice'.
- Invoice - Use the unique invoice (or list of invoices *) you supplied when you submitted the order. If you plan to use this XML response feature, you must make sure you supply a unique invoice when you submit the order.
- * You may also specify multiple (up to 100) Invoice values on a single request to get the status of multiple orders.
- String several Invoice values together with this delimiter [*|*]
- The limit is 100 invoices. Only the first 100 invoices in the list will be checked.
- This 5 character delimiter is necessary because invoices are allowed to be any combination of English text or numbers so the delimiter must be unique.
- e.g. Invoice=ABC2134234[*|*]DEF592839234[*|*]SDF234234234 would return 3 status sections with information about all three of these invoices.
- * You may also specify multiple (up to 100) Invoice values on a single request to get the status of multiple orders.
- CoLoginEmail - This is the email address you use to login to your TrepStar.com account. We use this for security reasons.
- CoLoginPassword - This is your account password used for security reasons.
URL Encoding
- Be sure to use proper URL encoding when sending text data. For example, if the invoice was "ID 000052 5/16/18", it would need to be URL encoded. This text properly URL encoded would be sent to the server looking like "ID+000052+5%2F16%2F18".
Here is what a sample getOrderStatusByInvoice request URL looks like using a single Invoice as input:
XML Response Example:
The response from the system will be in XML format.
XML Data Output Fields:
- <StatusN> Section(s) - All of the XML field values are contained within the StatusN Section(s) of the response.
- If you submit a single invoice as input there will only be one section in the response.
- <Status1>
...
</Status1>
- <Status1>
- If you submit multiple invoice values as input, multiple sections will be in the response.
The output sections are in the same positional order as the input invoice list.
- <Status1>
...
</Status1>
- <Status2>
...
</Status2>
- etc.
- <Status1>
- ErrorNum
- 0 - success.
- 100 - Unknown function name requested. Please specify a valid function on the get/post request. Valid functions are:
- getOrderStatusByInvoice
- 200 - Incorrect email or password used as input.
- 300 - Record Not found. The input Invoice data is not in our database. If you receive this error, you were correctly authenticated.
(correct login email and password), but no product order record was found with that invoice.
- ErrorDesc - Descriptive error text related to each error response.
ErrorDesc will be blank for successful (0 ErrorNum) requests.
- CustName - The customer name is returned mostly for testing purposes. You may want to confirm this customer is in fact the correct customer for the supplied Invoice.
- Invoice - The input Invoice is returned as output in case you want to check it when you've submitted multiple invoices as input.
- OrderStatus - Manufacturing and fulfillment status. Possible values are:
- ERROR - Usually an address error. Look at OrderStatusErrNum and OrderStatusErrDesc.
- HOLD - A payment needs to be made before this order is manufactured and fulfilled.
- PROCESSING - Currently being manufactured but not yet shipped.
- SHIPPED - Postage has printed, and product has shipped (or will be in the mail soon). See ShipDate for expected shipping date.
- OrderStatusErrNum - If OrderStatus = "ERROR", OrderStatusErrNum gives you an error code:
- 0 - success.
- 10 - Error with address. See the ErrorStatusErrDesc for more detailed information.
- 20 - Test order. You submitted a test order which will never be manufactured or shipped. Test orders may be submitted when you test your order automation.
- OrderStatusErrDesc - If OrderStatus = "ERROR", OrderStatusErrDesc gives you descriptive error text information related to the error code specified in OrderStatusErrNum.
- ShipDate - Date the package shipped (or is expected to ship). Format mm/dd/yyyy. Once postage has printed a ShipDate is set, and
sometimes this is in the future (tomorrow or next business day for example).
- ShippingMethod - The shipping method you requested during the order process. Possible Values:
- standard
- standard+tracking
- priority
- express
- TrackingID - The tracking ID (if tracking is available).
- Use this URL to see the tracking information: https://www.endicia.com/tracking/?pic=trackingID
- TrackingID will be blank if no tracking is available (such as domestic standard rate first class letters or flats).
- For International (INTL) shipments, tracking may only be available to the point the package leaves the USA unless you use Priority or Express shipping.
- If you submit a single invoice as input there will only be one section in the response.