コード例 #1
0
 /**
  * Check if last order is PayPalPlus
  * @return bool
  */
 public function isPPP()
 {
     if ($this->_order->getPayment()->getMethodInstance()->getCode() == self::IWAYS_PAYPALPLUS_PAYMENT) {
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * Check if can make payment for order
  *
  * @param Mage_Sales_Model_Order $order
  * @return bool
  */
 public function canMakePayment($order)
 {
     if ($order->getPayment() && $order->getPayment()->getMethod() == 'purchaseorder' && $order->canShip()) {
         return false;
     }
     if ($order->getStatus() != 'purchaseorder_pending_payment') {
         return false;
     }
     if (!$order->canInvoice()) {
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: Abstract.php プロジェクト: technomagegithub/olgo.nl
 /**
  * Add credit management required fields to the request
  *
  * @param $vars
  * @param string $serviceName
  * @return mixed
  */
 protected function _addCreditManagement(&$vars, $serviceName = 'creditmanagement')
 {
     $method = $this->_order->getPayment()->getMethod();
     $dueDaysInvoice = Mage::getStoreConfig('buckaroo/' . $method . '/due_date_invoice', $this->getStoreId());
     $dueDays = Mage::getStoreConfig('buckaroo/' . $method . '/due_date', $this->getStoreId());
     $invoiceDate = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") + $dueDaysInvoice, date("Y")));
     $dueDate = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") + $dueDaysInvoice + $dueDays, date("Y")));
     if (array_key_exists('customVars', $vars) && array_key_exists($serviceName, $vars['customVars']) && is_array($vars['customVars'][$serviceName])) {
         $vars['customVars'][$serviceName] = array_merge($vars['customVars'][$serviceName], array('DateDue' => $dueDate, 'InvoiceDate' => $invoiceDate));
     } else {
         $vars['customVars'][$serviceName] = array('DateDue' => $dueDate, 'InvoiceDate' => $invoiceDate);
     }
     return $vars;
 }
コード例 #4
0
 /**
  * Update payment status
  *
  * @param $paymentStatus
  * @param $payUOrderStatus
  */
 protected function updatePaymentStatus($paymentStatus, $payUOrderStatus)
 {
     $payment = $this->_order->getPayment();
     $currentState = $payment->getAdditionalInformation('payu_payment_status');
     if ($currentState == self::ORDER_V2_COMPLETED && $paymentStatus == self::ORDER_V2_PENDING || $currentState == self::ORDER_V2_COMPLETED && $paymentStatus == self::ORDER_V2_COMPLETED) {
         return;
     }
     if ($currentState != $paymentStatus) {
         try {
             switch ($paymentStatus) {
                 case self::ORDER_V2_NEW:
                     $this->updatePaymentStatusNew($payment);
                     break;
                 case self::ORDER_V2_PENDING:
                     $this->updatePaymentStatusPending($payment);
                     break;
                 case self::ORDER_V2_CANCELED:
                     $this->updatePaymentStatusCanceled($payment);
                     break;
                 case self::ORDER_V2_REJECTED:
                     $this->updatePaymentStatusDenied($payment);
                     break;
                 case self::ORDER_V2_COMPLETED:
                     $this->updatePaymentStatusCompleted($payment);
                     break;
             }
             // set current PayU status information and save
             $payment->setAdditionalInformation('payu_payment_status', $paymentStatus)->save();
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
 }
コード例 #5
0
 /**
  * @param Mage_Sales_Model_Order $order
  * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
  * @return void
  */
 public function updateByTransactionStatus(Mage_Sales_Model_Order $order, Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus)
 {
     // Update Status of Transaction
     $order->setPayoneTransactionStatus($transactionStatus->getTxaction());
     // Update dunning status
     if ($transactionStatus->getReminderlevel()) {
         $order->setPayoneDunningStatus($transactionStatus->getReminderlevel());
     }
     // Status mapping of Order by Transaction Status
     $statusMapping = $this->getConfigStore()->getGeneral()->getStatusMapping();
     $txAction = $transactionStatus->getTxaction();
     /**
      * @var $paymentMethod Payone_Core_Model_Payment_Method_Abstract
      */
     $paymentMethod = $order->getPayment()->getMethodInstance();
     $type = $paymentMethod->getMethodType();
     // Mapping
     $mapping = $statusMapping->getByType($type);
     if (!is_array($mapping) or !array_key_exists($txAction, $mapping)) {
         return;
     }
     // Check for valid Mapping
     $mappingOrderState = $mapping[$txAction];
     if (!is_array($mappingOrderState) or !array_key_exists('status', $mappingOrderState) or !array_key_exists('state', $mappingOrderState)) {
         return;
     }
     // Get State / Status and set to Order
     $newOrderState = $mappingOrderState['state'];
     $newOrderStatus = $mappingOrderState['status'];
     if ($newOrderState != '') {
         $order->setState($newOrderState, $newOrderStatus);
     } else {
         $order->setStatus($newOrderStatus);
     }
 }
 protected function _getButtonsHtml(SM_Vendors_Model_Order $vendorOrder, Mage_Sales_Model_Order $order, $vendorId)
 {
     $buttonGroups = array();
     $urlParams = array('order_id' => $order->getId(), 'do_as_vendor' => $vendorId);
     if ($vendorOrder->canCancel()) {
         $message = Mage::helper('sales')->__('Are you sure you want to cancel this order?');
         $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('id' => 'order_cancel_' . $vendorId, 'label' => Mage::helper('sales')->__('Cancel'), 'onclick' => 'deleteConfirm(\'' . $message . '\', \'' . $this->getUrl('*/vendors_order/cancel', $urlParams) . '\')'));
         $buttonGroups[] = $button->toHtml();
     }
     if ($vendorOrder->canInvoice()) {
         $_label = $order->getForcedDoShipmentWithInvoice() ? Mage::helper('sales')->__('Invoice and Ship') : Mage::helper('sales')->__('Invoice');
         $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('id' => 'order_invoice_' . $vendorId, 'label' => $_label, 'onclick' => 'setLocation(\'' . $this->getUrl('*/vendors_order_invoice/start', $urlParams) . '\')', 'class' => 'go'));
         $buttonGroups[] = $button->toHtml();
     }
     if ($vendorOrder->canShip() && !$order->getForcedDoShipmentWithInvoice()) {
         $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('id' => 'order_ship_' . $vendorId, 'label' => Mage::helper('sales')->__('Ship'), 'onclick' => 'setLocation(\'' . $this->getUrl('*/vendors_order_shipment/new', $urlParams) . '\')', 'class' => 'go'));
         $buttonGroups[] = $button->toHtml();
     }
     if ($vendorOrder->canCreditmemo()) {
         $message = Mage::helper('sales')->__('This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you wish to proceed?');
         $urlParams['_current'] = true;
         $creditMemoUrl = $this->getUrl('*/vendors_order_creditmemo/new', $urlParams);
         $onClick = "setLocation('{$creditMemoUrl}')";
         if ($order->getPayment()->getMethodInstance()->isGateway()) {
             $onClick = "confirmSetLocation('{$message}', '{$creditMemoUrl}')";
         }
         $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('id' => 'order_creditmemo_' . $vendorId, 'label' => Mage::helper('sales')->__('Credit Memo'), 'onclick' => $onClick, 'class' => 'go'));
         $buttonGroups[] = $button->toHtml();
     }
     if (!empty($buttonGroups)) {
         return '<p class="form-buttons">' . implode("\n", $buttonGroups) . '</p>';
     } else {
         return '';
     }
 }
コード例 #7
0
 /**
  * 
  * @return Mage_Sales_Model_Order
  */
 protected function getOrder()
 {
     if (is_null($this->_order)) {
         if ($profileIds = $this->getCheckout()->getLastRecurringProfileIds()) {
             if (is_array($profileIds)) {
                 foreach ($profileIds as $profileId) {
                     /* @var $profile Mage_Sales_Model_Recurring_Profile */
                     $profile = Mage::getModel('sales/recurring_profile')->load($profileId);
                     /* @var $_helperRecurring Allopass_Hipayrecurring_Helper_Data */
                     $_helperRecurring = Mage::helper('hipayrecurring');
                     if ($_helperRecurring->isInitialProfileOrder($profile)) {
                         $this->_order = $_helperRecurring->createOrderFromProfile($profile);
                     } else {
                         $orderId = current($profile->getChildOrderIds());
                         $this->_order = Mage::getModel('sales/order')->load($orderId);
                         $additionalInfo = $profile->getAdditionalInfo();
                         $this->_order->getPayment()->setCcType(isset($additionalInfo['ccType']) ? $additionalInfo['ccType'] : "");
                         $this->_order->getPayment()->setCcExpMonth(isset($additionalInfo['ccExpMonth']) ? $additionalInfo['ccExpMonth'] : "");
                         $this->_order->getPayment()->setCcExpYear(isset($additionalInfo['ccExpYear']) ? $additionalInfo['ccExpYear'] : "");
                         $this->_order->getPayment()->setAdditionalInformation('token', isset($additionalInfo['token']) ? $additionalInfo['token'] : "");
                         $this->_order->getPayment()->setAdditionalInformation('create_oneclick', isset($additionalInfo['create_oneclick']) ? $additionalInfo['create_oneclick'] : 1);
                         $this->_order->getPayment()->setAdditionalInformation('use_oneclick', isset($additionalInfo['use_oneclick']) ? $additionalInfo['use_oneclick'] : 0);
                         $this->_order->getPayment()->setAdditionalInformation('selected_oneclick_card', isset($additionalInfo['selected_oneclick_card']) ? $additionalInfo['selected_oneclick_card'] : 0);
                     }
                     return $this->_order;
                     //because only one nominal item in cart is authorized and Hipay not manage many profiles
                 }
             }
             Mage::throwException("An error occured. Profile Ids not present!");
         } else {
             $this->_order = Mage::getModel('sales/order')->load($this->getCheckout()->getLastOrderId());
         }
     }
     return $this->_order;
 }
コード例 #8
0
 public function prepareValues(Mage_Sales_Model_Order $order)
 {
     $billing_address = $order->getBillingAddress();
     $additional_data = unserialize($order->getPayment()->getAdditionalData());
     $code_banco = $additional_data['code_banco'];
     $data_vencimento = $additional_data['data_vencimento'];
     $numero_boleto = str_replace('-', '', $order->getIncrementId());
     $strtotime = strtotime($order->getCreatedAt());
     $data = array('logoempresa' => $this->getConfig('logoempresa'), 'nosso_numero' => $numero_boleto, 'numero_documento' => $numero_boleto, 'data_vencimento' => $data_vencimento, 'data_documento' => date('d/m/Y', $strtotime), 'data_processamento' => date('d/m/Y', $strtotime), 'valor_boleto' => number_format($order->getGrandTotal() + $this->getLayoutConfig($code_banco, 'valor_adicional'), 2, ',', ''), 'valor_unitario' => number_format($order->getGrandTotal() + $this->getLayoutConfig($code_banco, 'valor_adicional'), 2, ',', ''), 'sacado' => $billing_address->getFirstname() . ' ' . $billing_address->getLastname(), 'sacadocpf' => $order->getCustomerTaxvat(), 'endereco1' => implode(' ', $billing_address->getStreet()), 'endereco2' => $billing_address->getCity() . ' - ' . $billing_address->getRegion() . ' - CEP: ' . $billing_address->getPostcode(), 'identificacao' => $this->getLayoutConfig($code_banco, 'identificacao'), 'cpf_cnpj' => $this->getLayoutConfig($code_banco, 'cpf_cnpj'), 'endereco' => $this->getLayoutConfig($code_banco, 'endereco'), 'cidade_uf' => $this->getLayoutConfig($code_banco, 'cidade_uf'), 'cedente' => $this->getLayoutConfig($code_banco, 'cedente'), 'agencia' => $this->getLayoutConfig($code_banco, 'agencia'), 'agencia_dv' => $this->getLayoutConfig($code_banco, 'agencia_dv'), 'conta' => $this->getLayoutConfig($code_banco, 'conta'), 'conta_dv' => $this->getLayoutConfig($code_banco, 'conta_dv'), 'carteira' => $this->getLayoutConfig($code_banco, 'carteira'), 'especie' => $this->getLayoutConfig($code_banco, 'especie'), 'especie_doc' => $this->getLayoutConfig($code_banco, 'especie_doc'), 'aceite' => $this->getLayoutConfig($code_banco, 'aceite'), 'quantidade' => $this->getLayoutConfig($code_banco, 'quantidade'));
     if ($code_banco == 'santander_banespa') {
         $data['ponto_venda'] = $this->getLayoutConfig($code_banco, 'ponto_venda');
         $data['carteira_descricao'] = $this->getLayoutConfig($code_banco, 'carteira_descricao');
         $data['codigo_cliente'] = $this->getLayoutConfig($code_banco, 'codigo_cliente');
     }
     if ($code_banco == 'bradesco') {
         $data['conta_cedente'] = $this->getLayoutConfig($code_banco, 'conta_cedente');
         $data['conta_cedente_dv'] = $this->getLayoutConfig($code_banco, 'conta_cedente_dv');
     }
     if ($code_banco == 'cef' || $code_banco == 'cef_sinco' || $code_banco == 'cef_sigcb') {
         $data['conta_cedente_caixa'] = $this->getLayoutConfig($code_banco, 'conta_cedente_caixa');
         $data['conta_cedente_dv_caixa'] = $this->getLayoutConfig($code_banco, 'conta_cedente_dv_caixa');
         $data['inicio_nosso_numero'] = $this->getLayoutConfig($code_banco, 'inicio_nosso_numero');
     }
     if ($code_banco == 'bb') {
         $data['convenio'] = $this->getLayoutConfig($code_banco, 'convenio');
         $data['contrato'] = $this->getLayoutConfig($code_banco, 'contrato');
         $data['variacao_carteira'] = $this->getLayoutConfig($code_banco, 'variacao_carteira');
         $data['formatacao_convenio'] = $this->getLayoutConfig($code_banco, 'formatacao_convenio');
         $data['formatacao_nosso_numero'] = $this->getLayoutConfig($code_banco, 'formatacao_nosso_numero');
     }
     if ($code_banco == 'hsbc') {
         $data['codigo_cedente'] = $this->getLayoutConfig($code_banco, 'codigo_cedente');
     }
     if ($code_banco == 'cef_sinco') {
         $data['campo_fixo_obrigatorio'] = $this->getLayoutConfig($code_banco, 'campo_fixo_obrigatorio');
     }
     if ($code_banco == 'cef_sigcb') {
         $data['nosso_numero1'] = $this->getLayoutConfig($code_banco, 'nosso_numero1');
         $data['nosso_numero_const1'] = $this->getLayoutConfig($code_banco, 'nosso_numero_const1');
         $data['nosso_numero2'] = $this->getLayoutConfig($code_banco, 'nosso_numero2');
         $data['nosso_numero_const2'] = $this->getLayoutConfig($code_banco, 'nosso_numero_const2');
         $data['nosso_numero3'] = $numero_boleto;
     }
     if ($code_banco == 'sicoob') {
         $data['convenio'] = $this->getLayoutConfig($code_banco, 'codigo_cedente');
         $data["numero_parcela"] = '001';
     }
     $instrucoes = explode("\n", $this->getLayoutConfig($code_banco, 'instrucoes_boleto'));
     for ($i = 0; $i < 4; $i++) {
         $instrucao = isset($instrucoes[$i]) ? $instrucoes[$i] : '';
         $data['instrucoes' . ($i + 1)] = $instrucao;
     }
     $info = sprintf($this->getLayoutConfig($code_banco, 'informacoes'), $order->getIncrementId());
     $informacoes = explode("\n", $info);
     for ($i = 0; $i < 3; $i++) {
         $informacao = isset($informacoes[$i]) ? $informacoes[$i] : '';
         $data['demonstrativo' . ($i + 1)] = $informacao;
     }
     return $data;
 }
コード例 #9
0
ファイル: ExpiraPedido.php プロジェクト: adrianomelo5/magento
 public function cancelaPedido(Mage_Sales_Model_Order $order)
 {
     $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
     $listPaymentMethodsIdeasa = Mage::helper('base')->listPaymentMethods();
     $this->logger->info('Processando cancelamento do pedido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
     try {
         if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
             $order->cancel();
             //força o cancelamento
             if ($order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED) {
                 $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('Pedido cancelado'), $notified = false);
             } else {
                 $order->addStatusToHistory($order->getStatus(), Mage::helper('base')->__('Pedido cancelado.'));
             }
             if ($order->hasInvoices() != '') {
                 $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('O pagamento e o pedido foram cancelados, mas não foi possível retornar os produtos ao estoque pois já havia uma fatura gerada para este pedido.'), $notified = false);
             }
             $order->save();
         }
         if (Mage::helper('base')->isIdeasaPaymentMethod($paymentMethod) && Mage::helper('base/module')->isPagSeguroDiretoExists() && $paymentMethod == $listPaymentMethodsIdeasa[0]) {
             Mage::getModel('pagsegurodireto/notification')->sendEmail($order);
         }
     } catch (Exception $e) {
         $this->logger->error("Erro ao cancelar pedido {$orderId} \n {$e->__toString}()");
     }
     $this->logger->info('Cancelamento do pedido foi concluido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
     return;
 }
コード例 #10
0
 /**
  * Check if we can void the PayPal payment method in this order.
  *
  * @param Mage_Sales_Model_Order $order
  * @return bool
  */
 protected function _canVoid(Mage_Sales_Model_Order $order)
 {
     $payment = $order->getPayment();
     if (!$payment instanceof Mage_Sales_Model_Order_Payment) {
         return false;
     }
     $methodInstance = $payment->getMethodInstance();
     return $methodInstance instanceof EbayEnterprise_Paypal_Model_Method_Express && $methodInstance->canVoid($payment);
 }
コード例 #11
0
 /**
  * Cancels an order after the period for payment elapsed.
  */
 protected function _processTransactionExpired()
 {
     $payment = $this->_order->getPayment();
     if ($transaction = $payment->getTransaction($this->_receivedData['transaction_id'])) {
         $transaction->close();
     }
     $this->_order->registerCancellation($this->_createIpnComment(), false)->save();
     $this->_order->sendOrderUpdateEmail(true, $this->_createIpnComment());
 }
コード例 #12
0
 /**
  * Add PayPal context information to the payload
  * @param  Mage_Sales_Model_Order $order
  * @param  IOrderContext          $context
  * @return self
  */
 public function updateOrderContext(Mage_Sales_Model_Order $order, IOrderContext $context)
 {
     $payment = $order->getPayment();
     if ($payment->getMethod() === Mage::getModel('ebayenterprise_paypal/method_express')->getCode()) {
         $additionalInfo = new Varien_Object($payment->getAdditionalInformation());
         $context->setPayPalPayerId($additionalInfo->getPaypalExpressCheckoutPayerId())->setPayPalPayerStatus($additionalInfo->getPaypalExpressCheckoutPayerStatus())->setPayPalAddressStatus($additionalInfo->getPaypalExpressCheckoutAddressStatus());
     }
     return $this;
 }
コード例 #13
0
ファイル: Data.php プロジェクト: xiaoguizhidao/bb
 /**
  * Write purchase order info to order
  * @param Mage_Sales_Model_Order $order
  * @param XMLWriter $xml
  */
 public function writePoNumber($order, $xml)
 {
     $payment = $order->getPayment();
     $xml->startElement('PO');
     if ($payment) {
         $xml->writeCdata($payment->getPoNumber());
     }
     $xml->endElement();
 }
コード例 #14
0
ファイル: Event.php プロジェクト: chucky515/Magento-CE-Mirror
 /**
  * Checking returned parameters
  * Thorws Mage_Core_Exception if error
  * @param bool $fullCheck Whether to make additional validations such as payment status, transaction signature etc.
  *
  * @return array  $params request params
  */
 protected function _validateEventData($fullCheck = true)
 {
     // get request variables
     $params = $this->_eventData;
     if (empty($params)) {
         Mage::throwException('Request does not contain any elements.');
     }
     // check order ID
     if (empty($params['transaction_id']) || $fullCheck == false && $this->_getCheckout()->getMoneybookersRealOrderId() != $params['transaction_id']) {
         Mage::throwException('Missing or invalid order ID.');
     }
     // load order for further validation
     $this->_order = Mage::getModel('sales/order')->loadByIncrementId($params['transaction_id']);
     if (!$this->_order->getId()) {
         Mage::throwException('Order not found.');
     }
     if (0 !== strpos($this->_order->getPayment()->getMethodInstance()->getCode(), 'moneybookers_')) {
         Mage::throwException('Unknown payment method.');
     }
     // make additional validation
     if ($fullCheck) {
         // check payment status
         if (empty($params['status'])) {
             Mage::throwException('Unknown payment status.');
         }
         // check transaction signature
         if (empty($params['md5sig'])) {
             Mage::throwException('Invalid transaction signature.');
         }
         $checkParams = array('merchant_id', 'transaction_id', 'secret', 'mb_amount', 'mb_currency', 'status');
         $md5String = '';
         foreach ($checkParams as $key) {
             if ($key == 'merchant_id') {
                 $md5String .= Mage::getStoreConfig(Phoenix_Moneybookers_Helper_Data::XML_PATH_CUSTOMER_ID, $this->_order->getStoreId());
             } elseif ($key == 'secret') {
                 $secretKey = Mage::getStoreConfig(Phoenix_Moneybookers_Helper_Data::XML_PATH_SECRET_KEY, $this->_order->getStoreId());
                 if (empty($secretKey)) {
                     Mage::throwException('Secret key is empty.');
                 }
                 $md5String .= strtoupper(md5($secretKey));
             } elseif (isset($params[$key])) {
                 $md5String .= $params[$key];
             }
         }
         $md5String = strtoupper(md5($md5String));
         if ($md5String != $params['md5sig']) {
             Mage::throwException('Hash is not valid.');
         }
         // check transaction amount if currency matches
         if ($this->_order->getOrderCurrencyCode() == $params['mb_currency']) {
             if (round($this->_order->getGrandTotal(), 2) != $params['mb_amount']) {
                 Mage::throwException('Transaction amount does not match.');
             }
         }
     }
     return $params;
 }
コード例 #15
0
ファイル: TransactionTest.php プロジェクト: nemphys/magento2
 public function testLoadByTxnId()
 {
     $order = new Mage_Sales_Model_Order();
     $order->loadByIncrementId('100000001');
     $model = new Mage_Sales_Model_Order_Payment_Transaction();
     $model->setOrderPaymentObject($order->getPayment())->loadByTxnId('invalid_transaction_id');
     $this->assertNull($model->getId());
     $model->loadByTxnId('trx1');
     $this->assertNotNull($model->getId());
 }
コード例 #16
0
 public function setUp()
 {
     parent::setUp();
     $order = new Mage_Sales_Model_Order();
     $order->load('100000001', 'increment_id');
     $order->getPayment()->setMethod(Mage_Paypal_Model_Config::METHOD_PAYFLOWLINK);
     $order->save();
     $session = Mage::getSingleton('Mage_Checkout_Model_Session');
     $session->setLastRealOrderId($order->getRealOrderId())->setLastQuoteId($order->getQuoteId());
 }
コード例 #17
0
 /**
  * @param Mage_Sales_Model_Order $order
  *
  * @return bool
  */
 public function isSagePayMethod($order)
 {
     if (stripos($order->getPayment()->getMethodInstance()->getCode(), 'sagepay') === false) {
         return false;
     }
     if (Mage::app()->getRequest()->getControllerModule() !== 'Ebizmarts_SagePaySuite') {
         return false;
     }
     return true;
 }
コード例 #18
0
ファイル: Payflowlink.php プロジェクト: xiaoguizhidao/bb
 /**
  * Operate with order using information from silent post
  *
  * @param Mage_Sales_Model_Order $order
  */
 protected function _processOrder(Mage_Sales_Model_Order $order)
 {
     $response = $this->getResponse();
     $payment = $order->getPayment();
     $payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0);
     $canSendNewOrderEmail = true;
     if ($response->getResult() == self::RESPONSE_CODE_FRAUDSERVICE_FILTER || $response->getResult() == self::RESPONSE_CODE_DECLINED_BY_FILTER) {
         $canSendNewOrderEmail = false;
         $fraudMessage = $this->_getFraudMessage() ? $response->getFraudMessage() : $response->getRespmsg();
         $payment->setIsTransactionPending(true)->setIsFraudDetected(true)->setAdditionalInformation('paypal_fraud_filters', $fraudMessage);
     }
     if ($response->getAvsdata() && strstr(substr($response->getAvsdata(), 0, 2), 'N')) {
         $payment->setAdditionalInformation('paypal_avs_code', substr($response->getAvsdata(), 0, 2));
     }
     if ($response->getCvv2match() && $response->getCvv2match() != 'Y') {
         $payment->setAdditionalInformation('paypal_cvv2_match', $response->getCvv2match());
     }
     switch ($response->getType()) {
         case self::TRXTYPE_AUTH_ONLY:
             $payment->registerAuthorizationNotification($payment->getBaseAmountAuthorized());
             break;
         case self::TRXTYPE_SALE:
             $payment->registerCaptureNotification($payment->getBaseAmountAuthorized());
             break;
     }
     $order->save();
     $customerId = $order->getCustomerId();
     if ($response->getResult() == self::RESPONSE_CODE_APPROVED && $response->getMethod() == 'CC' && $customerId && $payment->hasAdditionalInformation('cc_save_future') && $payment->getAdditionalInformation('cc_save_future') == 'Y') {
         // Obtain CC type
         $ccType = 'OT';
         $responseCcType = $response->getCardtype();
         if (!is_null($responseCcType)) {
             $payflowResponseCcTypesMap = array(0 => 'VI', 1 => 'MC', 2 => 'DI', 3 => 'AE', 4 => 'OT', 5 => 'JCB');
             if (isset($payflowResponseCcTypesMap[$responseCcType])) {
                 $ccType = $payflowResponseCcTypesMap[$responseCcType];
             }
         }
         $ccExpMonth = $response->getExpdate() ? substr($response->getExpdate(), 0, 2) : '';
         if ($ccExpMonth[0] == '0') {
             $ccExpMonth = $ccExpMonth[1];
         }
         // Create new stored card
         $customerstoredModel = Mage::getModel('cls_paypal/customerstored');
         $customerstoredModel->setData(array('transaction_id' => $response->getPnref(), 'customer_id' => $customerId, 'cc_type' => $ccType, 'cc_last4' => $response->getAcct() ? substr($response->getAcct(), -4) : '', 'cc_exp_month' => $ccExpMonth, 'cc_exp_year' => $response->getExpdate() ? '20' . substr($response->getExpdate(), 2) : '', 'date' => Varien_Date::formatDate(true, true), 'payment_method' => $payment->getMethod()));
         $customerstoredModel->save();
     }
     try {
         if ($canSendNewOrderEmail) {
             $order->sendNewOrderEmail();
         }
         Mage::getModel('sales/quote')->load($order->getQuoteId())->setIsActive(false)->save();
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('paypal')->__('Can not send new order email.'));
     }
 }
