Beispiel #1
0
 /**
  * Called when cancelling an order.
  *
  * @param Varien_Event_Observer $observer
  */
 public function resetPaymentCancelOrder(Varien_Event_Observer $observer)
 {
     /* @var $order Mage_Sales_Model_Order */
     $order = $observer->getPayment()->getOrder();
     /* @var $contactQueue Bronto_Order_Model_Queue */
     Mage::getModel('bronto_order/queue')->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())->setBrontoImported(null)->save();
 }
Beispiel #2
0
 public function checkPoints(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     $paymentMethod = $observer->getPayment()->getMethod();
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $customerPoints = $customer->getPoints();
     $orderSum = $payment->getOrder()->getGrandTotal();
     if ($paymentMethod == "using_points") {
         $currentSumPoints = $customerPoints - $orderSum;
         $customer->setPoints($currentSumPoints);
         $customer->save();
     } else {
         $currentSumPoints = $customerPoints + $orderSum;
         $customer->setPoints($currentSumPoints);
         $customer->save();
     }
 }
 /**
  *
  * @param Varien_Event_Observer $observer (has data 'payment' with a payment info instance (Mage_Sales_Model_Order_Payment))
  */
 public function cancelPayment(Varien_Event_Observer $observer)
 {
     /** @var $payment Mage_Sales_Model_Order_Payment */
     $payment = $observer->getPayment();
     $methodInstance = $payment->getMethodInstance();
     if ($methodInstance instanceof Payone_Core_Model_Payment_Method_Abstract) {
         $methodInstance->cancel($payment);
     }
 }
Beispiel #4
0
 public function sales_order_payment_refund(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     $creditmemo = $observer->getCreditmemo();
     if (!$creditmemo->getTransactionKey()) {
         $creditmemo->setTransactionKey($payment->getTransactionKey())->save();
         $payment->setTransactionKey(null)->save();
         //the transaction key needs to be reset after every refund
     }
     $order = $creditmemo->getOrder();
     $this->_updateRefundedOrderStatus($creditmemo, $order, true);
     return $this;
 }
Beispiel #5
0
 /**
  * Adds Payment Fee to order
  * @param Varien_Event_Observer $observer
  */
 public function sales_order_payment_place_end(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     if ($payment->getMethodInstance()->getCode() !== 'payexinvoice') {
         return;
     }
     $order = $payment->getOrder();
     $base_fee = $order->getQuote()->getBasePayexinvoicePaymentFee();
     $fee = $order->getQuote()->getPayexinvoicePaymentFee();
     $order->setBasePayexinvoicePaymentFee($base_fee);
     $order->setPayexinvoicePaymentFee($fee);
     $order->save();
 }
 public function getPaymentInfo(Varien_Event_Observer $observer)
 {
     $transport = $observer->getTransport();
     $payment = $observer->getPayment();
     if ($payment->getAdditionalInformation('payment_currency')) {
         $transport['Payment Currency'] = $payment->getAdditionalInformation('payment_currency');
     }
     if ($payment->getAdditionalInformation('due_amount')) {
         $transport['Amount Due'] = $payment->getAdditionalInformation('due_amount');
     }
     if ($payment->getAdditionalInformation('exchange_rate')) {
         $transport['Exchange Rate'] = $payment->getAdditionalInformation('exchange_rate');
     }
     return;
 }
