public function order(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     $order_id = $order->getId();
     $order_increment_id = $order->getIncrementId();
     $store_id = $order->getStoreId();
     $ccType = $payment->getCcType();
     // reorder
     $reorder_increment_id = explode('-', $order_increment_id);
     // reorder
     $order_increment_id = $reorder_increment_id[0];
     $order_suffix_id = @$reorder_increment_id[1];
     $expiration = strtotime('+' . $this->_getStoreConfig($ccType, 'expiration') . 'days');
     $transaction_expiration = date('Y-m-d', $expiration);
     $increment = $this->_getStoreConfig('slips', 'order_id_increment');
     $order_increment_prefix = $this->_getOrderIncrementPrefix($store_id);
     $number = $order_increment_id - $order_increment_prefix;
     if (!empty($order_suffix_id)) {
         $number *= pow(10, strlen($order_suffix_id));
         $number += $order_suffix_id;
     }
     $number += $increment;
     $data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $number);
     $result = Mage::getModel('utils/sql')->insert('gamuza_slips_transactions', $data);
     if (!$result) {
         Mage::throwException(Mage::helper('slips')->__('Unable to save the Slip and Deposit informations. Please verify your database.'));
     }
     $this->setStore($payment->getOrder()->getStoreId());
     $payment->setAmount($amount);
     $payment->setLastTransId($order_id);
     $payment->setStatus(self::STATUS_APPROVED);
     return $this;
 }
Example #2
0
 /**
  * Perform operation before save
  *
  * @param Varien_Object $object
  * @return Mage_Sales_Model_Resource_Order_Attribute_Backend_Child
  */
 public function beforeSave($object)
 {
     if ($object->getOrder()) {
         $object->setParentId($object->getOrder()->getId());
     }
     parent::beforeSave($object);
     return $this;
 }
Example #3
0
 /**
  * Method is invoked before save
  *
  * @param Varien_Object $object
  * @return Mage_Sales_Model_Resource_Order_Invoice_Attribute_Backend_Order
  */
 public function beforeSave($object)
 {
     if ($object->getOrder()) {
         $object->setOrderId($object->getOrder()->getId());
         $object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId());
     }
     return parent::beforeSave($object);
 }
Example #4
0
 /**
  * Request an online refund
  * 
  * @param Varien_Object $payment
  * @param string $amount
  * 
  * @since 1.0.2
  * @return \Icepay_IceAdvanced_Model_Checkout_Standard
  */
 public function refund(Varien_Object $payment, $amount)
 {
     // Get Magento Order
     $order = $payment->getOrder();
     // Get StoreId
     $storeId = $order->getStoreId();
     // Check if Auto Refund is enabled
     if (!Mage::getStoreConfig(Icepay_IceCore_Model_Config::AUTOREFUND, $storeId)) {
         return $this;
     }
     // Fetch ICEPAY merchant settings
     $merchantID = Mage::getStoreConfig(Icepay_IceCore_Model_Config::MERCHANTID, $storeId);
     $secretCode = Mage::getStoreConfig(Icepay_IceCore_Model_Config::SECRETCODE, $storeId);
     // Get CurrencyCode
     $currency = $order->getOrderCurrencyCode();
     // Amount must be in cents
     $amount = (int) (string) ($amount * 100);
     // Fetch ICEPAY Payment ID
     $paymentID = $payment->getLastTransId();
     // Setup webservice
     $webservice = Mage::getModel('Icepay_IceAdvanced_Model_Webservice_Refund');
     $webservice->init($merchantID, $secretCode);
     // Request refund
     try {
         $webservice->requestRefund($paymentID, $amount, $currency);
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError("ICEPAY: Refund Failed! {$e->getMessage()}");
         Mage::helper('icecore')->log("ICEPAY: Refund Failed! {$e->getMessage()}");
     }
     return $this;
 }
Example #5
0
 /**
  * Getting all available childs for Invoice, Shipmen or Creditmemo item
  *
  * @param Varien_Object $item
  * @return array
  */
 public function getChilds($item)
 {
     $_itemsArray = array();
     if ($item instanceof Mage_Sales_Model_Order_Item) {
         $_items = $item->getOrder()->getAllItems();
     } else {
         if ($item instanceof Mage_Sales_Model_Order_Invoice_Item) {
             $_items = $item->getInvoice()->getAllItems();
         } else {
             if ($item instanceof Mage_Sales_Model_Order_Shipment_Item) {
                 $_items = $item->getShipment()->getAllItems();
             } else {
                 if ($item instanceof Mage_Sales_Model_Order_Creditmemo_Item) {
                     $_items = $item->getCreditmemo()->getAllItems();
                 }
             }
         }
     }
     if ($_items) {
         foreach ($_items as $_item) {
             $parentItem = $_item->getParentItem();
             if ($parentItem) {
                 $_itemsArray[$parentItem->getId()][$_item->getId()] = $_item;
             } else {
                 $_itemsArray[$_item->getId()][$_item->getId()] = $_item;
             }
         }
     }
     if (isset($_itemsArray[$item->getId()])) {
         return $_itemsArray[$item->getId()];
     } else {
         return null;
     }
 }
