Sharemagnet_Social_Rebate - Version 1.1.2

Version Notes

This is a development version.

Download this release

Release Info

Developer Ben Stewart
Extension Sharemagnet_Social_Rebate
Version 1.1.2
Comparing to
See all releases


Code changes from version 1.0.7 to 1.1.2

app/code/community/Sharemagnet/Social/Rebate/Model/Observer.php CHANGED
@@ -1,116 +1,129 @@
1
  <?php
2
-
3
- class Sharemagnet_Social_Rebate_Model_Observer
4
- {
5
- /*
6
- Resource name: rebate_session
7
- Request method: POST
8
- Endpoint URL: http://sharemagnet.com/rest/v1/social-rebates/rebate_session/
9
- Mime type: application/json
10
- */
11
- protected $_initSharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session/';
12
-
13
- /*
14
- Resource name: rebate_session
15
- Request method: GET
16
- Endpoint URL: http://sharemagnet.com/rest/v1/social-rebates/rebate_session/<id>/
17
- GET params:
18
 
19
- magnet_key = ‘538441DA’
20
- */
21
  protected $_requestSharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session/';
22
-
23
- /**
24
- *
25
- * Resource name: rebate_session_order
26
- Request method: PUT
27
- Endpoint URL: http://sharemagnet.com/rest/v1/social-rebates/rebate_session_order/<order_id>/
28
- GET params:
29
-
30
- api_key = ‘c7c43d18154e8fa317f0d0b8ae76d321f97fd221’
31
- api_secret = ‘0491c4c7f8e90ee93fd5b9e7be1b1d70a35374ca’
32
- magnet_key = ‘538441DA’
33
- backend = ‘magento’
34
- PUT params:
35
-
36
- order_verified (boolean)
37
- *
38
- *
39
- */
40
  protected $_verifySharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session_order/';
41
 
42
- public function prepareService($event)
43
- {
44
  $order = $event->getOrder();
45
  $orderId= $order->getId();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  $orderEmail=$order->getCustomerEmail();
47
  $purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
48
- try
49
- {
50
  $restApiKey = $this->getRestApiKey();
51
  $restApiSecret = $this->getRestApiSecret();
52
  $restApiMagnet = $this->getRestMagnetKey();
53
-
54
- if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!="")
55
- {
56
  $client = new Zend_Http_Client();
57
-
58
  // initialize api session
59
  $client->setUri($this->_initSharemagnetApiUrl);
60
-
61
-
62
- $arr=array('magnet_key'=>$restApiMagnet,'type'=>'magento','order_id'=>$orderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount);
63
  $response=$client->setRawData(json_encode($arr), 'application/json')->request('POST');
64
  $call_integration_url=$response->getHeader("Location")."?magnet_key=".$restApiMagnet."&format=json";
65
- if ($response->getStatus()==201 && $response->getMessage()=="CREATED")
66
- {
67
-
68
  //get existing api session
69
- $client1 =new Zend_Http_Client();
70
-
71
  $client1->setUri($response->getHeader("Location"));
72
- $client1->setParameterGet(array('magnet_key'=>$restApiMagnet,'format'=>'json'));
73
-
 
74
  $response1 = $client1->request();
75
- if ($response1->getStatus()==500 || $response1->getStatus()==501)
76
- {
77
-
78
- }
79
- else
80
- {
81
  $responseBody1 = json_decode($response1->getBody());
82
  $integration_code=$responseBody1->integration_code;
83
  $offer_type=$responseBody1->offer_type;
84
  $order_id=$responseBody1->order_id;
85
  $order_email=$responseBody1->order_email;
86
-
87
  Mage::getSingleton('core/session')->setIntegrationCode($integration_code);
88
- /* */
89
  Mage::getSingleton('core/session')->setOfferType($offer_type);
90
  }
91
  }
92
- else
93
- {
94
-
95
- }
96
  }
97
- } catch (Exception $e) {
98
- $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
99
- $responseBody = '';
100
  }
101
-
102
  return $this;
103
  }
104
- public function getRestApiKey() {
 
105
  return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apikey'));
106
  }
107
 
108
- public function getRestApiSecret() {
109
  return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apisecret'));
110
  }
