EC_Ipaymu - Version 0.1.0

Version Notes

First Stable Release

Download this release

Release Info

Developer Ellyx Christian
Extension EC_Ipaymu
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/EC/Ipaymu/Block/Form.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Form
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Block_Form extends Mage_Payment_Block_Form {
9
+
10
+ protected $_instructions;
11
+
12
+ protected function _construct() {
13
+ $html = '<a href="https://ipaymu.com/about-us/" target="_blank">' . Mage::helper('ipaymu')->__('What is ipaymu?') . '</a>';
14
+ $this->setTemplate('ipaymu/form.phtml');
15
+ $this->setMethodLabelAfterHtml($html);
16
+ parent::_construct();
17
+ }
18
+
19
+ public function getInstructions() {
20
+ if (is_null($this->_instructions)) {
21
+ $this->_instructions = $this->getMethod()->getInstructions();
22
+ }
23
+ return $this->_instructions;
24
+ }
25
+
26
+ }
app/code/local/EC/Ipaymu/Block/Info.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Info
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Block_Info extends Mage_Payment_Block_Info {
9
+
10
+ protected $_instructions;
11
+
12
+ protected function _construct() {
13
+ parent::_construct();
14
+ $this->setTemplate('ipaymu/info.phtml');
15
+ }
16
+
17
+ public function getInstructions() {
18
+ if (is_null($this->_instructions)) {
19
+ $this->_instructions = $this->getMethod()->getInstructions();
20
+ }
21
+ return $this->_instructions;
22
+ }
23
+
24
+ function getStatus(){
25
+ $statusText = array(
26
+ -1 => Mage::helper('ipaymu')->__('Processing'),
27
+ 0 => Mage::helper('ipaymu')->__('Pending'),
28
+ 1 => Mage::helper('ipaymu')->__('Success'),
29
+ 2 => Mage::helper('ipaymu')->__('Cancelled'),
30
+ 3 => Mage::helper('ipaymu')->__('Refund'),
31
+ );
32
+ $info = $this->getInfo();
33
+ /* @var $info Mage_Sales_Model_Order_Payment */
34
+ $collection = Mage::getModel('ipaymu/transaction')
35
+ ->getCollection();
36
+ $collection->addFieldToFilter('order_id', $info->getOrder()->getId());
37
+ $ipaymu = $collection->getFirstItem();
38
+ $html = '';
39
+ if($ipaymu->getId()){
40
+ $html .= '<p>';
41
+ if($ipaymu->getStatus() !== null){
42
+ $html .= Mage::helper('ipaymu')->__('Transaction Status: %s', $statusText[$ipaymu->getStatus()]).' - ';
43
+ }
44
+ $html .= '<a href="'.Mage::helper("adminhtml")->getUrl('ecipaymu/adminhtml_index/status', array(
45
+ 'id' => $ipaymu->getId(),
46
+ )).'">'.Mage::helper('ipaymu')->__('Check Status').'</a>';
47
+ $html .= '</p>';
48
+ }
49
+ return $html;
50
+ }
51
+
52
+ }
app/code/local/EC/Ipaymu/Helper/Data.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Data
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Helper_Data extends Mage_Core_Helper_Abstract {
9
+
10
+ function getRedirectUrl($orderId, $appId = null, $cancel = true) {
11
+ if($orderId instanceof Mage_Sales_Model_Order){
12
+ $order = $orderId;
13
+ }else{
14
+ $order = Mage::getModel('sales/order')->load($orderId);
15
+ }
16
+ if(!$appId){
17
+ $payment = Mage::getModel('ipaymu/payment');
18
+ $appId = $payment->getConfigData('app_key');
19
+ }
20
+ $url = $this->getIpaymuUrl().'/payment.htm';
21
+ $httpClient = new Zend_Http_Client($url, array(
22
+ 'adapter' => 'Zend_Http_Client_Adapter_Curl'
23
+ ));
24
+ try {
25
+ $httpClient->setParameterPost(array(
26
+ 'key' => $appId,
27
+ 'action' => 'payment',
28
+ 'product' => Mage::helper('ipaymu')->__('Sales Order #%s', $order->getIncrementId()),
29
+ 'price' => $this->getIpaymuAmount($order),
30
+ 'quantity' => 1,
31
+ 'format' => 'json',
32
+ 'ureturn' => $cancel ? Mage::getUrl('ipaymu/index/success') :Mage::getUrl('ipaymu/index/ipaymureturn', array('orderId' => $order->getId())),
33
+ 'ucancel' => $cancel ? Mage::getUrl('ipaymu/index/cancel', array('orderId' => $order->getId())) : Mage::getUrl('ipaymu/index/cancel'),
34
+ 'unotify' => Mage::getUrl('ipaymu/index/unotify', array('orderId' => $order->getId()))
35
+ ));
36
+ $httpClient->request(Zend_Http_Client::POST);
37
+ $result = Zend_Json::decode($httpClient->getLastResponse()->getBody());
38
+ if(isset($result['url'])){
39
+ $this->_saveIpaymuDetail($result['sessionID'], $order->getId());
40
+ return $result['url'];
41
+ }else{
42
+ throw new Exception($result['Keterangan'], $result['Status']);
43
+ }
44
+ } catch (Exception $e) {
45
+ throw $e;
46
+ }
47
+ }
48
+
49
+
50
+ protected function _saveIpaymuDetail($sid, $orderId){
51
+ $sid = sha1(md5($orderId).$sid);
52
+ $collection = Mage::getModel('ipaymu/transaction')->getCollection();
53
+ $collection->addFieldToFilter('sid', $sid);
54
+ // ->addFieldToFilter('order_id', $orderId);
55
+ $ipaymu = $collection->getFirstItem();
56
+ if(!$ipaymu->getId()){
57
+ $model = Mage::getModel('ipaymu/transaction');
58
+ $model->setOrderId($orderId);
59
+ $model->setSid($sid);
60
+ $model->setCreatedTime(now());
61
+ $model->setUpdateTime(now());
62
+ $model->save();
63
+ }
64
+ }
65
+
66
+ function getIpaymuAmount(Mage_Sales_Model_Order $order){
67
+ $amount = $order->getBaseGrandTotal();
68
+ if($order->getBaseCurrencyCode() != EC_Ipaymu_Model_Payment::IPAYMU_CURRENCY){
69
+ if($order->getOrderCurrencyCode() == EC_Ipaymu_Model_Payment::IPAYMU_CURRENCY){
70
+ $amount = $order->getGrandTotal();
71
+ }else{
72
+ throw new Mage_Core_Exception(Mage::helper('ipaymu')->__('Invalid order currency'));
73
+ // $amount = Mage::helper('directory')->currencyConvert($amount, $order->getBaseCurrencyCode(),EC_Ipaymu_Model_Payment::IPAYMU_CURRENCY);
74
+ }
75
+ }
76
+ $payment = Mage::getModel('ipaymu/payment');
77
+ if($payment->getConfigData('percent_fee')){
78
+ $fee = $amount * $payment->getConfigData('percent_fee') / 100;
79
+ $amount = $amount + $fee;
80
+ }
81
+ if($payment->getConfigData('fix_fee')){
82
+ $amount = $amount + $payment->getConfigData('fix_fee');
83
+ }
84
+ return $amount;
85
+ }
86
+
87
+ private function getIpaymuUrl(){
88
+ return 'https://my.ipaymu.com';
89
+ }
90
+
91
+ }
app/code/local/EC/Ipaymu/Model/Mysql4/Transaction.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Transaction
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Model_Mysql4_Transaction extends Mage_Core_Model_Mysql4_Abstract {
9
+
10
+ protected function _construct() {
11
+ $this->_init('ipaymu/transaction', 'transaction_id');
12
+ }
13
+
14
+ }
app/code/local/EC/Ipaymu/Model/Mysql4/Transaction/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Collection
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Model_Mysql4_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
9
+
10
+ protected function _construct() {
11
+ parent::_construct();
12
+ $this->_init('ipaymu/transaction');
13
+ }
14
+
15
+ }
app/code/local/EC/Ipaymu/Model/Payment.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Payment
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Model_Payment extends Mage_Payment_Model_Method_Abstract{
9
+
10
+ const IPAYMU_CURRENCY = 'IDR';
11
+
12
+ protected $_code = 'ipaymu';
13
+ protected $_formBlockType = 'ipaymu/form';
14
+ protected $_infoBlockType = 'ipaymu/info';
15
+ protected $_isInitializeNeeded = true;
16
+ protected $_canUseForMultishipping = false;
17
+ protected $_canManageRecurringProfiles = false;
18
+ protected $_canUseInternal = false;
19
+
20
+ protected $_ipaymu_order_increment_id;
21
+ protected $_ipaymu_order;
22
+
23
+ function getOrderPlaceRedirectUrl() {
24
+ return Mage::getUrl('ipaymu/index/redirect', array('_secure' => true));
25
+ }
26
+
27
+ public function getInstructions() {
28
+ return $this->getConfigData('instructions');
29
+ }
30
+
31
+ public function getIpaymuPaymenUrl(){
32
+ return Mage::helper('ipaymu')
33
+ ->getRedirectUrl($this->getOrder(),$this->getConfigData('app_key'));
34
+ }
35
+
36
+
37
+ /**
38
+ * Get checkout session namespace
39
+ *
40
+ * @return Mage_Checkout_Model_Session
41
+ */
42
+ public function getCheckout() {
43
+ return Mage::getSingleton('checkout/session');
44
+ }
45
+
46
+ function getOrderIncrementId(){
47
+ if(!$this->_ipaymu_order_increment_id){
48
+ $this->_ipaymu_order_increment_id = $this->getCheckout()->getLastRealOrderId();
49
+ }
50
+ return $this->_ipaymu_order_increment_id;
51
+ }
52
+
53
+ function setOrderIncrementId($incrementId){
54
+ $this->_ipaymu_order_increment_id = $incrementId;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @return Mage_Sales_Model_Order
61
+ */
62
+ function getOrder() {
63
+ if (!$this->_ipaymu_order) {
64
+ $orderIncrementId = $this->getOrderIncrementId();
65
+ $this->_ipaymu_order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
66
+ }
67
+ return $this->_ipaymu_order;
68
+ }
69
+
70
+ function getIpaymuAmount() {
71
+ return Mage::helper('ipaymu')->getIpaymuAmount($this->getOrder());
72
+ }
73
+
74
+ public function canUseForCurrency($currencyCode) {
75
+ return self::IPAYMU_CURRENCY == $currencyCode;
76
+ }
77
+ }
app/code/local/EC/Ipaymu/Model/Transaction.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Transaction
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Model_Transaction extends Mage_Core_Model_Abstract {
9
+
10
+ protected function _construct() {
11
+ parent::_construct();
12
+ $this->_init('ipaymu/transaction');
13
+ }
14
+
15
+ }
app/code/local/EC/Ipaymu/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of IndexController
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
9
+
10
+ function statusAction() {
11
+ $id = (int) $this->getRequest()->getParam('id');
12
+ if(!$id){
13
+ return $this->_redirect('adminhtml/sales_order/index');
14
+ }
15
+ $ipaymu = Mage::getModel('ipaymu/transaction')->load($id);
16
+ $payment = Mage::getModel('ipaymu/payment');
17
+ $appId = $payment->getConfigData('app_key');
18
+ $content = file_get_contents('https://my.ipaymu.com/api/CekTransaksi.php?key='.$appId.'&id='.$ipaymu->getTrxId().'&format=json');
19
+ $result = json_decode($content, true);
20
+ if(isset($result['Status'])){
21
+ $status = $result['Status'];
22
+ if($status >= -1 && $status <= 3){
23
+ $ipaymu->setStatus($status);
24
+ $ipaymu->save();
25
+ }
26
+ }
27
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ipaymu')->__('Ipaymu Transaction Status: "%s"', $result['Keterangan']));
28
+ return $this->_redirect('adminhtml/sales_order/view', array(
29
+ 'order_id' => $ipaymu->getOrderId()
30
+ ));
31
+ }
32
+
33
+ }
app/code/local/EC/Ipaymu/controllers/IndexController.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of IndexController
5
+ *
6
+ * @author ellyxc
7
+ */
8
+ class EC_Ipaymu_IndexController extends Mage_Core_Controller_Front_Action {
9
+
10
+ function redirectAction() {
11
+ $session = Mage::getSingleton('checkout/session');
12
+ $session->setIpaymuQuoteId($session->getQuoteId());
13
+ $payment = Mage::getModel('ipaymu/payment');
14
+ /* @var $payment EC_Ipaymu_Model_Payment */
15
+ $url = $payment->getIpaymuPaymenUrl();
16
+ $order = $payment->getOrder();
17
+ if (!$order->getEmailSent()) {
18
+ $order->sendNewOrderEmail();
19
+ $order->setEmailSent(true);
20
+ $order->save();
21
+ }
22
+ $session->unsQuoteId();
23
+ $session->unsRedirectUrl();
24
+ return $this->_redirectUrl($url);
25
+ }
26
+
27
+ function cancelAction(){
28
+ $orderId = (int)$this->getRequest()->getParam('orderId');
29
+ if($orderId){
30
+ $order = Mage::getModel('sales/order')->load($orderId);
31
+ if ($order->getId()) {
32
+ $order->cancel()->save();
33
+ $order->sendOrderUpdateEmail();
34
+ }
35
+ }
36
+ $this->_redirect('checkout/cart');
37
+ }
38
+
39
+ function successAction(){
40
+ $session = Mage::getSingleton('checkout/session');
41
+ $session->setQuoteId($session->getIpaymuQuoteId(true));
42
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
43
+ if ($order->getId()) {
44
+ if(!$order->getEmailSent()){
45
+ $order->sendNewOrderEmail();
46
+ $order->setEmailSent(true);
47
+ $order->save();
48
+ }
49
+ }
50
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
51
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
52
+ }
53
+
54
+ function ipaymureturnAction(){
55
+ $orderId = (int) $this->getRequest()->getParam('orderId');
56
+ return $this->_redirect('sales/order/view', array('order_id' => $orderId));
57
+ }
58
+
59
+ function unotifyAction(){
60
+ $orderId = (int) $this->getRequest()->getParam('orderId');
61
+ if(!$orderId){
62
+ return;
63
+ }
64
+ $data = $this->getRequest()->getPost();
65
+ $sid = sha1(md5($orderId).$data['sid']);
66
+ $collection = Mage::getModel('ipaymu/transaction')->getCollection();
67
+ $collection->addFieldToFilter('sid', $sid)
68
+ ->addFieldToFilter('order_id', $orderId);
69
+ $ipaymu = $collection->getFirstItem();
70
+ /* @var $ipaymu EC_Ipaymu_Model_Payment */
71
+ if($ipaymu->getId()){
72
+ $array = $ipaymu->toArray();
73
+
74
+ if(isset($data['id'])){
75
+ unset($data['id']);
76
+ }
77
+ if(isset($data['status'])){
78
+ if(strtolower($data['status']) == 'pending'){
79
+ $data['status'] = 0;
80
+ }elseif(strtolower($data['status']) == 'berhasil'){
81
+ $data['status'] = 1;
82
+ // update order status to processing
83
+ $order = Mage::getModel('sales/order')->load($orderId);
84
+ /* @var $order Mage_Sales_Model_Order */
85
+ if ($order->getId()) {
86
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING);
87
+ $order->save();
88
+ }
89
+ }
90
+ }
91
+ $data['sid'] = $sid;
92
+ $ipaymu->setData(array_merge($array, $data));
93
+ $ipaymu->setUpdateTime(now());
94
+ $ipaymu->save();
95
+ }
96
+ }
97
+ }
app/code/local/EC/Ipaymu/etc/config.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <EC_Ipaymu>
5
+ <version>0.1.0</version>
6
+ </EC_Ipaymu>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <ipaymu>
11
+ <class>EC_Ipaymu_Model</class>
12
+ <resourceModel>ipaymu_mysql4</resourceModel>
13
+ </ipaymu>
14
+ <ipaymu_mysql4>
15
+ <class>EC_Ipaymu_Model_Mysql4</class>
16
+ <entities>
17
+ <transaction>
18
+ <table>aluh_ipaymu_transaction</table>
19
+ </transaction>
20
+ </entities>
21
+ </ipaymu_mysql4>
22
+ </models>
23
+ <resources>
24
+ <ipaymu_setup>
25
+ <setup>
26
+ <module>EC_Ipaymu</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </ipaymu_setup>
32
+ <ipaymu_read>
33
+ <connection>
34
+ <use>core_read</use>
35
+ </connection>
36
+ </ipaymu_read>
37
+ <ipaymu_write>
38
+ <connection>
39
+ <use>core_write</use>
40
+ </connection>
41
+ </ipaymu_write>
42
+ </resources>
43
+ <blocks>
44
+ <ipaymu>
45
+ <class>EC_Ipaymu_Block</class>
46
+ </ipaymu>
47
+ </blocks>
48
+ <helpers>
49
+ <ipaymu>
50
+ <class>EC_Ipaymu_Helper</class>
51
+ </ipaymu>
52
+ </helpers>
53
+ </global>
54
+ <frontend>
55
+ <routers>
56
+ <ipaymu>
57
+ <use>standard</use>
58
+ <args>
59
+ <module>EC_Ipaymu</module>
60
+ <frontName>ipaymu</frontName>
61
+ </args>
62
+ </ipaymu>
63
+ </routers>
64
+ <layout>
65
+ <updates>
66
+ <ipaymu>
67
+ <file>ipaymu.xml</file>
68
+ </ipaymu>
69
+ </updates>
70
+ </layout>
71
+ <translate>
72
+ <modules>
73
+ <EC_Ipaymu>
74
+ <files>
75
+ <default>EC_Ipaymu.csv</default>
76
+ </files>
77
+ </EC_Ipaymu>
78
+ </modules>
79
+ </translate>
80
+ </frontend>
81
+ <admin>
82
+ <routers>
83
+ <ecipaymu>
84
+ <use>admin</use>
85
+ <args>
86
+ <module>EC_Ipaymu</module>
87
+ <frontName>ec_ipaymu</frontName>
88
+ </args>
89
+ </ecipaymu>
90
+ </routers>
91
+ </admin>
92
+ <adminhtml>
93
+ <translate>
94
+ <modules>
95
+ <EC_Ipaymu>
96
+ <files>
97
+ <default>EC_Ipaymu.csv</default>
98
+ </files>
99
+ </EC_Ipaymu>
100
+ </modules>
101
+ </translate>
102
+ </adminhtml>
103
+ <default>
104
+ <payment>
105
+ <ipaymu>
106
+ <active>0</active>
107
+ <order_status>pending</order_status>
108
+ <title>IPAYMU</title>
109
+ <model>ipaymu/payment</model>
110
+ <allowspecific>1</allowspecific>
111
+ <specificcountry>ID</specificcountry>
112
+ </ipaymu>
113
+ </payment>
114
+ </default>
115
+ </config>
app/code/local/EC/Ipaymu/etc/system.xml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <payment module="ipaymu">
5
+ <groups>
6
+ <ipaymu>
7
+ <label>IPAYMU</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>100</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</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>10</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </title>
31
+ <ipaymu_account translate="label">
32
+ <label>Ipaymu UserName</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>12</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </ipaymu_account>
39
+ <app_key translate="label">
40
+ <label>APP Key</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>14</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </app_key>
47
+ <order_status translate="label">
48
+ <label>New Order Status</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
51
+ <sort_order>20</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </order_status>
56
+ <allowspecific translate="label">
57
+ <label>Payment from Applicable Countries</label>
58
+ <frontend_type>allowspecific</frontend_type>
59
+ <sort_order>50</sort_order>
60
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </allowspecific>
65
+ <specificcountry translate="label">
66
+ <label>Payment from Specific Countries</label>
67
+ <frontend_type>multiselect</frontend_type>
68
+ <sort_order>51</sort_order>
69
+ <source_model>adminhtml/system_config_source_country</source_model>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ <can_be_empty>1</can_be_empty>
74
+ </specificcountry>
75
+ <instructions translate="label">
76
+ <label>Instructions</label>
77
+ <frontend_type>textarea</frontend_type>
78
+ <sort_order>62</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ </instructions>
83
+ <fix_fee translate="label">
84
+ <label>Fixed Amount Fee</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>70</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>0</show_in_store>
90
+ <comment>in IDR</comment>
91
+ </fix_fee>
92
+ <percent_fee translate="label">
93
+ <label>Percentage Fee</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>80</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>0</show_in_store>
99
+ <comment>in %</comment>
100
+ </percent_fee>
101
+ <min_order_total translate="label">
102
+ <label>Minimum Order Total</label>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>90</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ </min_order_total>
109
+ <sort_order translate="label">
110
+ <label>Sort Order</label>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>100</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </sort_order>
117
+ </fields>
118
+ </ipaymu>
119
+ </groups>
120
+ </payment>
121
+ </sections>
122
+ </config>
app/code/local/EC/Ipaymu/ipntest.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $url = 'http://ipaymu.local/ipaymu/index/unotify/orderId/4';
3
+ $params = array(
4
+ 'status' => 'berhasil',
5
+ 'trx_id' => '3440',
6
+ 'sid' => 'f0b3e464352b2642100b911c94db82da63c182ceef41e21d4b5cd8b0b80c8642dbcb562ddb3f02d2b08cee9037e5234bb94c18aad9a11310b5ea931560aa1e83',
7
+ 'product' => 'test',
8
+ 'quantity' => 1,
9
+ 'merchant' => 'nitybudaya',
10
+ 'buyer' => 'ellyxc',
11
+ 'total' => 3000,
12
+ 'action' => 'payment',
13
+ 'comments' => 'test',
14
+ 'referer' => 'https://my.ipaymu.com'
15
+ );
16
+
17
+ $params_string = http_build_query($params);
18
+
19
+ //open connection
20
+ $ch = curl_init();
21
+
22
+ curl_setopt($ch, CURLOPT_URL, $url);
23
+ curl_setopt($ch, CURLOPT_POST, count($params));
24
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
25
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
26
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
27
+
28
+ //execute post
29
+ $request = curl_exec($ch);
30
+
31
+ if ( $request === false ) {
32
+ echo 'Curl Error: ' . curl_error($ch);
33
+ } else {
34
+
35
+ echo 'success';
36
+ }
37
+
38
+ //close connection
39
+ curl_close($ch);
app/code/local/EC/Ipaymu/sql/ipaymu_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @author ellyxc
5
+ */
6
+ $installer = $this;
7
+
8
+ $installer->run("
9
+ -- DROP TABLE IF EXISTS {$this->getTable('ipaymu/transaction')};
10
+ CREATE TABLE {$this->getTable('ipaymu/transaction')}(
11
+ `transaction_id` int NOT NULL AUTO_INCREMENT,
12
+ `sid` varchar(255) NULL DEFAULT NULL,
13
+ `trx_id` varchar(255) NULL DEFAULT NULL,
14
+ `merchant` varchar(255) NULL DEFAULT NULL,
15
+ `buyer` varchar(255) NULL DEFAULT NULL,
16
+ `order_id` int NULL DEFAULT NULL,
17
+ `total` double DEFAULT 0,
18
+ `comments` text null default null,
19
+ `referer` varchar(255) NULL DEFAULT NULL,
20
+ `status` tinyint(1) NULL DEFAULT NULL,
21
+ `created_time` datetime NULL DEFAULT NULL,
22
+ `update_time` datetime NULL DEFAULT NULL,
23
+ PRIMARY KEY (`transaction_id`)
24
+ )
25
+ ENGINE=InnoDB
26
+ CHARACTER SET utf8 COLLATE utf8_general_ci;
27
+ ");
app/design/adminhtml/default/default/template/ipaymu/info.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
2
+ <?php if ($this->getInstructions()): ?>
3
+ <table>
4
+ <tbody>
5
+ <tr>
6
+ <td><?php echo nl2br($this->getInstructions()) ?></td>
7
+ </tr>
8
+ </tbody>
9
+ </table>
10
+ <?php endif; ?>
11
+ <?php
12
+ echo $this->getStatus();
app/design/frontend/default/default/layout/ipaymu.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <ipaymu_index_redirect>
4
+ <reference name="head">
5
+ <action method="setTitle" translate="title"><title>Connecting to ipaymu...</title></action>
6
+ <action method="addJs"><js>prototype/window.js</js></action>
7
+ <action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
8
+ <action method="addItem"><type>js_css</type><name>prototype/windows/themes/lighting.css</name></action>
9
+ </reference>
10
+ <reference name="root">
11
+ <action method="setTemplate"><template>page/empty.phtml</template></action>
12
+ </reference>
13
+ <reference name="content">
14
+ <block name="redirect" type="core/template" template="ipaymu/redirect.phtml"/>
15
+ </reference>
16
+ </ipaymu_index_redirect>
17
+ </layout>
app/design/frontend/default/default/template/ipaymu/form.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author ellyxc
4
+ */
5
+ ?>
6
+ <?php if ($instructions = $this->getInstructions()): ?>
7
+ <ul class="form-list checkout-agreements" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
8
+ <li>
9
+ <div class="<?php echo $this->getMethodCode() ?>-instructions-content agreement-content">
10
+ <?php echo nl2br($instructions) ?>
11
+ </div>
12
+ </li>
13
+ </ul>
14
+ <?php endif; ?>
app/design/frontend/default/default/template/ipaymu/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @author ellyxc
5
+ */
6
+ ?>
7
+ <p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
8
+ <?php if ($this->getInstructions()): ?>
9
+ <table>
10
+ <tbody>
11
+ <tr>
12
+ <td><?php echo nl2br($this->getInstructions()) ?></td>
13
+ </tr>
14
+ </tbody>
15
+ </table>
16
+ <?php endif; ?>
app/design/frontend/default/default/template/ipaymu/redirect.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if($this->getData('ipaymu_has_error')){?>
2
+ <ul class="messages"><li class="error-msg"><ul><li><span><?php echo $this->getData('ipaymu_has_error');?></span></li></ul></li></ul>
3
+ <p>
4
+ <strong><?php echo $this->__('Please click %shere%s to try again!', '<a href="'.Mage::getUrl('ipaymu/index/redirect', array('_current' => true)).'">','</a>')?></strong>
5
+ </p>
6
+ <?php }else{?>
7
+ <script type="text/javascript">
8
+ function openInaDialog(){
9
+ win = new Window({
10
+ className: "bluelighting",
11
+ title: "<?php echo $this->__('Ipaymu')?>",
12
+ width:400,
13
+ height:100,
14
+ destroyOnClose: true,
15
+ closable:false,
16
+ resizable:true,
17
+ minimizable:false,
18
+ maximizable:false,
19
+ top:20
20
+ });
21
+ var html = '<p>&nbsp;</p><h3 style="color:red"><?php echo Mage::helper('ipaymu')->__('Please click %shere%s to process your payment at ipaymu','<a href="'.$this->getData('ipaymu_url').'" target="_blank" onclick="window.location.href=\\\''.( $this->getRequest()->getParam('__from') == sha1('ipaymu_checkout_process') ? Mage::getUrl('ipaymu/index/success') : Mage::getUrl('customer/account')).'\\\'">','</a>')?></h3>';
22
+ win.setZIndex(1000);
23
+ win.getContent().update(html);
24
+ win.showCenter(true,30);
25
+ }
26
+
27
+
28
+ Event.observe(window, 'load', function() {
29
+ openInaDialog();
30
+ //document.getElementById('inapay_form').submit();
31
+ });
32
+ </script>
33
+ <?php } ?>
app/etc/modules/EC_Ipaymu.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <EC_Ipaymu>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Payment/>
9
+ </depends>
10
+ </EC_Ipaymu>
11
+ </modules>
12
+ </config>
app/locale/id_ID/EC_Ipaymu.csv ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Sales Order #%s","Pesanan #%s"
2
+ "Invalid order currency","Mata uang sales"
3
+ "What is ipaymu?","Apa itu ipaymu?"
4
+ "Please click %shere%s to try again!","Silahkan klik %sdisini%s untuk mencoba lagi!"
5
+ "Ipaymu","Ipaymu"
6
+ "Please click %shere%s to process your payment at ipaymu","Silahkan klik %sdisini%s untuk memproses pembayaran Anda di ipaymu"
7
+ "Transaction Status: %s","Status Transaksi: %s"
8
+ "Ipaymu Transaction Status: ""%s""","Status Transaksi Ipaymu: ""%s""",
9
+ "Success","Berhasil"
10
+ "Pending","Pending"
11
+ "Processing","Sedang diproses"
12
+ "Cancelled","Batal"
13
+ "Check Status","Cek Status"
14
+ "Enabled","Aktif"
15
+ "Title","Judul/Nama"
16
+ "Ipaymu UserName","Username Ipaymu"
17
+ "APP Key","APP Key"
18
+ "New Order Status","Status Order Baru"
19
+ "Payment from Applicable Countries","Berlaku untuk negara"
20
+ "Specific Countries","Negara Tententu"
21
+ "All Allowed Countries","Semua Negara"
22
+ "Payment from Specific Countries","Pembayaran untuk negara tertentu"
23
+ "Instructions","Instruksi"
24
+ "Fixed Amount Fee","Biaya Tetap (dalam rupiah)"
25
+ "Percentage Fee","Biaya dalam Persen"
26
+ "Minimum Order Total","Total Minimum Pesenana"
27
+ "Sort Order","Urutan"
28
+ "in IDR","dalam rupiah"
29
+ "in %", "dalam persen %"
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>EC_Ipaymu</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>MIT License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>IPAYMU Payment Gateway</summary>
10
+ <description>IPAYMU Payment Gateway&#xD;
11
+ IPAYMU menawarkan solusi pembayaran online. Bauran produk yang meliputi fungsi e-commerce untuk perdagangan ritel. IPAYMU memiliki tools terintegrasi ke e-commerce yang Anda butuhkan sebagai alat pembayaran secara online, dengan kartu debit, kartu kredit, bahkan penarikan uang dan pengiriman uang... https://ipaymu.com/about-us&#xD;
12
+ &#xD;
13
+ </description>
14
+ <notes>First Stable Release</notes>
15
+ <authors><author><name>Ellyx Christian</name><user>ellyxc</user><email>ellyxc@myphptutorials.com</email></author></authors>
16
+ <date>2013-06-02</date>
17
+ <time>06:31:16</time>
18
+ <contents><target name="magelocal"><dir name="EC"><dir name="Ipaymu"><dir name="Block"><file name="Form.php" hash="f3aa517e8336d94c80c22213541e3e8a"/><file name="Info.php" hash="36fccd2d0817c0bc7f208ed615670acc"/></dir><dir name="Helper"><file name="Data.php" hash="a34a22041682dfbdeb14ffb69535fcd2"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Transaction"><file name="Collection.php" hash="f026272c966f5a329ab3237d0ad3945b"/></dir><file name="Transaction.php" hash="6da0630c14c6aa300170faad1eb01293"/></dir><file name="Payment.php" hash="f9f6dc1add68faf233f9fe748148b370"/><file name="Transaction.php" hash="81b83f7c473d1d59c491924776297911"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="bbdd05e2a6337187ae2defae04b14d62"/></dir><file name="IndexController.php" hash="366e419debc3bd8eb14cf4fbaf22b248"/></dir><dir name="etc"><file name="config.xml" hash="599c00c5d54a687a4695d920b02b9cd3"/><file name="system.xml" hash="ea7b2431b01162e00c6b5f2980d8dce3"/></dir><file name="ipntest.php" hash="c1eaa51e42b9409260ed0a5f9ef3fb70"/><dir name="sql"><dir name="ipaymu_setup"><file name="mysql4-install-0.1.0.php" hash="b54be3dc6c4faeaae8338d445f8124bc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="ipaymu"><file name="info.phtml" hash="37a2886b1e484ab015fb7230cd78462f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ipaymu.xml" hash="eedd2a51aa99ab64b1ce6169e6f9df25"/></dir><dir name="template"><dir name="ipaymu"><file name="form.phtml" hash="f7fd54be765a423e7cc5c81a1b18af25"/><file name="info.phtml" hash="0f47a0cc46c67fde6b99549b5e1e699d"/><file name="redirect.phtml" hash="0ed2c829dc21a7168cb1ff0e1dd1118b"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="id_ID"><file name="EC_Ipaymu.csv" hash="44f88ea2fea895aae497c4dc74244fcd"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EC_Ipaymu.xml" hash="7044c8945021b4daabc70a8623459a86"/></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>core</channel><min>1.5.0</min><max>1.7</max></package></required></dependencies>
21
+ </package>