/**
  * update invoice items to sofortueberweisung
  * 
  * @param Varien_Object $payment object of the order
  * @param array $items of the the invoice
  * @param string $comment to add
  * @param string $invoiceNumber
  * @param string $customerNumber
  * @param string $orderNumber
  * @return Paymentnetwork_Pnsofortueberweisung_Model_Sofortrechnung
  * @throws Exception
  */
 public function updateInvoice(Varien_Object $payment, $items, $comment, $invoiceNumber = '', $customerNumber = '', $orderNumber = '')
 {
     // load current transaction id
     $transactionId = $payment->getAdditionalInformation('sofort_transaction');
     $order = $payment->getOrder();
     if (!empty($transactionId)) {
         // create articles
         $pnagArticles = array();
         foreach ($items as $item) {
             array_push($pnagArticles, array('itemId' => $item['item_id'], 'productNumber' => $item['product_number'], 'productType' => $item['product_type'], 'title' => $item['title'], 'description' => $item['description'], 'quantity' => $item['quantity'], 'unitPrice' => $item['unit_price'], 'tax' => $item['tax']));
         }
         // create connection class
         $PnagInvoice = new PnagInvoice(Mage::getStoreConfig('payment/sofort/configkey'), $transactionId);
         $PnagInvoice->setTransactionId($transactionId);
         $PnagInvoice->updateInvoice($transactionId, $pnagArticles, $comment, $invoiceNumber, $customerNumber, $orderNumber);
         // add error
         if ($PnagInvoice->isError()) {
             Mage::throwException($PnagInvoice->getError());
         } else {
             // update history
             $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('The invoice has been edit.') . "\n\n\"" . $comment . '"');
             $order->save();
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('pnsofortueberweisung')->__('Successfully edit invoice.'));
             return $this;
         }
     }
     // no transaction id exist
     Mage::getSingleton('adminhtml/session')->addError(Mage::helper('pnsofortueberweisung')->__('Could not edit invoice.'));
     return $this;
 }
Пример #2
0
    $paymentSecret = $_REQUEST['paymentSecret'];
    $statusReason = $SofortLib_TransactionData->getStatusReason();
    $status = $SofortLib_TransactionData->getStatus();
    $xCustomerId = $SofortLib_TransactionData->getUserVariable(1);
    //insert the serialized order into shop-db if it doesnt exist
    $xOrderId = handleOrderInsertion($transactionId, $paymentSecret, $paymentMethod, $xCustomerId);
    if (!$xOrderId) {
        exit('Error: No orderId found.');
    }
}
$configuration = getPaymentModuleConfiguration();
if ($paymentMethod == 'sr') {
    // Rechnung by Sofort
    $srOrderStatusArr = array('unconfirmed' => getStatusId($configuration['MODULE_PAYMENT_SOFORT_SR_UNCONFIRMED_STATUS_ID']), 'confirmed' => getStatusId($configuration['MODULE_PAYMENT_SOFORT_SR_ORDER_STATUS_ID']), 'cancelled' => getStatusId($configuration['MODULE_PAYMENT_SOFORT_SR_CANCEL_STATUS_ID']), 'check' => getStatusId($configuration['MODULE_PAYMENT_SOFORT_MULTIPAY_CHECK_STATUS_ID']));
    $PnagInvoice = new PnagInvoice(MODULE_PAYMENT_SOFORT_MULTIPAY_APIKEY, $transactionId);
    if ($PnagInvoice->isError()) {
        $errors = $PnagInvoice->getErrors();
        echo MODULE_PAYMENT_SOFORT_ERROR_TERMINATED . ' - ' . print_r($errors, true);
        exit;
    }
    $orderId = getOrderId($transactionId);
    $lastOrderStatus = getLastOrderStatus($orderId);
    $completeInvoiceStatus = $PnagInvoice->getState();
    $newTotal = checkIfNewTotal($PnagInvoice, $orderId);
    $newComments = '';
    // Update the order-status
    switch ($completeInvoiceStatus) {
        case PnagInvoice::PENDING_CONFIRM_INVOICE:
            updateShopAdresses($SofortLib_TransactionData->getInvoiceAddress(), $SofortLib_TransactionData->getShippingAddress(), $orderId);
            $historyComments = getHistoryComments($completeInvoiceStatus, $transactionId);
            $newComments = updateOrderStatus($PnagInvoice, $orderId, $srOrderStatusArr['unconfirmed'], $historyComments['customer'], $time, $newTotal);
Пример #3
0
 /**
  * cancel PNAG invoice
  * 
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function sales_order_payment_cancel($observer)
 {
     // dont trigger if we are notifyed
     if (!empty($GLOBALS['isNotificationAction'])) {
         return $this;
     }
     //get payment
     $payment = $observer->getEvent()->getPayment();
     $method = $payment->getMethod();
     if ($method != 'sofortrechnung') {
         return $this;
     }
     $transactionId = $payment->getAdditionalInformation('sofort_transaction');
     if (!empty($transactionId)) {
         $PnagInvoice = new PnagInvoice(Mage::getStoreConfig('payment/sofort/configkey'), $transactionId);
         if ($PnagInvoice->getStatus() != 'loss') {
             $PnagInvoice->cancelInvoice($transactionId);
         }
         if ($PnagInvoice->isError()) {
             Mage::throwException($PnagInvoice->getError());
         } else {
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('pnsofortueberweisung')->__('Successfully canceled invoice: %s', $transactionId));
             return $this;
         }
     }
     Mage::getSingleton('adminhtml/session')->addError(Mage::helper('pnsofortueberweisung')->__('Could not cancel invoice.'));
     return $this;
 }