Example #6
0
 /**
  * @param  Mage_Sales_Model_Order_Payment  $payment
  * @param  float                           $amount
  * @return Bitpay_Core_Model_PaymentMethod
  */
 public function authorize(Varien_Object $payment, $amount, $iframe = false)
 {
     if (false === isset($payment) || false === isset($amount) || true === empty($payment) || true === empty($amount)) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::authorize(): missing payment or amount parameters.');
         throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::authorize(): missing payment or amount parameters.');
     }
     $amount = $payment->getOrder()->getQuote()->getGrandTotal();
     $this->debugData('[INFO] Bitpay_Core_Model_Method_Bitcoin::authorize(): authorizing new order.');
     // Create BitPay Invoice
     $invoice = $this->initializeInvoice();
     if (false === isset($invoice) || true === empty($invoice)) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::authorize(): could not initialize invoice.');
         throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::authorize(): could not initialize invoice.');
     }
     $invoice = $this->prepareInvoice($invoice, $payment, $amount);
     try {
         $bitpayInvoice = \Mage::helper('bitpay')->getBitpayClient()->createInvoice($invoice);
     } catch (\Exception $e) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::authorize(): ' . $e->getMessage());
         \Mage::throwException('In Bitpay_Core_Model_Method_Bitcoin::authorize(): Could not authorize transaction.');
     }
     self::$_redirectUrl = Mage::getStoreConfig('payment/bitpay/fullscreen') ? $bitpayInvoice->getUrl() : $bitpayInvoice->getUrl() . '&view=iframe';
     $this->debugData(array('[INFO] BitPay Invoice created', sprintf('Invoice URL: "%s"', $bitpayInvoice->getUrl())));
     $quote = \Mage::getSingleton('checkout/session')->getQuote();
     $order = \Mage::getModel('sales/order')->load($quote->getId(), 'quote_id');
     // Save BitPay Invoice in database for reference
     $mirrorInvoice = \Mage::getModel('bitpay/invoice')->prepareWithBitpayInvoice($bitpayInvoice)->prepareWithOrder(array('increment_id' => $order->getIncrementId(), 'quote_id' => $quote->getId()))->save();
     $this->debugData('[INFO] Leaving Bitpay_Core_Model_Method_Bitcoin::authorize(): invoice id ' . $bitpayInvoice->getId());
     return $this;
 }
 public function capture(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     $billing = $order->getBillingAddress();
     $shipping = $order->getShippingAddress();
     $amount = round($order->getGrandTotal(), 2);
     try {
         $params = array("sellerId" => $this->getSid(), "merchantOrderId" => $order->getIncrementId(), "token" => Mage::app()->getRequest()->getParam('token'), "currency" => $order->getOrderCurrencyCode(), "total" => $amount, "billingAddr" => array("name" => $billing->getName(), "addrLine1" => $billing->getStreet(1), "addrLine2" => $billing->getStreet(2), "city" => $billing->getCity(), "state" => $billing->getRegion(), "zipCode" => $billing->getPostcode(), "country" => $billing->getCountry(), "email" => $order->getCustomerEmail(), "phoneNumber" => $billing->getTelephone()));
         if ($shipping) {
             $shippingAddr = array("name" => $shipping->getName(), "addrLine1" => $shipping->getStreet(1), "addrLine2" => $shipping->getStreet(2), "city" => $shipping->getCity(), "state" => $shipping->getRegion(), "zipCode" => $shipping->getPostcode(), "country" => $shipping->getCountry(), "email" => $order->getCustomerEmail(), "phoneNumber" => $billing->getTelephone());
             array_merge($shippingAddr, $params);
         }
         $charge = Twocheckout_Charge::auth($params);
     } catch (Twocheckout_Error $e) {
         Mage::throwException(Mage::helper('paygate')->__($e->getMessage()));
     }
     if ($charge['response']['responseCode'] == 'APPROVED') {
         $payment->setTransactionId($charge['response']['transactionId'])->setIsTransactionClosed(0);
         $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
         $order->setData('ext_order_id', $charge['response']['transactionId']);
         $order->save();
     } else {
         Mage::throwException(Mage::helper('paygate')->__('Payment capturing error: %s', "Could not Authorize Transaction"));
     }
     return $this;
 }
 /**
  * @param Varien_Object $payment
  * @param $amount
  * @param array $extraConfig
  * @return mixed
  */
 protected function _createCharge(Varien_Object $payment, $amount, $extraConfig = array())
 {
     $config = array();
     $scretKey = $this->getConfigData('privatekey');
     $order = $payment->getOrder();
     $billingAddress = $order->getBillingAddress();
     $shippingAddress = $order->getBillingAddress();
     $orderedItems = $order->getAllItems();
     $currencyDesc = $order->getBaseCurrencyCode();
     $orderId = $order->getIncrementId();
     $Api = CheckoutApi_Api::getApi(array('mode' => $this->getConfigData('mode')));
     $amountCents = $Api->valueToDecimal($amount, $currencyDesc);
     $street = Mage::helper('customer/address')->convertStreetLines($billingAddress->getStreet(), 2);
     $billingAddressConfig = array('addressLine1' => $street[0], 'addressLine2' => $street[1], 'postcode' => $billingAddress->getPostcode(), 'country' => $billingAddress->getCountry(), 'city' => $billingAddress->getCity(), 'phone' => array('number' => $billingAddress->getTelephone()));
     $street = Mage::helper('customer/address')->convertStreetLines($shippingAddress->getStreet(), 2);
     $shippingAddressConfig = array('addressLine1' => $street[0], 'addressLine2' => $street[1], 'postcode' => $shippingAddress->getPostcode(), 'country' => $shippingAddress->getCountry(), 'city' => $shippingAddress->getCity(), 'phone' => array('number' => $shippingAddress->getTelephone()), 'recipientName' => $shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname());
     $products = array();
     foreach ($orderedItems as $item) {
         $product = Mage::getModel('catalog/product')->load($item->getProductId());
         $products[] = array('name' => $item->getName(), 'sku' => $item->getSku(), 'price' => $item->getPrice(), 'quantity' => $item->getQtyOrdered(), 'image' => Mage::helper('catalog/image')->init($product, 'image')->__toString());
     }
     $config = array();
     $config['authorization'] = $scretKey;
     $config['mode'] = $this->getConfigData('mode');
     $config['timeout'] = $this->getConfigData('timeout');
     $config['postedParam'] = array('value' => $amountCents, 'currency' => $currencyDesc, 'shippingDetails' => $shippingAddressConfig, 'products' => $products, 'description' => "Order number::{$orderId}", 'metadata' => array("trackId" => $orderId), 'card' => array('billingDetails' => $billingAddressConfig));
     $config['postedParam'] = array_merge($config['postedParam'], $extraConfig);
     return $config;
 }
 public function order(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     //montaremos os dados a ser enviados via POST pra api em $params
     $params = Mage::helper('ricardomartins_pagseguro/internal')->getCreditCardApiCallParams($order, $payment);
     //chamamos a API
     $xmlRetorno = $this->callApi($params, $payment);
     $this->proccessNotificatonResult($xmlRetorno);
     if (isset($xmlRetorno->errors)) {
         $errMsg = array();
         foreach ($xmlRetorno->errors as $error) {
             $errMsg[] = (string) $error->message . '(' . $error->code . ')';
         }
         Mage::throwException('Um ou mais erros ocorreram no seu pagamento.' . PHP_EOL . implode(PHP_EOL, $errMsg));
     }
     if (isset($xmlRetorno->code)) {
         $additional = array('transaction_id' => (string) $xmlRetorno->code);
         if ($existing = $payment->getAdditionalInformation()) {
             if (is_array($existing)) {
                 $additional = array_merge($additional, $existing);
             }
         }
         $payment->setAdditionalInformation($additional);
     }
     return $this;
 }
