Ejemplo n.º 1
0
 public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $items = Mage::helper('iugu')->getItemsFromOrder($payment->getOrder());
     $payer = Mage::helper('iugu')->getPayerInfoFromOrder($payment->getOrder());
     $data = new Varien_Object();
     $data->setMethod(Inovarti_Iugu_Model_Api::PAYMENT_METHOD_BOLETO)->setEmail($order->getCustomerEmail())->setItems($items)->setPayer($payer)->setNotificationUrl(Mage::getUrl('iugu/notification'));
     // Discount
     if ($order->getBaseDiscountAmount()) {
         $data->setDiscountCents(Mage::helper('iugu')->formatAmount(abs($order->getBaseDiscountAmount())));
     }
     // Tax
     if ($order->getBaseTaxAmount()) {
         $data->setTaxCents($this->formatAmount($order->getBaseTaxAmount()));
     }
     $result = Mage::getSingleton('iugu/api')->charge($data);
     if ($result->getErrors()) {
         $messages = array();
         if (is_array($result->getErrors())) {
             foreach ($result->getErrors() as $field => $errors) {
                 foreach ($errors as $error) {
                     $messages[] = $field . ': ' . $error . '.';
                 }
             }
         } else {
             $messages[] = $result->getErrors();
         }
         Mage::throwException(implode("\n", $messages));
     }
     // iugu info
     $payment->setIuguInvoiceId($result->getInvoiceId())->setIuguUrl($result->getUrl())->setIuguPdf($result->getPdf());
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Checks if partial capture
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return bool
  */
 public function determineIsPartial($payment, $amount)
 {
     $grandTotal = $payment->getOrder()->getGrandTotal();
     if ($grandTotal != $amount) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
 /**
  * Convert order payment to quote payment
  *
  * @param   Mage_Sales_Model_Order_Payment $payment
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function paymentToQuotePayment(Mage_Sales_Model_Order_Payment $payment, $quotePayment = null)
 {
     if (!$quotePayment instanceof Mage_Sales_Model_Quote_Payment) {
         $quotePayment = Mage::getModel('sales/quote_payment');
     }
     $quotePayment->setStoreId($payment->getStoreId())->setCustomerPaymentId($payment->getCustomerPaymentId());
     Mage::helper('core')->copyFieldset('sales_convert_order_payment', 'to_quote_payment', $payment, $quotePayment);
     return $quotePayment;
 }
 /**
  * Unserialize additional data if required
  * @param Mage_Sales_Model_Order_Payment $payment
  */
 public function unserializeFields(Mage_Sales_Model_Order_Payment $payment)
 {
     $additionalInformation = $payment->getData('additional_information');
     if (empty($additionalInformation)) {
         $payment->setData('additional_information', array());
     } elseif (!is_array($additionalInformation)) {
         $payment->setData('additional_information', unserialize($additionalInformation));
     }
 }
Ejemplo n.º 5
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Method_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setBillingAgreementId($payment->getBillingAgreementId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)->setInvNum($order->getIncrementId());
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setAdditionalInformation(CLS_Paypal_Model_Paypaluk_Api_Nvp::RESPONSE_MSG, $api->getResponseMsg())->setPreparedMessage(Mage::helper('cls_paypal')->__('Payflow PNREF: #%s.', $api->getTransactionId()))->setTransactionAdditionalInfo(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId());
     $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0);
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return CLS_Paypal_Model_Paypal_Method_Orderstored_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setReferenceId($payment->getBillingAgreementId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)->setInvNum($order->getIncrementId());
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $api->callGetTransactionDetails();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * Magento $payment->addTransaction(...) needs the transaction_id = id from the transaction entry or string!
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param string $type
  * @param Mage_Sales_Model_Abstract $salesDocument
  * @param bool $failsafe
  * @param string $message
  * @return null|Mage_Sales_Model_Order_Payment_Transaction
  */
 public function addNewTransaction(Mage_Sales_Model_Order_Payment $payment, $type, $salesDocument = null, $failsafe = false, $message = false)
 {
     $transaction = null;
     try {
         $addInformation = $payment->getAdditionalInformation();
         $payment->setTransactionId($addInformation['transactionId'] . '-' . $type);
         $transaction = $payment->addTransaction($type, $salesDocument, $failsafe, $message);
         $transaction->save();
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $transaction;
 }
Ejemplo n.º 8
0
 public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     try {
         $order = $payment->getOrder();
         $azpay = new AZPay($this->_merchantId, $this->_merchantKey);
         $azpay->curl_timeout = 60;
         $azpay->config_order['reference'] = $order->getRealOrderId();
         $azpay->config_order['totalAmount'] = Mage::helper('azpay')->formatAmount($amount);
         $azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback');
         /*$azpay->config_boleto['acquirer'] = $this->getConfigData('operator');
           $azpay->config_boleto['expire'] = $this->_generateExpirationDate();
           $azpay->config_boleto['nrDocument'] = substr($order->getRealOrderId(), 1);
           $azpay->config_boleto['amount'] = Mage::helper('azpay')->formatAmount($amount);
           $azpay->config_boleto['instructions'] = $this->getConfigData('instructions');*/
         $azpay->config_online_debit['acquirer'] = $this->getConfigData('operator');
         $billingAddress = $order->getBillingAddress();
         if ($order->getCustomerTaxvat()) {
             $azpay->config_billing['customerIdentity'] = $order->getCustomerTaxvat();
         } else {
             $azpay->config_billing['customerIdentity'] = $order->getRealOrderId();
         }
         $azpay->config_billing['name'] = $order->getCustomerName();
         $azpay->config_billing['address'] = $billingAddress->getStreet(1) . ',' . $billingAddress->getStreet(2);
         $azpay->config_billing['address2'] = $billingAddress->getStreet(3) ? $billingAddress->getStreet(3) : '';
         $azpay->config_billing['city'] = $billingAddress->getCity();
         $azpay->config_billing['state'] = $billingAddress->getRegionCode();
         $azpay->config_billing['postalCode'] = Zend_Filter::filterStatic($billingAddress->getPostcode(), 'Digits');
         $azpay->config_billing['phone'] = Mage::helper('azpay')->splitTelephone($billingAddress->getTelephone());
         $azpay->config_billing['email'] = $order->getCustomerEmail();
         $azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback');
         // Execute
         $azpay->online_debit()->execute();
         $azpay->getXml();
         // usado para salvar o XML gerado no log
         // Log
         if ($this->getConfigData('log')) {
             Mage::log($azpay, null, "azpay_boleto.log");
         }
     } catch (AZPay_Error $e) {
         Mage::log($e->getMessage(), null, "azpay_boleto_error.log");
         $error = $azpay->responseError();
         return Mage::throwException("Ocorreu um problema com o seu pedido. Tente novamente ou entre em contato conosco informando este código: " . $error['status_message']);
     }
     // Response
     $gateway_response = $azpay->response();
     $paymentDetails['azpayboletourl'] = (string) $gateway_response->processor->Transfer->urlTransfer;
     $payment->setAdditionalData(serialize($paymentDetails));
     // azpay info
     $payment->setAzpayTransactionId($gateway_response->transactionId)->setAzpayBoletoUrl((string) $gateway_response->processor->Transfer->urlTransfer);
     return $this;
 }
