Version Notes
System Requirements:
Your web server needs to have PHP’s cURL extension installed. If you are unsure about this, the easiest way to find out is just to proceed with this set up and see if it works. If it turns out that the cURL extension is not installed, you should ask your system administrator to rebuild PHP with this extension enabled.
Note
If you are facing any problem with the extension, please enable log settings [Settings->Configuration->Developer->Log Settings] or contact us at support@invoicera.com
Download this release
Release Info
Developer | Sandeep Kumar |
Extension | Invoicera-Order-Integrator |
Version | 2.0.1 |
Comparing to | |
See all releases |
Version 2.0.1
app/code/community/Invoicera/Invoice/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Invoicera_Invoice_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/community/Invoicera/Invoice/controllers/OnepageController.php
ADDED
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require("Mage/Checkout/controllers/OnepageController.php");
|
3 |
+
class Invoicera_Invoice_OnepageController extends Mage_Checkout_OnepageController
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Create order action
|
7 |
+
*/
|
8 |
+
public function saveOrderAction()
|
9 |
+
{
|
10 |
+
if ($this->_expireAjax()) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
|
14 |
+
$result = array();
|
15 |
+
try {
|
16 |
+
if ($requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds()) {
|
17 |
+
$postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
|
18 |
+
if ($diff = array_diff($requiredAgreements, $postedAgreements)) {
|
19 |
+
$result['success'] = false;
|
20 |
+
$result['error'] = true;
|
21 |
+
$result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.');
|
22 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
if ($data = $this->getRequest()->getPost('payment', false)) {
|
27 |
+
$this->getOnepage()->getQuote()->getPayment()->importData($data);
|
28 |
+
}
|
29 |
+
$this->getOnepage()->saveOrder();
|
30 |
+
|
31 |
+
// CREATING INVOICE AT INVOICERA.COM
|
32 |
+
$this->createInvoiceForInvoicera();
|
33 |
+
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
|
34 |
+
$result['success'] = true;
|
35 |
+
$result['error'] = false;
|
36 |
+
} catch (Mage_Core_Exception $e) {
|
37 |
+
Mage::logException($e);
|
38 |
+
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
39 |
+
$result['success'] = false;
|
40 |
+
$result['error'] = true;
|
41 |
+
$result['error_messages'] = $e->getMessage();
|
42 |
+
|
43 |
+
if ($gotoSection = $this->getOnepage()->getCheckout()->getGotoSection()) {
|
44 |
+
$result['goto_section'] = $gotoSection;
|
45 |
+
$this->getOnepage()->getCheckout()->setGotoSection(null);
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($updateSection = $this->getOnepage()->getCheckout()->getUpdateSection()) {
|
49 |
+
if (isset($this->_sectionUpdateFunctions[$updateSection])) {
|
50 |
+
$updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection];
|
51 |
+
$result['update_section'] = array(
|
52 |
+
'name' => $updateSection,
|
53 |
+
'html' => $this->$updateSectionFunction()
|
54 |
+
);
|
55 |
+
}
|
56 |
+
$this->getOnepage()->getCheckout()->setUpdateSection(null);
|
57 |
+
}
|
58 |
+
} catch (Exception $e) {
|
59 |
+
Mage::logException($e);
|
60 |
+
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
61 |
+
$result['success'] = false;
|
62 |
+
$result['error'] = true;
|
63 |
+
$result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
|
64 |
+
}
|
65 |
+
$this->getOnepage()->getQuote()->save();
|
66 |
+
/**
|
67 |
+
* when there is redirect to third party, we don't want to save order yet.
|
68 |
+
* we will save the order in return action.
|
69 |
+
*/
|
70 |
+
if (isset($redirectUrl)) {
|
71 |
+
$result['redirect'] = $redirectUrl;
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
75 |
+
}
|
76 |
+
|
77 |
+
public function createInvoiceForInvoicera()
|
78 |
+
{
|
79 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
80 |
+
// GETTING ORDER ID
|
81 |
+
$resultOne = $db->query("SELECT max(entity_id) as LastOrderID FROM sales_flat_order");
|
82 |
+
$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
83 |
+
|
84 |
+
$varOrderID = $rowOne['LastOrderID'];
|
85 |
+
|
86 |
+
$varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
|
87 |
+
// GETTING ORDER STATUS
|
88 |
+
$resultOne = $db->query("SELECT entity_id, status, customer_email, base_currency_code, shipping_description, shipping_amount, increment_id FROM sales_flat_order WHERE entity_id=".$varOrderID);
|
89 |
+
$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
90 |
+
|
91 |
+
$clientListXml = '<?xml version="1.0" encoding="utf-8"?>
|
92 |
+
<request method="listClient">
|
93 |
+
<filter>
|
94 |
+
<client_email>'.$rowOne['customer_email'].'</client_email>
|
95 |
+
</filter>
|
96 |
+
</request>';
|
97 |
+
$curlClientListResult = $this->sendCurlRequest($clientListXml);
|
98 |
+
$xml = stripslashes($curlClientListResult);
|
99 |
+
$objXml = new SimpleXMLElement($xml);
|
100 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
101 |
+
|
102 |
+
$varClientID = 0;
|
103 |
+
if($arrParamList['@attributes']['status'] == '403')
|
104 |
+
{
|
105 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
106 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
107 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
108 |
+
$varMessage = "
|
109 |
+
Dear ".$rowAdmindata['Name']."
|
110 |
+
|
111 |
+
Invoicera API authentication failed. Please check your invoicera configuration.
|
112 |
+
|
113 |
+
Regards
|
114 |
+
Invoicera Team";
|
115 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
116 |
+
}
|
117 |
+
if($arrParamList['@attributes']['status'] == '200' && $arrParamList['clients']['@attributes']['total'] == 1)
|
118 |
+
{
|
119 |
+
$varClientID = $arrParamList['clients']['client']['client_id'];
|
120 |
+
}
|
121 |
+
else
|
122 |
+
{
|
123 |
+
// GETTING CLIENT DETAILS
|
124 |
+
$resultThree = $db->query("SELECT firstname, lastname, company, email, telephone, concat_ws(',', street, city, region, postcode) as ClientAddress FROM sales_flat_order_address WHERE email='".$rowOne['customer_email']."'");
|
125 |
+
$rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
|
126 |
+
|
127 |
+
$clientCreateXml = '<?xml version="1.0" encoding="utf-8"?>
|
128 |
+
<request method="createClient">
|
129 |
+
<name>'.$rowThree['firstname'].' '.$rowThree['lastname'].'</name>
|
130 |
+
<organization>'.$rowThree['firstname'].' '.$rowThree['lastname'].'</organization>
|
131 |
+
<email>'.$rowOne['customer_email'].'</email>
|
132 |
+
<work_phone>'.$rowThree['telephone'].'</work_phone>
|
133 |
+
<address>'.$rowThree['ClientAddress'].'</address>
|
134 |
+
<currency>'.$varCurrenyCode.'</currency>
|
135 |
+
</request>';
|
136 |
+
$curlClientResult = $this->sendCurlRequest($clientCreateXml);
|
137 |
+
$xml = stripslashes($curlClientResult);
|
138 |
+
$objXml = new SimpleXMLElement($xml);
|
139 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
140 |
+
|
141 |
+
if($arrParamList['@attributes']['status'] == '403')
|
142 |
+
{
|
143 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
144 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
145 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
146 |
+
$varMessage = "
|
147 |
+
Dear ".$rowAdmindata['Name']."
|
148 |
+
|
149 |
+
Invoicera API authentication failed. Please check your invoicera configuration.
|
150 |
+
|
151 |
+
Regards
|
152 |
+
Invoicera Team";
|
153 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
154 |
+
}
|
155 |
+
|
156 |
+
if($arrParamList['@attributes']['status'] == '426')
|
157 |
+
{
|
158 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
159 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
160 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
161 |
+
$varMessage = "
|
162 |
+
Dear ".$rowAdmindata['Name']."
|
163 |
+
|
164 |
+
This is to notify you that now your orders can not be imported and saved as invoices into your Invoicera account as your Invoicera account has exceeded the client limit. Due to which, your customers who would make any order on your store now, would not be able to get an invoice from your Invoicera Account. To avoid this inconvenience, we would request you to upgrade your Invoicera account.
|
165 |
+
|
166 |
+
Please feel free to contact us in case you have any query.
|
167 |
+
|
168 |
+
Thanks & Regards,
|
169 |
+
Invoicera Team
|
170 |
+
|
171 |
+
http://www.invoicera.com/
|
172 |
+
You may also catch us over Twitter at http://www.twitter.com/invoicera";
|
173 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
174 |
+
}
|
175 |
+
if($arrParamList['@attributes']['status'] == '200')
|
176 |
+
{
|
177 |
+
$varClientID = $arrParamList['client_id'];
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
if($rowOne['status'] == 'processing' || $rowOne['status'] == 'complete')
|
182 |
+
{
|
183 |
+
$varStatus = 'Paid';
|
184 |
+
}
|
185 |
+
else
|
186 |
+
{
|
187 |
+
$varStatus = 'Sent';
|
188 |
+
}
|
189 |
+
|
190 |
+
if($varClientID)
|
191 |
+
{
|
192 |
+
$result = $db->query("SELECT item_id, product_type, order_id, sku, name, description, qty_ordered, base_price, tax_percent, tax_amount, base_discount_amount FROM sales_flat_order_item WHERE order_id=".$varOrderID." AND parent_item_id IS NULL GROUP BY sku HAVING (order_id > 0) ORDER BY item_id desc");
|
193 |
+
|
194 |
+
if(!$result) {
|
195 |
+
return false;
|
196 |
+
}
|
197 |
+
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
198 |
+
$arrData[] = $row;
|
199 |
+
}
|
200 |
+
if(!$arrData) {
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
+
$comment = '';
|
205 |
+
$comment = $data['comment_text'];
|
206 |
+
// getting po_number
|
207 |
+
$random_number = rand(0, pow(10, 7));
|
208 |
+
// GETTING INVOICE PREFIX
|
209 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
210 |
+
$varPath = 'invoice_options/invoice/invoice_prefix';
|
211 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
212 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
213 |
+
$varInvoicePrefix = $rowTwo['value'];
|
214 |
+
// creating XML for creating invoice
|
215 |
+
$createInvoiceXML = '';
|
216 |
+
$createInvoiceXML .= '<?xml version="1.0" encoding="utf-8"?>
|
217 |
+
<request method="createInvoice">
|
218 |
+
<client>
|
219 |
+
<client_id>'.$varClientID.'</client_id>
|
220 |
+
<address>'.$rowThree['ClientAddress'].'</address>
|
221 |
+
</client>
|
222 |
+
<invoice_title>Order #'.$rowOne['increment_id'].'</invoice_title>
|
223 |
+
<number>'.$varInvoicePrefix.$rowOne['increment_id'].'</number>
|
224 |
+
<date>'.trim(substr($arrData[0]['created_at'], 0, 10)).'</date>
|
225 |
+
<due_date></due_date>
|
226 |
+
<schedule_date></schedule_date>
|
227 |
+
<po_number>'.trim($random_number).'</po_number>
|
228 |
+
<status>'.trim($varStatus).'</status>
|
229 |
+
<currency_code>'.trim($varCurrenyCode).'</currency_code>
|
230 |
+
<notes>'.$comment.'</notes>
|
231 |
+
<terms></terms>
|
232 |
+
<items>';
|
233 |
+
for($i=0;$i<count($arrData);$i++)
|
234 |
+
{
|
235 |
+
$result = $db->query("SELECT product_type, order_id, sku, name, description, qty_ordered, base_price, tax_percent, tax_amount, base_discount_amount FROM sales_flat_order_item WHERE order_id='".$varOrderID."' AND parent_item_id IS NOT NULL AND parent_item_id = '".$arrData[$i]['item_id']."'");
|
236 |
+
|
237 |
+
if(!$result) {
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
while ($item_row = $result->fetch(PDO::FETCH_ASSOC))
|
241 |
+
{
|
242 |
+
$arrItemData[] = $item_row;
|
243 |
+
}
|
244 |
+
$varDescription = '';
|
245 |
+
if($arrItemData)
|
246 |
+
{
|
247 |
+
for($j=0; $j<count($arrItemData); $j++)
|
248 |
+
{
|
249 |
+
$varDescription .= "[".$arrItemData[$j]['sku']."] ".$arrItemData[$j]['name']."\n";
|
250 |
+
}
|
251 |
+
//$varDescription = trim($varDescription, ', ');
|
252 |
+
}
|
253 |
+
else
|
254 |
+
{
|
255 |
+
$varDescription = "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']);
|
256 |
+
}
|
257 |
+
|
258 |
+
$createInvoiceXML .='<item>
|
259 |
+
<name>'.trim($arrData[$i]['name']).'</name>
|
260 |
+
<type>Product</type>
|
261 |
+
<description>'.$varDescription.'</description>
|
262 |
+
<unit_cost>'.trim(number_format($arrData[$i]['base_price'], 2, '.', '')).'</unit_cost>
|
263 |
+
<quantity>'.trim(number_format($arrData[$i]['qty_ordered'], 2, '.', '')).'</quantity>
|
264 |
+
<discount>'.trim(number_format($arrData[$i]['base_discount_amount'], 2, '.', '')).'</discount>
|
265 |
+
<discount_type>Fixed</discount_type>';
|
266 |
+
if($arrData[$i]['tax_percent'] > 0)
|
267 |
+
{
|
268 |
+
$createInvoiceXML .='
|
269 |
+
<tax1_name>Tax-1</tax1_name>
|
270 |
+
<tax1_percent>'.trim(number_format($arrData[$i]['tax_percent'], 2, '.', '')).'</tax1_percent>';
|
271 |
+
}
|
272 |
+
$createInvoiceXML .='
|
273 |
+
</item>';
|
274 |
+
}
|
275 |
+
$createInvoiceXML .= '</items>';
|
276 |
+
if($rowOne['shipping_amount'] > 0)
|
277 |
+
{
|
278 |
+
$createInvoiceXML .= '
|
279 |
+
<additional_charges>
|
280 |
+
<additional_charge>
|
281 |
+
<name>'.trim($rowOne['shipping_description']).'</name>
|
282 |
+
<type>Fixed</type>
|
283 |
+
<amount>'.trim($rowOne['shipping_amount']).'</amount>
|
284 |
+
</additional_charge>
|
285 |
+
</additional_charges>';
|
286 |
+
}
|
287 |
+
$createInvoiceXML .= '</request>';
|
288 |
+
$curlInvoiveResult = $this->sendCurlRequest($createInvoiceXML);
|
289 |
+
|
290 |
+
// GETTING SEND MAIL SETTING
|
291 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
292 |
+
$varPath = 'invoice_options/invoice/send_mail';
|
293 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
294 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
295 |
+
$varSendMailFlag = $rowTwo['value'];
|
296 |
+
|
297 |
+
if($varSendMailFlag)
|
298 |
+
{
|
299 |
+
$xml = stripslashes($curlInvoiveResult);
|
300 |
+
$objXml = new SimpleXMLElement($xml);
|
301 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
302 |
+
|
303 |
+
if($arrParamList['@attributes']['status'] == '200')
|
304 |
+
{
|
305 |
+
$varInvoiceID = $arrParamList['invoice_id'];
|
306 |
+
|
307 |
+
$varSendInvoiceXml = '<?xml version="1.0" encoding="utf-8"?>
|
308 |
+
<request method="sendInvoiceMail">
|
309 |
+
<invoice_id>'.$varInvoiceID.'</invoice_id>
|
310 |
+
</request>';
|
311 |
+
$curlInvoiceSendResult = $this->sendCurlRequest($varSendInvoiceXml);
|
312 |
+
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
public function sendCurlRequest($xml)
|
319 |
+
{
|
320 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
321 |
+
// GETTING API TOKEN
|
322 |
+
$varPath = 'invoice_options/invoice/api_token';
|
323 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
324 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
325 |
+
$token = $rowTwo['value'];
|
326 |
+
|
327 |
+
// GETTING API URL
|
328 |
+
$varURLPath = 'invoice_options/invoice/api_url';
|
329 |
+
$resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
|
330 |
+
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
331 |
+
$apiURL = $rowURL['value'];
|
332 |
+
|
333 |
+
$ch = curl_init($apiURL);
|
334 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
335 |
+
curl_setopt($ch, CURLOPT_USERPWD, $token.':123');
|
336 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml_request='.$xml);
|
337 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
338 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
339 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
340 |
+
curl_setopt($ch, CURLOPT_USERAGENT, "Invoicera API tester 1.0");
|
341 |
+
$curlClientResult = curl_exec($ch);
|
342 |
+
curl_close ($ch);
|
343 |
+
return $curlClientResult;
|
344 |
+
}
|
345 |
+
|
346 |
+
public function objectsIntoArray($arrObjData, $arrSkipIndices = array())
|
347 |
+
{
|
348 |
+
$arrData = array();
|
349 |
+
|
350 |
+
// if input is object, convert into array
|
351 |
+
if (is_object($arrObjData)) {
|
352 |
+
$arrObjData = get_object_vars($arrObjData);
|
353 |
+
}
|
354 |
+
|
355 |
+
if (is_array($arrObjData)) {
|
356 |
+
foreach ($arrObjData as $index => $value) {
|
357 |
+
if (is_object($value) || is_array($value)) {
|
358 |
+
$value = $this->objectsIntoArray($value, $arrSkipIndices); // recursive call
|
359 |
+
}
|
360 |
+
if (in_array($index, $arrSkipIndices)) {
|
361 |
+
continue;
|
362 |
+
}
|
363 |
+
$arrData[$index] = $value;
|
364 |
+
}
|
365 |
+
}
|
366 |
+
return $arrData;
|
367 |
+
}
|
368 |
+
|
369 |
+
public function notify_to_admin($name, $email, $msg)
|
370 |
+
{
|
371 |
+
$varSubject = 'Invoicera Notification';
|
372 |
+
|
373 |
+
Mage::log($msg);
|
374 |
+
|
375 |
+
$mail = Mage::getModel('core/email');
|
376 |
+
$mail->setToName($name);
|
377 |
+
$mail->setToEmail($email);
|
378 |
+
$mail->setBody($msg);
|
379 |
+
$mail->setSubject($varSubject);
|
380 |
+
$mail->setFromEmail("support@invoicera.com");
|
381 |
+
$mail->setFromName("Invoicera Support");
|
382 |
+
$mail->setType('text');
|
383 |
+
$mail->send();
|
384 |
+
}
|
385 |
+
}
|
386 |
+
?>
|
app/code/community/Invoicera/Invoice/etc/config.xml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<global>
|
4 |
+
<helpers>
|
5 |
+
<invoice>
|
6 |
+
<class>Invoicera_Invoice_Helper</class>
|
7 |
+
</invoice>
|
8 |
+
</helpers>
|
9 |
+
</global>
|
10 |
+
<frontend>
|
11 |
+
<routers>
|
12 |
+
<checkout>
|
13 |
+
<args>
|
14 |
+
<modules>
|
15 |
+
<Invoicera_Invoice before="Mage_Checkout">Invoicera_Invoice</Invoicera_Invoice>
|
16 |
+
</modules>
|
17 |
+
</args>
|
18 |
+
</checkout>
|
19 |
+
</routers>
|
20 |
+
</frontend>
|
21 |
+
<adminhtml>
|
22 |
+
<acl>
|
23 |
+
<resources>
|
24 |
+
<admin>
|
25 |
+
<children>
|
26 |
+
<system>
|
27 |
+
<children>
|
28 |
+
<config>
|
29 |
+
<children>
|
30 |
+
<invoice_options>
|
31 |
+
<title>Store Hello World Module Section</title>
|
32 |
+
</invoice_options>
|
33 |
+
</children>
|
34 |
+
</config>
|
35 |
+
</children>
|
36 |
+
</system>
|
37 |
+
</children>
|
38 |
+
</admin>
|
39 |
+
</resources>
|
40 |
+
</acl>
|
41 |
+
</adminhtml>
|
42 |
+
</config>
|
app/code/community/Invoicera/Invoice/etc/system.xml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<invoicera translate="label" module="invoice">
|
5 |
+
<label>Invoicera</label>
|
6 |
+
<sort_order>300</sort_order>
|
7 |
+
</invoicera>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<invoice_options translate="label" module="invoice">
|
11 |
+
<label>Invoicera Configuration</label>
|
12 |
+
<tab>invoicera</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>1000</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<invoice translate="label">
|
20 |
+
<label>Invoicera</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<api_url translate="label">
|
28 |
+
<label>API URL</label>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>1</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 |
+
<comment><![CDATA[e.g. https://subdomain.invoicera.com/app/api/xml/1.0/]]></comment>
|
35 |
+
</api_url>
|
36 |
+
<api_token translate="label">
|
37 |
+
<label>API Token</label>
|
38 |
+
<frontend_type>text</frontend_type>
|
39 |
+
<sort_order>2</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 |
+
</api_token>
|
44 |
+
<invoice_prefix translate="label">
|
45 |
+
<label>Invoice Prefix</label>
|
46 |
+
<frontend_type>text</frontend_type>
|
47 |
+
<sort_order>3</sort_order>
|
48 |
+
<show_in_default>1</show_in_default>
|
49 |
+
<show_in_website>1</show_in_website>
|
50 |
+
<show_in_store>1</show_in_store>
|
51 |
+
<comment><![CDATA[e.g. INV-, Invoice number would be visible like INV-110099, INV-110100 etc.]]></comment>
|
52 |
+
</invoice_prefix>
|
53 |
+
<send_mail translate="label">
|
54 |
+
<label>Email Customer</label>
|
55 |
+
<frontend_type>select</frontend_type>
|
56 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
57 |
+
<sort_order>5</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 |
+
</send_mail>
|
62 |
+
</fields>
|
63 |
+
</invoice>
|
64 |
+
</groups>
|
65 |
+
</invoice_options>
|
66 |
+
</sections>
|
67 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Invoicera-Order-Integrator</name>
|
4 |
+
<version>2.0.1</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>Create and send professional invoices to your customers with Invoicera in real time as soon as they place an order on your store. </summary>
|
10 |
+
<description>Invoicera is one of the leading online invoicing and billing software available in the market. 
|
11 |
+
Here are just a few of the benefits & features:
|
12 |
+
• Invoices are generated and would be sent automatically whenever any customer makes an order on your store.
|
13 |
+
• Cut down the amount of time spent on tracking and entering data from hours to seconds. 
|
14 |
+
• This service is available for free. 
|
15 |
+
• Easy installation with no files to change/upload.
|
16 |
+
• Orders are imported effortlessly and in real time.
|
17 |
+
• Maximize your Return on Investment (ROI).
|
18 |
+
• No more copy and pasting - if you get 6 or 7 orders a day, our service assures you to save over 10 hours per month.
|
19 |
+

|
20 |
+
System Requirements
|
21 |
+
• Your web server needs to have PHP’s cURL extension installed. If you are unsure about this, the easiest way to find out is just to proceed with this set up and see if it works. If it turns out that the cURL extension is not installed, you should ask your system administrator to rebuild PHP with this extension enabled.
|
22 |
+
</description>
|
23 |
+
<notes>System Requirements:
|
24 |
+

|
25 |
+
Your web server needs to have PHP’s cURL extension installed. If you are unsure about this, the easiest way to find out is just to proceed with this set up and see if it works. If it turns out that the cURL extension is not installed, you should ask your system administrator to rebuild PHP with this extension enabled.
|
26 |
+

|
27 |
+
Note
|
28 |
+

|
29 |
+
If you are facing any problem with the extension, please enable log settings [Settings->Configuration->Developer->Log Settings] or contact us at support@invoicera.com
|
30 |
+
</notes>
|
31 |
+
<authors><author><name>Sandeep Kumar</name><user>Invoicera</user><email>sandeep.kumar@mail.vinove.com</email></author></authors>
|
32 |
+
<date>2011-07-04</date>
|
33 |
+
<time>05:37:21</time>
|
34 |
+
<contents><target name="magecommunity"><dir name="Invoicera"><dir name="Invoice"><dir name="Helper"><file name="Data.php" hash="8bf2a13525f713b44269265b6c58231b"/></dir><dir name="controllers"><file name="OnepageController.php" hash="4ca4096bab195c447e92ca839e6d0ab2"/></dir><dir name="etc"><file name="config.xml" hash="ba27e9edb1c781f3a31535f893f5d8ee"/><file name="system.xml" hash="41f589f270aeb546bfb77f887b8aca7d"/></dir></dir></dir></target></contents>
|
35 |
+
<compatible/>
|
36 |
+
<dependencies><required><php><min>5.2.9</min><max>5.3.5</max></php></required></dependencies>
|
37 |
+
</package>
|