Example #10
0
 /**
  * Get "double" prices html (block with base and place currency)
  *
  * @param   Varien_Object $dataObject
  * @param   float $basePrice
  * @param   float $price
  * @param   bool $strong
  * @param   string $separator
  * @return  string
  */
 public function displayPrices($dataObject, $basePrice, $price, $strong = false, $separator = '<br/>')
 {
     $order = false;
     if ($dataObject instanceof Mage_Sales_Model_Order) {
         $order = $dataObject;
     } else {
         $order = $dataObject->getOrder();
     }
     if ($order && $order->isCurrencyDifferent()) {
         $res = '<strong>';
         $res .= $order->formatBasePrice($basePrice);
         $res .= '</strong>' . $separator;
         $res .= '[' . $order->formatPrice($price) . ']';
     } elseif ($order) {
         $res = $order->formatPrice($price);
         if ($strong) {
             $res = '<strong>' . $res . '</strong>';
         }
     } else {
         $res = Mage::app()->getStore()->formatPrice($price);
         if ($strong) {
             $res = '<strong>' . $res . '</strong>';
         }
     }
     return $res;
 }
Example #11
0
 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object $object
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     if ($this->getAttribute() == 'payment_method' && !$object->hasPaymentMethod()) {
         if ($object->getOrder()) {
             $object->setPaymentMethod($object->getOrder()->getPayment()->getMethod());
         } else {
             $object->setPaymentMethod($object->getPayment()->getMethod());
         }
     }
     if ($object instanceof Mage_Sales_Model_Order_Shipment) {
         $object = $object->getOrder();
     }
     #Zend_Debug::dump($object->getData());
     #Zend_Debug::dump($this->validateAttribute($object->getData($this->getAttribute())), $object->getData($this->getAttribute()));
     return $this->validateAttribute($object->getData($this->getAttribute()));
 }
