Version Notes
After succesful installation, kindly logout and relogin to you magento admin panel to avoid 404 error while trying to configure the extension.
Configuration is under system->configration->suregift checkout
Download this release
Release Info
Developer | Sodiq Fagbola |
Extension | Suregifts_gift |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.9.1 to 2.0.0
- app/code/community/Suregifts/Giftcardapi/Model/Giftcardapi.php +23 -1
- app/code/community/Suregifts/Giftcardapi/Model/Giftcardapi.php~ +36 -0
- app/code/community/Suregifts/Giftcardapi/Model/Observer.php +22 -35
- app/code/community/Suregifts/Giftcardapi/Model/Observer.php~ +132 -0
- app/code/community/Suregifts/Giftcardapi/Model/System/Config/Source/Dropdown/Values.php +19 -0
- app/code/community/Suregifts/Giftcardapi/Model/System/Config/Source/Dropdown/Values.php~ +19 -0
- app/code/community/Suregifts/Giftcardapi/controllers/IndexController.php +11 -27
- app/code/community/Suregifts/Giftcardapi/controllers/IndexController.php~ +104 -0
- app/code/community/Suregifts/Giftcardapi/etc/config.xml +2 -1
- app/code/community/Suregifts/Giftcardapi/etc/config.xml~ +216 -0
- app/code/community/Suregifts/Giftcardapi/etc/system.xml +11 -1
- app/code/community/Suregifts/Giftcardapi/etc/system.xml~ +126 -0
- app/design/frontend/base/default/layout/giftcardapi.xml +59 -0
- app/design/frontend/base/default/template/giftcardapi/discount.phtml +36 -0
- app/etc/modules/Suregifts_Giftcardapi.xml +9 -0
- app/locale/en_US/Suregifts_Giftcardapi.csv +81 -0
- package.xml +13 -11
app/code/community/Suregifts/Giftcardapi/Model/Giftcardapi.php
CHANGED
@@ -7,8 +7,30 @@
|
|
7 |
*/
|
8 |
class Suregifts_Giftcardapi_Model_Giftcardapi extends Mage_Core_Model_Abstract
|
9 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
public function _construct()
|
11 |
{
|
12 |
parent::_construct();
|
13 |
}
|
14 |
-
}
|
7 |
*/
|
8 |
class Suregifts_Giftcardapi_Model_Giftcardapi extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
+
|
11 |
+
private $_validationUrl=array(
|
12 |
+
'KEN'=>array('test'=>"http://kenyastaging.oms-suregifts.com/api/voucherredemption","live"=>"http://kenya.oms-suregifts.com/api/voucherredemption"),
|
13 |
+
'NGR'=>array('test'=>"http://sandbox.oms-suregifts.com/api/voucherredemption","live"=>"https://oms-suregifts.com/api/voucherredemption")
|
14 |
+
);
|
15 |
+
|
16 |
+
private $_confirmationUrl=array(
|
17 |
+
'KEN'=>array('test'=>"http://kenyastaging.oms-suregifts.com/api/voucherredemption","live"=>"http://kenya.oms-suregifts.com/api/voucherredemption"),
|
18 |
+
'NGR'=>array('test'=>"http://sandbox.oms-suregifts.com/api/voucherredemption","live"=>"https://oms-suregifts.com/api/voucherredemption")
|
19 |
+
);
|
20 |
+
|
21 |
+
public function getValidationUrl($country,$mode){
|
22 |
+
return $this->_validationUrl[$country][$mode=="1"?"test":"live"];
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getConfirmationUrl($country,$mode){
|
26 |
+
return $this->_confirmationUrl[$country][$mode=="1"?"test":"live"];
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
public function _construct()
|
33 |
{
|
34 |
parent::_construct();
|
35 |
}
|
36 |
+
}
|
app/code/community/Suregifts/Giftcardapi/Model/Giftcardapi.php~
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Suregifts Giftcard API Extension
|
4 |
+
* @category Magento Extensions
|
5 |
+
* @package Suregifts_Giftcardapi
|
6 |
+
* @author Sodiq <damilolasodiq@gmail.com>
|
7 |
+
*/
|
8 |
+
class Suregifts_Giftcardapi_Model_Giftcardapi extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
private $_validationUrl=array(
|
12 |
+
'KEN'=>array('test'=>"http://kenyastaging.oms-suregifts.com/api/voucherredemption","live"=>"http://kenya.oms-suregifts.com/api/voucherredemption"),
|
13 |
+
'NGR'=>array('test'=>"http://sandbox.oms-suregifts.com/api/voucherredemption","live"=>"https://oms-suregifts.com/api/voucherredemption")
|
14 |
+
);
|
15 |
+
|
16 |
+
private $_confirmationUrl=array(
|
17 |
+
'KEN'=>array('test'=>"http://kenyastaging.oms-suregifts.com/api/voucherredemption","live"=>"http://kenya.oms-suregifts.com/api/voucherredemption"),
|
18 |
+
'NGR'=>array('test'=>"http://sandbox.oms-suregifts.com/api/voucherredemption","live"=>"https://oms-suregifts.com/api/voucherredemption")
|
19 |
+
);
|
20 |
+
|
21 |
+
public function getValidationUrl($country,$mode){
|
22 |
+
return $this->_validationUrl[$country][$mode=="1"?"test":"live"];
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getConfirmationUrl($country,$mode){
|
26 |
+
return $this->_confirmationUrl[$country][$mode=="1"?"test":"live"];
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
public function _construct()
|
33 |
+
{
|
34 |
+
parent::_construct();
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Suregifts/Giftcardapi/Model/Observer.php
CHANGED
@@ -27,9 +27,16 @@ class Suregifts_Giftcardapi_Model_Observer {
|
|
27 |
$password =$array_config['suregifts_password'];
|
28 |
$website_host = $array_config['suregifts_websitehost'];
|
29 |
$mode = $array_config['suregifts_mode'];
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
$data = array(
|
35 |
"AmountToUse" => $order->getBaseGiftcardapiDiscount() ,
|
@@ -39,32 +46,8 @@ class Suregifts_Giftcardapi_Model_Observer {
|
|
39 |
);
|
40 |
|
41 |
$data_string = json_encode($data);
|
42 |
-
|
43 |
-
|
44 |
-
if ($mode == 1 ){
|
45 |
-
if(strlen($data['giftcard']) == 9){
|
46 |
-
$ch = curl_init('http://kenyastaging.oms-suregifts.com/api/voucherredemption');
|
47 |
-
}
|
48 |
-
elseif(strlen($data['giftcard']) == 8){
|
49 |
-
$ch = curl_init("http://sandbox.oms-suregifts.com/api/voucherredemption");
|
50 |
-
}
|
51 |
-
else{
|
52 |
-
|
53 |
-
}
|
54 |
-
|
55 |
-
}else{
|
56 |
-
if(strlen($data['giftcard']) == 9){
|
57 |
-
$ch = curl_init('http://kenya.oms-suregifts.com/api/voucherredemption');
|
58 |
-
}
|
59 |
-
elseif(strlen($data['giftcard']) == 8){
|
60 |
-
$ch = curl_init("https://oms-suregifts.com/api/voucherredemption");
|
61 |
-
}
|
62 |
-
else{
|
63 |
-
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
$header= array();
|
68 |
$header[0]= 'Content-Type: application/json';
|
69 |
$header[1]='Content-Length: ' . strlen($data_string);
|
70 |
|
@@ -87,17 +70,21 @@ class Suregifts_Giftcardapi_Model_Observer {
|
|
87 |
$response_info=array();
|
88 |
curl_close($ch);
|
89 |
$response_info=json_decode($resp, true);
|
|
|
90 |
Mage::log($order->getBaseGiftcardapiDiscount() , null, 'mode.log');
|
91 |
if ($response_info['Response']!="00"){
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
96 |
|
97 |
$controllerAction = $observer->getEvent()->getControllerAction();
|
98 |
$result = array();
|
99 |
$result['error'] = '-1';
|
100 |
-
$result['message'] = $response_info['Description']!=null
|
101 |
$controllerAction->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
102 |
exit;
|
103 |
}
|
@@ -135,4 +122,4 @@ exit;
|
|
135 |
}
|
136 |
|
137 |
}
|
138 |
-
}
|
27 |
$password =$array_config['suregifts_password'];
|
28 |
$website_host = $array_config['suregifts_websitehost'];
|
29 |
$mode = $array_config['suregifts_mode'];
|
30 |
+
$country=$array_config['suregifts_country'];
|
31 |
+
$auth = $username.':'.$password;
|
32 |
+
|
33 |
+
$confirmationUrl =Mage::getModel('giftcardapi/giftcardapi')->getConfirmationUrl($country,$mode);
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
//just added this Feb 12 2016
|
38 |
+
|
39 |
+
$ch = curl_init($confirmationUrl);
|
40 |
|
41 |
$data = array(
|
42 |
"AmountToUse" => $order->getBaseGiftcardapiDiscount() ,
|
46 |
);
|
47 |
|
48 |
$data_string = json_encode($data);
|
49 |
+
|
50 |
+
$header= array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
$header[0]= 'Content-Type: application/json';
|
52 |
$header[1]='Content-Length: ' . strlen($data_string);
|
53 |
|
70 |
$response_info=array();
|
71 |
curl_close($ch);
|
72 |
$response_info=json_decode($resp, true);
|
73 |
+
|
74 |
Mage::log($order->getBaseGiftcardapiDiscount() , null, 'mode.log');
|
75 |
if ($response_info['Response']!="00"){
|
76 |
+
Mage::getSingleton('checkout/session')->addError($this->__('Your Gift card discount amount is invalid or has already been used'));
|
77 |
+
Mage::getSingleton('checkout/session')->getQuote()->setGiftcardapiCode('')->save();
|
78 |
+
Mage::getSingleton('checkout/session')->setUseGiftcardapiDiscount(false);
|
79 |
+
Mage::getSingleton('checkout/session')->setGiftcardapiDiscountAmount(0);
|
80 |
+
$url = Mage::getUrl('checkout/cart');
|
81 |
+
$response = Mage::app()->getFrontController()->getResponse();
|
82 |
+
$response->setRedirect($url);
|
83 |
|
84 |
$controllerAction = $observer->getEvent()->getControllerAction();
|
85 |
$result = array();
|
86 |
$result['error'] = '-1';
|
87 |
+
$result['message'] = $response_info['Description']!=null?$response_info['Description']:"Could not redeem giftcard on suregift";
|
88 |
$controllerAction->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
89 |
exit;
|
90 |
}
|
122 |
}
|
123 |
|
124 |
}
|
125 |
+
}
|
app/code/community/Suregifts/Giftcardapi/Model/Observer.php~
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Suregifts Giftcard API Extension
|
4 |
+
* @category Magento Extensions
|
5 |
+
* @package Suregifts_Giftcardapi
|
6 |
+
* @author Sodiq <damilolasodiq@gmail.com>
|
7 |
+
*/
|
8 |
+
class Suregifts_Giftcardapi_Model_Observer {
|
9 |
+
|
10 |
+
public function salesOrderSaveBefore($observer){
|
11 |
+
$order = $observer->getEvent()->getOrder();
|
12 |
+
$giftcard = Mage::getSingleton('checkout/session')->getQuote()->getGiftcardapiCode();
|
13 |
+
$order->setGiftcardapiCode($giftcard);
|
14 |
+
|
15 |
+
|
16 |
+
}
|
17 |
+
public function salesOrderSaveAfter($observer){
|
18 |
+
$order = $observer->getEvent()->getOrder();
|
19 |
+
$giftcartCode = $order->getGiftcardapiCode();
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
if($giftcartCode){
|
24 |
+
|
25 |
+
$array_config= Mage::getStoreConfig('giftcardapi/suregifts_group',Mage::app()->getStore());
|
26 |
+
$username =$array_config['suregifts_username'];
|
27 |
+
$password =$array_config['suregifts_password'];
|
28 |
+
$website_host = $array_config['suregifts_websitehost'];
|
29 |
+
$mode = $array_config['suregifts_mode'];
|
30 |
+
$country=$array_config['suregifts_country'];
|
31 |
+
$auth = $username.':'.$password;
|
32 |
+
|
33 |
+
$confirmationUrl =Mage::getModel('giftcardapi/giftcardapi')->getConfirmationUrl($country,$mode);
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
//just added this Feb 12 2016
|
38 |
+
|
39 |
+
$ch = curl_init($confirmationUrl.'?vouchercode='.$data['giftcard']);
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
$data = array(
|
44 |
+
"AmountToUse" => $order->getBaseGiftcardapiDiscount() ,
|
45 |
+
//"AmountToUse" => 2000,
|
46 |
+
"VoucherCode" => $giftcartCode,
|
47 |
+
"WebsiteHost" => $website_host
|
48 |
+
);
|
49 |
+
|
50 |
+
$data_string = json_encode($data);
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
$header= array();
|
58 |
+
$header[0]= 'Content-Type: application/json';
|
59 |
+
$header[1]='Content-Length: ' . strlen($data_string);
|
60 |
+
|
61 |
+
|
62 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
63 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
|
64 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
65 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
66 |
+
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
|
67 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
68 |
+
|
69 |
+
if ($username!=''){
|
70 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
71 |
+
$header[2]= "Authorization: Basic ".base64_encode($auth);
|
72 |
+
}
|
73 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
|
74 |
+
|
75 |
+
|
76 |
+
$resp = curl_exec($ch);
|
77 |
+
$response_info=array();
|
78 |
+
curl_close($ch);
|
79 |
+
$response_info=json_decode($resp, true);
|
80 |
+
|
81 |
+
Mage::log($order->getBaseGiftcardapiDiscount() , null, 'mode.log');
|
82 |
+
if ($response_info['Response']!="00"){
|
83 |
+
Mage::getSingleton('checkout/session')->addError($this->__('Your Gift card discount amount is invalid or has already been used'));
|
84 |
+
Mage::getSingleton('checkout/session')->getQuote()->setGiftcardapiCode('')->save();
|
85 |
+
Mage::getSingleton('checkout/session')->setUseGiftcardapiDiscount(false);
|
86 |
+
Mage::getSingleton('checkout/session')->setGiftcardapiDiscountAmount(0);
|
87 |
+
$url = Mage::getUrl('checkout/cart');
|
88 |
+
$response = Mage::app()->getFrontController()->getResponse();
|
89 |
+
$response->setRedirect($url);
|
90 |
+
|
91 |
+
$controllerAction = $observer->getEvent()->getControllerAction();
|
92 |
+
$result = array();
|
93 |
+
$result['error'] = '-1';
|
94 |
+
$result['message'] = $response_info['Description']!=null?$response_info['Description']:"Could not redeem giftcard on suregift";
|
95 |
+
$controllerAction->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
96 |
+
exit;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
|
101 |
+
Mage::getSingleton('checkout/session')->getQuote()->setGiftcardapiCode('')->save();
|
102 |
+
Mage::getSingleton('checkout/session')->setUseGiftcardapiDiscount(false);
|
103 |
+
Mage::getSingleton('checkout/session')->setGiftcardapiDiscountAmount(0);
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
}
|
108 |
+
}
|
109 |
+
public function salesInvoiceCreateAfter($observer){
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
public function getProductFinalPrice($observer){
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
public function insertBlock($observer){
|
118 |
+
$_block=$observer->getBlock();
|
119 |
+
$_type=$_block->getType();
|
120 |
+
// echo $_type;
|
121 |
+
if($_type=='checkout/cart_coupon'){
|
122 |
+
// var_dump($_block);
|
123 |
+
$_child= clone $_block;
|
124 |
+
$_child->setType('giftcardapi/discount');
|
125 |
+
$_block->setChild('child',$_child);
|
126 |
+
$_block->setTemplate('giftcardapi/discount.phtml');
|
127 |
+
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
132 |
+
}
|
app/code/community/Suregifts/Giftcardapi/Model/System/Config/Source/Dropdown/Values.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Suregifts_Giftcardapi_Model_System_Config_Source_Dropdown_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
array(
|
9 |
+
'value' => 'KEN',
|
10 |
+
'label' => 'Kenya',
|
11 |
+
),
|
12 |
+
array(
|
13 |
+
'value' => 'NGR',
|
14 |
+
'label' => 'Nigeria',
|
15 |
+
),
|
16 |
+
);
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
app/code/community/Suregifts/Giftcardapi/Model/System/Config/Source/Dropdown/Values.php~
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Suregifts_Giftcardapi_Model_System_Config_Source_Dropdown_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
array(
|
9 |
+
'value' => 'KEN',
|
10 |
+
'label' => 'Kenya',
|
11 |
+
),
|
12 |
+
array(
|
13 |
+
'value' => 'NGR',
|
14 |
+
'label' => 'Nigeria',
|
15 |
+
),
|
16 |
+
);
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
app/code/community/Suregifts/Giftcardapi/controllers/IndexController.php
CHANGED
@@ -50,33 +50,17 @@ class Suregifts_Giftcardapi_IndexController extends Mage_Core_Controller_Front_A
|
|
50 |
$password =$array_config['suregifts_password'];
|
51 |
$website_host = $array_config['suregifts_websitehost'];
|
52 |
$mode = $array_config['suregifts_mode'];
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
if ($mode == 1 ){
|
58 |
-
//Testing Bed
|
59 |
-
if(strlen($data['giftcard']) == 9){
|
60 |
-
$ch = curl_init("http://kenyastaging.oms-suregifts.com/api/voucherredemption?vouchercode=".$data['giftcard']);
|
61 |
-
}
|
62 |
-
elseif(strlen($data['giftcard']) == 8){
|
63 |
-
$ch = curl_init("http://sandbox.oms-suregifts.com/api/voucherredemption?vouchercode=" .$data['giftcard']);
|
64 |
-
}else{
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
}else{
|
69 |
-
//LIVE bed
|
70 |
-
if(strlen($data['giftcard']) == 9){
|
71 |
-
$ch = curl_init("http://kenya.oms-suregifts.com/api/voucherredemption?vouchercode=".$data['giftcard']);
|
72 |
-
}
|
73 |
-
elseif(strlen($data['giftcard']) == 8){
|
74 |
-
$ch = curl_init("https://oms-suregifts.com/api/voucherredemption?vouchercode=" . $data['giftcard']);
|
75 |
-
}
|
76 |
-
else{
|
77 |
-
|
78 |
-
}
|
79 |
-
}
|
80 |
|
81 |
curl_setopt($ch, CURLOPT_POST, false);
|
82 |
|
@@ -116,4 +100,4 @@ class Suregifts_Giftcardapi_IndexController extends Mage_Core_Controller_Front_A
|
|
116 |
}
|
117 |
|
118 |
|
119 |
-
}
|
50 |
$password =$array_config['suregifts_password'];
|
51 |
$website_host = $array_config['suregifts_websitehost'];
|
52 |
$mode = $array_config['suregifts_mode'];
|
53 |
+
$country=$array_config['suregifts_country'];
|
54 |
+
$auth = $username.':'.$password;
|
55 |
+
$validationUrl =Mage::getModel('giftcardapi/giftcardapi')->getValidationUrl($country,$mode);
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
//just added this Feb 12 2016
|
60 |
+
|
61 |
+
$ch = curl_init($validationUrl.'?vouchercode='.$data['giftcard']);
|
62 |
+
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
curl_setopt($ch, CURLOPT_POST, false);
|
66 |
|
100 |
}
|
101 |
|
102 |
|
103 |
+
}
|
app/code/community/Suregifts/Giftcardapi/controllers/IndexController.php~
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Suregifts Giftcard API Extension
|
4 |
+
* @category Magento Extensions
|
5 |
+
* @package Suregifts_Giftcardapi
|
6 |
+
* @author Sodiq <damilolasodiq@gmail.com>
|
7 |
+
*/
|
8 |
+
class Suregifts_Giftcardapi_IndexController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _getSession()
|
12 |
+
{
|
13 |
+
return Mage::getSingleton('checkout/session');
|
14 |
+
}
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$this->loadLayout();
|
18 |
+
$this->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function reorderAction()
|
22 |
+
{
|
23 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
24 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
public function discountPostAction()
|
30 |
+
{
|
31 |
+
|
32 |
+
if($data = $this->getRequest()->getPost()){
|
33 |
+
if($data['remove'] ==1){
|
34 |
+
$this->_getSession()->getQuote()->setGiftcardapiCode('')->save();
|
35 |
+
$this->_getSession()->setUseGiftcardapiDiscount(false);
|
36 |
+
$this->_getSession()->setGiftcardapiDiscountAmount(0);
|
37 |
+
$this->_getSession()->addSuccess($this->__('Your Gift card discount has been removed.'));
|
38 |
+
$this->_redirect('checkout/cart');
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
if($data['giftcard'] ==''){
|
42 |
+
$this->_getSession()->addError($this->__('Please enter your gift card.'));
|
43 |
+
$this->_redirect('checkout/cart');
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
$array_config= Mage::getStoreConfig('giftcardapi/suregifts_group',Mage::app()->getStore());
|
49 |
+
$username =$array_config['suregifts_username'];
|
50 |
+
$password =$array_config['suregifts_password'];
|
51 |
+
$website_host = $array_config['suregifts_websitehost'];
|
52 |
+
$mode = $array_config['suregifts_mode'];
|
53 |
+
$country=$array_config['suregifts_country'];
|
54 |
+
$auth = $username.':'.$password;
|
55 |
+
$validationUrl =Mage::getModel('giftcardapi/giftcardapi')->getValidationUrl($country,$mode);
|
56 |
+
var_dump($validationUrl);
|
57 |
+
die($validationUrl);
|
58 |
+
|
59 |
+
|
60 |
+
//just added this Feb 12 2016
|
61 |
+
|
62 |
+
$ch = curl_init($validationUrl.'?vouchercode='.$data['giftcard']);
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
curl_setopt($ch, CURLOPT_POST, false);
|
67 |
+
|
68 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
69 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
70 |
+
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
|
71 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
72 |
+
|
73 |
+
if ($username!=''){
|
74 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
75 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
76 |
+
"Authorization: Basic ".base64_encode($auth),
|
77 |
+
)
|
78 |
+
);
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
$resp = curl_exec($ch);
|
83 |
+
$response_info=array();
|
84 |
+
curl_close($ch);
|
85 |
+
$response_info=json_decode($resp, true);
|
86 |
+
//$response_info['AmountToUse']=20000;
|
87 |
+
Mage::log($response_info['AmountToUse'] , null, 'mode.log');
|
88 |
+
if(isset($response_info['AmountToUse']) && $response_info['AmountToUse']) {
|
89 |
+
$this->_getSession()->getQuote()->setGiftcardapiCode($data['giftcard'])->save();
|
90 |
+
$this->_getSession()->addSuccess($this->__('Your SureGifts card discount has been applied.'));
|
91 |
+
$this->_getSession()->setUseGiftcardapiDiscount(true);
|
92 |
+
$this->_getSession()->setGiftcardapiDiscountAmount($response_info['AmountToUse']);
|
93 |
+
} else {
|
94 |
+
$this->_getSession()->getQuote()->setGiftcardapiCode('')->save();
|
95 |
+
$this->_getSession()->setUseGiftcardapiDiscount(false);
|
96 |
+
$this->_getSession()->setGiftcardapiDiscountAmount(0);
|
97 |
+
$this->_getSession()->addError($this->__('Your Gift card discount amount is invalid or has already been used'));
|
98 |
+
}
|
99 |
+
}
|
100 |
+
$this->_redirect('checkout/cart');
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
}
|
app/code/community/Suregifts/Giftcardapi/etc/config.xml
CHANGED
@@ -66,6 +66,7 @@
|
|
66 |
<giftcardapi>
|
67 |
<suregifts_group>
|
68 |
<suregifts_mode>0</suregifts_mode>
|
|
|
69 |
</suregifts_group>
|
70 |
</giftcardapi>
|
71 |
</default>
|
@@ -213,4 +214,4 @@
|
|
213 |
</totals>
|
214 |
</pdf>
|
215 |
</global>
|
216 |
-
</config>
|
66 |
<giftcardapi>
|
67 |
<suregifts_group>
|
68 |
<suregifts_mode>0</suregifts_mode>
|
69 |
+
<suregifts_country>NGR</suregifts_country>
|
70 |
</suregifts_group>
|
71 |
</giftcardapi>
|
72 |
</default>
|
214 |
</totals>
|
215 |
</pdf>
|
216 |
</global>
|
217 |
+
</config>
|
app/code/community/Suregifts/Giftcardapi/etc/config.xml~
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Suregifts_Giftcardapi>
|
5 |
+
<version>1.4.5</version>
|
6 |
+
</Suregifts_Giftcardapi>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<giftcardapi>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Suregifts_Giftcardapi</module>
|
14 |
+
<frontName>giftcardapi</frontName>
|
15 |
+
</args>
|
16 |
+
</giftcardapi>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<giftcardapi>
|
21 |
+
<file>giftcardapi.xml</file>
|
22 |
+
</giftcardapi>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
<translate>
|
26 |
+
<modules>
|
27 |
+
<Suregifts_Giftcardapi>
|
28 |
+
<files>
|
29 |
+
<default>Suregifts_Giftcardapi.csv</default>
|
30 |
+
</files>
|
31 |
+
</Suregifts_Giftcardapi>
|
32 |
+
</modules>
|
33 |
+
</translate>
|
34 |
+
</frontend>
|
35 |
+
<adminhtml>
|
36 |
+
<translate>
|
37 |
+
<modules>
|
38 |
+
<Suregifts_Giftcardapi>
|
39 |
+
<files>
|
40 |
+
<default>Suregifts_Giftcardapi.csv</default>
|
41 |
+
</files>
|
42 |
+
</Suregifts_Giftcardapi>
|
43 |
+
</modules>
|
44 |
+
</translate>
|
45 |
+
<acl>
|
46 |
+
<resources>
|
47 |
+
<admin>
|
48 |
+
<children>
|
49 |
+
<system>
|
50 |
+
<children>
|
51 |
+
<config>
|
52 |
+
<children>
|
53 |
+
<giftcardapi translate="title" module="giftcardapi">
|
54 |
+
<title>Options</title>
|
55 |
+
<sort_order>100</sort_order>
|
56 |
+
</giftcardapi>
|
57 |
+
</children>
|
58 |
+
</config>
|
59 |
+
</children>
|
60 |
+
</system>
|
61 |
+
</children>
|
62 |
+
</admin>
|
63 |
+
</resources>
|
64 |
+
</acl>
|
65 |
+
<default>
|
66 |
+
<giftcardapi>
|
67 |
+
<suregifts_group>
|
68 |
+
<suregifts_mode>0</suregifts_mode>
|
69 |
+
</suregifts_group>
|
70 |
+
</giftcardapi>
|
71 |
+
</default>
|
72 |
+
</adminhtml>
|
73 |
+
<global>
|
74 |
+
|
75 |
+
<events>
|
76 |
+
<core_block_abstract_to_html_before>
|
77 |
+
<observers>
|
78 |
+
<giftcardapi_observer>
|
79 |
+
<type>singleton</type>
|
80 |
+
<class>giftcardapi/observer</class>
|
81 |
+
<method>insertBlock</method>
|
82 |
+
</giftcardapi_observer>
|
83 |
+
</observers>
|
84 |
+
</core_block_abstract_to_html_before>
|
85 |
+
<sales_order_save_before>
|
86 |
+
<observers>
|
87 |
+
<giftcardapi_observer>
|
88 |
+
<type>singleton</type>
|
89 |
+
<class>giftcardapi/observer</class>
|
90 |
+
<method>salesOrderSaveBefore</method>
|
91 |
+
</giftcardapi_observer>
|
92 |
+
</observers>
|
93 |
+
</sales_order_save_before>
|
94 |
+
<sales_order_save_after>
|
95 |
+
<observers>
|
96 |
+
<giftcardapi_observer>
|
97 |
+
<type>singleton</type>
|
98 |
+
<class>giftcardapi/observer</class>
|
99 |
+
<method>salesOrderSaveAfter</method>
|
100 |
+
</giftcardapi_observer>
|
101 |
+
</observers>
|
102 |
+
</sales_order_save_after>
|
103 |
+
<sales_order_invoice_pay>
|
104 |
+
<observers>
|
105 |
+
<giftcardapi_observer>
|
106 |
+
<type>singleton</type>
|
107 |
+
<class>giftcardapi/observer</class>
|
108 |
+
<method>salesInvoiceCreateAfter</method>
|
109 |
+
</giftcardapi_observer>
|
110 |
+
</observers>
|
111 |
+
</sales_order_invoice_pay>
|
112 |
+
</events>
|
113 |
+
<models>
|
114 |
+
<giftcardapi>
|
115 |
+
<class>Suregifts_Giftcardapi_Model</class>
|
116 |
+
<resourceModel>giftcardapi_mysql4</resourceModel>
|
117 |
+
</giftcardapi>
|
118 |
+
<giftcardapi_mysql4>
|
119 |
+
<class>Suregifts_Giftcardapi_Model_Mysql4</class>
|
120 |
+
</giftcardapi_mysql4>
|
121 |
+
</models>
|
122 |
+
<resources>
|
123 |
+
<giftcardapi_setup>
|
124 |
+
<setup>
|
125 |
+
<module>Suregifts_Giftcardapi</module>
|
126 |
+
</setup>
|
127 |
+
<connection>
|
128 |
+
<use>core_setup</use>
|
129 |
+
</connection>
|
130 |
+
</giftcardapi_setup>
|
131 |
+
<giftcardapi_write>
|
132 |
+
<connection>
|
133 |
+
<use>core_write</use>
|
134 |
+
</connection>
|
135 |
+
</giftcardapi_write>
|
136 |
+
<giftcardapi_read>
|
137 |
+
<connection>
|
138 |
+
<use>core_read</use>
|
139 |
+
</connection>
|
140 |
+
</giftcardapi_read>
|
141 |
+
</resources>
|
142 |
+
<blocks>
|
143 |
+
<giftcardapi>
|
144 |
+
<class>Suregifts_Giftcardapi_Block</class>
|
145 |
+
</giftcardapi>
|
146 |
+
</blocks>
|
147 |
+
<helpers>
|
148 |
+
<giftcardapi>
|
149 |
+
<class>Suregifts_Giftcardapi_Helper</class>
|
150 |
+
</giftcardapi>
|
151 |
+
</helpers>
|
152 |
+
<sales>
|
153 |
+
<quote>
|
154 |
+
<totals>
|
155 |
+
<giftcardapi>
|
156 |
+
<class>giftcardapi/quote_total_giftcardapi</class>
|
157 |
+
<after>grand_total</after>
|
158 |
+
</giftcardapi>
|
159 |
+
<giftcardapi_tax>
|
160 |
+
<class>giftcardapi/quote_total_tax</class>
|
161 |
+
<after>subtotal,discount,shipping,tax</after>
|
162 |
+
<before>grand_total</before>
|
163 |
+
</giftcardapi_tax>
|
164 |
+
</totals>
|
165 |
+
</quote>
|
166 |
+
<order_invoice>
|
167 |
+
<totals>
|
168 |
+
<giftcardapi>
|
169 |
+
<class>giftcardapi/invoice_total_giftcardapi</class>
|
170 |
+
</giftcardapi>
|
171 |
+
<giftcardapi_tax>
|
172 |
+
<class>giftcardapi/invoice_total_tax</class>
|
173 |
+
</giftcardapi_tax>
|
174 |
+
</totals>
|
175 |
+
</order_invoice>
|
176 |
+
<order_creditmemo>
|
177 |
+
<totals>
|
178 |
+
<giftcardapi>
|
179 |
+
<class>giftcardapi/creditmemo_total</class>
|
180 |
+
</giftcardapi>
|
181 |
+
</totals>
|
182 |
+
</order_creditmemo>
|
183 |
+
</sales>
|
184 |
+
<fieldsets>
|
185 |
+
<sales_convert_quote_address>
|
186 |
+
<giftcardapi_code>
|
187 |
+
<to_order>*</to_order>
|
188 |
+
</giftcardapi_code>
|
189 |
+
<giftcardapi_discount>
|
190 |
+
<to_order>*</to_order>
|
191 |
+
</giftcardapi_discount>
|
192 |
+
<base_giftcardapi_discount>
|
193 |
+
<to_order>*</to_order>
|
194 |
+
</base_giftcardapi_discount>
|
195 |
+
<giftcardapi_discount_tax>
|
196 |
+
<to_order>*</to_order>
|
197 |
+
</giftcardapi_discount_tax>
|
198 |
+
<base_giftcardapi_discount_tax>
|
199 |
+
<to_order>*</to_order>
|
200 |
+
</base_giftcardapi_discount_tax>
|
201 |
+
</sales_convert_quote_address>
|
202 |
+
</fieldsets>
|
203 |
+
<pdf>
|
204 |
+
<totals>
|
205 |
+
<giftcardapi translate="title">
|
206 |
+
<title>Suregifts Gift Card Discount</title>
|
207 |
+
<source_field>giftcardapi_discount</source_field>
|
208 |
+
<font_size>7</font_size>
|
209 |
+
<display_zero>0</display_zero>
|
210 |
+
<sort_order>590</sort_order>
|
211 |
+
<amount_prefix>-</amount_prefix>
|
212 |
+
</giftcardapi>
|
213 |
+
</totals>
|
214 |
+
</pdf>
|
215 |
+
</global>
|
216 |
+
</config>
|
app/code/community/Suregifts/Giftcardapi/etc/system.xml
CHANGED
@@ -50,6 +50,16 @@
|
|
50 |
<show_in_website>1</show_in_website>
|
51 |
<show_in_store>1</show_in_store>
|
52 |
</suregifts_websitehost>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
<suregifts_mode translate="label">
|
54 |
<label>Test Mode </label>
|
55 |
<comment>select 'No' to authenticate with live server</comment>
|
@@ -113,4 +123,4 @@
|
|
113 |
</groups>
|
114 |
</tax>
|
115 |
</sections>
|
116 |
-
</config>
|
50 |
<show_in_website>1</show_in_website>
|
51 |
<show_in_store>1</show_in_store>
|
52 |
</suregifts_websitehost>
|
53 |
+
<suregifts_country translate="label">
|
54 |
+
<label>Country </label>
|
55 |
+
<comment>Select your store location</comment>
|
56 |
+
<frontend_type>select</frontend_type>
|
57 |
+
<sort_order>50</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
<source_model>giftcardapi/system_config_source_dropdown_values</source_model>
|
62 |
+
</suregifts_country>
|
63 |
<suregifts_mode translate="label">
|
64 |
<label>Test Mode </label>
|
65 |
<comment>select 'No' to authenticate with live server</comment>
|
123 |
</groups>
|
124 |
</tax>
|
125 |
</sections>
|
126 |
+
</config>
|
app/code/community/Suregifts/Giftcardapi/etc/system.xml~
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<suregifts_tab module="giftcardapi" translate="label">
|
5 |
+
<label>Suregifts Checkout</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</suregifts_tab>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<giftcardapi module="giftcardapi" translate="label">
|
11 |
+
<label>Options</label>
|
12 |
+
<sort_order>200</sort_order>
|
13 |
+
<show_in_default>1</show_in_default>
|
14 |
+
<show_in_website>1</show_in_website>
|
15 |
+
<show_in_store>1</show_in_store>
|
16 |
+
<tab>suregifts_tab</tab>
|
17 |
+
<groups>
|
18 |
+
<suregifts_group translate="label">
|
19 |
+
<label>Suregifts GiftCard Configuration</label>
|
20 |
+
<comment>Enter the merchant username and password provided to you by SUREGIFTS</comment>
|
21 |
+
<sort_order>10</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
<fields>
|
26 |
+
<suregifts_username translate="label">
|
27 |
+
<label>Username: </label>
|
28 |
+
<comment>Enter the merchant username</comment>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>20</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</suregifts_username>
|
35 |
+
<suregifts_password translate="label">
|
36 |
+
<label>Password: </label>
|
37 |
+
<comment>Enter the merchant password</comment>
|
38 |
+
<frontend_type>text</frontend_type>
|
39 |
+
<sort_order>30</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
</suregifts_password>
|
44 |
+
<suregifts_websitehost translate="label">
|
45 |
+
<label>Website Host: </label>
|
46 |
+
<comment>Enter website host for authentication</comment>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<sort_order>40</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
</suregifts_websitehost>
|
53 |
+
<suregifts_country translate="label">
|
54 |
+
<label>Country </label>
|
55 |
+
<comment>Select your store location</comment>
|
56 |
+
<frontend_type>select</frontend_type>
|
57 |
+
<sort_order>60</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
<source_model>giftcardapi/system_config_source_dropdown_values</source_model>
|
62 |
+
</suregifts_country>
|
63 |
+
<suregifts_mode translate="label">
|
64 |
+
<label>Test Mode </label>
|
65 |
+
<comment>select 'No' to authenticate with live server</comment>
|
66 |
+
<frontend_type>select</frontend_type>
|
67 |
+
<sort_order>60</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
72 |
+
</suregifts_mode>
|
73 |
+
</fields>
|
74 |
+
</suregifts_group>
|
75 |
+
</groups>
|
76 |
+
</giftcardapi>
|
77 |
+
</sections>
|
78 |
+
<sections>
|
79 |
+
<sales>
|
80 |
+
<groups>
|
81 |
+
<totals_sort>
|
82 |
+
<fields>
|
83 |
+
<giftcardapi module="giftcardapi" translate="label">
|
84 |
+
<label>Giftcardapi Discount</label>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>5</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
</giftcardapi>
|
91 |
+
</fields>
|
92 |
+
</totals_sort>
|
93 |
+
</groups>
|
94 |
+
</sales>
|
95 |
+
<tax translate="label" module="tax">
|
96 |
+
<groups>
|
97 |
+
<classes translate="label">
|
98 |
+
<fields>
|
99 |
+
<giftcardapi_tax_class translate="label">
|
100 |
+
<label>Giftcardapi Tax Class</label>
|
101 |
+
<frontend_type>select</frontend_type>
|
102 |
+
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
|
103 |
+
<sort_order>20</sort_order>
|
104 |
+
<show_in_default>1</show_in_default>
|
105 |
+
<show_in_website>1</show_in_website>
|
106 |
+
<show_in_store>1</show_in_store>
|
107 |
+
</giftcardapi_tax_class>
|
108 |
+
</fields>
|
109 |
+
</classes>
|
110 |
+
<calculation translate="label">
|
111 |
+
<fields>
|
112 |
+
<giftcardapi_includes_tax translate="label comment">
|
113 |
+
<label>Giftcardapi Discount</label>
|
114 |
+
<frontend_type>select</frontend_type>
|
115 |
+
<source_model>tax/system_config_source_priceType</source_model>
|
116 |
+
<sort_order>35</sort_order>
|
117 |
+
<show_in_default>1</show_in_default>
|
118 |
+
<show_in_website>1</show_in_website>
|
119 |
+
<show_in_store>1</show_in_store>
|
120 |
+
</giftcardapi_includes_tax>
|
121 |
+
</fields>
|
122 |
+
</calculation>
|
123 |
+
</groups>
|
124 |
+
</tax>
|
125 |
+
</sections>
|
126 |
+
</config>
|
app/design/frontend/base/default/layout/giftcardapi.xml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<checkout_cart_index>
|
4 |
+
<reference name="checkout.cart">
|
5 |
+
<action method="chooseTemplate"/>
|
6 |
+
<!--<action method="setCartTemplate"><value>giftcardapi/checkout/cart.phtml</value></action>-->
|
7 |
+
<block type="giftcardapi/discount" name="discount" before="-" after="checkout_discount" template="giftcardapi/discount.phtml" />
|
8 |
+
</reference>
|
9 |
+
</checkout_cart_index>
|
10 |
+
<sales_order_view>
|
11 |
+
<reference name="order_totals">
|
12 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
13 |
+
</reference>
|
14 |
+
</sales_order_view>
|
15 |
+
|
16 |
+
<sales_order_print>
|
17 |
+
<reference name="order_totals">
|
18 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
19 |
+
</reference>
|
20 |
+
</sales_order_print>
|
21 |
+
|
22 |
+
<sales_email_order_items>
|
23 |
+
<reference name="order_totals">
|
24 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
25 |
+
</reference>
|
26 |
+
</sales_email_order_items>
|
27 |
+
|
28 |
+
<sales_order_invoice>
|
29 |
+
<reference name="invoice_totals">
|
30 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
31 |
+
</reference>
|
32 |
+
</sales_order_invoice>
|
33 |
+
<sales_order_printinvoice>
|
34 |
+
<reference name="invoice_totals">
|
35 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
36 |
+
</reference>
|
37 |
+
</sales_order_printinvoice>
|
38 |
+
<sales_email_order_invoice_items>
|
39 |
+
<reference name="invoice_totals">
|
40 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
41 |
+
</reference>
|
42 |
+
</sales_email_order_invoice_items>
|
43 |
+
|
44 |
+
<sales_order_creditmemo>
|
45 |
+
<reference name="creditmemo_totals">
|
46 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
47 |
+
</reference>
|
48 |
+
</sales_order_creditmemo>
|
49 |
+
<sales_order_printcreditmemo>
|
50 |
+
<reference name="creditmemo_totals">
|
51 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
52 |
+
</reference>
|
53 |
+
</sales_order_printcreditmemo>
|
54 |
+
<sales_email_order_creditmemo_items>
|
55 |
+
<reference name="creditmemo_totals">
|
56 |
+
<block type="giftcardapi/sales_order_totals_discount" name="giftcardapi" />
|
57 |
+
</reference>
|
58 |
+
</sales_email_order_creditmemo_items>
|
59 |
+
</layout>
|
app/design/frontend/base/default/template/giftcardapi/discount.phtml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<form method="post" action="<?php echo $this->getUrl('giftcardapi/index/discountPost') ?>" id="giftcard-discount-form">
|
3 |
+
<input type="hidden" name="remove" id="remove-discount" value="0" />
|
4 |
+
|
5 |
+
<div class="discount">
|
6 |
+
<h2><?php echo $this->__('SureGifts Card')?></h2>
|
7 |
+
<div class="discount-form">
|
8 |
+
<label for="giftcard"><?php echo $this->__('<a href="http://suregifts.com.ng" target="_blank">SureGifts</a> card code')?></label>
|
9 |
+
<div class="input-box">
|
10 |
+
<input value="" name="giftcard" id="giftcard" class="input-text">
|
11 |
+
</div>
|
12 |
+
<div class="buttons-set">
|
13 |
+
<button value="<?php echo $this->__('Update Order')?>" onclick="giftcardDiscountForm.submit(false)" class="button" title="<?php echo $this->__('Update Order')?>" type="button"><span><span><?php echo $this->__('Update Order')?></span></span></button>
|
14 |
+
<?php if(Mage::getSingleton('checkout/session')->getUseGiftcardapiDiscount()):?>
|
15 |
+
<button type="button" title="<?php echo $this->__('Cancel Gift Discount') ?>" class="button" onclick="giftcardDiscountForm.submit(true)" value="<?php echo $this->__('Cancel Discount') ?>"><span><span><?php echo $this->__('Cancel Discount') ?></span></span></button>
|
16 |
+
<?php endif;?>
|
17 |
+
</div>
|
18 |
+
</div>
|
19 |
+
</div>
|
20 |
+
</form>
|
21 |
+
<script type="text/javascript">
|
22 |
+
//<![CDATA[
|
23 |
+
var giftcardDiscountForm = new VarienForm('giftcard-discount-form');
|
24 |
+
giftcardDiscountForm.submit = function (isRemove) {
|
25 |
+
if (isRemove) {
|
26 |
+
$('giftcard').removeClassName('required-entry');
|
27 |
+
$('remove-discount').value = "1";
|
28 |
+
} else {
|
29 |
+
$('giftcard').addClassName('required-entry');
|
30 |
+
$('remove-discount').value = "0";
|
31 |
+
}
|
32 |
+
return VarienForm.prototype.submit.bind(giftcardDiscountForm)();
|
33 |
+
}
|
34 |
+
//]]>
|
35 |
+
</script>
|
36 |
+
<?php echo $this->getChildHtml('child');
|
app/etc/modules/Suregifts_Giftcardapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Suregifts_Giftcardapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Suregifts_Giftcardapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/en_US/Suregifts_Giftcardapi.csv
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'Name','Name'
|
2 |
+
'Email','Email'
|
3 |
+
'Priority','Priority'
|
4 |
+
'Description','Description'
|
5 |
+
'Product Price','Product Price'
|
6 |
+
'Status','Status'
|
7 |
+
'Enabled','Enabled'
|
8 |
+
'Disabled','Disabled'
|
9 |
+
'Group Information','Group Information'
|
10 |
+
'Manage Products','Manage Products'
|
11 |
+
'Save Group','Save Group'
|
12 |
+
'Delete Group','Delete Group'
|
13 |
+
'Add Group','Add Group'
|
14 |
+
'Group Manager','Group Manager'
|
15 |
+
'Member Information','Member Information'
|
16 |
+
'View Packages','View Packages'
|
17 |
+
'Save Member','Save Member'
|
18 |
+
'Delete Member','Delete Member'
|
19 |
+
'Add Member','Add Member'
|
20 |
+
'View customer','View customer'
|
21 |
+
'Member Manager','Member Manager'
|
22 |
+
'View Member','View Member'
|
23 |
+
'Member Package Manager','Member Package Manager'
|
24 |
+
'Item information','Item information'
|
25 |
+
'Item Manager','Item Manager'
|
26 |
+
'Manage Groups','Manage Groups'
|
27 |
+
'Members','Members'
|
28 |
+
'Package Manager','Package Manager'
|
29 |
+
'Add Package','Add Package'
|
30 |
+
'Paymenthistory Manager','Paymenthistory Manager'
|
31 |
+
'Group News','Group News'
|
32 |
+
'Group does not exist','Group does not exist'
|
33 |
+
'Group was successfully saved','Group was successfully saved'
|
34 |
+
'Unable to find group to save','Unable to find group to save'
|
35 |
+
'Group was successfully deleted','Group was successfully deleted'
|
36 |
+
'Please select group(s)','Please select group(s)'
|
37 |
+
'Member does not exist','Member does not exist'
|
38 |
+
'Member was successfully saved','Member was successfully saved'
|
39 |
+
'Unable to find member to save','Unable to find member to save'
|
40 |
+
'Member was successfully deleted','Member was successfully deleted'
|
41 |
+
'Package does not exist','Package does not exist'
|
42 |
+
'Package was successfully saved','Package was successfully saved'
|
43 |
+
'Unable to find package to save','Unable to find package to save'
|
44 |
+
'Package was successfully deleted','Package was successfully deleted'
|
45 |
+
'Total of %d record(s) were successfully updated','Total of %d record(s) were successfully updated'
|
46 |
+
'Payment History','Payment History'
|
47 |
+
'Select All Products','Select All Products'
|
48 |
+
'-- Please Select --','-- Please Select --'
|
49 |
+
'Unselect All Products','Unselect All Products'
|
50 |
+
'Print This Page','Print This Page'
|
51 |
+
'Regular Price','Regular Price'
|
52 |
+
'Membership Price','Membership Price'
|
53 |
+
'You Saved','You Saved'
|
54 |
+
'Buy Now','Buy Now'
|
55 |
+
'Sign Up Now','Sign Up Now'
|
56 |
+
'Close Window','Close Window'
|
57 |
+
'Compare Membership Packages Price','Compare Membership Packages Price'
|
58 |
+
'View Membership Price','View Membership Price'
|
59 |
+
'Duration','Duration'
|
60 |
+
'Description','Description'
|
61 |
+
'Price','Price'
|
62 |
+
'View Detail','View Detail'
|
63 |
+
'Sign Up','Sign Up'
|
64 |
+
'month(s)','month(s)'
|
65 |
+
'Expire on %s','Expire on %s'
|
66 |
+
'There is no package available','There is no package available'
|
67 |
+
'Product','Product'
|
68 |
+
'View Product','View Product'
|
69 |
+
'Membership Infomation','Membership Infomation'
|
70 |
+
'My Packages','My Packages'
|
71 |
+
'You did not signup to any package.','You did not signup to any package.'
|
72 |
+
'Expired Date','Expired Date'
|
73 |
+
'Product Boughts','Product Boughts'
|
74 |
+
'Money Saved','Money Saved'
|
75 |
+
'Renew','Renew'
|
76 |
+
'Renew Now','Renew Now'
|
77 |
+
'Payment History','Payment History'
|
78 |
+
'Order Date','Order Date'
|
79 |
+
'Status','Status'
|
80 |
+
|
81 |
+
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
-
<name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="www.
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
<notes>
|
12 |
-
|
13 |
-
|
14 |
-
<
|
15 |
-
<
|
|
|
|
|
16 |
<compatible/>
|
17 |
-
<dependencies
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
+
<name>Suregifts_gift</name>
|
4 |
+
<version>2.0.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Suregifts giftcardapi</summary>
|
10 |
+
<description>Suregifts giftcardapi</description>
|
11 |
+
<notes>After succesful installation, kindly logout and relogin to you magento admin panel to avoid 404 error while trying to configure the extension.
|
12 |
+

|
13 |
+
Configuration is under system->configration->suregift checkout</notes>
|
14 |
+
<authors><author><name>Sodiq Fagbola</name><user>realdammy</user><email>realdammy@hotmail.com</email></author></authors>
|
15 |
+
<date>2016-02-13</date>
|
16 |
+
<time>09:05:30</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Suregifts"><dir name="Giftcardapi"><dir name="Block"><file name="Discount.php" hash="2faf19df16f0eac5dc61ad21e128dde7"/><dir name="Sales"><dir name="Creditmemo"><dir name="Totals"><file name="Discount.php" hash="5f69bbd2bf97529fc7d4fb9511f2c0e6"/></dir></dir><dir name="Invoice"><dir name="Totals"><file name="Discount.php" hash="4d145f37816e4fc15e5c095e607a9f99"/></dir></dir><dir name="Order"><dir name="Totals"><file name="Discount.php" hash="f81ae9ba01669f5db613693af53c7c52"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="531b91ff1c759a605e9a97233e0b3fc7"/></dir><dir name="Model"><dir name="Creditmemo"><file name="Total.php" hash="c6d482ce1543369fbbf7389e89e5569e"/></dir><file name="Giftcardapi.php" hash="83a6adee5278e7c28d2102e778f9d29c"/><file name="Giftcardapi.php~" hash="83a6adee5278e7c28d2102e778f9d29c"/><dir name="Invoice"><dir name="Total"><file name="Giftcardapi.php" hash="87d426b08a4403ed46f7ee108cd01322"/><file name="Tax.php" hash="4850403ee908c7019f770ddb982889e5"/></dir></dir><file name="Observer.php" hash="419aa92c0679183396974bd61c30eef9"/><file name="Observer.php~" hash="ac52f99ad3ce2c84d251a33dea4fcc52"/><dir name="Quote"><dir name="Total"><file name="Giftcardapi.php" hash="3c5d5f5d0d6517a176d7563960b08714"/><file name="Tax.php" hash="8ab99227fc0f52a209a7e68c2a400f7c"/></dir></dir><dir name="Source"><file name="Discount.php" hash="2fb6a3ccac3608681650414570c13a86"/></dir><file name="Status.php" hash="c497955ef14589b8e5c066b660e1fbd4"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Values.php" hash="da30171d87b95a5e92a14206b488d174"/><file name="Values.php~" hash="da30171d87b95a5e92a14206b488d174"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExtendoController.php" hash="13fc78a452f1a9f4b26f9701dba7a94a"/></dir><file name="IndexController.php" hash="12830f93e5ac39bafc28c22aef5d56e5"/><file name="IndexController.php~" hash="05c0da8daaa080b27944e779244d3ffe"/></dir><dir name="etc"><file name="config.xml" hash="3625e5bf06a1e7b42b934771e2e6bed2"/><file name="config.xml~" hash="0bd3ea874e2d10d8aeeb60a02219f84c"/><file name="system.xml" hash="75028024b0619a7adb6243a5d664a7a9"/><file name="system.xml~" hash="58604d44fbbba13ce9584449b8117e7c"/></dir><dir name="sql"><dir name="giftcardapi_setup"><file name="mysql4-install-0.1.0.php" hash="8c8ea981a81cf84c52b864438a10db1a"/><file name="mysql4-upgrade-0.4.2-0.4.3.php" hash="8c8ea981a81cf84c52b864438a10db1a"/><file name="mysql4-upgrade-0.4.3-0.4.4.php" hash="37d346ce4aee03d14a22c91c383a03bc"/><file name="mysql4-upgrade-0.4.4-0.4.5.php" hash="c6211165f64dd1047340127e462531ba"/></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Suregifts_Giftcardapi.csv" hash="51ff5879f9decb522e0d0236079774a2"/></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="giftcardapi.xml" hash="7f2125c1e63bb5159207fb3932ac83a4"/></dir><dir name="template"><dir name="giftcardapi"><file name="discount.phtml" hash="73865da391a37f990eabf3b7c3481240"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Suregifts_Giftcardapi.xml" hash="4c9d919bf7e805947e30ce53e4536e5b"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.0.0</min><max>5.6.1</max></php></required></dependencies>
|
20 |
</package>
|