Ejemplo n.º 9
0
 /**
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return 	array
  */
 protected function getVaultParams($payment)
 {
     $params = array();
     $params['card_number'] = $payment->getCcNumber();
     $params['card_expiry_month'] = $payment->getCcExpMonth() < 10 ? '0' . $payment->getCcExpMonth() : $payment->getCcExpMonth();
     $params['card_expiry_year'] = $payment->getCcExpYear();
     $params['cvc'] = $payment->getCcCid();
     $params['multi_use'] = 1;
     //Add card holder
     $billing = $payment->getOrder()->getBillingAddress();
     $defaultOwner = $billing->getFirstname() && $billing->getLastname() ? $billing->getFirstname() . ' ' . $billing->getLastname() : $billing->getEmail();
     $params['card_holder'] = $payment->getCcOwner() ? $payment->getCcOwner() : $defaultOwner;
     $this->_debug($params);
     return $params;
 }
Ejemplo n.º 10
0
 /**
  * Order cancellation hook for payment method instance
  * Adds void transaction if needed
  * @return Mage_Sales_Model_Order_Payment
  */
 public function cancel()
 {
     if ($this->getMethodInstance()->getCode() == Braintree_Payments_Model_Creditcard::PAYMENT_METHOD_CODE) {
         Mage::register(self::REGISTRY_KEY_CANCEL, true);
     }
     return parent::cancel();
 }
 /**
  * Verify data required for saving
  * @return Mage_Sales_Model_Order_Payment_Transaction
  * @throws Mage_Core_Exception
  */
 protected function _beforeSave()
 {
     // set parent id
     $this->_verifyPaymentObject();
     $this->setPaymentId($this->_paymentObject->getId())->setOrderId($this->getOrderId());
     return parent::_beforeSave();
 }