Example #12
0
 /**
  * Capture (confirm) an open transaction ('AUTHORIZED') at svea. We use the
  * ConfirmTransaction class directly because the operation is simple.
  *
  * @param Varien_Object $payment
  * @param float $amount
  * @return $this|void
  * @throws Mage_Payment_Exception
  */
 public function capture(Varien_Object $payment, $amount)
 {
     $sveaOrderId = $payment->getParentTransactionId();
     if (null === $sveaOrderId) {
         // If there is no previous authorization
         $sveaOrderId = $payment->getTransactionId();
     }
     $order = $payment->getOrder();
     $paymentMethodConfig = $this->getSveaStoreConfClass($order->getStoreId());
     $config = new SveaMageConfigProvider($paymentMethodConfig);
     $countryId = $order->getBillingAddress()->getCountryId();
     $confirmTransactionRequest = new Svea\HostedService\ConfirmTransaction($config);
     $confirmTransactionRequest->countryCode = $countryId;
     $confirmTransactionRequest->transactionId = $sveaOrderId;
     $defaultCaptureDate = explode('T', date('c'));
     // [0] contains date part
     $confirmTransactionRequest->captureDate = $defaultCaptureDate[0];
     $response = $confirmTransactionRequest->doRequest();
     if ($response->accepted !== 1) {
         $message = 'Capture failed for transaction ' . $sveaOrderId . ': ' . $response->errormessage . ' (' . $response->resultcode . ')';
         throw new Mage_Payment_Exception($message);
     }
     $result = $this->_flatten($response);
     $payment->setIsTransactionClosed(true)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
     return $this;
 }
Example #13
0
 /**
  * Try to create a card record from legacy data.
  */
 public function importLegacyData(Varien_Object $payment)
 {
     // Customer ID -- pull from customer if possible, otherwise go to Authorize.Net.
     if ($this->getCustomer()->getAuthnetcimProfileId() != '') {
         $this->setProfileId($this->getCustomer()->getAuthnetcimProfileId());
     } else {
         $this->_createCustomerProfile();
     }
     // Payment ID -- pull from order if possible.
     $this->setPaymentId($payment->getOrder()->getExtCustomerId());
     if ($this->getProfileId() == '' || $this->getPaymentId() == '') {
         Mage::helper('tokenbase')->log($this->getMethod(), 'Authorize.Net CIM: Unable to covert legacy data for processing. Please seek support.');
         Mage::throwException(Mage::helper('tokenbase')->__('Authorize.Net CIM: Unable to covert legacy data for processing. Please seek support.'));
     }
     if ($payment->getCcType() != '') {
         $this->setAdditional('cc_type', $payment->getCcType());
     }
     if ($payment->getCcLast4() != '') {
         $this->setAdditional('cc_last4', $payment->getCcLast4());
     }
     if ($payment->getCcExpYear() > date('Y') || $payment->getCcExpYear() == date('Y') && $payment->getCcExpMonth() >= date('n')) {
         $this->setAdditional('cc_exp_year', $payment->getCcExpYear())->setAdditional('cc_exp_month', $payment->getCcExpMonth())->setExpires(sprintf("%s-%s-%s 23:59:59", $payment->getCcExpYear(), $payment->getCcExpMonth(), date('t', strtotime($payment->getCcExpYear() . '-' . $payment->getCcExpMonth()))));
     }
     return $this;
 }