コード例 #19
0
 /**
  * Check if the current user made the given order
  *
  * @param Mage_Sales_Model_Order $order
  * @return boolean
  */
 protected function _canViewOrder($order)
 {
     $customerId = Mage::getSingleton('customer/session')->getCustomerId();
     $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates();
     $method = $order->getPayment()->getMethod();
     if ($order->getCustomerId() == $customerId && in_array($order->getState(), $availableStates, true) && strpos($method, 'boleto_') !== false) {
         $this->_method = substr($method, 7);
         return true;
     }
     return false;
 }
コード例 #20
0
 public function testRedirectActionIsContentGenerated()
 {
     $order = new Mage_Sales_Model_Order();
     $order->load('100000001', 'increment_id');
     $order->getPayment()->setMethod(Mage_Paypal_Model_Config::METHOD_WPS);
     $order->save();
     $session = Mage::getSingleton('Mage_Checkout_Model_Session');
     $session->setLastRealOrderId($order->getRealOrderId())->setLastQuoteId($order->getQuoteId());
     $this->dispatch('paypal/standard/redirect');
     $this->assertContains('<form action="https://www.paypal.com/webscr" id="paypal_standard_checkout"' . ' name="paypal_standard_checkout" method="POST">', $this->getResponse()->getBody());
 }