Ejemplo n.º 12
0
 public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $customer = Mage::helper('pagarme')->getCustomerInfoFromOrder($payment->getOrder());
     $data = new Varien_Object();
     $data->setPaymentMethod(Inovarti_Pagarme_Model_Api::PAYMENT_METHOD_BOLETO)->setAmount(Mage::helper('pagarme')->formatAmount($amount))->setBoletoExpirationDate($this->_generateExpirationDate())->setCustomer($customer)->setPostbackUrl(Mage::getUrl('pagarme/transaction_boleto/postback'));
     $pagarme = Mage::getModel('pagarme/api');
     $transaction = $pagarme->charge($data);
     if ($transaction->getErrors()) {
         $messages = array();
         foreach ($transaction->getErrors() as $error) {
             $messages[] = $error->getMessage() . '.';
         }
         Mage::throwException(implode("\n", $messages));
     }
     // pagar.me info
     $payment->setPagarmeTransactionId($transaction->getId())->setPagarmeBoletoUrl($transaction->getBoletoUrl())->setPagarmeBoletoBarcode($transaction->getBoletoBarcode())->setPagarmeBoletoExpirationDate($transaction->getBoletoExpirationDate());
     return $this;
 }
 /**
  * @see parent::_construct()
  * overriding this method to update ROM payment type
  * with Magento payment type.
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     // @see parent::_order property.
     $this->setOrder($this->getData('order'));
     // remove the order key, we no long need it.
     $this->unsetData('order');
     if ($this->getPaymentTypeName()) {
         $this->_updatePayments();
     }
 }
Ejemplo n.º 14
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testGetTotalsHtml()
 {
     $order = new Mage_Sales_Model_Order();
     Mage::register('current_order', $order);
     $payment = new Mage_Sales_Model_Order_Payment();
     $payment->setMethod('checkmo');
     $order->setPayment($payment);
     $layout = new Mage_Core_Model_Layout();
     $block = new Mage_Sales_Block_Order_Print_Creditmemo();
     $layout->addBlock($block, 'block');
     $childBlock = $layout->addBlock('Mage_Core_Block_Text', 'creditmemo_totals', 'block');
     $expectedHtml = '<b>Any html</b>';
     $creditmemo = new Mage_Sales_Model_Order_Creditmemo();
     $this->assertEmpty($childBlock->getCreditmemo());
     $this->assertNotEquals($expectedHtml, $block->getTotalsHtml($creditmemo));
     $childBlock->setText($expectedHtml);
     $actualHtml = $block->getTotalsHtml($creditmemo);
     $this->assertSame($creditmemo, $childBlock->getCreditmemo());
     $this->assertEquals($expectedHtml, $actualHtml);
 }
Ejemplo n.º 15
0
 /**
  * Verify data required for saving
  * @return Mage_Sales_Model_Order_Payment_Transaction
  * @throws Mage_Core_Exception
  */
 protected function _beforeSave()
 {
     // set parent id
     $this->_verifyPaymentObject();
     if (!$this->getId()) {
         // We need to set order and payment ids only for new transactions
         if (null !== $this->_paymentObject) {
             $this->setPaymentId($this->_paymentObject->getId());
         }
         if (null !== $this->_order) {
             $this->setOrderId($this->_order->getId());
         }
         $this->setCreatedAt(Mage::getModel('core/date')->gmtDate());
     }
     return parent::_beforeSave();
 }