Example #14
0
 /**
  * For Svea, Deliver order
  *
  * @param Varien_Object $payment
  * @param float $amount
  * @return type
  */
 public function capture(Varien_Object $payment, $amount)
 {
     //Alternative: $sveaOrderId = $payment->getTransactionId(), comes with -capture
     $sveaOrderId = $this->getInfoInstance()->getAdditionalInformation('svea_order_id');
     if (empty($sveaOrderId)) {
         if (!$this->getConfigData('autodeliver')) {
             $errorTranslated = Mage::helper('svea_webpay')->responseCodes("", 'no_orderid');
             Mage::throwException($errorTranslated);
         }
         $sveaOrderId = $this->getInfoInstance()->getAdditionalInformation('svea_order_id');
     }
     $order = $payment->getOrder();
     $countryCode = $order->getBillingAddress()->getCountryId();
     $paymentMethodConfig = $this->getSveaStoreConfClass($order->getStoreId());
     $conf = new SveaMageConfigProvider($paymentMethodConfig);
     $sveaObject = WebPay::deliverOrder($conf);
     $response = $sveaObject->setCountryCode($countryCode)->setOrderId($sveaOrderId)->deliverPaymentPlanOrder()->doRequest();
     if ($response->accepted == 1) {
         $successMessage = Mage::helper('svea_webpay')->__('delivered');
         $orderStatus = $this->getConfigData('paid_order_status') ?: $order->getStatus();
         if (!empty($orderStatus)) {
             $order->addStatusToHistory($orderStatus, $successMessage, false);
         }
         $rawDetails = $this->_sveaResponseToArray($response);
         $payment->setTransactionId($response->contractNumber)->setIsTransactionClosed(false)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $rawDetails);
     } else {
         $errorMessage = $response->errormessage;
         $statusCode = $response->resultcode;
         $errorTranslated = Mage::helper('svea_webpay')->responseCodes($statusCode, $errorMessage);
         $order->addStatusToHistory($order->getStatus(), $errorTranslated, false);
         Mage::throwException($errorTranslated);
     }
 }
Example #15
0
 /**
  * @param null|Varien_Object $dataObject
  * @return Xcom_Xfabric_Model_Message_Request
  */
 public function _prepareData(Varien_Object $dataObject = null)
 {
     $avroDataObject = Mage::getModel('xcom_chronicle/message_order', array('order' => $dataObject->getOrder(), 'type' => 'regular'));
     $data = array('cancelledOrders' => array($avroDataObject->toArray()));
     $this->setMessageData($data);
     return parent::_prepareData($dataObject);
 }
Example #16
0
 /**
  * @param null|Varien_Object $dataObject
  * @return Xcom_Xfabric_Model_Message_Request
  */
 public function _prepareData(Varien_Object $dataObject = null)
 {
     $avroDataObject = Mage::getModel('xcom_chronicle/message_customer_guest', $dataObject->getOrder());
     $data = array('data' => $avroDataObject->toArray());
     $this->setMessageData($data);
     return parent::_prepareData($dataObject);
 }
 protected function _prepareArrayRow(Varien_Object $row)
 {
     $row->setData('option_extra_attr_' . $this->getRenderer('attribute')->calcOptionHash($row->getAttribute()), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->getRenderer('searchable')->calcOptionHash($row->getSearchable()), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->getRenderer('searchable')->calcOptionHash($row->getRetrievable()), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->getRenderer('order')->calcOptionHash($row->getOrder()), 'selected="selected"');
 }
 public function order(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     $order_id = $order->getId();
     $order_increment_id = $order->getIncrementId();
     $quote = $order->getQuote();
     $store_id = $order->getStoreId();
     $ccType = $payment->getCcType();
     // reorder
     $reorder_increment_id = explode('-', $order_increment_id);
     // reorder
     $order_increment_id = $reorder_increment_id[0];
     $order_suffix_id = @$reorder_increment_id[1];
     $code = $this->_getStoreConfig('settings/code');
     $key = $this->_getStoreConfig('settings/key');
     $obs = $this->_getStoreConfig('settings/obs');
     $obsadd1 = $this->_getStoreConfig('settings/obsadd1');
     $obsadd2 = $this->_getStoreConfig('settings/obsadd2');
     $obsadd3 = $this->_getStoreConfig('settings/obsadd3');
     $tax_vat = $order->getCustomerTaxvat();
     $address = $quote->getBillingAddress();
     $name = $address->getName();
     list($street1, $street2) = $this->_getSplittedStreet($address, $store_id);
     $postcode = $address->getPostcode();
     $city = $address->getCity();
     $region = $address->getRegion();
     $expiration = strtotime('+' . $this->_getStoreConfig('settings/expiration') . 'days');
     $bank_expiration = date('dmY', $expiration);
     $transaction_expiration = date('Y-m-d', $expiration);
     $return_url = $this->_getStoreConfig('settings/return_url');
     $increment = $this->_getStoreConfig('settings/order_id_increment');
     $order_increment_prefix = $this->_getOrderIncrementPrefix($store_id);
     $number = $order_increment_id - $order_increment_prefix;
     if (!empty($order_suffix_id)) {
         $number *= pow(10, strlen($order_suffix_id));
         $number += $order_suffix_id;
     }
     $number += $increment;
     $short_number = substr($number, -8);
     /* Order number max. length for ItauShopLine */
     $submit_dc = Mage::getModel('itaushopline/itaucripto')->geraDados($code, $short_number, str_replace('.', "", number_format($amount, 2, ',', '.')), $obs, $key, $name, '01', $tax_vat, $street1, $street2, $postcode, $city, $region, $bank_expiration, $return_url, $obsadd1, $obsadd2, $obsadd3);
     if (strlen($submit_dc) < self::ITAU_SHOPLINE_SUBMIT_TRANSACTION_LENGTH) {
         Mage::throwException(Mage::helper('itaushopline')->__('Unable to generate submit transaction code. Please check your settings.'));
     }
     $query_dc = Mage::getModel('itaushopline/itaucripto')->geraConsulta($code, $short_number, '0', $key);
     if (strlen($query_dc) < self::ITAU_SHOPLINE_QUERY_TRANSACTION_LENGTH) {
         Mage::throwException(Mage::helper('itaushopline')->__('Unable to generate query transaction code. Please check your settings.'));
     }
     $data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $short_number, 'submit_dc' => $submit_dc, 'query_dc' => $query_dc);
     $result = Mage::getModel('utils/sql')->insert('gamuza_itaushopline_transactions', $data);
     if (!$result) {
         Mage::throwException(Mage::helper('itaushopline')->__('Unable to save the Itau ShopLine informations. Please verify your database.'));
     }
     $this->setStore($payment->getOrder()->getStoreId());
     $payment->setAmount($amount);
     $payment->setLastTransId($order_id);
     $payment->setStatus(self::STATUS_APPROVED);
     return $this;
 }
 public function authorize(Varien_Object $payment, $amount)
 {
     if (AW_Sarp_Model_Subscription::isIterating()) {
         $Subscription = AW_Sarp_Model_Subscription::getInstance()->processPayment($payment->getOrder());
         return $this;
     }
     return parent::authorize($payment, $amount);
 }
