Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
integration:zapier-datafeed [2014/10/07 15:28] – created foxybrett | integration:zapier-datafeed [2018/11/26 20:27] (current) – [Zapier] marija | ||
---|---|---|---|
Line 1: | Line 1: | ||
---- dataentry integration ---- | ---- dataentry integration ---- | ||
type : integration | type : integration | ||
- | supports-foxycart-version-from : | + | supports-foxycart-version-from : |
supports-foxycart-version-to | supports-foxycart-version-to | ||
- | systems | + | systems |
- | name : | + | name : Zapier Datafeed |
- | description | + | description |
- | tags_tags | + | tags_tags |
- | date_dt | + | date_dt |
- | version | + | version |
- | developer_url : | + | developer_url : |
---- | ---- | ||
- | ====== | + | ====== |
- | <WRAP important round> | + | < |
+ | **We have implemented a different approach for Zapier.** In place of the following snippet, we now have [[v: | ||
+ | |||
+ | |||
+ | <WRAP center | ||
//**Please note:**// | //**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:// | 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:// | ||
Line 22: | Line 26: | ||
===== Description ===== | ===== Description ===== | ||
+ | Use the FoxyCart datafeed to push your orders to Zapier for processing and submitting to third-party API's. | ||
+ | ===== Requirements ===== | ||
+ | PHP, cURL | ||
- | ===== Installation | + | ===== Code ===== |
+ | <code php><? | ||
+ | //Zapier Webhook Script by David Hollander, www.sparkweb.net | ||
+ | //Version 1.0, 2014-10-07 | ||
+ | //Setup Instructions | ||
+ | // | ||
- | ===== Requirements ===== | + | //Go to this url to enable the Zapier app: https:// |
+ | //Get this field from the FoxyCart > Advanced Settings page | ||
+ | $foxycart_api_key = ""; | ||
- | ===== Code ===== | + | // |
- | <code html> | + | $zapier_static_webhook_url |
- | insert your code here, or upload | + | |
+ | //This file needs to be saved on your webserver. Then go to Advanced Settings and check the box to enable store datafeed. | ||
+ | //Put the url for this file in the datafeed box. | ||
+ | |||
+ | //When Zapier asks you to create a brand new transaction in FoxyCart, just refeed a transaction. | ||
+ | //You can do this by expanding the transaction on the FoxyCart transactions page. | ||
+ | |||
+ | // | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | // | ||
+ | if (isset($_POST[" | ||
+ | |||
+ | //Make sure we have everything we need | ||
+ | if (!$foxycart_api_key) { | ||
+ | die(" | ||
+ | } elseif (!$zapier_static_webhook_url) { | ||
+ | die(" | ||
+ | } | ||
+ | |||
+ | //Decrypt the Datafeed | ||
+ | $decrypted | ||
+ | $xml_string | ||
+ | $json | ||
+ | |||
+ | //Send to Zapier | ||
+ | $ch = curl_init(); | ||
+ | curl_setopt_array($ch, | ||
+ | CURLOPT_URL | ||
+ | CURLOPT_FAILONERROR | ||
+ | CURLOPT_RETURNTRANSFER | ||
+ | CURLOPT_TIMEOUT | ||
+ | CURLOPT_POSTFIELDS | ||
+ | CURLOPT_POST => true, | ||
+ | )); | ||
+ | $result = curl_exec($ch); | ||
+ | curl_close($ch); | ||
+ | |||
+ | //Process Response | ||
+ | $json = json_decode($result, | ||
+ | |||
+ | //No JSON Returned | ||
+ | if (!is_array($json)) { | ||
+ | die(" | ||
+ | |||
+ | // | ||
+ | } elseif ($json[' | ||
+ | die(" | ||
+ | |||
+ | //All Good! | ||
+ | } else { | ||
+ | die(" | ||
+ | } | ||
+ | |||
+ | } else { | ||
+ | die(' | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | //Decrypt Data From Source | ||
+ | function foxycart_decrypt($src) { | ||
+ | global $foxycart_api_key; | ||
+ | return rc4crypt:: | ||
+ | } | ||
+ | |||
+ | |||
+ | // ====================================================================================== | ||
+ | // RC4 ENCRYPTION CLASS | ||
+ | // Do not modify. | ||
+ | // ====================================================================================== | ||
+ | /** | ||
+ | * RC4Crypt 3.2 | ||
+ | * | ||
+ | * RC4Crypt is a petite library that allows you to use RC4 | ||
+ | * encryption easily in PHP. It's OO and can produce outputs | ||
+ | * in binary and hex. | ||
+ | * | ||
+ | * (C) Copyright 2006 Mukul Sabharwal [http:// | ||
+ | | ||
+ | * | ||
+ | * @link http:// | ||
+ | * @author Mukul Sabharwal | ||
+ | * @version $Id: class.rc4crypt.php,v 3.2 2006/03/10 05:47:24 mukul Exp $ | ||
+ | * @copyright Copyright © 2006 Mukul Sabharwal | ||
+ | * @license http:// | ||
+ | * @package RC4Crypt | ||
+ | */ | ||
+ | class rc4crypt { | ||
+ | /** | ||
+ | * The symmetric encryption function | ||
+ | * | ||
+ | * @param string $pwd Key to encrypt with (can be binary of hex) | ||
+ | * @param string $data Content to be encrypted | ||
+ | * @param bool $ispwdHex Key passed is in hexadecimal | ||
+ | * @access public | ||
+ | * @return string | ||
+ | */ | ||
+ | public static function encrypt ($pwd, $data, $ispwdHex = 0) { | ||
+ | if ($ispwdHex) $pwd = @pack(' | ||
+ | | ||
+ | $box[] = ''; | ||
+ | $cipher = ''; | ||
+ | $pwd_length = strlen($pwd); | ||
+ | $data_length = strlen($data); | ||
+ | for ($i = 0; $i < 256; $i++) { | ||
+ | $key[$i] = ord($pwd[$i % $pwd_length]); | ||
+ | $box[$i] = $i; | ||
+ | } | ||
+ | for ($j = $i = 0; $i < 256; $i++) { | ||
+ | $j = ($j + $box[$i] + $key[$i]) % 256; | ||
+ | $tmp = $box[$i]; | ||
+ | $box[$i] = $box[$j]; | ||
+ | $box[$j] = $tmp; | ||
+ | } | ||
+ | for ($a = $j = $i = 0; $i < $data_length; | ||
+ | $a = ($a + 1) % 256; | ||
+ | $j = ($j + $box[$a]) % 256; | ||
+ | $tmp = $box[$a]; | ||
+ | $box[$a] = $box[$j]; | ||
+ | $box[$j] = $tmp; | ||
+ | $k = $box[(($box[$a] + $box[$j]) % 256)]; | ||
+ | $cipher .= chr(ord($data[$i]) ^ $k); | ||
+ | } | ||
+ | return $cipher; | ||
+ | } | ||
+ | /** | ||
+ | * Decryption, recall encryption | ||
+ | * | ||
+ | * @param string $pwd Key to decrypt with (can be binary of hex) | ||
+ | * @param string $data Content to be decrypted | ||
+ | * @param bool $ispwdHex Key passed is in hexadecimal or not | ||
+ | * @access public | ||
+ | * @return string | ||
+ | */ | ||
+ | public static function decrypt ($pwd, $data, $ispwdHex = 0) { | ||
+ | return rc4crypt:: | ||
+ | } | ||
+ | } | ||
</ | </ | ||