MEOWallet - Version 0.0.2

Version Notes

Register payment method.

Download this release

Release Info

Developer PT Pay, S. A.
Extension MEOWallet
Version 0.0.2
Comparing to
See all releases


Code changes from version 0.0.1 to 0.0.2

app/code/community/Meowallet/Payment/Model/Meowallet/Abstract.php CHANGED
@@ -44,8 +44,10 @@ class Meowallet_Payment_Model_Meowallet_Abstract extends Mage_Payment_Model_Meth
44
  $payment->registerRefundNotification($amount);
45
  }
46
 
47
- private function _registerPayment($payment, $amount, $action = Meowallet_Payment_Model_Meowallet_Abstract::ACTION_AUTHORIZE)
48
  {
 
 
49
  switch ($action)
50
  {
51
  case Meowallet_Payment_Model_Meowallet_Abstract::ACTION_AUTHORIZE_CAPTURE:
@@ -132,7 +134,7 @@ class Meowallet_Payment_Model_Meowallet_Abstract extends Mage_Payment_Model_Meth
132
  return $this->_decrypt( Mage::getStoreConfig($key) );
133
  }
134
 
135
- protected function processPayment($invoice_id, $status, $amount)
136
  {
137
  Mage::log(sprintf("Processing payment for invoice_id '%s' with status '%s', amount '%s'", $invoice_id, $status, $amount));
138
 
@@ -150,25 +152,24 @@ class Meowallet_Payment_Model_Meowallet_Abstract extends Mage_Payment_Model_Meth
150
  throw new \Exception('No payment associated with an order?!');
151
  }
152
 
153
- $comment = Mage::helper('meowallet')->__('%s<br/>Status: %s', "MEO Wallet", $status);
154
  $order->addStatusHistoryComment($comment);
155
 
156
  switch ($status)
157
  {
158
  case Meowallet_Payment_Model_Operation::COMPLETED:
159
  $action = $this->_getPaymentConfig('payment_action');
160
- $this->_registerPayment($payment, $amount, $action);
161
- #$payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_ACCEPT, true);
162
  break;
163
 
164
  case Meowallet_Payment_Model_Operation::FAIL:
165
- #$payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY, true);
166
  $order->cancel();
 
167
  break;
168
 
169
  case Meowallet_Payment_Model_Operation::CREATED:
170
  case Meowallet_Payment_Model_Operation::PENDING:
171
- #$payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true);
172
  break;
173
 
174
  default:
@@ -186,8 +187,8 @@ class Meowallet_Payment_Model_Meowallet_Abstract extends Mage_Payment_Model_Meth
186
 
187
  $callback = json_decode($verbatim_callback);
188
 
189
- Mage::log(sprintf("MEOWallet callback for invoice_id '%s' with status '%s'", $callback->ext_invoice_id, $callback->operation_status));
190
 
191
- $this->processPayment($callback->ext_invoiceid, $callback->operation_status, $callback->amount);
192
  }
193
  }
44
  $payment->registerRefundNotification($amount);
45
  }
46
 
47
+ private function _registerPayment($transaction_id, $payment, $amount, $action = Meowallet_Payment_Model_Meowallet_Abstract::ACTION_AUTHORIZE)
48
  {
49
+ $payment->setTransactionId($transaction_id);
50
+
51
  switch ($action)
52
  {
53
  case Meowallet_Payment_Model_Meowallet_Abstract::ACTION_AUTHORIZE_CAPTURE:
134
  return $this->_decrypt( Mage::getStoreConfig($key) );
135
  }
136
 
137
+ protected function processPayment($transaction_id, $invoice_id, $status, $amount, $method)
138
  {
139
  Mage::log(sprintf("Processing payment for invoice_id '%s' with status '%s', amount '%s'", $invoice_id, $status, $amount));
140
 
152
  throw new \Exception('No payment associated with an order?!');
153
  }
154
 
155
+ $comment = Mage::helper('meowallet')->__('%s status update: %s<br/>Payment Method: %s', "MEO Wallet", $status, $method);
156
  $order->addStatusHistoryComment($comment);
157
 
158
  switch ($status)
159
  {
160
  case Meowallet_Payment_Model_Operation::COMPLETED:
161
  $action = $this->_getPaymentConfig('payment_action');
162
+ $this->_registerPayment($transaction_id, $payment, $amount, $action);
163
+ $order->sendOrderUpdateEmail();
164
  break;
165
 
166
  case Meowallet_Payment_Model_Operation::FAIL:
 
167
  $order->cancel();
168
+ $order->sendOrderUpdateEmail();
169
  break;
170
 
171
  case Meowallet_Payment_Model_Operation::CREATED:
172
  case Meowallet_Payment_Model_Operation::PENDING:
 
173
  break;
174
 
175
  default:
187
 
188
  $callback = json_decode($verbatim_callback);
189
 
190
+ Mage::log(sprintf("MEOWallet callback for invoice_id '%s' with status '%s'", $callback->ext_invoiceid, $callback->operation_status));
191
 
192
+ $this->processPayment($callback->operation_id, $callback->ext_invoiceid, $callback->operation_status, $callback->amount, $callback->method);
193
  }
194
  }