コード例 #21
0
 private function _getPostResponseActionUrl(Mage_Sales_Model_Order $order)
 {
     $token = $_GET['token'];
     $server = Mage::getSingleton('customer/session')->getServerMode();
     $url = getStatusUrl($server, $token);
     $resultJson = checkStatusPayment($url);
     $theResult = $resultJson['transaction']['processing']['result'];
     $returnCode = $resultJson['transaction']['processing']['return']['code'];
     $returnMessage = $resultJson['transaction']['processing']['return']['message'];
     $currency = $resultJson['transaction']['payment']['clearing']['currency'];
     $payment_type = substr($resultJson['transaction']['payment']['code'], -2);
     $refId = $resultJson['transaction']['identification']['uniqueId'];
     $pageName = '';
     $params = array();
     if ($theResult == 'ACK') {
         $order->getPayment()->setAdditionalInformation('IDENTIFICATION_REFERENCEID', $refId);
         $order->getPayment()->setAdditionalInformation('CURRENCY', $currency);
         $order->getPayment()->setAdditionalInformation('hyperpay_transaction_code', $payment_type);
         $order->save();
         $order->sendNewOrderEmail();
         if ($payment_type == 'PA') {
             $order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
         } else {
             Mage::helper('hyperpay')->invoice($order);
         }
         Mage::getModel('sales/quote')->load($order->getQuoteId())->setIsActive(false)->save();
         $pageName = 'checkout/onepage/success/';
     } else {
         Mage::getSingleton('core/session')->setPiHyperpayPaymentError($returnCode);
         $returnMessage .= " ( transaction id : " . $order->getIncrementId() . " )";
         $order->cancel()->save();
         $pageName = 'hyperpay/response/addErrorAndRedirect/';
         //            if (trim($this->getRequest()->getPost('FRONTEND_REQUEST_CANCELLED')) == 'false' && $this->getRequest()->getPost('PROCESSING_RETURN') != 'Cancelled by user') {
         $params = array('message' => $returnMessage);
         //            }
     }
     $params['_secure'] = true;
     //return Mage::getUrl($pageName, $params);
     $this->_redirect($pageName, $params);
 }