111
- public function getRestMagnetKey() {
 
112
  return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_magnetkey'));
113
  }
114
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
- ?>
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ class Sharemagnet_Social_Rebate_Model_Observer{
4
+ protected $_initSharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session/';
5
  protected $_requestSharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session/';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  protected $_verifySharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session_order/';
7
 
8
+ public function prepareService($event){
 
9
  $order = $event->getOrder();
10
  $orderId= $order->getId();
11
+ $incrementId = $order->getIncremementId();
12
+ $realOrderId=$order->getRealOrderId();
13
+ if(!$orderId){
14
+ $orderId = 'NONE';
15
+ }
16
+ if(!$realOrderId){
17
+ $realOrderId = 'NONE';
18
+ }
19
+ if(!$incrementId){
20
+ $incrementId = 'NONE';
21
+ }
22
+ try{
23
+ $order_created = $order->created_at;
24
+ }
25
+ catch(Exception $e){
26
+ $order_created = NULL;
27
+ }
28
+ if(!$order_created){
29
+ $order_created = strftime('%Y-%m-%d %H:%M:%S',time());
30
+ }
31
  $orderEmail=$order->getCustomerEmail();
32
  $purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
33
+ try{
 
34
  $restApiKey = $this->getRestApiKey();
35
  $restApiSecret = $this->getRestApiSecret();
36
  $restApiMagnet = $this->getRestMagnetKey();
37
+ if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!=""){
 
 
38
  $client = new Zend_Http_Client();
 
39
  // initialize api session
40
  $client->setUri($this->_initSharemagnetApiUrl);
41
+ $client->setConfig(array(
42
+ 'timeout' => 5));
43
+ $arr=array('magnet_key'=>$restApiMagnet,'type'=>'magento','order_id'=>$orderId,'increment_id'=>$incrementId,'real_order_id'=>$realOrderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount,'order_created'=>$order_created);
44
  $response=$client->setRawData(json_encode($arr), 'application/json')->request('POST');
45
  $call_integration_url=$response->getHeader("Location")."?magnet_key=".$restApiMagnet."&format=json";
46
+ $call_integration_url .= "&real_order_id=" . $realOrderId . "&increment_id=" . $incrementId . "&order_created=" . $order_created . "&order_email=" . $orderEmail. "&purchase_amount=" . $purchase_amount;
47
+ if ($response->getStatus()==201 && $response->getMessage()=="CREATED"){
 
48
  //get existing api session
49
+ $client1 =new Zend_Http_Client();
 
50
  $client1->setUri($response->getHeader("Location"));
51
+ $client1->setConfig(array(
52
+ 'timeout' => 5));
53
+ $client1->setParameterGet(array('magnet_key'=>$restApiMagnet,'type'=>'magento','format'=>'json','order_id'=>$orderId,'increment_id'=>$incrementId,'real_order_id'=>$realOrderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount,'order_created'=>$order_created));
54
  $response1 = $client1->request();
55
+ if($response1->getStatus()!=500 && $response1->getStatus()!=501){
 
 
 
 
 
56
  $responseBody1 = json_decode($response1->getBody());
57
  $integration_code=$responseBody1->integration_code;
58
  $offer_type=$responseBody1->offer_type;
59
  $order_id=$responseBody1->order_id;
60
  $order_email=$responseBody1->order_email;
 
61
  Mage::getSingleton('core/session')->setIntegrationCode($integration_code);
 
62
  Mage::getSingleton('core/session')->setOfferType($offer_type);
63
  }
64
  }
 
 
 
 
65
  }
66
+ }catch(Exception $e){
67
+ #$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
68
+ #$responseBody = '';
69
  }
 
70
  return $this;
71
  }
72
+
73
+ public function getRestApiKey(){
74
  return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apikey'));
75
  }
76
 
77
+ public function getRestApiSecret(){
78
  return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apisecret'));
79
  }
80
+
81
+ public function getRestMagnetKey(){
82
  return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_magnetkey'));
83
  }
