Completed
Pull Request — master (#287)
by Nic
08:29
created
code/controllers/FoxyStripe_Controller.php 1 patch
Spacing   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
 	    // handle POST from FoxyCart API transaction
18 18
 		if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) {
19 19
 			$FoxyData_encrypted = (isset($_POST["FoxyData"])) ?
20
-                urldecode($_POST["FoxyData"]) :
21
-                urldecode($_POST["FoxySubscriptionData"]);
22
-			$FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted);
20
+                urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]);
21
+			$FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted);
23 22
 			self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted);
24 23
 			
25 24
 			// extend to allow for additional integrations with Datafeed
@@ -27,14 +26,14 @@  discard block
 block discarded – undo
27 26
 			
28 27
 			return 'foxy';
29 28
 			
30
-		} else {
29
+		}else {
31 30
 			
32 31
 			return "No FoxyData or FoxySubscriptionData received.";
33 32
 			
34 33
 		}
35 34
 	}
36 35
 
37
-    public function handleDataFeed($encrypted, $decrypted){
36
+    public function handleDataFeed($encrypted, $decrypted) {
38 37
         //handle encrypted & decrypted data
39 38
         $orders = new SimpleXMLElement($decrypted);
40 39
 
@@ -43,12 +42,11 @@  discard block
 block discarded – undo
43 42
 
44 43
             if (isset($order->id)) {
45 44
                 ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ?
46
-                    $transaction :
47
-                    $transaction = Order::create();
45
+                    $transaction : $transaction = Order::create();
48 46
             }
49 47
 
50 48
             // save base order info
51
-            $transaction->Order_ID = (int) $order->id;
49
+            $transaction->Order_ID = (int)$order->id;
52 50
             $transaction->Response = $decrypted;
53 51
 
54 52
             // record transaction as order
@@ -103,11 +101,11 @@  discard block
 block discarded – undo
103 101
             if (isset($order->customer_email) && $order->is_anonymous == 0) {
104 102
 
105 103
                 // if Customer is existing member, associate with current order
106
-                if(Member::get()->filter('Email', $order->customer_email)->First()) {
104
+                if (Member::get()->filter('Email', $order->customer_email)->First()) {
107 105
 
108 106
                     $customer = Member::get()->filter('Email', $order->customer_email)->First();
109 107
 
110
-                } else {
108
+                }else {
111 109
 
112 110
                     // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again
113 111
                     Config::inst()->update('Security', 'password_encryption_algorithm', 'none');
@@ -213,17 +211,17 @@  discard block
 block discarded – undo
213 211
         // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
214 212
         // fake user will redirect to FC checkout, ask customer to log in
215 213
         // to do: consider a login/registration form here if not logged in
216
-        if($Member = Member::currentUser()) {
214
+        if ($Member = Member::currentUser()) {
217 215
             $Member = Member::currentUser();
218
-        } else {
216
+        }else {
219 217
             $Member = new Member();
220 218
             $Member->Customer_ID = 0;
221 219
         }
222 220
 
223
-        $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey());
221
+        $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::getStoreKey());
224 222
 
225
-        $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token .
226
-            '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '&timestamp=' . $timestampNew;
223
+        $redirect_complete = 'https://'.FoxyCart::getFoxyCartStoreName().'.foxycart.com/checkout?fc_auth_token='.$auth_token.
224
+            '&fcsid='.$fcsid.'&fc_customer_id='.$Member->Customer_ID.'&timestamp='.$timestampNew;
227 225
 	
228 226
 	    $this->redirect($redirect_complete);
229 227
 
Please login to merge, or discard this patch.
tests/StoreSettingsTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class StoreSettingsTest extends FS_Test{
3
+class StoreSettingsTest extends FS_Test {
4 4
 
5 5
 	protected static $use_draft_site = true;
6 6
 
7
-	function setUp(){
7
+	function setUp() {
8 8
 		parent::setUp();
9 9
 
10 10
 		$siteConf = SiteConfig::current_site_config();
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		$siteConf->write();
14 14
 	}
15 15
 
16
-	function testStoreKey(){
16
+	function testStoreKey() {
17 17
 		$pref = FoxyCart::getKeyPrefix();
18 18
 		$siteConf = SiteConfig::current_site_config();
19 19
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         $this->assertEquals(substr($siteConf->StoreKey, 0, 6), $pref);
23 23
 	}
24 24
 
25
-	function testStoreName(){
25
+	function testStoreName() {
26 26
 		$siteConf = SiteConfig::current_site_config();
27 27
 
28 28
         $this->assertEquals($siteConf->StoreName, 'foxystripe');
Please login to merge, or discard this patch.
tests/ProductDiscountTierTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class ProductDiscountTierTest extends FS_Test{
3
+class ProductDiscountTierTest extends FS_Test {
4 4
 
5 5
 	protected static $use_draft_site = true;
6 6
 
7
-	function setUp(){
7
+	function setUp() {
8 8
 		parent::setUp();
9 9
 
10 10
 		$productHolder = ProductHolder::create();
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$product->write();
17 17
 	}
18 18
 
19
-	public function testProductDiscountTierCreation(){
19
+	public function testProductDiscountTierCreation() {
20 20
 		$this->logInWithPermission('Product_CANCRUD');
21 21
 
22 22
 		$discount = ProductPage::get()->first();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		$this->logOut();
35 35
 	}
36 36
 
37
-	public function testProductDiscountTierEdit(){
37
+	public function testProductDiscountTierEdit() {
38 38
 		$this->logInWithPermission('ADMIN');
39 39
 
40 40
 		$discount = ProductPage::get()->first();
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		$this->logOut();
58 58
 	}
59 59
 
60
-	public function testProductDiscountTierDeletion(){
60
+	public function testProductDiscountTierDeletion() {
61 61
 		$this->logInWithPermission('ADMIN');
62 62
 
63 63
 		$discount = ProductPage::get()->first();
Please login to merge, or discard this patch.
code/form/FoxyStripePurchaseForm.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'product_id',
121 121
                 $this->product->ID))->setValue($this->product->ID));
122 122
             $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'price',
123
-                $this->product->Price))->setValue($this->product->Price));//can't override id
123
+                $this->product->Price))->setValue($this->product->Price)); //can't override id
124 124
             $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'weight',
125 125
                 $this->product->Weight))->setValue($this->product->Weight));
126 126
             if ($this->DiscountTitle && $this->ProductDiscountTiers()->exists()) {
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 
152 152
             $fields->push(DropdownField::create('quantity', 'Quantity', $quantity));
153 153
 
154
-            $fields->push(HeaderField::create('submitPrice', '$' . $this->product->Price, 4));
154
+            $fields->push(HeaderField::create('submitPrice', '$'.$this->product->Price, 4));
155 155
 
156 156
 
157 157
             $this->extend('updatePurchaseFormFields', $fields);
158
-        } else {
158
+        }else {
159 159
             $fields->push(HeaderField::create('submitPrice', 'Currently Out of Stock'), 4);
160 160
         }
161 161
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     protected function getProductOptionSet()
193 193
     {
194 194
 
195
-        $assignAvailable = function ($self) {
195
+        $assignAvailable = function($self) {
196 196
             $this->extend('updateFoxyStripePurchaseForm', $form);
197 197
             $self->Available = ($self->getAvailability()) ? true : false;
198 198
         };
Please login to merge, or discard this patch.
code/objects/Order.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@
 block discarded – undo
85 85
 
86 86
     public function getReceiptLink()
87 87
     {
88
-        $obj= HTMLVarchar::create();
89
-        $obj->setValue('<a href="' . $this->ReceiptURL . '" target="_blank" class="cms-panel-link action external-link">view</a>');
88
+        $obj = HTMLVarchar::create();
89
+        $obj->setValue('<a href="'.$this->ReceiptURL.'" target="_blank" class="cms-panel-link action external-link">view</a>');
90 90
         return $obj;
91 91
     }
92 92
 
Please login to merge, or discard this patch.
code/objects/products/FoxyStripeProduct.php 1 patch
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             'Image used throughout site to represent this product');
92 92
 
93 93
         // Cateogry Dropdown field w/ add new
94
-        $source = function () {
94
+        $source = function() {
95 95
             return ProductCategory::get()->map()->toArray();
96 96
         };
97 97
         $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source())
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         if (class_exists('GridFieldSortableRows')) {
136 136
             $config->addComponent(new GridFieldSortableRows('SortOrder'));
137 137
             $products = $this->ProductOptions()->sort('SortOrder');
138
-        } else {
138
+        }else {
139 139
             $products = $this->ProductOptions();
140 140
         }
141 141
         $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 ->setFolderName('Uploads/Products')
192 192
                 ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))
193 193
                 ->setAllowedMaxFileNumber(1),
194
-            HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD' . 'Product Image Gallery'), 2),
194
+            HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'.'Product Image Gallery'), 2),
195 195
             $prodImagesField
196 196
                 ->setDescription(_t(
197 197
                     'ProductPage.ProductImagesDescription',
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             $product = ProductPage::get()->byID($this->ID);
253 253
             if (isset($product->ParentID)) {
254 254
                 $origParent = $product->ParentID;
255
-            } else {
255
+            }else {
256 256
                 $origParent = null;
257 257
             }
258 258
             $currentParent = $this->ParentID;
@@ -333,14 +333,13 @@  discard block
 block discarded – undo
333 333
     ) {
334 334
         $optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName;
335 335
         return (SiteConfig::current_site_config()->CartValidation)
336
-            ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) :
337
-            $optionValue;
336
+            ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) : $optionValue;
338 337
     }
339 338
 
340 339
     // get FoxyCart Store Name for JS call
341 340
     public function getCartScript()
342 341
     {
343
-        return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>';
342
+        return '<script src="https://cdn.foxycart.com/'.FoxyCart::getFoxyCartStoreName().'/loader.js" async defer></script>';
344 343
     }
345 344
 
346 345
     public function getDiscountFieldValue()
Please login to merge, or discard this patch.
tests/FoxyStripeProductTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,14 +53,14 @@
 block discarded – undo
53 53
         $product2->doPublish();
54 54
         $this->assertTrue($product2->isPublished());
55 55
 
56
-        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = ' . $productID);
56
+        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = '.$productID);
57 57
         $versionsPostPublish = array();
58 58
         foreach ($versions as $versionRow) $versionsPostPublish[] = $versionRow;
59 59
 
60 60
         $product2->delete();
61 61
         $this->assertTrue(!$product2->isPublished());
62 62
 
63
-        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = ' . $productID);
63
+        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = '.$productID);
64 64
         $versionsPostDelete = array();
65 65
         foreach ($versions as $versionRow) $versionsPostDelete[] = $versionRow;
66 66
 
Please login to merge, or discard this patch.