コード例 #22
0
ファイル: Quote.php プロジェクト: roshu1980/add-computers
 /**
  * get payment operation code
  *
  * @param Mage_Sales_Model_Order $order
  *
  * @return string
  */
 public function getPaymentAction($order)
 {
     $operation = Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION;
     // different capture operation name for direct debits
     if ('Direct Debits DE' == $order->getPayment()->getAdditionalInformation('PM') || 'Direct Debits AT' == $order->getPayment()->getAdditionalInformation('PM')) {
         if ('authorize_capture' == Mage::getModel('ops/config')->getPaymentAction($order->getStoreId())) {
             return Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION;
         }
         return Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION;
     }
     // no RES for Direct Debits NL, so we'll do the final sale
     if ('Direct Debits NL' == $order->getPayment()->getAdditionalInformation('PM')) {
         if ('authorize_capture' == Mage::getModel('ops/config')->getPaymentAction($order->getStoreId())) {
             return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_DIRECTDEBIT_NL;
         }
         return Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION;
     }
     if ('authorize_capture' == Mage::getModel('ops/config')->getPaymentAction($order->getStoreId())) {
         $operation = Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION;
     }
     return $operation;
 }
コード例 #23
0
ファイル: Abstract.php プロジェクト: xD83d/E-MailPreview
 /**
  * @param Mage_Sales_Model_Order $order
  * @return string
  */
 protected function _getPaymentBlockHtmlFrom(Mage_Sales_Model_Order $order)
 {
     $storeId = $order->getStore()->getStoreId();
     try {
         // Retrieve specified view block from appropriate design package (depends on emulated store)
         $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
         $paymentBlock->getMethod()->setStore($storeId);
         $paymentBlockHtml = $paymentBlock->toHtml();
     } catch (Exception $exception) {
         throw $exception;
     }
     return $paymentBlockHtml;
 }