84
+
85
+ public function verifyOrderToSharemagnet($event){
86
+ try{
87
+ $order = $event->getOrder();
88
+ if ($order->getState()==Mage_Sales_Model_Order::STATE_PROCESSING){
89
+ $restApiKey = $this->getRestApiKey();
90
+ $restApiSecret = $this->getRestApiSecret();
91
+ $restApiMagnet = $this->getRestMagnetKey();
92
+ $orderId= $order->getId();
93
+ $incrementId = $order->getIncremementId();
94
+ $realOrderId=$order->getRealOrderId();
95
+ if(!$orderId){
96
+ $orderId = 'NONE';
97
+ }
98
+ if(!$realOrderId){
99
+ $realOrderId = 'NONE';
100
+ }
101
+ if(!$incrementId){
102
+ $incrementId = 'NONE';
103
+ }
104
+
105
+ try{
106
+ $order_created = $order->created_at;
107
+ }
108
+ catch(Exception $e){
109
+ $order_created = NULL;
110
+ }
111
+ if(!$order_created){
112
+ $order_created = 'NONE';
113
+ }
114
+ $orderEmail=$order->getCustomerEmail();
115
+ $purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
116
+ if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!=""){
117
+ $client1 =new Zend_Http_Client();
118
+ $client1->setUri($this->_verifySharemagnetApiUrl.$order->getId().'/');
119
+ $client1->setConfig(array(
120
+ 'timeout' => 5));
121
+ $client1->setParameterGet(array('api_key'=>$restApiKey,'api_secret'=>$restApiSecret,'magnet_key'=>$restApiMagnet,'type'=>'magento','backend'=>'magento','format'=>'json','order_id'=>$orderId,'increment_id'=>$incrementId,'real_order_id'=>$realOrderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount,'order_created'=>$order_created));
122
+ $arr1=array('order_verified'=>1);
123
+ $response=$client1->setRawData(json_encode($arr1), 'application/json')->request(Zend_Http_Client::PUT);
124
+ }
125
+ }
126
+ }catch(Exception $e){}
127
+ }
128
  }
