Content-type: text/html
You must provide several options to this script as hidden fields on the submission form. This will allow the script to operate in a way most compatible with your site.
The following fields are required. If they are not present, this error message will be displayed.
result_url- the result URL when credit card validation is successful -- see note below
result_url_unverified- the result URL when credit card validation is unsuccessful -- see note below
vt_url- the URL of the TMM Virtual Terminal which will be used to validate credit cards
mail_company- the name of the company that is receiving payment (your company)
mail_address- the street address of the above
mail_city- the city of the above
mail_state- the state of the above
mail_zip- the zip code of the above
mail_recipient- the e-mail address of the person who should receive the orders
script_url- the URL of this script
local_country- the name of the country in which the receiving company (your company) is located
mail_result_url- the URL of the result page when the output of the script is a mail to you without TMM interaction (when the total order is /usr/local/src/tmmorder/tmmorder.pl.00 but there is one or more items--i.e. for free items)
mailserver- the mailserver to use when the order is e-mailed instead of going through TMM. This happens when there are items being ordered, but the total cost is zero (i.e. request of a free trial, etc)
The following fields allow finer control over the behavior of the script.
bgcolor- the background color of all pages generated. Default is FFFFFF. It must be in RGB hex triplet format, as with the bgcolor attribute of the tag, but without the leading hash mark. Thus, for black, use
<input type=hidden name=bgcolor value=000000>
textcolor- the text color of all pages generated. Default is 000000
bg_image- the background image for all pages generated Default is same as bgcolor.
no_print_validated- Normally, when a user is validated, this script prints a message saying that the person was validated and gives the validation code, then prints the contents of result_url after this. If you would rather that TMM returns to a different page (a different script, for instance), set this variable to "true". Otherwise do not set this variable
head_image- the URL of the image that should be printed at the top of all output pages
table_bgcolor- the background color of the table containing the items that the person is ordering
cc_recipient- recipients of copies of the e-mails generated by this script (but not by TMM) in a comma-delimited list, i.e. "foo@bar.com,user@domain.com"
The following fields must be entered by the user or the script will generate an error.
snd_name- the name of the user
snd_addr1- the address of the user
snd_city- the city of the user
snd_state- the state of the user (2-letter postal abbreviations only)
snd_zip- the zip code of the user
snd_country- the country of the user
snd_phone- the phone number of the user
snd_mail- the e-mail address of the user
You can also make other fields required. In order to do this, make a hidden field called [name]_required where [name] is the name of the field. For instance, to require the user to enter the last_name field, use
<input type="hidden" name="last_name_required" value="true">
The following fields are required for each item:
itemXnum- the item number (not quantity) for item X. Replace X with sequential numbers starting with 1
itemXprice- the price each for item X
itemXqty- the quantity of item X being purchased
itemXdesc- a string description of item X
itemXship, itemXiship- see description below in Shipping
The following is how to specify tax rates
[STATE]_tax- to specify the tax rate for a certain state, use this form, where [STATE] is the two-letter postal abbreviation for the state. The value of the input field should be the decimal tax rate. For instance, to specify that purchasers in Iowa pay 5% tax, use the following:
<input type="hidden" name="IA_tax" value=".05">You may specify as many tax rates as you like. Users who are from unlisted states pay no tax.
If you want to give the option to use an alternate shipping address, simply add a checkbox named "diffship" as in this example:
Check here if you want this order shipped to a different address: <input type="checkbox" name="diffship">
Each option for specifiying shipping prices should be followed by a number (the X in each option below). This number is the shipping method. ship_method should be used to choose which rate is desirable. If there is only one shipping rate, provide only option 1 and ship_method will be automatically set to 1 by the script.
ship_method- a radio button which determines which shipping price will be used. If omitted, method 1 is used
ship_method_X_name- a hidden field which should be included for each shipping method which provides the name of the shipping method (i.e. "2nd day", "first class", etc). If you are specifying shipping price by item, you must specify the price for each shipping method on every item
Choose one of the following methods for determining shipping rate. The methods are listed in order of precedence; if two methods are used, the one of higher precedence will be the one that actually determines the rate for shipping.
global_shipX- The total shipping price. Only enter this field if you want the shipping rate to remain the same regardless of the order
global_ishipX- The total international shipping price. Enter this along with the above to indicate a difference in rate to countries other than the one specified in local_country. Leave unused if the rate is the same to all countries
global_ship_eachX- The shipping rate for each item. Only enter this field if each item ordered has the same shipping rate. global_ship_each * totalquantity gives the shipping cost
global_iship_eachX- The international shipping rate for each item. Enter this field along with the above to indicate a difference in rate to countries other than the one specified in local_country. Leave unused if the rate is the same to all countries
itemXshipX- the shipping rate for each item X. Enter this field if you want each item to have a different shipping rate. If you want to use this for one item, you must use it for every item. Total shipping is determined by itemXship * itemXqty + itemYship * itemYqty etc.
itemXishipX- the shipping rate for each item X. Enter this field along with the above to indicate a difference in rate to countries other than the one specified in local_country. Leave unused if the rate is the same to all countries
It is possible to make the Total Merchant Manager Virtual Terminal return directly to result_url instead of printing the validation information and then dumping the appropriate HTML. This is useful if you want to return to a CGI script, such as one that will add a user to a database. If it is necessary to pass variables based on the user input, the following methods of setting variables to pass through the TMM Virtual Terminal are available:
passthruX- to always pass a variable through, use this tag. X is any number 1 - 9
passvarX- to pass the value of the variable specified as the value of this option through the script, use this variant of the above. Any number used as X here may not be used above. Valid X is 1 - 9, excluding values used above.
These will be passed through as POST variables USER1 - USER9. passthruX corresponds to USERX.
Total Merchant Manager returns the following variables:
VALIDATED = Y | N
APP_CODE = approval code
These indicate status of validation (Y is validated, N is not), and the approval code if the card was validated. TMM does not return the credit card number unless there is a secure URL whose SSL certificate matches the Merchant Name. Contact TMM for more information.
The HTML page pointed to by result_url or result_url_unverified should not be a full HTML page, but rather the latter half of one. The output of the script will print out the beginning tags, and state whether the credit card was validated or not, then dump the HTML code from either result_url or result_url_unverified as appropriate.
The above is only true if no_print_validated is unset. If no_print_validated is set, result_url must be either a full HTML page or a CGI script, and result_url_unverified is ignored.
See the section Returning to CGI Scripts above for more information.
This script was written by Riad Wahby (rsw@mit.edu). I provide no warranties of any kind. Any damage done by this script is not my responsibility. If you have any questions or suggestions for improving this script, please mail them to me.
TMMOrder version 1.0.7
The newest version is always available at ftp://ftp.phonon.net/pub/tmmorder.