Ejemplo n.º 16
0
 /**
  * Decide whether authorization transaction may close (if the amount to capture will cover entire order)
  *
  * @param float $amountToCapture            
  * @return bool
  */
 protected function _isCaptureFinal($amountToCapture)
 {
     /**
      * Declare repeted string variable
      */
     $coreResource = 'core/resource';
     $coreWrite = 'core_write';
     $processing = 'processing';
     $orderNo = 'order_no=?';
     $superdealsOrders = 'superdeals_orders';
     /**
      * load order item
      */
     foreach ($this->getOrder()->getAllItems() as $oOrderItems) {
         /**
          * get order id from loop value
          */
         $ordrId = $this->getOrder()->getIncrementId();
         $connection = Mage::getSingleton($coreResource)->getConnection($coreWrite);
         $connection->beginTransaction();
         $fields = array();
         $fields = $this->statusForPayment($fields, $oOrderItems, $processing, $Processing);
         /**
          * check condition if order item is equal to pending paypal
          */
         if ($oOrderItems()->getStatus() == 'pending_paypal') {
             $fields['status'] = 'Pending PayPal';
         }
         /**
          * update and commit order status
          */
         $where = $connection->quoteInto($orderNo, $ordrId);
         $connection->update($superdealsOrders, $fields, $where);
         $connection->commit();
     }
     return parent::_isCaptureFinal($amountToCapture);
 }
Ejemplo n.º 17
0
 /**
  * Import payment data to billing agreement
  *
  * $payment->getBillingAgreementData() contains array with following structure :
  *  [billing_agreement_id]  => string
  *  [method_code]           => string
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Sales_Model_Billing_Agreement
  */
 public function importOrderPayment(Mage_Sales_Model_Order_Payment $payment)
 {
     $baData = $payment->getBillingAgreementData();
     $this->_paymentMethodInstance = isset($baData['method_code']) ? Mage::helper('payment')->getMethodInstance($baData['method_code']) : $payment->getMethodInstance();
     if ($this->_paymentMethodInstance) {
         $this->_paymentMethodInstance->setStore($payment->getMethodInstance()->getStore());
         $this->setCustomerId($payment->getOrder()->getCustomerId())->setMethodCode($this->_paymentMethodInstance->getCode())->setReferenceId($baData['billing_agreement_id'])->setStatus(self::STATUS_ACTIVE);
     }
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Add payment transaction
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param string $transactionId
  * @param string $transactionType
  * @param array $transactionDetails
  * @param array $transactionAdditionalInfo
  * @return null|Mage_Sales_Model_Order_Payment_Transaction
  */
 protected function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType, array $transactionDetails = array(), array $transactionAdditionalInfo = array(), $message = false)
 {
     $payment->setTransactionId($transactionId);
     $payment->resetTransactionAdditionalInfo();
     foreach ($transactionDetails as $key => $value) {
         $payment->setData($key, $value);
     }
     foreach ($transactionAdditionalInfo as $key => $value) {
         $payment->setTransactionAdditionalInfo($key, $value);
     }
     $transaction = $payment->addTransaction($transactionType, null, false, $message);
     foreach ($transactionDetails as $key => $value) {
         $payment->unsetData($key);
     }
     $payment->unsLastTransId();
     /**
      * It for self using
      */
     $transaction->setMessage($message);
     return $transaction;
 }
Ejemplo n.º 19
0
 public function setPayment(Mage_Sales_Model_Order_Payment $payment)
 {
     if (!$this->getIsMultiPayment() && ($old = $this->getPayment())) {
         $payment->setId($old->getId());
     }
     $this->addPayment($payment);
     return $payment;
 }