129
+ ?>
app/code/community/Sharemagnet/Social/Rebate/Model/Observer.php~ ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sharemagnet_Social_Rebate_Model_Observer{
4
+ protected $_initSharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session/';
5
+ protected $_requestSharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session/';
6
+ protected $_verifySharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session_order/';
7
+
8
+ public function prepareService($event){
9
+ $order = $event->getOrder();
10
+ $orderId= $order->getId();
11
+ $incrementId = $order->getIncremementId();
12
+ $realOrderId=$order->getRealOrderId();
13
+ if(!$orderId){
14
+ $orderId = 'NONE';
15
+ }
16
+ if(!$realOrderId){
17
+ $realOrderId = 'NONE';
18
+ }
19
+ if(!$incrementId){
20
+ $incrementId = 'NONE';
21
+ }
22
+ try{
23
+ $order_created = $order->created_at;
24
+ }
25
+ catch(Exception $e){
26
+ $order_created = NULL;
27
+ }
28
+ if(!$order_created){
29
+ $order_created = strftime('%Y-%m-%d %H:%M:%S',time());
30
+ }
31
+ $orderEmail=$order->getCustomerEmail();
32
+ $purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
33
+ try{
34
+ $restApiKey = $this->getRestApiKey();
35
+ $restApiSecret = $this->getRestApiSecret();
36
+ $restApiMagnet = $this->getRestMagnetKey();
37
+ if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!=""){
38
+ $client = new Zend_Http_Client();
39
+ // initialize api session
40
+ $client->setUri($this->_initSharemagnetApiUrl);
41
+ $client->setConfig(array(
42
+ 'timeout' => 5));
43
+ $arr=array('magnet_key'=>$restApiMagnet,'type'=>'magento','order_id'=>$orderId,'increment_id'=>$incrementId,'real_order_id'=>$realOrderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount,'order_created'=>$order_created);
44
+ $response=$client->setRawData(json_encode($arr), 'application/json')->request('POST');
45
+ $call_integration_url=$response->getHeader("Location")."?magnet_key=".$restApiMagnet."&format=json";
46
+ $call_integration_url .= "&real_order_id=" . $realOrderId . "&increment_id=" . $incrementId . "&order_created=" . $order_created . "&order_email=" . $orderEmail. "&purchase_amount=" . $purchase_amount;
47
+ if ($response->getStatus()==201 && $response->getMessage()=="CREATED"){
48
+ //get existing api session
49
+ $client1 =new Zend_Http_Client();
50
+ $client1->setUri($response->getHeader("Location"));
51
+ $client1->setConfig(array(
52
+ 'timeout' => 5));
53
+ $client1->setParameterGet(array('magnet_key'=>$restApiMagnet,'type'=>'magento','format'=>'json','order_id'=>$orderId,'increment_id'=>$incrementId,'real_order_id'=>$realOrderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount,'order_created'=>$order_created));
54
+ $response1 = $client1->request();
55
+ if($response1->getStatus()!=500 && $response1->getStatus()!=501){
56
+ $responseBody1 = json_decode($response1->getBody());
57
+ $integration_code=$responseBody1->integration_code;
58
+ $offer_type=$responseBody1->offer_type;
59
+ $order_id=$responseBody1->order_id;
60
+ $order_email=$responseBody1->order_email;
61
+ Mage::getSingleton('core/session')->setIntegrationCode($integration_code);
62
+ Mage::getSingleton('core/session')->setOfferType($offer_type);
63
+ }
64
+ }
65
+ }
66
+ }catch(Exception $e){
67
+ #$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
68
+ #$responseBody = '';
69
+ }
70
+ return $this;
71
+ }
72
+
73
+ public function getRestApiKey(){
74
+ return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apikey'));
75
+ }
76
+
77
+ public function getRestApiSecret(){
78
+ return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apisecret'));
79
+ }
80
+
81
+ public function getRestMagnetKey(){
82
+ return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_magnetkey'));
83
+ }
84
+
85
+ public function verifyOrderToSharemagnet($event){
86
+ try{
87
+ $order = $event->getOrder();
88
+ if ($order->getState()==Mage_Sales_Model_Order::STATE_PROCESSING){
89
+ $restApiKey = $this->getRestApiKey();
90
+ $restApiSecret = $this->getRestApiSecret();
91
+ $restApiMagnet = $this->getRestMagnetKey();
92
+ $orderId= $order->getId();
93
+ $incrementId = $order->getIncremementId();
94
+ $realOrderId=$order->getRealOrderId();
95
+ if(!$orderId){
96
+ $orderId = 'NONE';
97
+ }
98
+ if(!$realOrderId){
99
+ $realOrderId = 'NONE';
100
+ }
101
+ if(!$incrementId){
102
+ $incrementId = 'NONE';
103
+ }
104
+
105
+ try{
106
+ $order_created = $order->created_at;
107
+ }
108
+ catch(Exception $e){
109
+ $order_created = NULL;
110
+ }
111
+ if(!$order_created){
112
+ $order_created = 'NONE';
113
+ }
114
+ $orderEmail=$order->getCustomerEmail();
115
+ $purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
116
+ if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!=""){
117
+ $client1 =new Zend_Http_Client();
118
+ $client1->setUri($this->_verifySharemagnetApiUrl.$order->getId().'/');
119
+ $client1->setConfig(array(
120
+ 'timeout' => 5));
121
+ $client1->setParameterGet(array('api_key'=>$restApiKey,'api_secret'=>$restApiSecret,'magnet_key'=>$restApiMagnet,'type'=>'magento','backend'=>'magento','format'=>'json','order_id'=>$orderId,'increment_id'=>$incrementId,'real_order_id'=>$realOrderId,'order_email'=>$orderEmail,'total_purchase'=>$purchase_amount,'order_created'=>$order_created));
122
+ $arr1=array('order_verified'=>1);
123
+ $response=$client1->setRawData(json_encode($arr1), 'application/json')->request(Zend_Http_Client::PUT);
124
+ }
125
+ }
126
+ }catch(Exception $e){}
127
+ }
128
+ }
129
+ ?>
app/code/community/Sharemagnet/Social/Rebate/Model/Order.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- class Sharemagnet_Social_Rebate_Model_Order extends Mage_Sales_Model_Order
3
- {
4
- /**
5
- *
6
- * Resource name: rebate_session_order
7
- Request method: PUT
8
- Endpoint URL: http://sharemagnet.com/rest/v1/social-rebates/rebate_session_order/<order_id>/
9
- GET params:
10
-
11
- api_key = ‘c7c43d18154e8fa317f0d0b8ae76d321f97fd221’
12
- api_secret = ‘0491c4c7f8e90ee93fd5b9e7be1b1d70a35374ca’
13
- magnet_key = ‘538441DA’
14
- backend = ‘magento’
15
- PUT params:
16
-
17
- order_verified (boolean)
18
- *
19
- *
20
- */
21
- protected $_verifySharemagnetApiUrl = 'http://sharemagnet.com/rest/v1/social-rebates/rebate_session_order/';
22
-
23
- protected function _beforeSave()
24
- {
25
- parent::_beforeSave();
26
- if ($this->getState()==Mage_Sales_Model_Order::STATE_PROCESSING) //STATE_PROCESSING
27
- {
28
- $restApiKey = $this->getRestApiKey();
29
- $restApiSecret = $this->getRestApiSecret();
30
- $restApiMagnet = $this->getRestMagnetKey();
31
- if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!="")
32
- {
33
- $client1 =new Zend_Http_Client();
34
-
35
-
36
- $client1->setUri($this->_verifySharemagnetApiUrl.$this->getId().'/?api_key='.$restApiKey.'&api_secret='.$restApiSecret.'&magnet_key='.$restApiMagnet.'&backend=magento');
37
-
38
-
39
- $arr1=array('order_verified'=>1);
40
- $response=$client1->setRawData(json_encode($arr1), 'application/json')->request(Zend_Http_Client::PUT);
41
-
42
-
43
- }
44
- }
45
-
46
- }
47
- public function getRestApiKey() {
48
- return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apikey'));
49
- }
50
-
51
- public function getRestApiSecret() {
52
- return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apisecret'));
53
- }
54
- public function getRestMagnetKey() {
55
- return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_magnetkey'));
56
- }
57
- }
58
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sharemagnet/Social/Rebate/etc/config.xml CHANGED
@@ -1,6 +1,7 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
 