コード例 #24
0
 public function testCancelActionIsContentGenerated()
 {
     $order = new Mage_Sales_Model_Order();
     $order->load('100000001', 'increment_id');
     $order->getPayment()->setMethod(Mage_Paypal_Model_Config::METHOD_HOSTEDPRO);
     $order->save();
     $session = Mage::getSingleton('Mage_Checkout_Model_Session');
     $session->setLastRealOrderId($order->getRealOrderId())->setLastQuoteId($order->getQuoteId());
     $this->dispatch('paypal/hostedpro/cancel');
     $this->assertContains('window.top.checkout.gotoSection("payment");', $this->getResponse()->getBody());
     $this->assertContains('window.top.document.getElementById(\'checkout-review-submit\').show();', $this->getResponse()->getBody());
     $this->assertContains('window.top.document.getElementById(\'iframe-warning\').hide();', $this->getResponse()->getBody());
 }
コード例 #25
0
ファイル: Cancel.php プロジェクト: FranchuCorraliza/magento
 /**
  * Save cancellation date of order
  * 
  * @param Mage_Sales_Model_Order $order
  * @return Soon_StockReleaser_Model_Cancel
  */
 public function registerCancel($order)
 {
     $paymentMethod = $order->getPayment()->getMethod();
     $leadtimeValue = Mage::getStoreConfig('stockreleaser/leadtime/' . $paymentMethod);
     if ($leadtimeValue != '') {
         //Only continue if leadtime value is set.
         $leadtime = $leadtimeValue * $this->_getLeadtimeMultiplier(Mage::getStoreConfig('stockreleaser/leadtime/' . $paymentMethod . '-unit'));
         $autoCancelDate = date("Y-m-d H:i:s", strtotime($order->getCreatedAt()) + $leadtime);
         $data = array('order_id' => $order->getId(), 'autocancel_date' => $autoCancelDate);
         $this->setData($data);
         $this->save();
     }
     return $this;
 }