Beispiel #7
0
 public function salesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     if ($payment->getMethodInstance()->getCode() != 'billmateinvoice') {
         return;
     }
     $info = $payment->getMethodInstance()->getInfoInstance();
     $quote = Mage::getSingleton('checkout/session')->getQuote();
     if (!$quote->getId()) {
         $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
     }
     //Set the invoice fee included tax value
     $info->setAdditionalInformation('billmateinvoice_fee', $quote->getFeeAmount());
     $info->setAdditionalInformation('billmateinvoice_fee_tax', $quote->getFeeTaxAmount());
     $info->save();
 }
 /**
  * Adds codFee to order
  * 
  * @param Varien_Event_Observer $observer
  */
 public function sales_order_payment_place_end(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     if ($payment->getMethodInstance()->getCode() != 'cashondelivery') {
         return;
     }
     $order = $payment->getOrder();
     $quote = Mage::getSingleton('checkout/session')->getQuote();
     if (!$quote->getId()) {
         $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
     }
     $order->setCodFee($quote->getCodFee());
     $order->setBaseCodFee($quote->getBaseCodFee());
     $order->setCodTaxAmount($quote->getCodTaxAmount());
     $order->setBaseCodTaxAmount($quote->getBaseCodTaxAmount());
     $order->save();
 }
Beispiel #9
0
 public function salesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     if (substr($payment->getMethodInstance()->getCode(), 0, 5) != 'sisow') {
         return;
     }
     $info = $payment->getMethodInstance()->getInfoInstance();
     $quote = Mage::getSingleton('checkout/session')->getQuote();
     if (!$quote->getId()) {
         $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
     }
     //Set the payment fee included tax value
     $info->setAdditionalInformation('invoice_fee', $quote->getInvoiceFee());
     $info->setAdditionalInformation('base_invoice_fee', $quote->getBaseInvoiceFee());
     $info->setAdditionalInformation('invoice_fee_exluding_vat', $quote->getInvoiceFeeExcludedVat());
     $info->setAdditionalInformation('base_invoice_fee_exluding_vat', $quote->getBaseInvoiceFeeExcludedVat());
     //Set the payment fee tax amount
     $info->setAdditionalInformation('invoice_tax_amount', $quote->getInvoiceTaxAmount());
     $info->setAdditionalInformation('base_invoice_tax_amount', $quote->getBaseInvoiceTaxAmount());
     //Set the payment fee rate used
     $info->setAdditionalInformation('invoice_fee_rate', $quote->getInvoiceFeeRate());
     $info->save();
 }
Beispiel #10
0
 /**
  * Process the seamless Payment after Order is complete
  *
  * @param Varien_Event_Observer $observer
  *
  * @throws Exception
  * @return Wirecard_CheckoutSeamless_Model_Observer
  */
 public function salesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
 {
     /** @var Mage_Checkout_Model_Session $session */
     $session = Mage::getSingleton('checkout/session');
     /** @var Wirecard_CheckoutSeamless_Helper_Data $helper */
     $helper = Mage::helper('wirecard_checkoutseamless');
     $payment = $observer->getPayment();
     $this->_order = $payment->getOrder();
     /** @var Wirecard_CheckoutSeamless_Model_Abstract $paymentInstance */
     $paymentInstance = $payment->getMethodInstance();
     if (!$paymentInstance instanceof Wirecard_CheckoutSeamless_Model_Abstract) {
         return $this;
     }
     $init = $paymentInstance->initPayment($session->getWirecardCheckoutSeamlessStorageId(), $session->getQuoteId());
     if ($init->getStatus() == WirecardCEE_QMore_Response_Initiation::STATE_SUCCESS) {
         $helper->log(__METHOD__ . ':setting redirect url:' . $init->getRedirectUrl());
         Mage::getSingleton('core/session')->unsWirecardCheckoutSeamlessPaymentInfo();
         $session->setWirecardCheckoutSeamlessRedirectUrl($init->getRedirectUrl());
     } else {
         Mage::getSingleton('core/session')->unsWirecardCheckoutSeamlessPaymentInfo();
     }
     return $this;
 }