4
  <Sharemagnet_Social_Rebate>
5
  <version>1.5.0.0</version>
6
  </Sharemagnet_Social_Rebate>
@@ -11,16 +12,6 @@
11
  <class>Sharemagnet_Social_Rebate_Block</class>
12
  </social_rebate>
13
  </blocks>
14
- <models>
15
- <social_rebate>
16
- <class>Sharemagnet_Social_Rebate_Model</class>
17
- </social_rebate>
18
- <sales>
19
- <rewrite>
20
- <order>Sharemagnet_Social_Rebate_Model_Order</order>
21
- </rewrite>
22
- </sales>
23
- </models>
24
  <helpers>
25
  <social_rebate>
26
  <class>Sharemagnet_Social_Rebate_Helper</class>
@@ -29,14 +20,23 @@
29
  <events>
30
  <sales_order_place_after>
31
  <observers>
32
- <prepare_sharemagent_service>
33
  <type>singleton</type>
34
  <class>Sharemagnet_Social_Rebate_Model_Observer</class>
35
  <method>prepareService</method>
36
- </prepare_sharemagent_service>
37
  </observers>
38
  </sales_order_place_after>
39
- </events>
 
 
 
 
 
 
 
 
 
40
  </global>
41
  <frontend>
42
  <layout>
@@ -82,4 +82,4 @@
82
  </resources>
83
  </acl>
84
  </adminhtml>
85
- </config>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+
5
  <Sharemagnet_Social_Rebate>
6
  <version>1.5.0.0</version>
7
  </Sharemagnet_Social_Rebate>
12
  <class>Sharemagnet_Social_Rebate_Block</class>
13
  </social_rebate>
14
  </blocks>
 
 
 
 
 
 
 
 
 
 
15
  <helpers>
16
  <social_rebate>
17
  <class>Sharemagnet_Social_Rebate_Helper</class>
20
  <events>
21
  <sales_order_place_after>
22
  <observers>
23
+ <sharemagnet_social_rebate_model_observer>
24
  <type>singleton</type>
