This is an old revision of the document!
Table of Contents
- type:
- integration
- supports-foxycart-version-from:
- 0.7.0
- system:
- MODx Evolution
- name:
- HMAC Price Validation
- description:
- A plugin to automatically verify all links and forms output using MODX.
- date:
- 2011-06-28
Automatic HMAC Price Validation for MODX Evolution + FoxyCart
Please note: The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please post in our forum, but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.
Description
Automatically validates all links and forms on pages generated by MODX Evolution, according to FoxyCart's HMAC Price Validation functionality.
This plugin is easy to install, and should “just work”, so it is recommended for all MODX Evolution installs.
Installation
- Create a directory in your
assets/plugins/directory calledfoxycart_validation. - Download the source file here and put it into the newly created
assets/plugins/foxycart_validation/directory. - Edit that file and enter the appropriate
$secretand$cart_urlvalues. (The$secretvalue is your store's API / datafeed key.) - Create a plugin named “FoxyCart Validation”.
- In the “System Events” tab, check the
OnWebPagePrerendercheckbox. - Paste in the code below and save.
- Go to your FoxyCart admin and enable the price validation under your “advanced” section. Save.
- Test.
- Test some more.
Requirements
- Form “code” values should not have leading or trailing whitespace.
- Cannot use double-pipes in an input's name.
- Empty textareas are assumed to be “open”.
Code
/** * FoxyCart Validation Plugin for MODx 1.x (Evolution) * * @author FoxyCart.com * @copyright FoxyCart.com LLC, 2010 * @version 0.7.0.20100730 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @example http://wiki.foxycart.com/docs/cart/validation * * Requirements: * - Form "code" values should not have leading or trailing whitespace. * - Cannot use double-pipes in an input's name * - Empty textareas are assumed to be "open" */ $e = &$modx->Event; switch ($e->name) { case "OnWebPagePrerender": $validate = $modx->config["base_path"].'assets/plugins/foxycart_validation/foxycart.cart_validation.php'; if (file_exists($validate)) { include_once($validate); $doc = $modx->documentOutput; $modx->documentOutput = FoxyCart_Helper::fc_hash_html($doc); } break; default: // stop here return; break; }