Beispiel #11
0
 /**
  * Method to send a partial (refund) or total (cancel) refund to aplazame when a creditmemo is created
  *
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function salesOrderPaymentRefund($observer)
 {
     /** @var Mage_Sales_Model_Order_Payment $payment */
     $payment = $observer->getPayment();
     /** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
     $creditmemo = $observer->getCreditmemo();
     /** @var Mage_Sales_Model_Order $order */
     $order = $payment->getOrder();
     if (!$this->is_aplazame_payment($order)) {
         return $this;
     }
     $remainingAmountAfterRefund = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded();
     $refundedTotal = $creditmemo->getBaseGrandTotal();
     /** @var Aplazame_Aplazame_Model_Api_Client $client */
     $client = Mage::getModel('aplazame/api_client');
     if ($remainingAmountAfterRefund == 0) {
         //total is refunded so we cancel order at aplazame side
         $client->cancelOrder($order);
     } else {
         //partial refund so we refund at aplazame side
         $client->refundAmount($order, $refundedTotal);
     }
     return $this;
 }
Beispiel #12
0
 /**
  * Add custom data to the payment info block
  *
  * @param Varien_Event_Observer $observer
  * @return void
  */
 public function paymentInfoBlockPrepareSpecificInformation(Varien_Event_Observer $observer)
 {
     /** @var $payment Mage_Sales_Model_Quote_Payment */
     $payment = $observer->getPayment();
     /** @var $transport Varien_Object */
     $transport = $observer->getTransport();
     $paymentMethod = $payment->getMethod();
     // Display custom data for supported payment methods only
     /** @var $helper CLS_Paypal_Helper_Data */
     $helper = Mage::helper('cls_paypal');
     if ($helper->isSupportedPaymentMethod($paymentMethod)) {
         if ($payment->hasAdditionalInformation('cc_save_future')) {
             $transport->setData($helper->__('Save this card for future use'), $helper->__('Yes'));
         }
     }
 }
Beispiel #13
0
 public function savePayment(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     $order = $payment->getOrder();
     $pmName = $payment->getMethodInstance()->getCode();
     $param = Mage::app()->getFrontController()->getRequest()->getParam('payment');
     $paymentMethod = isset($param[$pmName . '_paymentmethod']) ? $param[$pmName . '_paymentmethod'] : $param['method'];
     $issuer = isset($param[$pmName . '_issuer']) ? $param[$pmName . '_issuer'] : '0';
     $country = isset($param[$pmName . '_country']) ? $param[$pmName . '_country'] : $order->getBillingAddress()->getCountryId();
     if ($country == "00") {
         $country = $order->getBillingAddress()->getCountryId();
     }
     $ice_payment = array('ic_merchantid' => Mage::helper('icecore')->getMerchantIDForStore($order->getStore()->getId()), 'ic_currency' => $order->getOrderCurrencyCode(), 'ic_amount' => Mage::helper('icecore')->formatTotal($order->getGrandTotal()), 'ic_description' => Mage::helper('icecore')->getTransactionDescription($order->getRealOrderId()), 'ic_country' => $country, 'ic_language' => Mage::helper("icecore")->getLangISO2(), 'ic_reference' => $order->getRealOrderId(), 'ic_paymentmethod' => $paymentMethod, 'ic_issuer' => $issuer, 'ic_orderid' => $order->getRealOrderId(), 'ic_moduleid' => $this->getAuthID(), 'ic_authkey' => $this->getAuthKey($order->getStore()->getId()));
     $data = array('order_id' => $order->getRealOrderId(), 'model' => $pmName, 'transaction_data' => urlencode(serialize($ice_payment)), 'store_id' => $order->getStore()->getId(), 'status' => Icepay_IceCore_Model_Config::STATUS_NEW, 'update_time' => now(), 'creation_time' => now());
     $this->_getWriteAdapter()->insert($this->getTable('icepay_transactions'), $data);
 }
Beispiel #14
0
 /**
  * resets the order status back to pending payment in case of direct debits nl with order id as merchant ref
  * @event sales_order_payment_place_end
  * @param Varien_Event_Observer $event
  */
 public function setOrderStateForDirectDebitsNl(Varien_Event_Observer $event)
 {
     $payment = $event->getPayment();
     if ($payment->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_DirectDebit && Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment) && $payment->getAdditionalInformation('PM') == 'Direct Debits NL' && $payment->getAdditionalInformation('STATUS') == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING) {
         $payment->getOrder()->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
         $payment->getOrder()->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
     }
 }
