Esempio n. 1
0
 /**
  * envia a embarque y notifica al cliente
  * @param type $order
  */
 private function shippedOrder($order)
 {
     $shipment = $order->prepareShipment();
     $shipment->register();
     $order->setCustomerNoteNotify(true);
     $order->setIsInProcess(true);
     $order->addStatusHistoryComment('Automatically SHIPPED by PagoFacil.', false);
     $transactionSave = Mage::getModel('core/resource_transaction');
     $transactionSave->addObject($shipment)->addObject($shipment->getOrder());
     $transactionSave->save();
 }
Esempio n. 2
0
 /**
  * @desc order comments or history
  * @param type $order
  */
 protected function _addStatusHistoryComment($order)
 {
     $success_result = strcmp($this->_success, 'true') == 0 || strcmp($this->_success, '1') == 0 ? 'true' : 'false';
     $success = !empty($this->_reason) ? "{$success_result} <br />reason:{$this->_reason}" : $success_result;
     if ($this->_eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_REFUND || $this->_eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_CAPTURE) {
         $currency = $order->getOrderCurrencyCode();
         // check if it is a full or partial refund
         $amount = $this->_value;
         $orderAmount = (int) Mage::helper('adyen')->formatAmount($order->getGrandTotal(), $currency);
         $this->_debugData['_addStatusHistoryComment amount'] = 'amount notification:' . $amount . ' amount order:' . $orderAmount;
         if ($amount == $orderAmount) {
             $order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
         } else {
             $order->setAdyenEventCode("(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
         }
     } else {
         $order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
     }
     // if payment method is klarna or openinvoice/afterpay show the reservartion number
     if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" || $this->_paymentMethod == "openinvoice") && ($this->_klarnaReservationNumber != null && $this->_klarnaReservationNumber != "")) {
         $klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
     } else {
         $klarnaReservationNumberText = "";
     }
     if ($this->_boletoPaidAmount != null && $this->_boletoPaidAmount != "") {
         $boletoPaidAmountText = "<br /> Paid amount: " . $this->_boletoPaidAmount;
     } else {
         $boletoPaidAmountText = "";
     }
     $type = 'Adyen HTTP Notification(s):';
     $comment = Mage::helper('adyen')->__('%s <br /> eventCode: %s <br /> pspReference: %s <br /> paymentMethod: %s <br /> success: %s %s %s', $type, $this->_eventCode, $this->_pspReference, $this->_paymentMethod, $success, $klarnaReservationNumberText, $boletoPaidAmountText);
     // If notification is pending status and pending status is set add the status change to the comment history
     if ($this->_eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_PENDING) {
         $pendingStatus = $this->_getConfigData('pending_status', 'adyen_abstract', $order->getStoreId());
         if ($pendingStatus != "") {
             $order->addStatusHistoryComment($comment, $pendingStatus);
             $this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $pendingStatus;
             return;
         }
     }
     // if manual review is accepted and a status is selected. Change the status through this comment history item
     if ($this->_eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_MANUAL_REVIEW_ACCEPT && $this->_getFraudManualReviewAcceptStatus($order) != "") {
         $manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus($order);
         $order->addStatusHistoryComment($comment, $manualReviewAcceptStatus);
         $this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus;
         return;
     }
     $order->addStatusHistoryComment($comment);
     $this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification';
 }
