Version Notes
This is a development version.
Download this release
Release Info
Developer | Ben Stewart |
Extension | Sharemagnet_Social_Rebate |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.1.0
- app/code/community/Sharemagnet/Social/Rebate/Model/Observer.php +35 -9
- app/code/community/Sharemagnet/Social/Rebate/Model/Observer.php~ +142 -0
- app/code/community/Sharemagnet/Social/Rebate/Model/Order.php +28 -5
- app/code/community/Sharemagnet/Social/Rebate/Model/Order.php~ +81 -0
- app/code/community/Sharemagnet/Social/Rebate/etc/system.xml +7 -7
- app/code/community/Sharemagnet/Social/Rebate/etc/system.xml~ +77 -0
- package.xml +4 -4
app/code/community/Sharemagnet/Social/Rebate/Model/Observer.php
CHANGED
@@ -43,9 +43,35 @@ class Sharemagnet_Social_Rebate_Model_Observer
|
|
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();
|
@@ -58,32 +84,32 @@ class Sharemagnet_Social_Rebate_Model_Observer
|
|
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 |
-
|
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);
|
@@ -98,7 +124,7 @@ class Sharemagnet_Social_Rebate_Model_Observer
|
|
98 |
$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
|
99 |
$responseBody = '';
|
100 |
}
|
101 |
-
|
102 |
return $this;
|
103 |
}
|
104 |
public function getRestApiKey() {
|
@@ -113,4 +139,4 @@ class Sharemagnet_Social_Rebate_Model_Observer
|
|
113 |
}
|
114 |
|
115 |
}
|
116 |
-
?>
|
43 |
{
|
44 |
$order = $event->getOrder();
|
45 |
$orderId= $order->getId();
|
46 |
+
$incrementId = $order->getIncremementId();
|
47 |
+
$realOrderId=$order->getRealOrderId();
|
48 |
+
|
49 |
+
if(!$orderId){
|
50 |
+
$orderId = 'NONE';
|
51 |
+
}
|
52 |
+
|
53 |
+
if(!$realOrderId){
|
54 |
+
$realOrderId = 'NONE';
|
55 |
+
}
|
56 |
+
|
57 |
+
if(!$incrementId){
|
58 |
+
$incrementId = 'NONE';
|
59 |
+
}
|
60 |
+
|
61 |
+
try{
|
62 |
+
$order_created = $order->created_at;
|
63 |
+
}
|
64 |
+
catch(Exception $e){
|
65 |
+
$order_created = NULL;
|
66 |
+
}
|
67 |
+
|
68 |
+
if(!$order_created){
|
69 |
+
$order_created = strftime('%Y-%m-%d %H:%M:%S',time());
|
70 |
+
}
|
71 |
+
|
72 |
$orderEmail=$order->getCustomerEmail();
|
73 |
$purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
|
74 |
+
try
|
75 |
{
|
76 |
$restApiKey = $this->getRestApiKey();
|
77 |
$restApiSecret = $this->getRestApiSecret();
|
84 |
// initialize api session
|
85 |
$client->setUri($this->_initSharemagnetApiUrl);
|
86 |
|
87 |
+
$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);
|
|
|
88 |
$response=$client->setRawData(json_encode($arr), 'application/json')->request('POST');
|
89 |
$call_integration_url=$response->getHeader("Location")."?magnet_key=".$restApiMagnet."&format=json";
|
90 |
+
$call_integration_url .= "&real_order_id=" . $realOrderId . "&increment_id=" . $incrementId . "&order_created=" . $order_created . "&order_email=" . $orderEmail. "&purchase_amount=" . $purchase_amount;
|
91 |
if ($response->getStatus()==201 && $response->getMessage()=="CREATED")
|
92 |
{
|
93 |
|
94 |
//get existing api session
|
95 |
+
$client1 =new Zend_Http_Client();
|
96 |
|
97 |
$client1->setUri($response->getHeader("Location"));
|
98 |
+
$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));
|
99 |
|
100 |
$response1 = $client1->request();
|
101 |
if ($response1->getStatus()==500 || $response1->getStatus()==501)
|
102 |
{
|
103 |
+
error_log('woops');
|
104 |
}
|
105 |
else
|
106 |
{
|
107 |
$responseBody1 = json_decode($response1->getBody());
|
108 |
$integration_code=$responseBody1->integration_code;
|
109 |
$offer_type=$responseBody1->offer_type;
|
110 |
+
|
111 |
$order_id=$responseBody1->order_id;
|
112 |
$order_email=$responseBody1->order_email;
|
|
|
113 |
Mage::getSingleton('core/session')->setIntegrationCode($integration_code);
|
114 |
/* */
|
115 |
Mage::getSingleton('core/session')->setOfferType($offer_type);
|
124 |
$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
|
125 |
$responseBody = '';
|
126 |
}
|
127 |
+
|
128 |
return $this;
|
129 |
}
|
130 |
public function getRestApiKey() {
|
139 |
}
|
140 |
|
141 |
}
|
142 |
+
?>
|
app/code/community/Sharemagnet/Social/Rebate/Model/Observer.php~
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$incrementId = $order->getIncremementId();
|
47 |
+
$realOrderId=$order->getRealOrderId();
|
48 |
+
|
49 |
+
if(!$orderId){
|
50 |
+
$orderId = 'NONE';
|
51 |
+
}
|
52 |
+
|
53 |
+
if(!$realOrderId){
|
54 |
+
$realOrderId = 'NONE';
|
55 |
+
}
|
56 |
+
|
57 |
+
if(!$incrementId){
|
58 |
+
$incrementId = 'NONE';
|
59 |
+
}
|
60 |
+
|
61 |
+
try{
|
62 |
+
$order_created = $order->created_at;
|
63 |
+
}
|
64 |
+
catch(Exception $e){
|
65 |
+
$order_created = NULL;
|
66 |
+
}
|
67 |
+
|
68 |
+
if(!$order_created){
|
69 |
+
$order_created = strftime('%Y-%m-%d %H:%M:%S',time());
|
70 |
+
}
|
71 |
+
|
72 |
+
$orderEmail=$order->getCustomerEmail();
|
73 |
+
$purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
|
74 |
+
try
|
75 |
+
{
|
76 |
+
$restApiKey = $this->getRestApiKey();
|
77 |
+
$restApiSecret = $this->getRestApiSecret();
|
78 |
+
$restApiMagnet = $this->getRestMagnetKey();
|
79 |
+
|
80 |
+
if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!="")
|
81 |
+
{
|
82 |
+
$client = new Zend_Http_Client();
|
83 |
+
|
84 |
+
// initialize api session
|
85 |
+
$client->setUri($this->_initSharemagnetApiUrl);
|
86 |
+
|
87 |
+
$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);
|
88 |
+
$response=$client->setRawData(json_encode($arr), 'application/json')->request('POST');
|
89 |
+
$call_integration_url=$response->getHeader("Location")."?magnet_key=".$restApiMagnet."&format=json";
|
90 |
+
$call_integration_url .= "&real_order_id=" . $realOrderId . "&increment_id=" . $incrementId . "&order_created=" . $order_created . "&order_email=" . $orderEmail. "&purchase_amount=" . $purchase_amount;
|
91 |
+
if ($response->getStatus()==201 && $response->getMessage()=="CREATED")
|
92 |
+
{
|
93 |
+
|
94 |
+
//get existing api session
|
95 |
+
$client1 =new Zend_Http_Client();
|
96 |
+
|
97 |
+
$client1->setUri($response->getHeader("Location"));
|
98 |
+
$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));
|
99 |
+
|
100 |
+
$response1 = $client1->request();
|
101 |
+
if ($response1->getStatus()==500 || $response1->getStatus()==501)
|
102 |
+
{
|
103 |
+
error_log('woops');
|
104 |
+
}
|
105 |
+
else
|
106 |
+
{
|
107 |
+
$responseBody1 = json_decode($response1->getBody());
|
108 |
+
$integration_code=$responseBody1->integration_code;
|
109 |
+
$offer_type=$responseBody1->offer_type;
|
110 |
+
|
111 |
+
$order_id=$responseBody1->order_id;
|
112 |
+
$order_email=$responseBody1->order_email;
|
113 |
+
Mage::getSingleton('core/session')->setIntegrationCode($integration_code);
|
114 |
+
/* */
|
115 |
+
Mage::getSingleton('core/session')->setOfferType($offer_type);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
else
|
119 |
+
{
|
120 |
+
|
121 |
+
}
|
122 |
+
}
|
123 |
+
} catch (Exception $e) {
|
124 |
+
$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
|
125 |
+
$responseBody = '';
|
126 |
+
}
|
127 |
+
|
128 |
+
return $this;
|
129 |
+
}
|
130 |
+
public function getRestApiKey() {
|
131 |
+
return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apikey'));
|
132 |
+
}
|
133 |
+
|
134 |
+
public function getRestApiSecret() {
|
135 |
+
return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apisecret'));
|
136 |
+
}
|
137 |
+
public function getRestMagnetKey() {
|
138 |
+
return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_magnetkey'));
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
?>
|
app/code/community/Sharemagnet/Social/Rebate/Model/Order.php
CHANGED
@@ -17,7 +17,7 @@
|
|
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()
|
@@ -25,17 +25,40 @@
|
|
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 |
|
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()
|
25 |
parent::_beforeSave();
|
26 |
if ($this->getState()==Mage_Sales_Model_Order::STATE_PROCESSING) //STATE_PROCESSING
|
27 |
{
|
28 |
+
$order = $this;
|
29 |
$restApiKey = $this->getRestApiKey();
|
30 |
$restApiSecret = $this->getRestApiSecret();
|
31 |
$restApiMagnet = $this->getRestMagnetKey();
|
32 |
+
$orderId= $order->getId();
|
33 |
+
$incrementId = $order->getIncremementId();
|
34 |
+
$realOrderId=$order->getRealOrderId();
|
35 |
+
if(!$orderId){
|
36 |
+
$orderId = 'NONE';
|
37 |
+
}
|
38 |
+
if(!$realOrderId){
|
39 |
+
$realOrderId = 'NONE';
|
40 |
+
}
|
41 |
+
if(!$incrementId){
|
42 |
+
$incrementId = 'NONE';
|
43 |
+
}
|
44 |
+
try{
|
45 |
+
$order_created = $order->created_at;
|
46 |
+
}
|
47 |
+
catch(Exception $e){
|
48 |
+
$order_created = NULL;
|
49 |
+
}
|
50 |
+
if(!$order_created){
|
51 |
+
$order_created = 'NONE';
|
52 |
+
}
|
53 |
+
$orderEmail=$order->getCustomerEmail();
|
54 |
+
$purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
|
55 |
+
|
56 |
if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!="")
|
57 |
{
|
58 |
$client1 =new Zend_Http_Client();
|
59 |
+
$client1->setUri($this->_verifySharemagnetApiUrl.$this->getId().'/');
|
60 |
+
$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));
|
61 |
|
|
|
|
|
|
|
62 |
$arr1=array('order_verified'=>1);
|
63 |
$response=$client1->setRawData(json_encode($arr1), 'application/json')->request(Zend_Http_Client::PUT);
|
64 |
|
app/code/community/Sharemagnet/Social/Rebate/Model/Order.php~
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$order = $this;
|
29 |
+
$restApiKey = $this->getRestApiKey();
|
30 |
+
$restApiSecret = $this->getRestApiSecret();
|
31 |
+
$restApiMagnet = $this->getRestMagnetKey();
|
32 |
+
$orderId= $order->getId();
|
33 |
+
$incrementId = $order->getIncremementId();
|
34 |
+
$realOrderId=$order->getRealOrderId();
|
35 |
+
if(!$orderId){
|
36 |
+
$orderId = 'NONE';
|
37 |
+
}
|
38 |
+
if(!$realOrderId){
|
39 |
+
$realOrderId = 'NONE';
|
40 |
+
}
|
41 |
+
if(!$incrementId){
|
42 |
+
$incrementId = 'NONE';
|
43 |
+
}
|
44 |
+
try{
|
45 |
+
$order_created = $order->created_at;
|
46 |
+
}
|
47 |
+
catch(Exception $e){
|
48 |
+
$order_created = NULL;
|
49 |
+
}
|
50 |
+
if(!$order_created){
|
51 |
+
$order_created = 'NONE';
|
52 |
+
}
|
53 |
+
$orderEmail=$order->getCustomerEmail();
|
54 |
+
$purchase_amount = $order->getGrandTotal() - $order->getShippingAmount();
|
55 |
+
|
56 |
+
if ($restApiKey !="" && $restApiSecret !="" & $restApiMagnet!="")
|
57 |
+
{
|
58 |
+
$client1 =new Zend_Http_Client();
|
59 |
+
$client1->setUri($this->_verifySharemagnetApiUrl.$this->getId().'/');
|
60 |
+
$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));
|
61 |
+
|
62 |
+
$arr1=array('order_verified'=>1);
|
63 |
+
$response=$client1->setRawData(json_encode($arr1), 'application/json')->request(Zend_Http_Client::PUT);
|
64 |
+
|
65 |
+
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
public function getRestApiKey() {
|
71 |
+
return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apikey'));
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getRestApiSecret() {
|
75 |
+
return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_apisecret'));
|
76 |
+
}
|
77 |
+
public function getRestMagnetKey() {
|
78 |
+
return trim(Mage::getStoreConfig('social_rebate_section/social_rebate_group/social_rebate_magnetkey'));
|
79 |
+
}
|
80 |
+
}
|
81 |
+
?>
|
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 |
-
<
|
50 |
-
<label>Social Rebate API
|
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 |
-
|
57 |
-
|
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 |
-
|
|
|
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/code/community/Sharemagnet/Social/Rebate/etc/system.xml~
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Sharemagnet_Rebateorder
|
5 |
+
*
|
6 |
+
* This module was developed by Sharemagnet Company. If you require any
|
7 |
+
* support or have any questions please contact us at info@sharemagnet.com.
|
8 |
+
*
|
9 |
+
* @category Sharemagnet
|
10 |
+
* @package Sharemagnet_Social_Rebate
|
11 |
+
* @author Sharemagnet Company <nfo@sharemagnet.com>
|
12 |
+
* @copyright Copyright (c) 2013 Share Magnet, LLC
|
13 |
+
*/
|
14 |
+
-->
|
15 |
+
<config>
|
16 |
+
<tabs>
|
17 |
+
<social_rebate_tab module="social_rebate" translate="label">
|
18 |
+
<label>Social Rebate</label>
|
19 |
+
<sort_order>100</sort_order>
|
20 |
+
</social_rebate_tab>
|
21 |
+
</tabs>
|
22 |
+
<sections>
|
23 |
+
<social_rebate_section module="social_rebate" translate="label">
|
24 |
+
<label>Social Rebate Settings</label>
|
25 |
+
<sort_order>200</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>1</show_in_store>
|
29 |
+
<tab>social_rebate_tab</tab>
|
30 |
+
<groups>
|
31 |
+
<social_rebate_group translate="label">
|
32 |
+
<label>Rebate Integration Setting</label>
|
33 |
+
<comment><![CDATA[<h3>NEW USERS</h3>
|
34 |
+
<p> 1. To create and manage your social rebates, you will need to login to the social rebate application manager. If you have not already created your free Social Rebate account <a href="http://socialrebate.net/account/signup/?source=integration&platform=magento" target="_blank">click here.</a></p>
|
35 |
+
<p>2. Check your email to confirm your Social Rebate account.</p>
|
36 |
+
<p>3. You will be guided through the steps of completing your Magento store integration. When you reach the final step, copy/paste the API KEY, API SECRET and STORE KEY into the form on this page below.</p>
|
37 |
+
<br/>
|
38 |
+
<h3>EXISTING USERS</h3>
|
39 |
+
<p>If your have already filled in the form below you are done! You can manage the Social Rebate that is integrated into your store at socialrebate.net. Simply select your store name from the "My Stores" area of the dashboard and click "Click here to integrate a different rebate into this store"</p>
|
40 |
+
<p>If you have not already filled in the form below:</p>
|
41 |
+
<p>1. please sign into <a href="http://socialrebate.net/" target="_blank">Social Rebate</a>, and click ‘add a new store’.</p>
|
42 |
+
<p>2. Select "Magento" from the "Select a platform" page and follow the prompts.</p>
|
43 |
+
<p>3. Copy/Paste the API KEY, API SECRET and STORE KEY from your store overview page into the form below.</p>]]></comment>
|
44 |
+
<sort_order>10</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
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>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>1</show_in_store>
|
70 |
+
|
71 |
+
</social_rebate_magnetkey>
|
72 |
+
</fields>
|
73 |
+
</social_rebate_group>
|
74 |
+
</groups>
|
75 |
+
</social_rebate_section>
|
76 |
+
</sections>
|
77 |
+
</config>
|
package.xml
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Sharemagnet_Social_Rebate</name>
|
4 |
-
<version>1.0
|
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
|
12 |
<authors><author><name>Ben Stewart</name><user>SocialRebate</user><email>info@sharemagnet.com</email></author></authors>
|
13 |
-
<date>2013-
|
14 |
-
<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>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Sharemagnet_Social_Rebate</name>
|
4 |
+
<version>1.1.0</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"/><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>
|