Ejemplo n.º 20
0
 /**
  * Set capture transaction ID to invoice for informational purposes
  * @param Mage_Sales_Model_Order_Invoice $invoice
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function processInvoice($invoice, $payment)
 {
     $invoice->setTransactionId($payment->getLastTransId());
     return $this;
 }
Ejemplo n.º 21
0
 /**
  * Convert order payment to quote payment
  *
  * @param   Mage_Sales_Model_Order_Payment $payment
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function paymentToQuotePayment(Mage_Sales_Model_Order_Payment $payment, $quotePayment = null)
 {
     if (!$quotePayment instanceof Mage_Sales_Model_Quote_Payment) {
         $quotePayment = AO::getModel('sales/quote_payment');
     }
     $quotePayment->setStoreId($payment->getStoreId())->setCustomerPaymentId($payment->getCustomerPaymentId());
     AO::helper('core')->copyFieldset('sales_convert_order_payment', 'to_quote_payment', $payment, $quotePayment);
     //            ->setMethod($payment->getMethod())
     //            ->setAdditionalData($payment->getAdditionalData())
     //            ->setPoNumber($payment->getPoNumber())
     //            ->setCcType($payment->getCcType())
     //            ->setCcNumberEnc($payment->getCcNumberEnc())
     //            ->setCcLast4($payment->getCcLast4())
     //            ->setCcOwner($payment->getCcOwner())
     //            ->setCcCidEnc($payment->getCcCidEnc())
     //            ->setCcExpMonth($payment->getCcExpMonth())
     //            ->setCcExpYear($payment->getCcExpYear())
     //
     //            ->setCcSsIssue($payment->getCcSsIssue())  //for direct payment
     //            ->setCcSsStartMonth($payment->getCcSsStartMonth()) //for direct payment
     //            ->setCcSsStartYear($payment->getCcSsStartYear())  //for direct payment
     //              ;
     return $quotePayment;
 }
Ejemplo n.º 22
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Direct
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setPaymentAction($this->_pro->getConfig()->paymentAction)->setIpAddress(Mage::app()->getRequest()->getClientIp(false))->setAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode())->setInvNum($order->getIncrementId())->setEmail($order->getCustomerEmail())->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setCreditCardType($payment->getCcType())->setCreditCardNumber($payment->getCcNumber())->setCreditCardExpirationDate($this->_getFormattedCcExpirationDate($payment->getCcExpMonth(), $payment->getCcExpYear()))->setCreditCardCvv2($payment->getCcCid())->setMaestroSoloIssueNumber($payment->getCcSsIssue());
     if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) {
         $year = sprintf('%02d', substr($payment->getCcSsStartYear(), -2, 2));
         $api->setMaestroSoloIssueDate($this->_getFormattedCcExpirationDate($payment->getCcSsStartMonth(), $year));
     }
     if ($this->getIsCentinelValidationEnabled()) {
         $this->getCentinelValidator()->exportCmpiData($api);
     }
     // add shipping and billing addresses
     if ($order->getIsVirtual()) {
         $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
     } else {
         $api->setAddress($order->getShippingAddress());
         $api->setBillingAddress($order->getBillingAddress());
     }
     // add line items
     $api->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and import transaction and other payment information
     $api->callDoDirectPayment();
     $this->_importResultToPayment($api, $payment);
     try {
         $api->callGetTransactionDetails();
     } catch (Mage_Core_Exception $e) {
         // if we recieve errors, but DoDirectPayment response is Success, then set Pending status for transaction
         $payment->setIsTransactionPending(true);
     }
     $this->_importResultToPayment($api, $payment);
     return $this;
 }
Ejemplo n.º 23
0
 /**
  * @deprecated after 1.4.0.0-alpha3
  * this method doesn't make sense, because invoice must not void entire authorization
  * there should be method for invoice cancellation
  * @param Mage_Sales_Model_Order_Invoice $invoice
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function processBeforeVoid($invoice, $payment)
 {
     $payment->setVoidTransactionId($invoice->getTransactionId());
     return $this;
 }
Ejemplo n.º 24
0
 /**
  * @param Mage_Sales_Model_Order_Payment $payment
  */
 protected function init(Mage_Sales_Model_Order_Payment $payment)
 {
     $this->setOrder($payment->getOrder());
     $this->setPaymentMethod($payment->getMethodInstance());
 }