app/code/community/Meowallet/Payment/Model/Meowallet/Procheckout.php CHANGED
@@ -92,15 +92,21 @@ class Meowallet_Payment_Model_Meowallet_Procheckout extends Meowallet_Payment_Mo
92
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
93
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
94
  $response = json_decode( curl_exec($ch) );
95
- # $payment = $oder->getPayment();
96
- # $payment->setTransactionId($response->id);
97
- # $payment->save();
98
 
99
- if (false == is_object($response) || false == property_exists($response, 'url_redirect'))
 
 
 
100
  {
101
- Mage::throwException($this->_getHelper()->__('Could not create MEO Wallet procheckout'));
 
 
 
102
  }
103
 
 
 
 
104
  return $response;
105
  }
106
  }
92
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
93
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
94
  $response = json_decode( curl_exec($ch) );
 
 
 
95
 
96
+ if ( false == is_object($response)
97
+ || false == property_exists($response, 'id')
98
+ || false == property_exists($response, 'url_redirect')
99
+ )
100
  {
101
+ $response_data = var_export($response);
102
+ Mage::throwException(sprintf('%s. Service response: %s',
103
+ $this->_getHelper()->__('Could not create MEO Wallet procheckout'),
104
+ $response_data));
105
  }
106
 
107
+ $order->setExtOrderId($response->id);
108
+ $order->save();
109
+
110
  return $response;
111
  }
112
  }
app/code/community/Meowallet/Payment/controllers/ProcheckoutController.php CHANGED
@@ -48,11 +48,11 @@ class Meowallet_Payment_ProcheckoutController extends Mage_Core_Controller_Front
48
 
49
  public function redirectAction()