コード例 #26
0
ファイル: OrderTest.php プロジェクト: nayanchamp/magento2
 /**
  * @magentoConfigFixture current_store design/theme/full_name default/default/default
  * @magentoDataFixture Mage/Sales/_files/order.php
  */
 public function testSendNewOrderEmail()
 {
     $order = new Mage_Sales_Model_Order();
     $order->loadByIncrementId('100000001');
     $order->setCustomerEmail('*****@*****.**');
     $payment = $order->getPayment();
     $paymentInfoBlock = Mage::helper('Mage_Payment_Helper_Data')->getInfoBlock($payment);
     $paymentInfoBlock->setArea('invalid-area');
     $payment->setBlockMock($paymentInfoBlock);
     $this->assertEmpty($order->getEmailSent());
     $order->sendNewOrderEmail();
     $this->assertNotEmpty($order->getEmailSent());
     $this->assertEquals('frontend', $paymentInfoBlock->getArea());
 }
コード例 #27
0
ファイル: Direct.php プロジェクト: xiaoguizhidao/mydigibits
 /**
  * Processes payment for specified order
  * @param Mage_Sales_Model_Order $Order
  * @return
  */
 public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null)
 {
     if ($Order->getBaseGrandTotal() > 0) {
         $data = array('amount' => $Order->getBaseGrandTotal() * 100, 'invoice_reference' => $Order->getIncrementId());
         $eWayCustomerId = $this->getSubscription()->getRealId();
         try {
             $response = $this->getWebService()->createTransaction($eWayCustomerId, $data);
             $Order->getPayment()->setCcTransId(@$response->ewayResponse->ewayTrxnNumber);
         } catch (Exception $e) {
             Mage::throwException($e->getMessage());
             return $this;
         }
     }
     return $this;
 }