Example #20
0
 /**
  * retrieves the basic parameters for a capture call
  *
  * @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
  * @param Varien_Object $payment
  * @param                                        $amount
  * @param                                        $arrInfo
  *
  * @return $this
  */
 protected function getBaseParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod, Varien_Object $payment, $amount, $arrInfo)
 {
     $this->requestParams['AMOUNT'] = $this->getDataHelper()->getAmount($amount);
     $this->requestParams['PAYID'] = $payment->getAdditionalInformation('paymentId');
     $this->requestParams['OPERATION'] = $arrInfo['operation'];
     $this->requestParams['CURRENCY'] = Mage::app()->getStore($payment->getOrder()->getStoreId())->getBaseCurrencyCode();
     return $this;
 }
Example #21
0
 /**
  * @param null|Varien_Object $dataObject
  * @return Xcom_Xfabric_Model_Message_Request
  */
 public function _prepareData(Varien_Object $dataObject = null)
 {
     /* @var $orderMessage Xcom_Chronicle_Model_Message_Order */
     $orderMessage = Mage::getModel('xcom_chronicle/message_order', array('order' => $dataObject->getOrder(), 'type' => 'simple'));
     $data = $orderMessage->getRecord('PartialOrderReturn', array($dataObject->getCreditMemo()));
     $this->setMessageData($data);
     return parent::_prepareData($dataObject);
 }
