@@ -2,37 +2,37 @@ discard block |
||
2 | 2 | |
3 | 3 | class FoxyStripe_Controller extends Page_Controller { |
4 | 4 | |
5 | - const URLSegment = 'foxystripe'; |
|
5 | + const URLSegment = 'foxystripe'; |
|
6 | 6 | |
7 | - public function getURLSegment() { |
|
8 | - return self::URLSegment; |
|
9 | - } |
|
7 | + public function getURLSegment() { |
|
8 | + return self::URLSegment; |
|
9 | + } |
|
10 | 10 | |
11 | - static $allowed_actions = array( |
|
12 | - 'index', |
|
11 | + static $allowed_actions = array( |
|
12 | + 'index', |
|
13 | 13 | 'sso' |
14 | - ); |
|
14 | + ); |
|
15 | 15 | |
16 | - public function index() { |
|
17 | - // handle POST from FoxyCart API transaction |
|
18 | - if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
|
19 | - $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
|
16 | + public function index() { |
|
17 | + // handle POST from FoxyCart API transaction |
|
18 | + if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
|
19 | + $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
|
20 | 20 | urldecode($_POST["FoxyData"]) : |
21 | 21 | urldecode($_POST["FoxySubscriptionData"]); |
22 | - $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
23 | - self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
|
22 | + $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
23 | + self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
|
24 | 24 | |
25 | - // extend to allow for additional integrations with Datafeed |
|
26 | - $this->extend('addIntegrations', $FoxyData_encrypted); |
|
25 | + // extend to allow for additional integrations with Datafeed |
|
26 | + $this->extend('addIntegrations', $FoxyData_encrypted); |
|
27 | 27 | |
28 | - return 'foxy'; |
|
28 | + return 'foxy'; |
|
29 | 29 | |
30 | - } else { |
|
30 | + } else { |
|
31 | 31 | |
32 | - return "No FoxyData or FoxySubscriptionData received."; |
|
32 | + return "No FoxyData or FoxySubscriptionData received."; |
|
33 | 33 | |
34 | - } |
|
35 | - } |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | 37 | public function handleDataFeed($encrypted, $decrypted){ |
38 | 38 | //handle encrypted & decrypted data |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - // Single Sign on integration with FoxyCart |
|
220 | + // Single Sign on integration with FoxyCart |
|
221 | 221 | public function sso() { |
222 | 222 | |
223 | - // GET variables from FoxyCart Request |
|
223 | + // GET variables from FoxyCart Request |
|
224 | 224 | $fcsid = $this->request->getVar('fcsid'); |
225 | 225 | $timestampNew = strtotime('+30 days'); |
226 | 226 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $redirect_complete = 'https://' . $link . '/checkout?fc_auth_token=' . $auth_token . |
247 | 247 | '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
248 | 248 | |
249 | - $this->redirect($redirect_complete); |
|
249 | + $this->redirect($redirect_complete); |
|
250 | 250 | |
251 | 251 | } |
252 | 252 |
@@ -8,40 +8,40 @@ discard block |
||
8 | 8 | class FoxyCart |
9 | 9 | { |
10 | 10 | |
11 | - private static $keyPrefix = 'dYnm1c'; |
|
12 | - |
|
13 | - public static function setStoreKey($length = 54, $count = 0){ |
|
14 | - $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now'); |
|
15 | - $strLength = strlen($charset); |
|
16 | - $str = ''; |
|
17 | - while($count < $length){ |
|
18 | - $str .= $charset[mt_rand(0, $strLength-1)]; |
|
19 | - $count++; |
|
20 | - } |
|
21 | - return self::getKeyPrefix().substr(base64_encode($str),0,$length); |
|
22 | - } |
|
23 | - |
|
24 | - public static function getStoreKey(){ |
|
25 | - $config = SiteConfig::current_site_config(); |
|
26 | - if($config->StoreKey){ |
|
27 | - return $config->StoreKey; |
|
28 | - } |
|
29 | - return null; |
|
30 | - } |
|
31 | - |
|
32 | - public static function store_name_warning(){ |
|
33 | - $warning = null; |
|
34 | - if(self::getFoxyCartStoreName()===null){ |
|
35 | - $warning = 'Must define FoxyCart Store Name or Store Remote Domain in your site settings in the cms'; |
|
36 | - } |
|
37 | - return $warning; |
|
38 | - } |
|
39 | - |
|
40 | - public static function getFoxyCartStoreName(){ |
|
41 | - $config = SiteConfig::current_site_config(); |
|
42 | - if ($config->CustomSSL) { |
|
43 | - if ($config->RemoteDomain) { |
|
44 | - return $config->RemoteDomain; |
|
11 | + private static $keyPrefix = 'dYnm1c'; |
|
12 | + |
|
13 | + public static function setStoreKey($length = 54, $count = 0){ |
|
14 | + $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now'); |
|
15 | + $strLength = strlen($charset); |
|
16 | + $str = ''; |
|
17 | + while($count < $length){ |
|
18 | + $str .= $charset[mt_rand(0, $strLength-1)]; |
|
19 | + $count++; |
|
20 | + } |
|
21 | + return self::getKeyPrefix().substr(base64_encode($str),0,$length); |
|
22 | + } |
|
23 | + |
|
24 | + public static function getStoreKey(){ |
|
25 | + $config = SiteConfig::current_site_config(); |
|
26 | + if($config->StoreKey){ |
|
27 | + return $config->StoreKey; |
|
28 | + } |
|
29 | + return null; |
|
30 | + } |
|
31 | + |
|
32 | + public static function store_name_warning(){ |
|
33 | + $warning = null; |
|
34 | + if(self::getFoxyCartStoreName()===null){ |
|
35 | + $warning = 'Must define FoxyCart Store Name or Store Remote Domain in your site settings in the cms'; |
|
36 | + } |
|
37 | + return $warning; |
|
38 | + } |
|
39 | + |
|
40 | + public static function getFoxyCartStoreName(){ |
|
41 | + $config = SiteConfig::current_site_config(); |
|
42 | + if ($config->CustomSSL) { |
|
43 | + if ($config->RemoteDomain) { |
|
44 | + return $config->RemoteDomain; |
|
45 | 45 | } |
46 | 46 | } else { |
47 | 47 | if ($config->StoreName){ |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - return null; |
|
53 | - } |
|
52 | + return null; |
|
53 | + } |
|
54 | 54 | |
55 | - public static function FormActionURL() { |
|
55 | + public static function FormActionURL() { |
|
56 | 56 | $config = SiteConfig::current_site_config(); |
57 | 57 | |
58 | 58 | if ($config->CustomSSL) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } else { |
61 | 61 | return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName()); |
62 | 62 | } |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * FoxyCart API v1.1 functions |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | return self::getAPIRequest($foxyData); |
127 | 127 | } |
128 | 128 | |
129 | - public static function getKeyPrefix(){ |
|
130 | - return self::$keyPrefix; |
|
131 | - } |
|
129 | + public static function getKeyPrefix(){ |
|
130 | + return self::$keyPrefix; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |