okpay_payments_module - Version 0.0.3

Version Notes

okpay payments module

Download this release

Release Info

Developer Magento Core Team
Extension okpay_payments_module
Version 0.0.3
Comparing to
See all releases


Version 0.0.3

app/code/community/MagentoCenter/Okpay/Block/Form.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MagentoCenter_Okpay_Block_Form extends Mage_Payment_Block_Form
5
+ {
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('okpay/form.phtml');
10
+ }
11
+ }
app/code/community/MagentoCenter/Okpay/Block/Info.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MagentoCenter_Okpay_Block_Info extends Mage_Payment_Block_Info {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ $this->setTemplate('okpay/info.phtml');
8
+ }
9
+ }
app/code/community/MagentoCenter/Okpay/Block/Redirect.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MagentoCenter_Okpay_Block_Redirect extends Mage_Core_Block_Abstract
5
+ {
6
+ protected function _toHtml()
7
+ {
8
+ $okpay = Mage::getModel('okpay/checkout');
9
+
10
+ $form = new Varien_Data_Form();
11
+ $form->setAction($okpay->getOkpayUrl())
12
+ ->setId('pay')
13
+ ->setName('pay')
14
+ ->setMethod('POST')
15
+ ->setUseContainer(true);
16
+ foreach ($okpay->getOkpayCheckoutFormFields() as $field=>$value) {
17
+ // echo $field.' - '.$value.'<br>';
18
+ $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
19
+ }
20
+
21
+ $html = '<html><body>';
22
+ $html.= $this->__('Redirect to Okpay.com ...');
23
+ $html.= '<hr>';
24
+ $html.= $form->toHtml();
25
+ $html.= '<script type="text/javascript">document.getElementById("pay").submit();</script>';
26
+ $html.= '</body></html>';
27
+
28
+
29
+ return $html;
30
+ }
31
+ }
app/code/community/MagentoCenter/Okpay/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MagentoCenter_Okpay_Helper_Data extends Mage_Core_Helper_Abstract
5
+ {
6
+
7
+
8
+ }
app/code/community/MagentoCenter/Okpay/Model/Checkout.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MagentoCenter_Okpay_Model_Checkout extends Mage_Payment_Model_Method_Abstract {
5
+
6
+ protected $_code = 'okpay';
7
+ protected $_formBlockType = 'okpay/form';
8
+ protected $_infoBlockType = 'okpay/info';
9
+ protected $_order;
10
+
11
+ const WALLET_ID = 'payment/okpay/okpay_walletid';
12
+
13
+
14
+
15
+
16
+ public function getCheckout() {
17
+ return Mage::getSingleton('checkout/session');
18
+ }
19
+
20
+ public function getOrderPlaceRedirectUrl() {
21
+ return Mage::getUrl('okpay/redirect', array('_secure' => true));
22
+ }
23
+
24
+ public function getOkpayUrl() {
25
+ $url = 'https://www.okpay.com/process.html';
26
+ return $url;
27
+ }
28
+
29
+ public function getLocale()
30
+ {
31
+ return Mage::app()->getLocale()->getLocaleCode();
32
+ }
33
+
34
+ public function getOkpayCheckoutFormFields() {
35
+
36
+ $order_id = $this->getCheckout()->getLastRealOrderId();
37
+ $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
38
+ if ($order->getBillingAddress()->getEmail()) {
39
+ $email = $order->getBillingAddress()->getEmail();
40
+ } else {
41
+ $email = $order->getCustomerEmail();
42
+ }
43
+
44
+ $params = array(
45
+ 'ok_receiver' => Mage::getStoreConfig(MagentoCenter_Okpay_Model_Checkout::WALLET_ID),
46
+ 'ok_invoice' => $order_id,
47
+ 'ok_return_success' => Mage::getUrl('okpay/redirect/success', array('transaction_id' => $order_id)),
48
+ 'ok_return_fail' => Mage::getUrl('okpay/redirect/cancel', array('transaction_id' => $order_id)),
49
+ 'ok_language' => $this->getLocale(),
50
+ 'ok_item_1_name' => Mage::helper('okpay')->__('Payment for order #').$order_id,
51
+ 'ok_item_1_price' => trim(round($order->getGrandTotal(), 2)),
52
+ 'ok_currency' => $order->getOrderCurrencyCode(),
53
+ // 'base_currency' => $order->getBaseCurrencyCode(),
54
+ // 'recipient_description' => $order->getStore()->getWebsite()->getName(),
55
+ 'ok_payer_first_name' => $order->getBillingAddress()->getFirstname(),
56
+ 'ok_payer_last_name' => $order->getBillingAddress()->getLastname(),
57
+ 'ok_payer_email' => $email,
58
+ );
59
+ return $params;
60
+
61
+ }
62
+
63
+ public function initialize($paymentAction, $stateObject)
64
+ {
65
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
66
+ $stateObject->setState($state);
67
+ $stateObject->setStatus('pending_payment');
68
+ $stateObject->setIsNotified(false);
69
+ }
70
+
71
+ }
app/code/community/MagentoCenter/Okpay/controllers/RedirectController.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MagentoCenter_Okpay_RedirectController extends Mage_Core_Controller_Front_Action {
5
+
6
+ protected $_order;
7
+
8
+ protected function _expireAjax() {
9
+ if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
10
+ $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
11
+ exit;
12
+ }
13
+ }
14
+ protected function _getCheckout()
15
+ {
16
+ return Mage::getSingleton('checkout/session');
17
+ }
18
+
19
+ public function indexAction() {
20
+ $this->getResponse()
21
+ ->setHeader('Content-type', 'text/html; charset=utf8')
22
+ ->setBody($this->getLayout()
23
+ ->createBlock('okpay/redirect')
24
+ ->toHtml());
25
+ }
26
+
27
+
28
+ public function successAction() {
29
+ $event = $this->getRequest()->getParams();
30
+ $transaction_id= $event['transaction_id'];
31
+ $session = Mage::getSingleton('checkout/session');
32
+ $session->setQuoteId($transaction_id);
33
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
34
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
35
+ }
36
+
37
+
38
+ public function cancelAction()
39
+ {
40
+ $event = $this->getRequest()->getParams();
41
+ $transaction_id= $event['transaction_id'];
42
+ $this->_getCheckout()->addError(Mage::helper('okpay')->__('The order has been canceled. Order #').$transaction_id);
43
+ $this->_redirect('checkout/cart');
44
+ }
45
+
46
+
47
+
48
+ }
49
+
50
+ ?>
app/code/community/MagentoCenter/Okpay/etc/config.xml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <MagentoCenter_Okpay>
6
+ <version>0.0.1</version>
7
+ </MagentoCenter_Okpay>
8
+ </modules>
9
+
10
+ <global>
11
+
12
+ <models>
13
+ <okpay>
14
+ <class>MagentoCenter_Okpay_Model</class>
15
+ </okpay>
16
+ </models>
17
+
18
+ <blocks>
19
+ <okpay>
20
+ <class>MagentoCenter_Okpay_Block</class>
21
+ </okpay>
22
+ </blocks>
23
+
24
+ <resources>
25
+ <okpay_setup>
26
+ <setup>
27
+ <module>MagentoCenter_Okpay</module>
28
+ </setup>
29
+ <connection>
30
+ <use>core_setup</use>
31
+ </connection>
32
+ </okpay_setup>
33
+ <okpay_write>
34
+ <connection>
35
+ <use>core_write</use>
36
+ </connection>
37
+ </okpay_write>
38
+ <okpay_read>
39
+ <connection>
40
+ <use>core_read</use>
41
+ </connection>
42
+ </okpay_read>
43
+ </resources>
44
+ <helpers>
45
+ <okpay>
46
+ <class>MagentoCenter_Okpay_Helper</class>
47
+ </okpay>
48
+ </helpers>
49
+ </global>
50
+
51
+
52
+ <frontend>
53
+ <secure_url>
54
+ <okpay_redirect>/okpay/redirect/00</okpay_redirect>
55
+ </secure_url>
56
+ <routers>
57
+ <okpay>
58
+ <use>standard</use>
59
+ <args>
60
+ <module>MagentoCenter_Okpay</module>
61
+ <frontName>okpay</frontName>
62
+ </args>
63
+ </okpay>
64
+ </routers>
65
+ <translate>
66
+ <modules>
67
+ <MagentoCenter_Okpay>
68
+ <files>
69
+ <default>MagentoCenter_Okpay.csv</default>
70
+ </files>
71
+ </MagentoCenter_Okpay>
72
+ </modules>
73
+ </translate>
74
+ </frontend>
75
+
76
+
77
+ <adminhtml>
78
+ <translate>
79
+ <modules>
80
+ <MagentoCenter_Okpay>
81
+ <files>
82
+ <default>MagentoCenter_Okpay.csv</default>
83
+ </files>
84
+ </MagentoCenter_Okpay>
85
+ </modules>
86
+ </translate>
87
+ </adminhtml>
88
+
89
+ <default>
90
+ <payment>
91
+ <okpay>
92
+ <active>0</active>
93
+ <model>okpay/checkout</model>
94
+ <title>Okpay.com</title>
95
+ <okpay_walletid>OK########</okpay_walletid>
96
+ </okpay>
97
+ </payment>
98
+ </default>
99
+ </config>
app/code/community/MagentoCenter/Okpay/etc/system.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <okpay translate="label" module="okpay">
7
+ <label>Okpay.com</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>3</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>0</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ </active>
23
+ <title translate="label">
24
+ <label>Title</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>0</show_in_store>
30
+ </title>
31
+ <okpay_walletid translate="label,comment">
32
+ <label>WalletID</label>
33
+ <comment>To have access to the international payment network of Okpay.com please register on Okpay.com for a free account, if you don’t have one yet.</comment>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>1</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </okpay_walletid>
40
+ <allowspecific translate="label">
41
+ <label>Payment from applicable countries</label>
42
+ <frontend_type>allowspecific</frontend_type>
43
+ <sort_order>50</sort_order>
44
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </allowspecific>
49
+ <specificcountry translate="label">
50
+ <label>Payment from Specific countries</label>
51
+ <frontend_type>multiselect</frontend_type>
52
+ <sort_order>51</sort_order>
53
+ <source_model>adminhtml/system_config_source_country</source_model>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>0</show_in_store>
57
+ </specificcountry>
58
+ </fields>
59
+ </okpay>
60
+ </groups>
61
+ </payment>
62
+ </sections>
63
+ </config>
app/design/adminhtml/default/default/template/okpay/form.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ echo $this->__('You will be redirected to Okpay website when you place an order.')
3
+ ?>
app/design/adminhtml/default/default/template/okpay/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ echo $this->__('Okpay.com payments');
3
+ ?>
4
+
5
+
app/design/frontend/base/default/template/okpay/form.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ echo $this->__('You will be redirected to Okpay.com when you place an order.')
3
+ ?>
app/design/frontend/base/default/template/okpay/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ echo $this->__('Okpay.com payments');
3
+ ?>
4
+
5
+
app/etc/modules/MagentoCenter_Okpay.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MagentoCenter_Okpay>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Paygate/>
9
+ <Mage_Checkout/>
10
+ <Mage_Sales/>
11
+ </depends>
12
+ </MagentoCenter_Okpay>
13
+ </modules>
14
+ </config>
app/locale/en_US/MagentoCenter_Okpay.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ "Payment for order #","Payment for order #"
2
+ "The order has been canceled. Order #",The order has been canceled. Order #"
3
+ "Redirect to Okpay.com ...","Redirect to Okpay.com ..."
4
+ "WalletID","WalletID"
5
+ "Okpay.com payments","Okpay.com payments"
6
+ "You will be redirected to Okpay.com when you place an order.","You will be redirected to Okpay.com when you place an order."
7
+ "To have access to the international payment network of Okpay.com please register on Okpay.com for a free account, if you don’t have one yet.","To have access to the international payment network of Okpay.com please register on Okpay.com for a free account, if you don’t have one yet."
app/locale/ru_RU/MagentoCenter_Okpay.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ "Payment for order #","Оплата счета №"
2
+ "The order has been canceled. Order #","Заказ был отменен, заказ #"
3
+ "Redirect to Okpay.com ...","Перенаправление на Okpay.com ..."
4
+ "WalletID","WalletID"
5
+ "Okpay.com payments","Платежи Okpay.com"
6
+ "You will be redirected to Okpay.com when you place an order.","Олата происходит автоматически на сайте платежей Okpay.com"
7
+ "To have access to the international payment network of Okpay.com please register on Okpay.com for a free account, if you don’t have one yet.","Если у вас еще нет WalletID для приема платежей с помощью Okpay. Вы можете зарегистировать его бесплатно на Okpay.com </a>"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>okpay_payments_module</name>
4
+ <version>0.0.3</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>okpay payments module</summary>
10
+ <description>okpay payments module</description>
11
+ <notes>okpay payments module</notes>
12
+ <authors><author><name>MagentoCenter</name><user>auto-converted</user><email>volgodark@gmail.com</email></author></authors>
13
+ <date>2010-08-28</date>
14
+ <time>19:25:32</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="okpay"><file name="form.phtml" hash="6469e47cdee6f175ad1dafea37d450a0"/><file name="info.phtml" hash="1281de09e56e8b11625bdac7e1849f12"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="okpay"><file name="form.phtml" hash="d48ff03a940932fdd7ed1c41768171e5"/><file name="info.phtml" hash="1281de09e56e8b11625bdac7e1849f12"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="MagentoCenter_Okpay.csv" hash="d06bae3e8b36ece751b749ecf29499f6"/></dir><dir name="ru_RU"><file name="MagentoCenter_Okpay.csv" hash="04c7ef1f8a612db65a4623194f5bc5a6"/></dir></target><target name="magecommunity"><dir name="MagentoCenter"><dir name="Okpay"><dir name="Block"><file name="Form.php" hash="6006303527f4024606b52414641faa72"/><file name="Info.php" hash="844a3442793a49a6abace85d481b3eac"/><file name="Redirect.php" hash="4325dfa311b6ae3ffa1de72425502bab"/></dir><dir name="controllers"><file name="RedirectController.php" hash="27d7348e676c6ce95a90e9822b20b7e4"/></dir><dir name="etc"><file name="config.xml" hash="d2b77ff231ca5fc750c102360d090b54"/><file name="system.xml" hash="a181044a573d690d01ffac33ed107558"/></dir><dir name="Helper"><file name="Data.php" hash="aa7adaf30f06e80f9421e317f5a51b75"/></dir><dir name="Model"><file name="Checkout.php" hash="7e9010568269f0af255c2b3435daab0c"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MagentoCenter_Okpay.xml" hash="c2b660e7fd0b92d7357e7609669f81c5"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>