Example #22
0
 public function authorize(Varien_Object $payment, $amount)
 {
     $payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
     $order = $payment->getOrder();
     /*
      * Do not send a email notification when order is created.
      * Only do this on the AUHTORISATION notification.
      * This is needed for old versions where there is no check if email is already send
      */
     $order->setCanSendNewEmailFlag(false);
     if (Mage::app()->getStore()->isAdmin()) {
         $storeId = $payment->getOrder()->getStoreId();
     } else {
         $storeId = null;
     }
     $merchantAccount = trim($this->_getConfigData('merchantAccount', 'adyen_abstract', $storeId));
     $incrementId = $order->getIncrementId();
     $orderCurrencyCode = $order->getOrderCurrencyCode();
     $customerId = $order->getCustomerId();
     $amount = Mage::helper('adyen')->formatAmount($amount, $orderCurrencyCode);
     // do cash API
     $request = array("merchantAccount" => $merchantAccount, "shopperReference" => $customerId, "variantCode" => 'c_cash', "reference" => $incrementId, "amount.value" => $amount, "amount.currency" => $orderCurrencyCode);
     $ch = curl_init();
     $isConfigDemoMode = $this->getConfigDataDemoMode($storeId = null);
     $wsUsername = $this->getConfigDataWsUserName($storeId);
     $wsPassword = $this->getConfigDataWsPassword($storeId);
     if ($isConfigDemoMode) {
         curl_setopt($ch, CURLOPT_URL, "https://pal-test.adyen.com/pal/servlet/CustomPayment/beginCustomPayment");
     } else {
         curl_setopt($ch, CURLOPT_URL, "https://pal-live.adyen.com/pal/servlet/CustomPayment/beginCustomPayment");
     }
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_USERPWD, $wsUsername . ":" . $wsPassword);
     curl_setopt($ch, CURLOPT_POST, count($request));
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $results = curl_exec($ch);
     $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($httpStatus != 200) {
         Mage::throwException(Mage::helper('adyen')->__('HTTP Status code %s received, data %s', $httpStatus, $results));
     }
     if ($results === false) {
         Mage::throwException(Mage::helper('adyen')->__('Got an empty response, status code %s', $httpStatus));
     }
 }
 /**
  * Authorize payment method
  *
  * @param Varien_Object $payment
  * @param float $amount
  *
  * @throws Exception Payment could not be executed
  *
  * @return Iways_PayPalPlus_Model_Payment
  */
 public function authorize(Varien_Object $payment, $amount)
 {
     $paymentId = Mage::app()->getRequest()->getParam('paymentId');
     $payerId = Mage::app()->getRequest()->getParam('PayerID');
     try {
         if (Mage::getStoreConfig('payment/iways_paypalplus_payment/transfer_reserved_order_id')) {
             Mage::getModel('iways_paypalplus/api')->patchInvoiceNumber($paymentId, $payment->getOrder()->getIncrementId());
         }
     } catch (\Exception $e) {
         Mage::logException($e);
     }
     /**
      * @var \PayPal\Api\Payment $ppPayment
      */
     $ppPayment = Mage::getModel('iways_paypalplus/api')->executePayment($paymentId, $payerId);
     Mage::getSingleton('customer/session')->setPayPalPaymentId(null);
     Mage::getSingleton('customer/session')->setPayPalPaymentPatched(null);
     if (!$ppPayment) {
         Mage::throwException('Payment could not be executed.');
     }
     if ($paymentInstructions = $ppPayment->getPaymentInstruction()) {
         $payment->setData('ppp_pui_reference_number', $paymentInstructions->getReferenceNumber());
         $payment->setData('ppp_pui_instruction_type', $paymentInstructions->getInstructionType());
         $payment->setData('ppp_pui_payment_due_date', Mage::helper('iways_paypalplus')->convertDueDate($paymentInstructions->getPaymentDueDate()));
         $payment->setData('ppp_pui_note', $paymentInstructions->getNote());
         $bankInsctructions = $paymentInstructions->getRecipientBankingInstruction();
         $payment->setData('ppp_pui_bank_name', $bankInsctructions->getBankName());
         $payment->setData('ppp_pui_account_holder_name', $bankInsctructions->getAccountHolderName());
         $payment->setData('ppp_pui_international_bank_account_number', $bankInsctructions->getInternationalBankAccountNumber());
         $payment->setData('ppp_pui_bank_identifier_code', $bankInsctructions->getBankIdentifierCode());
         $payment->setData('ppp_pui_routing_number', $bankInsctructions->getRoutingNumber());
         $ppAmount = $paymentInstructions->getAmount();
         $payment->setData('ppp_pui_amount', $ppAmount->getValue());
         $payment->setData('ppp_pui_currency', $ppAmount->getCurrency());
     }
     $transactionId = null;
     try {
         $transactions = $ppPayment->getTransactions();
         if ($transactions && isset($transactions[0])) {
             $resource = $transactions[0]->getRelatedResources();
             if ($resource && isset($resource[0])) {
                 $sale = $resource[0]->getSale();
                 $transactionId = $sale->getId();
                 if ($sale->getState() == self::PENDING) {
                     $payment->setIsTransactionPending(true);
                 }
             }
         }
     } catch (Exception $e) {
         $transactionId = $ppPayment->getId();
     }
     $payment->setTransactionId($transactionId);
     $payment->setParentTransactionId($ppPayment->getId());
     if ($ppPayment->getState() == self::PPP_STATUS_APPROVED) {
         $payment->setStatus(self::STATUS_APPROVED);
     }
     return $this;
 }