25
  <class>Sharemagnet_Social_Rebate_Model_Observer</class>
26
  <method>prepareService</method>
27
+ </sharemagnet_social_rebate_model_observer>
28
  </observers>
29
  </sales_order_place_after>
30
+ <sales_order_save_after>
31
+ <observers>
32
+ <sharemagnet_social_rebate_model_observer>
33
+ <type>singleton</type>
34
+ <class>Sharemagnet_Social_Rebate_Model_Observer</class>
35
+ <method>verifyOrderToSharemagnet</method>
36
+ </sharemagnet_social_rebate_model_observer>
37
+ </observers>
38
+ </sales_order_save_after>
39
+ </events>
40
  </global>
41
  <frontend>
42
  <layout>
82
  </resources>
83
  </acl>
84
  </adminhtml>
85
+ </config>
app/code/community/Sharemagnet/Social/Rebate/etc/config.xml~ ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+
5
+ <Sharemagnet_Social_Rebate>
6
+ <version>1.5.0.0</version>
7
+ </Sharemagnet_Social_Rebate>
8
+ </modules>
9
+ <global>
10
+ <blocks>
11
+ <social_rebate>
12
+ <class>Sharemagnet_Social_Rebate_Block</class>
13
+ </social_rebate>
14
+ </blocks>
15
+ <helpers>
16
+ <social_rebate>
17
+ <class>Sharemagnet_Social_Rebate_Helper</class>
18
+ </social_rebate>
19
+ </helpers>
20
+ <events>
21
+ <sales_order_place_after>
22
+ <observers>
23
+ <sharemagnet_social_rebate_model_observer>
24
+ <type>singleton</type>
25
+ <class>Sharemagnet_Social_Rebate_Model_Observer</class>
26
+ <method>prepareService</method>
27
+ </sharemagnet_social_rebate_model_observer>
28
+ </observers>
29
+ </sales_order_place_after>
30
+ <sales_order_save_after>
31
+ <observers>
32
+ <sharemagnet_social_rebate_model_observer>
33
+ <type>singleton</type>
34
+ <class>Sharemagnet_Social_Rebate_Model_Observer</class>
35
+ <method>verifyOrderToSharemagnet</method>
36
+ </sharemagnet_social_rebate_model_observer>
37
+ </observers>
38
+ </sales_order_save_after>
39
+ </events>
40
+ </global>
41
+ <frontend>
42
+ <layout>
43
+ <updates>
44
+ <social_rebate>
45
+ <file>sharemagnet/social/rebate.xml</file>
46
+ </social_rebate>
47
+ </updates>
48
+ </layout>
49
+
50
+ </frontend>
51
+
52
+ <admin>
53
+ <routers>
54
+ <adminhtml>
55
+ <args>
56
+ <modules>
57
+ <Sharemagnet_Social_Rebate before="Mage_Adminhtml">Sharemagnet_Social_Rebate_Adminhtml</Sharemagnet_Social_Rebate>
58
+ </modules>
59
+ </args>
60
+ </adminhtml>
61
+ </routers>
62
+ </admin>
63
+
64
+ <adminhtml>
65
+ <acl>
66
+ <resources>
67
+ <admin>
68
+ <children>
69
+ <system>
70
+ <children>
71
+ <config>
72
+ <children>
73
+ <social_rebate_section>
74
+ <title>Social Rebate Section</title>
75
+ </social_rebate_section>
76
+ </children>
77
+ </config>
78
+ </children>
79
+ </system>
80
+ </children>
81
+ </admin>
82
+ </resources>
83
+ </acl>
84
+ </adminhtml>
85
+ </config>
app/code/community/Sharemagnet/Social/Rebate/etc/system.xml CHANGED
@@ -46,21 +46,21 @@
46
  <show_in_website>1</show_in_website>
47
  <show_in_store>1</show_in_store>
48
  <fields>
49
- <social_rebate_apikey translate="label tooltip comment">
50
- <label>Social Rebate API Key</label>
51
  <frontend_type>text</frontend_type>
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
54
  <show_in_store>1</show_in_store>
55
-
56
- </social_rebate_apikey>
57
- <social_rebate_apisecret translate="label tooltip comment">
58
- <label>Social Rebate API Secret</label>
59
  <frontend_type>text</frontend_type>