Beispiel #15
0
 public function sales_order_payment_place_end(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     $paymentMethodCode = $payment->getMethodInstance()->getCode();
     if (strpos($paymentMethodCode, 'icepayadv_') === false) {
         return;
     }
     if ($this->coreSQL()->isActive("iceadvanced")) {
         $this->coreSQL()->savePayment($observer);
     }
     return;
 }
 /**
  * Process the seamless Payment after Order is complete
  *
  * @param Varien_Event_Observer $observer
  *
  * @throws Exception
  * @return Phoenix_WirecardCheckoutPage_Model_Observer
  */
 public function salesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
 {
     /**
      * @var Phoenix_WirecardCheckoutPage_Model_Abstract
      */
     $payment = $observer->getPayment();
     $this->_order = $payment->getOrder();
     $storeId = $this->_order->getStoreId();
     $paymentInstance = $payment->getMethodInstance();
     if (Mage::getStoreConfigFlag('payment/' . $payment->getMethod() . '/useSeamless', $storeId)) {
         $storageId = $payment->getAdditionalData();
         $orderIdent = $this->_order->getQuoteId();
         $customerId = Mage::getStoreConfig('payment/' . $payment->getMethod() . '/customer_id', $storeId);
         $shopId = Mage::getStoreConfig('payment/' . $payment->getMethod() . '/shop_id', $storeId);
         $secretKey = Mage::getStoreConfig('payment/' . $payment->getMethod() . '/secret_key', $storeId);
         $serviceUrl = Mage::getUrl(Mage::getStoreConfig('payment/' . $payment->getMethod() . '/service_url', $storeId));
         $paymentType = $this->_getMappedPaymentCode($payment->getMethod());
         $returnurl = Mage::getUrl('wirecard_checkout_page/processing/checkresponse', array('_secure' => true, '_nosid' => true));
         $pluginVersion = WirecardCEE_Client_QPay_Request_Initiation::generatePluginVersion('Magento', Mage::getVersion(), $paymentInstance->getPluginName(), $paymentInstance->getPluginVersion());
         $initiation = new WirecardCEE_Client_QPay_Request_Initiation($customerId, $shopId, $secretKey, substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2), $pluginVersion);
         $consumerData = new WirecardCEE_Client_QPay_Request_Initiation_ConsumerData();
         if (Mage::getStoreConfigFlag('payment/' . $payment->getMethod() . '/send_additional_data', $storeId)) {
             $consumerData->setEmail($this->_order->getCustomerEmail());
             $dob = $payment->getMethodInstance()->getCustomerDob();
             if ($dob) {
                 $consumerData->setBirthDate($dob);
             }
             $consumerData->addAddressInformation($this->_getBillingObject());
             if ($this->_order->hasShipments()) {
                 $consumerData->addAddressInformation($this->_getShippingObject());
             }
         }
         if ($payment->getMethod() == 'wirecard_checkout_page_invoice' || $payment->getMethod() == 'wirecard_checkout_page_installment') {
             $consumerData->setEmail($this->_order->getCustomerEmail());
             $dob = $payment->getMethodInstance()->getCustomerDob();
             if ($dob) {
                 $consumerData->setBirthDate($dob);
             } else {
                 throw new Exception('Invalid dob');
             }
             $consumerData->addAddressInformation($this->_getBillingObject('invoice'));
         }
         $consumerData->setIpAddress($this->_order->getRemoteIp());
         $consumerData->setUserAgent(Mage::app()->getRequest()->getServer('HTTP_USER_AGENT'));
         $initiation->setConfirmUrl(Mage::getUrl('wirecard_checkout_page/processing/seamlessConfirm', array('_secure' => true, '_nosid' => true)));
         $initiation->setWindowName('paymentIframe');
         $initiation->orderId = $this->_order->getIncrementId();
         $initiation->companyTradeRegistryNumber = $payment->getMethodInstance()->getCompanyTradeRegistrationNumber();
         if ($orderIdent && $storageId) {
             $initiation->setStorageReference($orderIdent, $storageId);
         }
         if (Mage::getStoreConfigFlag('payment/' . $payment->getMethod() . '/auto_deposit', $storeId)) {
             $initiation->setAutoDeposit(true);
         }
         $initiation->setOrderReference($this->_order->getIncrementId());
         $financialInstitution = $payment->getMethodInstance()->getFinancialInstitution();
         if ($financialInstitution) {
             $initiation->setFinancialInstitution($financialInstitution);
         }
         Phoenix_WirecardCheckoutPage_Helper_Configuration::configureWcsLibrary();
         $response = $initiation->initiate(round($this->_order->getBaseGrandTotal(), 2), $this->_order->getBaseCurrencyCode(), $paymentType, $this->_order->getIncrementId(), $returnurl, $returnurl, $returnurl, $returnurl, $serviceUrl, $consumerData);
         if (isset($response) && $response->getStatus() == WirecardCEE_Client_QPay_Response_Initiation::STATE_SUCCESS) {
             $payment->setAdditionalData(serialize($payment->getAdditionalData()))->save();
             Mage::getSingleton('core/session')->unsetData('wirecard_checkout_page_payment_info');
             Mage::getSingleton('core/session')->setWirecardCheckoutPageRedirectUrl(urldecode($response->getRedirectUrl()));
         } elseif (isset($response)) {
             $errorMessage = '';
             foreach ($response->getErrors() as $error) {
                 $errorMessage .= ' ' . $error->getMessage();
             }
             throw new Exception(trim($errorMessage));
         } else {
             $payment->setAdditionalData(serialize($payment->getAdditionalData()))->save();
             Mage::getSingleton('core/session')->unsetData('wirecard_checkout_page_payment_info');
         }
     }
     return $this;
 }