コード例 #28
0
ファイル: Ipn.php プロジェクト: quyip8818/Mag
 /**
  * Map payment information from IPN to payment object
  * Returns true if there were changes in information
  *
  * @param Mage_Payment_Model_Info $payment
  * @return bool
  */
 protected function _importPaymentInformation()
 {
     $payment = $this->_order->getPayment();
     $was = $payment->getAdditionalInformation();
     // collect basic information
     $from = array();
     foreach (array(Mage_Paypal_Model_Info::PAYER_ID, 'payer_email' => Mage_Paypal_Model_Info::PAYER_EMAIL, Mage_Paypal_Model_Info::PAYER_STATUS, Mage_Paypal_Model_Info::ADDRESS_STATUS, Mage_Paypal_Model_Info::PROTECTION_EL, Mage_Paypal_Model_Info::PAYMENT_STATUS, Mage_Paypal_Model_Info::PENDING_REASON) as $privateKey => $publicKey) {
         if (is_int($privateKey)) {
             $privateKey = $publicKey;
         }
         $value = $this->getRequestData($privateKey);
         if ($value) {
             $from[$publicKey] = $value;
         }
     }
     if (isset($from['payment_status'])) {
         $from['payment_status'] = $this->_filterPaymentStatus($this->getRequestData('payment_status'));
     }
     // collect fraud filters
     $fraudFilters = array();
     for ($i = 1; $value = $this->getRequestData("fraud_management_pending_filters_{$i}"); $i++) {
         $fraudFilters[] = $value;
     }
     if ($fraudFilters) {
         $from[Mage_Paypal_Model_Info::FRAUD_FILTERS] = $fraudFilters;
     }
     $this->_info->importToPayment($from, $payment);
     /**
      * Detect pending payment, frauds
      * TODO: implement logic in one place
      * @see Mage_Paypal_Model_Pro::importPaymentInfo()
      */
     if ($this->_info->isPaymentReviewRequired($payment)) {
         $payment->setIsTransactionPending(true);
         if ($fraudFilters) {
             $payment->setIsFraudDetected(true);
         }
     }
     if ($this->_info->isPaymentSuccessful($payment)) {
         $payment->setIsTransactionApproved(true);
     } elseif ($this->_info->isPaymentFailed($payment)) {
         $payment->setIsTransactionDenied(true);
     }
     return $was != $payment->getAdditionalInformation();
 }