Example #24
0
 public function authorize(Varien_Object $payment, $amount)
 {
     if ($this->getConfigData('invoice_settlement') == 'after_order') {
         $order = $payment->getOrder();
         $realOrderId = $payment->getOrder()->getRealOrderId();
         $order->loadByIncrementId($realOrderId);
         if ($order->canInvoice()) {
             $invoice = $order->prepareInvoice();
             $invoice->register();
             $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
             $transactionSave->save();
             if ($this->getConfigData('invoice_send_email')) {
                 $invoice->sendEmail();
             }
         }
     }
     return $this;
 }
 /**
  * @param Varien_Object $payment
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function cancel(Varien_Object $payment)
 {
     $status = $payment->getOrder()->getPayoneTransactionStatus();
     if (empty($status) or $status == 'REDIRECT') {
         return $this;
     }
     // DonĀ“t send cancel to PAYONE on orders without TxStatus
     $this->capture($payment, 0.0);
     return $this;
 }
Example #26
0
 /**
  * Create or update a token from a payment object
  *
  * @param Varien_Object $payment
  * @param string $vault
  * @param string $bin
  * @return Litle_Palorus_Model_Vault
  */
 public function setTokenFromPayment(Varien_Object $payment, $token, $bin)
 {
     if (!$payment->getCcNumber() || !$token) {
         return false;
     }
     $vault = $this->getCustomerToken($payment->getOrder()->getCustomer(), $token);
     if (!$vault) {
         $vault = Mage::getModel('palorus/vault');
     }
     $order = $payment->getOrder();
     Mage::helper('core')->copyFieldset('palorus_vault_order', 'to_vault', $order, $vault);
     Mage::helper('core')->copyFieldset('palorus_vault_payment', 'to_vault', $payment, $vault);
     $last4 = substr($payment->getCcNumber(), -4);
     $ccType = $payment->getCcType();
     $vault->setLast4(substr($payment->getCcNumber(), -4))->setLitleCcType($payment->getCcType())->setToken($token)->setBin($bin);
     $vault->save();
     $order->setLitleVaultId($vault->getId());
     return $vault;
 }
 /**
  * @param Varien_Object $payment
  * @param $amount
  * @param array $extraConfig
  * @return mixed
  */
 protected function _createCharge(Varien_Object $payment, $amount, $extraConfig = array())
 {
     /** @var CheckoutApi_Client_ClientGW3  $Api */
     $Api = CheckoutApi_Api::getApi(array('mode' => $this->getConfigData('mode')));
     $order = $payment->getOrder();
     $billingAddress = $order->getBillingAddress();
     $config = parent::_createCharge($payment, $amount, $extraConfig);
     $config['postedParam']['email'] = $billingAddress->getData('email');
     $config['postedParam']['card'] = array_merge(array('phoneNumber' => $billingAddress->getData('telephone'), 'name' => $payment->getCcOwner(), 'number' => $payment->getCcNumber(), 'expiryMonth' => (int) $payment->getCcExpMonth(), 'expiryYear' => (int) $payment->getCcExpYear(), 'cvv' => $payment->getCcCid()), $config['postedParam']['card']);
     return $Api->createCharge($config);
 }
Example #28
0
 public function authorize(Varien_Object $payment, $amount)
 {
     if (AW_Sarp_Model_Subscription::isIterating()) {
         $Subscription = AW_Sarp_Model_Subscription::getInstance()->processPayment($payment->getOrder());
         return $this;
     }
     $result = parent::authorize($payment, $amount);
     $verify_result = Mage::getModel('sarp/payment_method_paypaluk_direct')->getPnref($payment, $amount, $payment->getOrder()->getBaseCurrencyCode());
     Mage::dispatchEvent(self::EVENT_NAME_AUTH_AFTER, array('verification' => $verify_result));
     return $result;
 }
Example #29
0
 public function authorize(Varien_Object $payment, $amount)
 {
     if (AW_Sarp_Model_Subscription::isIterating()) {
         AW_Sarp_Model_Subscription::getInstance()->processPayment($payment->getOrder());
         if (Mage::helper('sarp')->checkVersion('1.5.0.0')) {
             $this->_copyDataFromLastPayment($payment, $amount, parent::REQUEST_TYPE_AUTH_ONLY);
             $this->_placeTransaction($payment, $amount, parent::REQUEST_TYPE_AUTH_ONLY);
             $payment->setSkipTransactionCreation(1);
         }
         return $this;
     }
     return parent::authorize($payment, $amount);
 }
Example #30
0
 public function refund(Varien_Object $payment, $amount)
 {
     $hlp = Mage::helper('googlecheckout');
     //        foreach ($payment->getCreditMemo()->getCommentsCollection() as $comment) {
     //            $this->setReason($hlp->__('See Comments'));
     //            $this->setComment($comment->getComment());
     //        }
     $reason = $this->getReason() ? $this->getReason() : $hlp->__('No Reason');
     $comment = $this->getComment() ? $this->getComment() : $hlp->__('No Comment');
     $api = Mage::getModel('googlecheckout/api');
     $api->refund($payment->getOrder()->getExtOrderId(), $amount, $reason, $comment);
     return $this;
 }