Esempio n. 3
0
 /**
  * @desc order comments or history
  * @param type $order
  * @param Varien_Object $response
  */
 protected function _addStatusHistoryComment($order, Varien_Object $response, $status = false)
 {
     Mage::log("_addStatusHistoryComment", Zend_Log::DEBUG, "adyen_notification.log", true);
     //notification
     $pspReference = $response->getData('pspReference');
     $success = trim($response->getData('success'));
     $success_result = strcmp($success, 'false') == 0 || !$success ? 'false' : 'true';
     $eventCode = $response->getData('eventCode');
     $reason = $response->getData('reason');
     $success = !empty($reason) ? "{$success_result} <br />reason:{$reason}" : $success_result;
     $klarnaReservationNumber = $response->getData('additionalData_additionalData_acquirerReference');
     $boletoPaidAmount = $response->getData('additionalData_boletobancario_paidAmount');
     //post
     $authResult = $response->getData('authResult');
     $pspReference = $response->getData('pspReference');
     //payment method
     $paymentMethod = $response->getData('paymentMethod');
     //data type
     $type = !empty($authResult) ? 'Adyen Result URL Notification(s):' : 'Adyen HTTP Notification(s):';
     switch ($type) {
         case 'Adyen Result URL Notification(s):':
             /*PCD*/
             // choose not to update the adyen_event_code in the order when the order is already on notification:Authorisation status and authresult = resultURL:Authorised
             if (!(substr($order->getAdyenEventCode(), 0, 13) == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISATION && $authResult == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISED)) {
                 Mage::log("Adyen Result URL order authResult:" . $authResult, Zend_Log::DEBUG, "adyen_notification.log", true);
                 $order->setAdyenEventCode($authResult);
             }
             $comment = Mage::helper('adyen')->__('%s <br /> authResult: %s <br /> pspReference: %s <br /> paymentMethod: %s', $type, $authResult, $pspReference, $paymentMethod);
             break;
         default:
             Mage::log("default order authResult:" . $eventCode . " : " . strtoupper($success_result), Zend_Log::DEBUG, "adyen_notification.log", true);
             if ($eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_REFUND) {
                 $currency = $order->getOrderCurrencyCode();
                 // check if it is a full or partial refund
                 $amount = Mage::helper('adyen')->formatAmount($response->getValue() / 100, $currency);
                 $orderAmount = Mage::helper('adyen')->formatAmount($order->getGrandTotal(), $currency);
                 if ($amount == $orderAmount) {
                     $order->setAdyenEventCode($eventCode . " : " . strtoupper($success_result));
                 } else {
                     $order->setAdyenEventCode("(PARTIAL) " . $eventCode . " : " . strtoupper($success_result));
                 }
             } else {
                 $order->setAdyenEventCode($eventCode . " : " . strtoupper($success_result));
             }
             // if payment method is klarna or openinvoice/afterpay show the reservartion number
             if (($paymentMethod == "klarna" || $paymentMethod == "afterpay_default" || $paymentMethod == "openinvoice") && ($klarnaReservationNumber != null && $klarnaReservationNumber != "")) {
                 $klarnaReservationNumberText = "<br /> reservationNumber: " . $klarnaReservationNumber;
             } else {
                 $klarnaReservationNumberText = "";
             }
             if ($boletoPaidAmount != null && $boletoPaidAmount != "") {
                 $boletoPaidAmountText = "<br /> Paid amount: " . $boletoPaidAmount;
             } else {
                 $boletoPaidAmountText = "";
             }
             $comment = Mage::helper('adyen')->__('%s <br /> eventCode: %s <br /> pspReference: %s <br /> paymentMethod: %s <br /> success: %s %s %s', $type, $eventCode, $pspReference, $paymentMethod, $success, $klarnaReservationNumberText, $boletoPaidAmountText);
             break;
     }
     $order->addStatusHistoryComment($comment, $status);
     $order->save();
 }
Esempio n. 4
0
 /**
  * @desc order comments or history
  * @param type $order
  * @param Varien_Object $response 
  */
 protected function _addStatusHistoryComment($order, Varien_Object $response, $status = false)
 {
     //notification
     $pspReference = $response->getData('pspReference');
     $success = trim($response->getData('success'));
     $success = strcmp($success, 'false') == 0 || !$success ? 'false' : 'true';
     $eventCode = $response->getData('eventCode');
     $reason = $response->getData('reason');
     $success = !empty($reason) ? "{$success} <br />reason:{$reason}" : $success;
     //post
     $authResult = $response->getData('authResult');
     $pspReference = $response->getData('pspReference');
     //payment method
     $paymentMethod = $response->getData('paymentMethod');
     //data type
     $type = !empty($authResult) ? 'Adyen Result URL Notification(s):' : 'Adyen HTTP Notification(s):';
     switch ($type) {
         case 'Adyen Result URL Notification(s):':
             /*PCD*/
             // choose not to update the adyen_event_code in the order when the order is already on notification:Authorisation status and authresult = resultURL:Authorised
             if (!($order->getAdyenEventCode() == Madia_Adyen_Model_Event::ADYEN_EVENT_AUTHORISATION && $authResult == Madia_Adyen_Model_Event::ADYEN_EVENT_AUTHORISED)) {
                 $order->setAdyenEventCode($authResult);
             }
             $comment = Mage::helper('adyen')->__('%s <br /> authResult: %s <br /> pspReference: %s <br /> paymentMethod: %s', $type, $authResult, $pspReference, $paymentMethod);
             break;
         default:
             $order->setAdyenEventCode($eventCode);
             $comment = Mage::helper('adyen')->__('%s <br /> eventCode: %s <br /> pspReference: %s <br /> paymentMethod: %s <br /> success: %s ', $type, $eventCode, $pspReference, $paymentMethod, $success);
             break;
     }
     $order->addStatusHistoryComment($comment, $status);
     /*PCD*/
     $order->save();
 }