Beispiel #17
0
 /**
  * Adds Payment Fee to order
  * @param Varien_Event_Observer $observer
  */
 public function sales_order_payment_place_end(Varien_Event_Observer $observer)
 {
     $_allowed_methods = array('payex_financing', 'payex_partpayment', 'payex_invoice');
     $payment = $observer->getPayment();
     if (!in_array($payment->getMethodInstance()->getCode(), $_allowed_methods)) {
         return;
     }
     $order = $payment->getOrder();
     $order->setBasePayexPaymentFee($order->getQuote()->getBasePayexPaymentFee());
     $order->setBasePayexPaymentFeeTax($order->getQuote()->getBasePayexPaymentFeeTax());
     $order->setPayexPaymentFee($order->getQuote()->getPayexPaymentFee());
     $order->setPayexPaymentFeeTax($order->getQuote()->getPayexPaymentFeeTax());
     $order->save();
 }
 /**
  * Adds Payment Fee to order
  * @param Varien_Event_Observer $observer
  */
 public function sales_order_payment_place_end(Varien_Event_Observer $observer)
 {
     $payment = $observer->getPayment();
     if (!preg_match('/^capayable/', $payment->getMethodInstance()->getCode())) {
         return;
     }
     $order = $payment->getOrder();
     $quote = Mage::getSingleton('checkout/session')->getQuote();
     if (!$quote->getId()) {
         $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
     }
     $order->setCapayableFee($quote->getCapayableFee());
     $order->setBaseCapayableFee($quote->getBaseCapayableFee());
     $order->setCapayableFeeTaxAmount($quote->getCapayableFeeTaxAmount());
     $order->setBaseCapayableFeeTaxAmount($quote->getBaseCapayableFeeTaxAmount());
     $order->save();
 }