50
  {
51
- $orderId = $this->_getSession()->getLastRealOrderId();
52
- $order = $this->_getSalesOrderModel()->loadByIncrementId($orderId);
53
  $ProCheckout = $this->_getProcheckoutModel();
54
  $checkout = $ProCheckout->createCheckout($order,
55
- Mage::getUrl('checkout/onepage/success'),
56
  Mage::getUrl('meowallet/procheckout/failure'));
57
 
58
  $url = sprintf('%s%s%s=%s', $checkout->url_redirect,
@@ -73,10 +73,44 @@ class Meowallet_Payment_ProcheckoutController extends Mage_Core_Controller_Front
73
  return;
74
  }
75
 
 
 
 
 
 
 
 
 
 
76
  $this->loadLayout();
77
  $this->renderLayout();
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  public function callbackAction()
81
  {
82
  $callback = $this->_getRequestPayload();
48
 
49
  public function redirectAction()
50
  {
51
+ $lastOrderId = $this->_getSession()->getLastRealOrderId();
52
+ $order = $this->_getSalesOrderModel()->loadByIncrementId($lastOrderId);
53
  $ProCheckout = $this->_getProcheckoutModel();
54
  $checkout = $ProCheckout->createCheckout($order,
55
+ Mage::getUrl('meowallet/procheckout/success'),
56
  Mage::getUrl('meowallet/procheckout/failure'));
57
 
58
  $url = sprintf('%s%s%s=%s', $checkout->url_redirect,
73
  return;
74
  }
75
 
76
+ $order = $this->_getSalesOrderModel()->loadByIncrementId($lastOrderId);
77
+ $checkout_id = strval($this->getRequest()->getParam('checkoutid'));
78
+
79
+ if ($order && $checkout_id && $order->getExtOrderId() == $checkout_id)
80
+ {
81
+ $order->cancel();
82
+ $order->save();
83
+ }
84
+
85
  $this->loadLayout();
86
  $this->renderLayout();
87
  }
88
 
89
+ public function successAction()
90
+ {
91
+ $lastOrderId = $this->_getSession()->getLastRealOrderId();
92
+ $order = null;
93
+
94
+ if ($lastOrderId)
95
+ {
96
+ $order = $this->_getSalesOrderModel()->loadByIncrementId($lastOrderId);
97
+ }
98
+
99
+ if ( $order && $order->getCanSendNewEmailFlag() )
100
+ {
101
+ try
102
+ {
103
+ $order->sendNewOrderEmail();
104
+ }
105
+ catch (\Exception $e)
106
+ {
107
+ Mage::log("MEOWallet cannot send new order email. Reason: ".$e->getMessage());
108
+ }
109
+ }
110
+
111
+ $this->_redirect('checkout/onepage/success');
112
+ }
113
+
114
  public function callbackAction()
115
  {
116
  $callback = $this->_getRequestPayload();
app/code/community/Meowallet/Payment/etc/config.xml CHANGED
@@ -1,7 +1,7 @@
1
  <config>
2
  <modules>
3
  <Meowallet_Payment>
4
- <version>0.0.1</version>
5
  </Meowallet_Payment>
6
  </modules>
7
  <global>
@@ -89,7 +89,7 @@
89
  <meowallet_procheckout>
90
  <active>0</active>
91
  <model>meowallet/meowallet_procheckout</model>
92
- <title>MEO Wallet (Saldo/CC/MB)</title>
93
  <payment_action>sale</payment_action>
94
  <allowspecific>0</allowspecific>
95
  <environment>1</environment>
1
  <config>
2
  <modules>
3
  <Meowallet_Payment>
4
+ <version>0.0.2</version>
5
  </Meowallet_Payment>
6
  </modules>
7
  <global>
89
  <meowallet_procheckout>
90
  <active>0</active>
91
  <model>meowallet/meowallet_procheckout</model>
92
+ <title>MEO Wallet (Saldo/Cartão Bancário/MB)</title>
93
  <payment_action>sale</payment_action>
94
  <allowspecific>0</allowspecific>
95
  <environment>1</environment>
app/design/frontend/base/default/template/meowallet/procheckout/failure.phtml CHANGED
@@ -1,6 +1,5 @@
1
  <div class="page-title">
2
  <h1><?php echo $this->__('Your order has been cancelled') ?></h1>
3
  </div>
4
- <?php if ($this->getRealOrderId()) : ?><p><?php echo $this->__('Order #') . $this->getRealOrderId() ?></p><?php endif ?>
5
  <?php if ($error = $this->getErrorMessage()) : ?><p><?php echo $error ?></p><?php endif ?>
6
- <p><?php echo $this->__('Click <a href="%s">here</a> to continue shopping.', $this->getContinueShoppingUrl()) ?></p>
1
  <div class="page-title">
2
  <h1><?php echo $this->__('Your order has been cancelled') ?></h1>
3
  </div>
 
4
  <?php if ($error = $this->getErrorMessage()) : ?><p><?php echo $error ?></p><?php endif ?>
5
+ <p><?php echo $this->__('Click <a href="%s">here</a> to continue shopping.', Mage::helper('core/url')->getHomeUrl()) ?></p>
app/locale/pt_PT/Meowallet_Payment.csv ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ "Production","Produção"
2
+ "API Token - Production","API Token - Produção"
3
+ "Environment in use","Ambiente em uso"
4
+ "New order status","Estado para as novas compras"
5
+ "More info <a target="_blank"" href=""https://developers.wallet.pt/en/basics/auth.html"">here</a>","Mais informação <a target=""_blank"" href=""https://developers.wallet.pt/en/basics/auth.html"">aqui</a>"
6
+ "Your order has been cancelled","A sua encomenda foi cancelada"
package.xml CHANGED
@@ -1,18 +1,24 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MEOWallet</name>
4
- <version>0.0.1</version>
5
  <stability>stable</stability>
6
  <license>MIT</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Official MEO Wallet extension.</summary>
10
- <description>Official MEO Wallet extension to receive online payments, simple, fast and totally secure.</description>
11
- <notes>Initial release with procheckout payment method.</notes>
 
 
 
 
 
 
12
  <authors><author><name>PT Pay, S. A.</name><user>walletpt</user><email>walletpt@telecom.pt</email></author></authors>
13
- <date>2015-04-06</date>
14
- <time>18:33:29</time>
15
- <contents><target name="magecommunity"><dir name="Meowallet"><dir name="Payment"><dir name="Helper"><file name="Data.php" hash="21881d69c35446e7c12b0f032675167d"/></dir><dir name="Model"><dir name="Meowallet"><file name="Abstract.php" hash="9d42dbcb74b3c82053de3b09536460e0"/><file name="Procheckout.php" hash="cc36c6d85da660bcdea98eb993c8f9ec"/></dir><file name="Operation.php" hash="546a9a09a77224747872bc1cbe7ce07f"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Environment"><file name="View.php" hash="a4af2d583723a2834421fbad08fe48cf"/></dir><dir name="Payment"><file name="Actions.php" hash="12eca297e01a63c5f9b5abcb19e8221d"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="ProcheckoutController.php" hash="5806bab4668a44b3e80f6f407da0eeb9"/></dir><dir name="etc"><file name="config.xml" hash="69e3df9377d27ed964fdc4c0e0993198"/><file name="system.xml" hash="cfb5c0ba4f5026b370e89a9913818729"/></dir><dir name="sql"><file name="mysql4-install-0.0.1.php" hash="24c6f7aeea694036ff277d42545eebc3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Meowallet_Payment.xml" hash="4852d681cec539e144ab19a3b372937d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="meowallet.xml" hash="01dc73dd7e3532b5141c8a3ecc34dba9"/></dir><dir name="template"><dir name="meowallet"><dir name="procheckout"><file name="failure.phtml" hash="adaf4a6d642ad933e9cd17f026654e7c"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="pt_PT"><file name="Meowallet_Payment.xml" hash=""/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MEOWallet</name>
4
+ <version>0.0.2</version>
5
  <stability>stable</stability>
6
  <license>MIT</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>MEO Wallet official extension to receive online payments. Simple, fast and totally secure.</summary>
10
+ <description>The MEO Wallet is an innovative service, with personalized support, which allows you to accept payments on your store, online store or on TV, in a fast, convenient and secure way. All with competitive rates and no other costs.&#xD;
11
+ &#xD;
12
+ One service and one contract, based on security and confidentiality best practices, to support all essential payment methods - bank cards (debit and credit, VISA and Mastercard), MB References and MEO Wallet balance.&#xD;
13
+ &#xD;
14
+ Ensure customer satisfaction and enhance your business. Find more at wallet.pt.&#xD;
15
+ &#xD;
16
+ The MEO Wallet is a service of PT Pay, SA, registered payment institution at the Bank of Portugal under number 8705, belonging to PT Portugal. &#xA9;</description>
17
+ <notes>Register payment method.</notes>
18
  <authors><author><name>PT Pay, S. A.</name><user>walletpt</user><email>walletpt@telecom.pt</email></author></authors>
19
+ <date>2015-04-29</date>
20
+ <time>15:51:09</time>
21
+ <contents><target name="magecommunity"><dir name="Meowallet"><dir name="Payment"><dir name="Helper"><file name="Data.php" hash="21881d69c35446e7c12b0f032675167d"/></dir><dir name="Model"><dir name="Meowallet"><file name="Abstract.php" hash="f1742659e7c1fcf057303fc1771d7f57"/><file name="Procheckout.php" hash="eee62cb423d097245178742f0c01ad5a"/></dir><file name="Operation.php" hash="546a9a09a77224747872bc1cbe7ce07f"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Environment"><file name="View.php" hash="a4af2d583723a2834421fbad08fe48cf"/></dir><dir name="Payment"><file name="Actions.php" hash="12eca297e01a63c5f9b5abcb19e8221d"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="ProcheckoutController.php" hash="363afaf199c0152b1c0aee2892674ec5"/></dir><dir name="etc"><file name="config.xml" hash="2fde843ffd1b123595e24476b4dd8252"/><file name="system.xml" hash="cfb5c0ba4f5026b370e89a9913818729"/></dir><dir name="sql"><file name="mysql4-install-0.0.1.php" hash="24c6f7aeea694036ff277d42545eebc3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Meowallet_Payment.xml" hash="4852d681cec539e144ab19a3b372937d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="meowallet.xml" hash="01dc73dd7e3532b5141c8a3ecc34dba9"/></dir><dir name="template"><dir name="meowallet"><dir name="procheckout"><file name="failure.phtml" hash="5656cc0b386c6f02c8ae5e1017f81386"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="pt_PT"><file name="Meowallet_Payment.csv" hash="7c1e344bd75a4be0437b512f6bd6a6e3"/></dir></dir></target></contents>
22
  <compatible/>
23
+ <dependencies><required><php><min>5.4.0</min><max>5.7.0</max></php></required></dependencies>
24
  </package>