60
  <show_in_default>1</show_in_default>
61
  <show_in_website>1</show_in_website>
62
  <show_in_store>1</show_in_store>
63
- </social_rebate_apisecret>
 
64
  <social_rebate_magnetkey translate="label tooltip comment">
65
  <label>Social Rebate Store Key</label>
66
  <frontend_type>text</frontend_type>
46
  <show_in_website>1</show_in_website>
47
  <show_in_store>1</show_in_store>
48
  <fields>
49
+ <social_rebate_apisecret translate="label tooltip comment">
50
+ <label>Social Rebate API Secret</label>
51
  <frontend_type>text</frontend_type>
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
54
  <show_in_store>1</show_in_store>
55
+ </social_rebate_apisecret>
56
+ <social_rebate_apikey translate="label tooltip comment">
57
+ <label>Social Rebate API Key</label>
 
58
  <frontend_type>text</frontend_type>
59
  <show_in_default>1</show_in_default>
60
  <show_in_website>1</show_in_website>
61
  <show_in_store>1</show_in_store>
62
+
63
+ </social_rebate_apikey>
64
  <social_rebate_magnetkey translate="label tooltip comment">
65
  <label>Social Rebate Store Key</label>
66
  <frontend_type>text</frontend_type>
app/design/frontend/base/default/template/sharemagnet/social/rebate.phtml CHANGED
@@ -78,12 +78,6 @@
78
  ?>
79
  <!-- add integration code part -->
80
  </div>
81
- <?php
82
- if (Mage::getSingleton('core/session')->getOfferType()=="POPUP")
83
- {
84
- echo "<script type='text/javascript'>iframe = document.getElementById('iframe');iframe.setAttribute('data-fb-options','width:600 height:620 scrolling:no');fb.activateElements();fb.start('#iframe');</script>";
85
- }
86
- ?>
87
  <?php endif; ?>
88
  <!-- End Sharemagnet Rebate Order -->
89
 
78
  ?>
79
  <!-- add integration code part -->
80
  </div>
 
 
 
 
 
 
81
  <?php endif; ?>
82
  <!-- End Sharemagnet Rebate Order -->
83
 
app/design/frontend/base/default/template/sharemagnet/social/rebate.phtml~ ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div id="fb-root"></div>
28
+ <script>(function(d, s, id) {
29
+ var js, fjs = d.getElementsByTagName(s)[0];
30
+ if (d.getElementById(id)) return;
31
+ js = d.createElement(s); js.id = id;
32
+ js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
33
+ fjs.parentNode.insertBefore(js, fjs);
34
+ }(document, 'script', 'facebook-jssdk'));</script>
35
+
36
+ <div class="page-title">
37
+ <h1><?php echo $this->__('Your order has been received') ?></h1>
38
+ </div>
39
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
40
+ <p><strong><?php echo $this->__('Thank you for your purchase!') ?></strong></p>
41
+
42
+ <?php if ($this->getOrderId()):?>
43
+ <?php if ($this->getCanViewOrder()) :?>
44
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
45
+ <?php else :?>
46
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?>.</p>
47
+ <?php endif;?>
48
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
49
+ <?php if ($this->getViewOrder() && $this->getCanPrintOrder()) :?>
50
+ <p>
51
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
52
+ <?php echo $this->getChildHtml() ?>
53
+ </p>
54
+ <?php endif;?>
55
+ <?php endif;?>
56
+
57
+ <?php if ($this->getAgreementRefId()): ?>
58
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
59
+ <?php endif;?>
60
+
61
+ <?php if ($profiles = $this->getRecurringProfiles()):?>
62
+ <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
63
+ <ul>
64
+ <?php foreach($profiles as $profile):?>
65
+ <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
66
+ <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
67
+ <?php endforeach;?>
68
+ </ul>
69
+ <?php endif;?>
70
+ <!-- Sharemagnet Rebate Order -->
71
+ <?php if ($this->getOrderId()):?>
72
+ <script type="text/javascript" src="https://sharemagnet.com/site_media/static/lb/floatbox.js"></script>
73
+ <link type="text/css" rel="stylesheet" href="https://sharemagnet.com/site_media/static/lb/floatbox.css" />
74
+ <link rel="stylesheet" href="https://sharemagnet.com/site_media/static/css/social_integration.css" type="text/css" media="screen" />
75
+ <div id="iframe-holder">
76
+ <?php
77
+ echo Mage::getSingleton('core/session')->getIntegrationCode();
78
+ ?>
79
+ <!-- add integration code part -->
80
+ </div>
81
+ <?php endif; ?>
82
+ <!-- End Sharemagnet Rebate Order -->
83
+
84
+ <div class="buttons-set">
85
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
86
+ </div>
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sharemagnet_Social_Rebate</name>
4
- <version>1.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/artistic-license-2.0">Artistic License 2.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Turn customers purchases into highly credible Social Media Marketing for your store with Social Rebate!</summary>
10
  <description>Social Rebate provides a comprehensive Social Commerce platform for online retailers to help increase social sharing and customer referrals from Social Media to their eCommerce stores.</description>