コード例 #29
0
 /**
  * Sends notification mail for selected shipping rate
  *
  * The code for this functionality is based on Mage_Sales_Model_Order::sendNewOrderEmail()
  *
  * @param Mage_Sales_Model_Order $order
  * @return boolean
  * @throws Exception
  * @see Mage_Sales_Model_Order
  */
 public function sendEmailNotification($order)
 {
     if (strncmp($order->getShippingMethod(), 'shippingrates_', 14) != 0) {
         return false;
     }
     $notificationMail = $order->getShippingCarrier()->getNotificationMail($order->getShippingMethod());
     if (!strlen(trim($notificationMail))) {
         return false;
     }
     $storeId = $order->getStore()->getId();
     // Start store emulation process
     $appEmulation = Mage::getSingleton('core/app_emulation');
     $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
     try {
         // Retrieve specified view block from appropriate design package (depends on emulated store)
         $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
         $paymentBlock->getMethod()->setStore($storeId);
         $paymentBlockHtml = $paymentBlock->toHtml();
     } catch (Exception $exception) {
         // Stop store emulation process
         $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
         throw $exception;
     }
     // Stop store emulation process
     $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
     // Retrieve corresponding email template id and customer name
     if ($order->getCustomerIsGuest()) {
         $templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
         $customerName = $order->getBillingAddress()->getName();
     } else {
         $templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_TEMPLATE, $storeId);
         $customerName = $order->getCustomerName();
     }
     $mailer = Mage::getModel('core/email_template_mailer');
     $emailInfo = Mage::getModel('core/email_info');
     $emailInfo->addTo($notificationMail);
     $mailer->addEmailInfo($emailInfo);
     // Set all required params and send emails
     $mailer->setSender(Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId));
     $mailer->setStoreId($storeId);
     $mailer->setTemplateId($templateId);
     $mailer->setTemplateParams(array('order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml));
     $mailer->send();
     return true;
 }
コード例 #30
0
ファイル: Push.php プロジェクト: technomagegithub/olgo.nl
 /**
  * Saves an invoice and sets total-paid for the order
  *
  * @return bool
  */
 protected function _saveInvoice()
 {
     if ($this->_order->canInvoice() && !$this->_order->hasInvoices()) {
         $payment = $this->_order->getPayment();
         $payment->registerCaptureNotification($this->_order->getBaseGrandTotal());
         $this->_order->save();
         $this->_debugEmail .= 'Invoice created and saved. \\n';
         //sets the invoice's transaction ID as the Buckaroo TRX. This is to allow the order to be refunded using Buckaroo later on.
         foreach ($this->_order->getInvoiceCollection() as $invoice) {
             if (!isset($this->_postArray['brq_transactions'])) {
                 continue;
             }
             $invoice->setTransactionId($this->_postArray['brq_transactions'])->save();
         }
         return true;
     }
     return false;
 }