diff --git a/app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php b/app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php
index f4eb7205..1685f5f9 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php
@@ -11,6 +11,8 @@
*/
class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
{
+ protected $_instructions = null;
+
/**
* Set block template
*/
@@ -162,4 +164,13 @@ public function getCurrentCustomerDocument()
return "";
}
+
+ protected function getInstructions()
+ {
+ if (is_null($this->_instructions)) {
+ $this->_instructions = $this->getMethod()->getInstructions();
+ }
+
+ return $this->_instructions;
+ }
}
diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Internal.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Internal.php
index d5336fa1..47f15784 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Helper/Internal.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Internal.php
@@ -72,7 +72,7 @@ public function getCreditCardApiCallParams(Mage_Sales_Model_Order $order, $payme
'extraAmount' => $extraAmount,
'notificationURL' => Mage::getUrl(
'ricardomartins_pagseguro/notification',
- array('_secure' => true, '_nosid' => $noSID)
+ array('_store' => $order->getStoreId(), '_secure' => true, '_nosid' => $noSID)
),
);
$params = array_merge($params, $pHelper->getItemsParams($order));
diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
index 66005194..ceeaf8a3 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
@@ -476,7 +476,7 @@ protected function _extractPhone($phone)
$phone = substr($phone, 1, strlen($phone));
}
- $originalPhone = $phone;
+ $originalPhone = $phone = substr($phone, -11);
$phone = preg_replace('/^(\d{2})(\d{7,9})$/', '$1-$2', $phone);
@@ -724,7 +724,13 @@ public function getPaymentHash($param=null)
$registry = ($isAdmin)?$registry->get('PsPayment'):$registry->getData('PsPayment');
if (!$registry) {
- return false;
+ $session = Mage::getSingleton('api/session');
+
+ if (!$session->isLoggedIn()) {
+ return false;
+ }
+
+ $registry = $session->getData('PsPayment');
}
$registry = unserialize($registry);
diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php b/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php
index acf44efe..87aa7aa1 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php
@@ -679,7 +679,8 @@ protected function _confirmPayment($payment, $notification)
$order->addStatusHistoryComment
(
- sprintf('Fatura #%s criada com sucesso.', $invoice->getIncrementId())
+ sprintf('Fatura #%s criada com sucesso.', $invoice->getIncrementId()),
+ Mage::getStoreConfig('payment/rm_pagsecuro_cc/paid_status') ?: false
);
}
}
diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Api.php b/app/code/community/RicardoMartins/PagSeguro/Model/Api.php
new file mode 100644
index 00000000..9afd65bb
--- /dev/null
+++ b/app/code/community/RicardoMartins/PagSeguro/Model/Api.php
@@ -0,0 +1,15 @@
+
+ */
+
+class RicardoMartins_PagSeguro_Model_Api extends Mage_Api_Model_Resource_Abstract
+{
+ public function sessionId()
+ {
+ return Mage::helper('ricardomartins_pagseguro')->getSessionId();
+ }
+}
+
diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php b/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php
index 381741f3..d769909d 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php
@@ -11,7 +11,9 @@
*/
class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro_Model_Abstract
{
- protected $_code = 'rm_pagseguro_cc';
+ const CODE = 'rm_pagseguro_cc';
+
+ protected $_code = self::CODE;
protected $_formBlockType = 'ricardomartins_pagseguro/form_cc';
protected $_infoBlockType = 'ricardomartins_pagseguro/form_info_cc';
protected $_isGateway = true;
@@ -75,6 +77,12 @@ public function assignData($data)
$data = new Varien_Object($data);
}
+ $session = Mage::getSingleton('api/session');
+
+ if ($session->isLoggedIn()) {
+ $session->setData('PsPayment', serialize($data->getData('PsPayment')));
+ }
+
$info = $this->getInfoInstance();
$info->setAdditionalInformation('sender_hash', $this->_pHelper->getPaymentHash('sender_hash'));
@@ -316,6 +324,8 @@ protected function _order($payment, $amount, $ccIdx)
{
$order = $payment->getOrder();
+ $order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true);
+
if ($this->isMultiCardPayment($payment)) {
$cardData = $payment->getAdditionalInformation("cc" . $ccIdx);
$payment->setData("_current_card_index", $ccIdx);
@@ -1302,4 +1312,9 @@ public function recalculateInstallmentsAndPlaceOrder($payment, $amount)
Mage::throwException($e->getMessage());
}
}
+
+ public function getInstructions()
+ {
+ return trim($this->getConfigData('instructions'));
+ }
}
diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Source/Algorithms.php b/app/code/community/RicardoMartins/PagSeguro/Model/Source/Algorithms.php
index 0f19cb44..e7e5a160 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Model/Source/Algorithms.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Model/Source/Algorithms.php
@@ -16,7 +16,8 @@ public function toOptionArray()
{
$options = array(
array('value' => 'md5', 'label' => 'MD5'),
- array('value' => 'sha256', 'label' => 'SHA256')
+ array('value' => 'sha256', 'label' => 'SHA256'),
+ array('value' => 'sha512', 'label' => 'SHA512'),
);
return $options;
diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Source/Hash.php b/app/code/community/RicardoMartins/PagSeguro/Model/Source/Hash.php
index 88ad0cca..a1c62b58 100644
--- a/app/code/community/RicardoMartins/PagSeguro/Model/Source/Hash.php
+++ b/app/code/community/RicardoMartins/PagSeguro/Model/Source/Hash.php
@@ -17,7 +17,7 @@ class RicardoMartins_PagSeguro_Model_Source_Hash
public function toOptionArray()
{
$options = array();
- if(!function_exists('hash') || !in_array('sha256',hash_algos()) || !in_array('md5',hash_algos())){
+ if ($this->_noHashable()) {
$options[] = array('value'=>0, 'label'=>'Não suportado no seu ambiente.');
return $options;
}
@@ -32,7 +32,7 @@ public function toOptionArray()
*/
public function toArray()
{
- if(!function_exists('hash') || !in_array('sha256',hash_algos()) || !in_array('md5',hash_algos())){
+ if ($this->_noHashable()) {
return array(
0 => Mage::helper('adminhtml')->__('No')
);
@@ -40,4 +40,15 @@ public function toArray()
return Mage::getModel('adminhtml/system_config_source_yesno')->toArray();
}
+
+ /**
+ * @return bool
+ */
+ private function _noHashable()
+ {
+ return !function_exists('hash')
+ || !in_array('sha512',hash_algos())
+ || !in_array('sha256',hash_algos())
+ || !in_array('md5',hash_algos());
+ }
}
diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/api.xml b/app/code/community/RicardoMartins/PagSeguro/etc/api.xml
new file mode 100644
index 00000000..4147a9c1
--- /dev/null
+++ b/app/code/community/RicardoMartins/PagSeguro/etc/api.xml
@@ -0,0 +1,39 @@
+
+
+
+