xonu_PayPalInvoiceSender - Version 1.0.0

Version Notes

Sends invoice automatically after an order is paid using PayPal.

Download this release

Release Info

Developer Pawel Kazakow
Extension xonu_PayPalInvoiceSender
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/xonu/PayPalInvoiceSender/Block/Adminhtml/Notification/Window.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+
7
+ ?>
8
+
9
+ <?php
10
+
11
+ require_once ('Mage/Adminhtml/Block/Notification/Window.php');
12
+ class xonu_PayPalInvoiceSender_Block_Adminhtml_Notification_Window extends Mage_Adminhtml_Block_Notification_Window
13
+ {
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+
18
+ $type = $this->getLastNotice()->getType();
19
+
20
+ if ( isset ( $type ) && $type == "paypalinvoice" )
21
+ {
22
+ $this->setNoticeMessageText(addslashes($this->getLastNotice()->getDescription()));
23
+ $this->messageID = $this->getLastNotice()->getId();
24
+ $this->setTemplate("paypalinvoicesender/notification/window.phtml");
25
+ }
26
+ else
27
+ {
28
+ $this->setTemplate("notification/window.phtml");
29
+ }
30
+ }
31
+ }
app/code/community/xonu/PayPalInvoiceSender/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+
7
+ ?>
8
+
9
+ <?php
10
+
11
+ class xonu_PayPalInvoiceSender_Helper_Data extends Mage_Core_Helper_Abstract
12
+ {
13
+
14
+ }
app/code/community/xonu/PayPalInvoiceSender/Model/Ipn.php ADDED
@@ -0,0 +1,71 @@
1
+ <?php
2
+
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+
7
+ ?>
8
+
9
+ <?php
10
+
11
+ require_once ('Mage/Paypal/Model/Ipn.php');
12
+ class xonu_PayPalInvoiceSender_Model_Ipn extends Mage_Paypal_Model_Ipn
13
+ {
14
+
15
+ /**
16
+ * Process completed payment (either full or partial)
17
+ */
18
+ protected function _registerPaymentCapture()
19
+ {
20
+ if ($this->getRequestData('transaction_entity') == 'auth') {
21
+ return;
22
+ }
23
+ $this->_importPaymentInformation();
24
+ $payment = $this->_order->getPayment();
25
+ $payment->setTransactionId($this->getRequestData('txn_id'))
26
+ ->setPreparedMessage($this->_createIpnComment(''))
27
+ ->setParentTransactionId($this->getRequestData('parent_txn_id'))
28
+ ->setShouldCloseParentTransaction('Completed' === $this->getRequestData('auth_status'))
29
+ ->setIsTransactionClosed(0)
30
+ ->registerCaptureNotification($this->getRequestData('mc_gross'));
31
+ $this->_order->save();
32
+
33
+ // notify customer
34
+ if ($invoice = $payment->getCreatedInvoice()) {
35
+
36
+ $comment = $this->_order->sendNewOrderEmail()->addStatusHistoryComment(
37
+ Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId())
38
+ )
39
+ ->setIsCustomerNotified(true)
40
+ ->save();
41
+
42
+ $this->_sendInvoiceToCustomer( $this->_order );
43
+
44
+ }
45
+ }
46
+
47
+ /*
48
+ * Send Invoice
49
+ */
50
+ protected function _sendInvoiceToCustomer (Mage_Sales_Model_Order $order)
51
+ {
52
+
53
+ // get send invoice config
54
+ $sendInvoiceFlag = Mage::getStoreConfig("paypalinvoicesender/general/send_invoice");
55
+ if ( $sendInvoiceFlag != 1 ) return false;
56
+
57
+ if ( $order->hasInvoices() )
58
+ {
59
+ foreach ( $order->getInvoiceCollection() as $invoice )
60
+ {
61
+ $invoice->setEmailSent(true);
62
+ try {
63
+ $invoice->sendEmail(true);
64
+ } catch (Exception $e) {
65
+ Mage::logException($e);
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ }
app/code/community/xonu/PayPalInvoiceSender/etc/config.xml ADDED
@@ -0,0 +1,89 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <xonu_PayPalInvoiceSender>
10
+ <version>1.0.0</version>
11
+ </xonu_PayPalInvoiceSender>
12
+ </modules>
13
+
14
+ <admin>
15
+ <routers>
16
+ <paypalinvoicesender>
17
+ <use>admin</use>
18
+ <args>
19
+ <module>xonu_PayPalInvoiceSender</module>
20
+ <frontName>paypalinvoicesender</frontName>
21
+ </args>
22
+ </paypalinvoicesender>
23
+ </routers>
24
+ </admin>
25
+
26
+ <adminhtml>
27
+ <layout>
28
+ <updates>
29
+ <paypalinvoicesender>
30
+ <file>paypalinvoicesender.xml</file>
31
+ </paypalinvoicesender>
32
+ </updates>
33
+ </layout>
34
+ </adminhtml>
35
+
36
+ <global>
37
+ <models>
38
+
39
+ <!-- Rewrite PayPal IPN Model -->
40
+ <paypal>
41
+ <rewrite>
42
+ <ipn>xonu_PayPalInvoiceSender_Model_Ipn</ipn>
43
+ </rewrite>
44
+ </paypal>
45
+
46
+ </models>
47
+
48
+ <resources>
49
+ <paypalinvoicesender_setup>
50
+ <setup>
51
+ <module>xonu_PayPalInvoiceSender</module>
52
+ </setup>
53
+ <connection>
54
+ <use>core_setup</use>
55
+ </connection>
56
+ </paypalinvoicesender_setup>
57
+ <paypalinvoicesender_write>
58
+ <connection>
59
+ <use>core_write</use>
60
+ </connection>
61
+ </paypalinvoicesender_write>
62
+ <paypalinvoicesender_read>
63
+ <connection>
64
+ <use>core_read</use>
65
+ </connection>
66
+ </paypalinvoicesender_read>
67
+ </resources>
68
+
69
+ <blocks>
70
+
71
+ <paypalinvoicesender>
72
+ <class>xonu_PayPalInvoiceSender_Block</class>
73
+ </paypalinvoicesender>
74
+
75
+ <adminhtml>
76
+ <rewrite>
77
+ <notification_window>xonu_PayPalInvoiceSender_Block_Adminhtml_Notification_Window</notification_window>
78
+ </rewrite>
79
+ </adminhtml>
80
+ </blocks>
81
+
82
+ <helpers>
83
+ <paypalinvoicesender>
84
+ <class>xonu_PayPalInvoiceSender_Helper</class>
85
+ </paypalinvoicesender>
86
+ </helpers>
87
+
88
+ </global>
89
+ </config>
app/code/community/xonu/PayPalInvoiceSender/etc/system.xml ADDED
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+ -->
7
+ <config>
8
+ <sections>
9
+ <payment>
10
+ <groups>
11
+ <account translate="label">
12
+ <label>PayPal Additional Settings</label>
13
+ <fieldset_css>paypal-config</fieldset_css>
14
+ <expanded>1</expanded>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>0</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <fields>
20
+ <send_invoice translate="label comment">
21
+ <label>Send Invoice</label>
22
+ <config_path>paypalinvoicesender/general/send_invoice</config_path>
23
+ <comment>Send invoice to customer after succesfull operation</comment>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <sort_order>5</sort_order>
29
+ </send_invoice>
30
+ </fields>
31
+ </account>
32
+ </groups>
33
+ </payment>
34
+ </sections>
35
+ </config>
app/code/community/xonu/PayPalInvoiceSender/sql/paypalinvoicesender_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,45 @@
1
+ <?php
2
+
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+
7
+ ?>
8
+
9
+ <?php
10
+
11
+ //set config
12
+ Mage::getModel('core/config')->saveConfig('paypalinvoicesender/general/send_invoice', 1 );
13
+
14
+ /* *
15
+ * Notification Data
16
+ * */
17
+ $title = 'PayPal Invoice Sender extension have been successfully installed.';
18
+ $description = 'PayPal Invoice Sender extension have been successfully installed. To disable/enable this extension, please go to System > Configuration > Sales: Payment Methods > PayPal Additional Settings.';
19
+ $website = "http://xonu.de/magento-extensions/paypal-invoice-sender.html";
20
+ $time = date("Y-m-d H:i:s");
21
+
22
+ //update feed
23
+ $feed = new Mage_AdminNotification_Model_Feed();
24
+ $feed->setLastUpdate();
25
+
26
+ $installer = $this;
27
+
28
+ $installer->startSetup();
29
+
30
+ //add notification message
31
+ try {
32
+ $installer->run('ALTER TABLE `adminnotification_inbox` DROP `type`;');
33
+ } catch ( Exception $e ) {}
34
+
35
+
36
+ $installer->run('
37
+ ALTER TABLE `adminnotification_inbox` ADD COLUMN `type` ENUM("normal","paypalinvoice") NOT NULL DEFAULT "normal" AFTER `is_remove`;
38
+
39
+ DELETE FROM `adminnotification_inbox` WHERE `type` = "paypalinvoice";
40
+ INSERT INTO `adminnotification_inbox`
41
+ ( `severity`, `date_added`, `title`, `description`, `url`, `is_read`, `is_remove`, `type`)
42
+ VALUES ( 3, "' . $time . '", " ' . $title . ' ", "' . $description . '", "' . $website . '", 0, 0, "paypalinvoice")
43
+ ');
44
+
45
+ $installer->endSetup();
app/etc/modules/xonu_PayPalInvoiceSender.xml ADDED
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @copyright Copyright (c) 2012 Pawel Kazakow (http://xonu.de)
5
+ */
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <xonu_PayPalInvoiceSender>
10
+ <active>true</active>
11
+ <codePool>community</codePool>
12
+ </xonu_PayPalInvoiceSender>
13
+ </modules>
14
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>xonu_PayPalInvoiceSender</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://xonu.de/license/">xonu.de EULA</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Sends invoice automatically after an order is paid using PayPal.</summary>
10
+ <description>After successful PayPal payment, Magento automatically creates invoice but it is not sent to customer. PayPal Invoice Sender automatically sends the invoice after an order have been paid using PayPal.</description>
11
+ <notes>Sends invoice automatically after an order is paid using PayPal.</notes>
12
+ <authors><author><name>Pawel Kazakow</name><user>xonu</user><email>support@xonu.de</email></author></authors>
13
+ <date>2012-07-30</date>
14
+ <time>10:31:29</time>
15
+ <contents><target name="magecommunity"><dir name="xonu"><dir name="PayPalInvoiceSender"><dir name="Block"><dir name="Adminhtml"><dir name="Notification"><file name="Window.php" hash="139e3ee7e6e502c0a484e521afd944ae"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2cc7f47219bd710fa74601c3f95b1804"/></dir><dir name="Model"><file name="Ipn.php" hash="1da69b8a52d95d450e27752f6b4cddef"/></dir><dir name="etc"><file name="config.xml" hash="4a611609caf4558532132c3fc5f95cf6"/><file name="system.xml" hash="00e6ba0db9aa402a9cd64b1b7847500b"/></dir><dir name="sql"><dir name="paypalinvoicesender_setup"><file name="mysql4-install-1.0.0.php" hash="a3f6f0e131df9d802185e64bcd467809"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="xonu_PayPalInvoiceSender.xml" hash="97703713ae2f3b122a04bb52019ffe83"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="paypalinvoice.png" hash="8d4e360fd375f0e4e22ffdbcf24ac020"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/images/paypalinvoice.png ADDED
Binary file