11
- <notes>This is beta version.</notes>
12
  <authors><author><name>Ben Stewart</name><user>SocialRebate</user><email>info@sharemagnet.com</email></author></authors>
13
- <date>2013-04-24</date>
14
- <time>03:31:01</time>
15
- <contents><target name="magecommunity"><dir name="Sharemagnet"><dir name="Social"><dir name="Rebate"><dir name="Block"><file name="Rebateorder.php" hash="894088ccc6bf24d5d3221666b9484c63"/></dir><dir name="Helper"><file name="Data.php" hash="eb8159561687773312ad8b668b4739ee"/></dir><dir name="Model"><file name="Observer.php" hash="d8c96bdae67f28aa08394dac920be678"/><file name="Order.php" hash="49961a5f4997415fb8e3272880ffb0cd"/></dir><dir name="etc"><file name="config.xml" hash="810c87942360b4b1d440657fee091652"/><file name="system.xml" hash="805f09f45dfd5da1e808b80e86a07967"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="sharemagnet"><dir name="social"><file name="rebate.xml" hash="18aeacd2950d493fde5042326944d98e"/></dir></dir></dir><dir name="template"><dir name="sharemagnet"><dir name="social"><file name="rebate.phtml" hash="336dfd41c67b36a038d4e04ec84ed3d0"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sharemagnet_Social_Rebate.xml" hash="ddd29c70265716206160515bc8f980f0"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
 
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sharemagnet_Social_Rebate</name>
4
+ <version>1.1.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/artistic-license-2.0">Artistic License 2.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Turn customers purchases into highly credible Social Media Marketing for your store with Social Rebate!</summary>
10
  <description>Social Rebate provides a comprehensive Social Commerce platform for online retailers to help increase social sharing and customer referrals from Social Media to their eCommerce stores.</description>
11
+ <notes>This is a development version.</notes>
12
  <authors><author><name>Ben Stewart</name><user>SocialRebate</user><email>info@sharemagnet.com</email></author></authors>
13
+ <date>2013-06-12</date>
14
+ <time>12:31:01</time>
15
+ <contents><target name="magecommunity"><dir name="Sharemagnet"><dir name="Social"><dir name="Rebate"><dir name="Block"><file name="Rebateorder.php" hash="894088ccc6bf24d5d3221666b9484c63"/></dir><dir name="Helper"><file name="Data.php" hash="eb8159561687773312ad8b668b4739ee"/></dir><dir name="Model"><file name="Observer.php" hash="d8c96bdae67f28aa08394dac920be678"/></dir><dir name="etc"><file name="config.xml" hash="810c87942360b4b1d440657fee091652"/><file name="system.xml" hash="805f09f45dfd5da1e808b80e86a07967"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="sharemagnet"><dir name="social"><file name="rebate.xml" hash="18aeacd2950d493fde5042326944d98e"/></dir></dir></dir><dir name="template"><dir name="sharemagnet"><dir name="social"><file name="rebate.phtml" hash="336dfd41c67b36a038d4e04ec84ed3d0"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sharemagnet_Social_Rebate.xml" hash="ddd29c70265716206160515bc8f980f0"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
19
+