Ejemplo n.º 25
0
 /**
  * Build the request with necessary parameters for doAuthorisation() and doTransaction()
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param $amount
  * @return Eway_Rapid31_Model_Request_Direct
  */
 protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     // Empty Varien_Object's data
     $this->unsetData();
     $methodInstance = $payment->getMethodInstance();
     $infoInstance = $methodInstance->getInfoInstance();
     $order = $payment->getOrder();
     $billing = $order->getBillingAddress();
     $shipping = $order->getShippingAddress();
     $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
     if (Mage::helper('ewayrapid')->isBackendOrder()) {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
     } else {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
     }
     $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion());
     $this->setShippingMethod('Other');
     $paymentParam = Mage::getModel('ewayrapid/field_payment');
     $paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode());
     $this->setPayment($paymentParam);
     $customerParam = Mage::getModel('ewayrapid/field_customer');
     $customerParam->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription('')->setStreet1($billing->getStreet1())->setStreet2($billing->getStreet2())->setCity($billing->getCity())->setState($billing->getRegion())->setPostalCode($billing->getPostcode())->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))->setEmail($billing->getEmail())->setPhone($billing->getTelephone())->setMobile('')->setComments('')->setFax($billing->getFax())->setUrl('');
     $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
     $cardDetails->setName($infoInstance->getCcOwner())->setNumber($infoInstance->getCcNumber())->setExpiryMonth($infoInstance->getCcExpMonth())->setExpiryYear($infoInstance->getCcExpYear())->setCVN($infoInstance->getCcCid());
     $customerParam->setCardDetails($cardDetails);
     $this->setCustomer($customerParam);
     $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
     $shippingParam->setFirstName($shipping->getFirstname())->setLastName($shipping->getLastname())->setStreet1($shipping->getStreet1())->setStreet2($shipping->getStreet2())->setCity($shipping->getCity())->setState($shipping->getRegion())->setPostalCode($shipping->getPostcode())->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))->setEmail($shipping->getEmail())->setPhone($shipping->getTelephone())->setFax($shipping->getFax());
     $this->setShippingAddress($shippingParam);
     if ($methodInstance->getConfigData('transfer_cart_items')) {
         $orderItems = $order->getAllVisibleItems();
         $lineItems = array();
         foreach ($orderItems as $orderItem) {
             /* @var Mage_Sales_Model_Order_Item $orderItem */
             $lineItem = Mage::getModel('ewayrapid/field_lineItem');
             $lineItem->setSKU($orderItem->getSku());
             $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
             $lineItem->setQuantity($orderItem->getQtyOrdered());
             $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
             $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
             $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
             $lineItems[] = $lineItem;
         }
         $this->setItems($lineItems);
     }
     return $this;
 }
Ejemplo n.º 26
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Express
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     // prepare api call
     $token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
     $api = $this->_pro->getApi()->setToken($token)->setPayerId($payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))->setAmount($amount)->setPaymentAction($this->_pro->getConfig()->paymentAction)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setInvNum($order->getIncrementId())->setCurrencyCode($order->getBaseCurrencyCode())->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and get details from it
     $api->callDoExpressCheckoutPayment();
     $this->_importToPayment($api, $payment);
     return $this;
 }
Ejemplo n.º 27
0
 /**
  * Generate end return new secure hash value
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return string
  */
 protected function _generateSecureSilentPostHash($payment)
 {
     $secureHash = md5(Mage::helper('core')->getRandomString(10));
     $payment->setAdditionalInformation($this->_secureSilentPostHashKey, $secureHash);
     return $secureHash;
 }
Ejemplo n.º 28
0
 /**
  * Import refund results to payment
  *
  * @param Mage_Paypal_Model_Api_Nvp $api
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param bool $canRefundMore
  */
 protected function _importRefundResultToPayment($api, $payment, $canRefundMore)
 {
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(1)->setShouldCloseParentTransaction(!$canRefundMore)->setTransactionAdditionalInfo(self::TRANSPORT_PAYFLOW_TXN_ID, $api->getPayflowTrxid());
     $payment->setPreparedMessage(Mage::helper('enterprise_pbridge')->__('Payflow PNREF: #%s.', $api->getData(self::TRANSPORT_PAYFLOW_TXN_ID)));
     Mage::getModel('paypal/info')->importToPayment($api, $payment);
 }
Ejemplo n.º 29
0
 /**
  * Return additional information`s transaction_id value of parent transaction model
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return string
  */
 protected function _getRealParentTransactionId($payment)
 {
     $transaction = $payment->getTransaction($payment->getParentTransactionId());
     return $transaction->getAdditionalInformation($this->_realTransactionIdKey);
 }
Ejemplo n.º 30
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Method_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $billingAgreement = Mage::getModel('sales/billing_agreement')->load($payment->getAdditionalInformation(Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID));
     $api = $this->_pro->getApi()->setReferenceId($billingAgreement->getReferenceId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $api->callGetTransactionDetails();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     if ($api->getBillingAgreementId()) {
         $order->addRelatedObject($billingAgreement);
         $billingAgreement->setIsObjectChanged(true);
         $billingAgreement->addOrderRelation($order);
     }
     return $this;
 }