Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| integration:modx:hmac_price_validation [2011/06/28 17:46] – [Installation] foxybrett | integration:modx:hmac_price_validation [2017/07/13 02:21] (current) – [Code] adam | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ---- dataentry integration ---- | ---- dataentry integration ---- | ||
| - | type : integration | + | type |
| - | supports-foxycart-version-from : 0.7.0 # Minimum required FoxyCart version for this to work | + | supports-foxycart-version-from : 0.7.0 # Minimum required FoxyCart version for this to work |
| - | supports-foxycart-version-to | + | supports-foxycart-version-to |
| - | systems | + | systems |
| - | name : HMAC Price Validation | + | name |
| - | description | + | description |
| - | tags_tags | + | tags : hmac # tags, separated by commas. don't include the " |
| - | date_dt | + | date_dt |
| - | version | + | version |
| - | developer_url : | + | developer_url |
| ---- | ---- | ||
| - | ====== HMAC Price Validation for MODX Evolution + FoxyCart ====== | + | <WRAP important round> |
| + | //**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 [[http:// | ||
| + | </ | ||
| + | |||
| + | Depending on which version of MODx you're working with - please review the different sections below, with approaches for MODx Revo and Evolution. | ||
| + | |||
| + | |||
| + | ====== Automatic HMAC Price Validation for MODX Revo + FoxyCart ====== | ||
| + | |||
| + | ===== Description ===== | ||
| + | Automatically validates all links and forms on pages generated by [[http:// | ||
| + | |||
| + | This plugin is easy to install, and should "just work", so it is recommended for all MODX Revo installs. | ||
| + | |||
| + | Thanks to [[https:// | ||
| + | ===== Installation ===== | ||
| + | - Create a directory in your '' | ||
| + | - Download the source '' | ||
| + | - Edit that file and enter the appropriate '' | ||
| + | - Within MODx, under " | ||
| + | - Paste in the code below into the " | ||
| + | - In the " | ||
| + | - Save the plugin. | ||
| + | - Go to your [[https:// | ||
| + | - Test. | ||
| + | - Test some more. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | After creating the plugin - any add to cart link or forms on your website should be automatically signed for you. | ||
| + | |||
| + | ===== Requirements ===== | ||
| + | * All add to carts need to have a '' | ||
| + | * Cannot use double-pipes in an input' | ||
| + | * Empty textareas are assumed to be " | ||
| + | |||
| + | |||
| + | ===== Code ===== | ||
| + | <code php><? | ||
| + | /** | ||
| + | * FoxyCart Validation Plugin for MODx 2.x (Revolution) | ||
| + | */ | ||
| + | |||
| + | $e = & | ||
| + | switch ($e-> | ||
| + | case ' | ||
| + | include $modx-> | ||
| + | $modx-> | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | return; | ||
| + | </ | ||
| + | |||
| + | ====== | ||
| ===== Description ===== | ===== Description ===== | ||
| Automatically validates all links and forms on pages generated by [[http:// | Automatically validates all links and forms on pages generated by [[http:// | ||
| Line 39: | Line 95: | ||
| ===== Code ===== | ===== Code ===== | ||
| <code php> | <code php> | ||
| - | //<? | ||
| /** | /** | ||
| * FoxyCart Validation Plugin for MODx 1.x (Evolution) | * FoxyCart Validation Plugin for MODx 1.x (Evolution) | ||
| Line 59: | Line 114: | ||
| switch ($e-> | switch ($e-> | ||
| case " | case " | ||
| - | $validate = $modx-> | + | $validate = $modx-> |
| if (file_exists($validate)) { | if (file_exists($validate)) { | ||
| include_once($validate); | include_once($validate); | ||
| $doc = $modx-> | $doc = $modx-> | ||
| - | $modx-> | + | $modx-> |
| } | } | ||
| break; | break; | ||
| Line 71: | Line 126: | ||
| break; | break; | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | ====== Manual HMAC Price Validation for MODX Evolution + FoxyCart ====== | ||
| + | |||
| + | ===== Description ===== | ||
| + | Creates a snippet to manually validates links and forms in your pages, according to FoxyCart' | ||
| + | |||
| + | ===== Installation ===== | ||
| + | |||
| + | ==== Create a MODX snippet ==== | ||
| + | |||
| + | **Snippet Name:** | ||
| + | FoxyCartGetHMAC | ||
| + | |||
| + | **Snippet Code (paste into text box):** | ||
| + | <code php> | ||
| + | <?php | ||
| + | if(!function_exists(get_verification)) { | ||
| + | function get_verification($var_name, | ||
| + | $api_key = 'KEY HERE'; | ||
| + | $encodingval = htmlspecialchars($var_code) . htmlspecialchars($var_name) . htmlspecialchars($var_value); | ||
| + | return ' | ||
| + | |||
| + | //Use the following to test whether api_key has a value or not (only use in safe, sandbox scenarios!) | ||
| + | //return ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | ( isset($varName) ) ? $varName : $varName = ''; | ||
| + | ( isset($varValue) ) ? $varValue : $varValue = ''; | ||
| + | ( isset($varCode) ) ? $varCode : $varCode = ''; | ||
| + | |||
| + | if (empty($varName) || empty($varValue) || empty($varCode)) { | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | return get_verification($varName, | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Snippet Usage ==== | ||
| + | |||
| + | < | ||
| + | |||
| + | Example: | ||
| + | <code html>< | ||
| + | |||
| + | Notice the parts where the variable name code is the same: '' | ||
| + | and where the value is the same: '' | ||
| + | and where ''& | ||
| + | |||
| + | ===== Example Form ===== | ||
| + | |||
| + | Assuming you're using template variables price as '' | ||
| + | |||
| + | <code html> | ||
| + | <form name=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | </ | ||
| </ | </ | ||