*/ public function canUseInternal() { return false; } public function getConfig() { return new Varien_Object(Mage::getStoreConfig('payment/fastcash_transferencia')); } /** * Authorize * * @param Varien_Object $orderPayment * @param float $amount * @return Mage_Payment_Model_Abstract */ public function authorize(Varien_Object $payment, $amount) { //$config = mage::helper('fastcash')->getConfig(); //$auth = mage::helper('fastcash')->getAuthConfig(); $gateway = Mage::getModel('fastcash/order')->load($payment->getOrder()->getId(), 'order_id'); $data = new Varien_Object(unserialize(Mage::helper('core')->decrypt($gateway->getInfo()))); $order = $payment->getOrder(); $customer = Mage::getModel('customer/customer')->load($order->getCustomerId()); $transactionClient = new Fastcash\TransactionClient(); $req = new Fastcash\TransactionRequest(); $req->Transaction->Tid = uniqid('', true); $req->Transaction->Pid = Fastcash\IntegrationData::Pid; $req->Transaction->ProdId = Fastcash\IntegrationData::$ProductIds["Default"]; $req->Transaction->ItemDescription = "Magento API 2.0-php"; $req->Transaction->Price = $amount; $req->Transaction->PaymentMethod = Fastcash\PaymentMethods::Transference; $req->Transaction->SubPaymentMethod = $data->getFastcashTransferenciaType(); $req->Client->Name = $order->getCustomerFirstname() . ' ' . $order->getLastname(); $req->Client->Email = $order->getCustomerEmail(); $req->Client->MobilePhoneNumber = $order->getBillingAddress()->getCellPhone() ? $order->getBillingAddress()->getCellPhone() : $order->getBillingAddress()->getTelephone(); //"011999999999" $req->Client->Cpf = $customer->getCpf(); //If Client bank account is provided, initialize an instance of ClientTransactionData. //Otherwise, leave it null. if (!$data->getFastcashTransferenciaAg()) { $req->ClientTransactionData = null; } else { $req->ClientTransactionData = new Fastcash\ClientTransactionData(); $req->ClientTransactionData->BankAgency = $data->getFastcashTransferenciaAg(); $req->ClientTransactionData->BankAccountNumber = $data->getFastcashTransferenciaCc(); } $res = $transactionClient->Send($req); if ($res == null) { Mage::throwException(Mage::helper('fastcash')->__("Transaction Error: " . $transactionClient->Error . ' - ' . "Transaction Error Body: " . $transactionClient->ErrorBody)); return $this; } else { $gateway->setTransactionId($req->Transaction->Tid); $gateway->setInfo($res->Transaction); $this->_confirmation = Zend_Json::decode($res->Confirmation); $gateway->setFieldCount($this->_confirmation['FieldsCount']); if ($this->_confirmation['F1']['Name']) { $gateway->setF1Name($this->_confirmation['F1']['Name']); $gateway->setF1Required($this->_confirmation['F1']['Required']); $gateway->setF1DataType($this->_confirmation['F1']['DataType']); } if ($this->_confirmation['F2']['Name']) { $gateway->setF2Name($this->_confirmation['F2']['Name']); $gateway->setF2Required($this->_confirmation['F2']['Required']); $gateway->setF2DataType($this->_confirmation['F2']['DataType']); } if ($this->_confirmation['F3']['Name']) { $gateway->setF3Name($this->_confirmation['F3']['Name']); $gateway->setF3Required($this->_confirmation['F3']['Required']); $gateway->setF3DataType($this->_confirmation['F3']['DataType']); }