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 @@ + + + + + + + + ricardomartins_pagseguro/api + RicardoMartins PagSeguro API + ricardomartins_pagseguro + + + Get session ID to process card token. + ricardomartins_pagseguro/session_id + sessionId + + + + + + + + RicardoMartins PagSeguro API + 0 + + Session ID + + + + + + + diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml index 8169288e..2a291ff7 100644 --- a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml +++ b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml @@ -173,6 +173,7 @@ 0 Cartão de Crédito - via PagSeguro UOL pending + paid 0 42x20 order @@ -182,18 +183,21 @@ 0 1 - 0 + 1 + 1 0 0 Parcele em até {num_parcelas}x de R${valor_parcela} (Total R${valor_total}) com PagSeguro UOL. 1 - taxvat - telephone + customer|taxvat + cellphone street_1 street_2 - street_2 + street_3 + street_4 + 1 https://ws.pagseguro.uol.com.br/v2/ https://ws.ricardomartins.net.br/pspro/v7/wspagseguro/v2/ https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js @@ -204,8 +208,9 @@ 1 1 1 - 0 - 0 + 1 + 1 + 1 0 diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/system.xml b/app/code/community/RicardoMartins/PagSeguro/etc/system.xml index 9b011566..02a47774 100644 --- a/app/code/community/RicardoMartins/PagSeguro/etc/system.xml +++ b/app/code/community/RicardoMartins/PagSeguro/etc/system.xml @@ -343,6 +343,15 @@ 1 0 + + + select + adminhtml/system_config_source_order_status + 22 + 1 + 1 + 1 + select @@ -506,12 +515,20 @@ 1 + + + textarea + 220 + 1 + 1 + 1 + select adminhtml/system_config_source_yesno ricardomartins_pagseguro/system_config_backend_validateMultiCc - 220 + 230 1 1 1 diff --git a/app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml b/app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml index 85134e0a..5c0146a8 100644 --- a/app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml +++ b/app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml @@ -25,6 +25,13 @@ $multiCcEnabled = Mage::helper('ricardomartins_pagseguro')->isMultiCcEnabled(); */ ?> + getInstructions()): ?> +
  • +
    + getInstructions()) ?> +
    +
  • +
  • diff --git a/app/locale/pt_BR/RicardoMartins_PagSeguro.csv b/app/locale/pt_BR/RicardoMartins_PagSeguro.csv index 72993f11..d94fdb38 100644 --- a/app/locale/pt_BR/RicardoMartins_PagSeguro.csv +++ b/app/locale/pt_BR/RicardoMartins_PagSeguro.csv @@ -196,4 +196,5 @@ "invalid security field","código de segurança inválido" "PagSeguro: Payment with two credit cards is only available in the application model. Authorize your account for free to enable it.","PagSeguro: Pagamento com dois cartões só está disponível no modelo de aplicação. Autorize sua conta gratuitamente." "Not applicable","Não aplicável" -"Show Download PDF Button","Mostrar Botão de Download em PDF" \ No newline at end of file +"Show Download PDF Button","Mostrar Botão de Download em PDF" +"Paid Order Status","Status Pago do Pedido"