public function buildParameters($amount)
 {
     $parameters = array_merge($this->getServiceParameters(), $this->getRefundParameters());
     $refundNumber = count($this->getTransaction()->getRefunds()) + 1;
     $parameters['AMOUNT'] = number_format($amount, 2, '', '');
     $parameters['CURRENCY'] = $this->getTransaction()->getCurrencyCode();
     $parameters['ORDERID'] = Customweb_Util_String::substrUtf8($this->getTransactionAppliedSchema() . '-refund' . $refundNumber, -80);
     $parameters['DESCRIPTION'] = Customweb_I18n_Translation::__("Refunding Transaction '!transactionId'", array('!transactionId' => $this->getTransaction()->getExternalTransactionId()));
     return $parameters;
 }
 public function process()
 {
     if ($this->transactionId == null) {
         return;
     }
     if ($this->getUpdateAdapter() === null) {
         return;
     }
     $this->getTransactionHandler()->beginTransaction();
     $transactionObject = $this->getTransactionHandler()->findTransactionByTransactionId($this->transactionId);
     if ($transactionObject == null) {
         $this->getHandler()->log(Customweb_Util_String::formatString("No transaction found for transaction id '!id'.", array('!id' => $this->transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR);
     } else {
         try {
             $this->getUpdateAdapter()->updateTransaction($transactionObject);
             $this->getHandler()->log(Customweb_Util_String::formatString("Transaction with id '!id' successful updated.", array('!id' => $this->transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_INFO);
         } catch (Exception $e) {
             $this->getHandler()->log($e->getMessage(), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR);
         }
         $this->getTransactionHandler()->persistTransactionObject($transactionObject);
     }
     $this->getTransactionHandler()->commitTransaction();
 }
 private function executeUpdate($transactionId)
 {
     if (!$this->getTransactionHandler()->isTransactionRunning()) {
         $this->getTransactionHandler()->beginTransaction();
     }
     $transactionObject = $this->getTransactionHandler()->findTransactionByTransactionId($transactionId);
     if ($transactionObject == null) {
         $this->getHandler()->log(Customweb_Util_String::formatString("No transaction found for transaction id '!id'.", array('!id' => $transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR);
     } else {
         if ($transactionObject->getUpdateExecutionDate() !== null && $transactionObject->getUpdateExecutionDate()->getTimestamp() <= time()) {
             // 				$lastUpdateDate = $transactionObject->getUpdateExecutionDate();
             try {
                 if (method_exists($transactionObject, 'setUpdateExecutionDate')) {
                     $transactionObject->setUpdateExecutionDate(null);
                 }
                 $this->getUpdateAdapter()->updateTransaction($transactionObject);
                 $this->getHandler()->log(Customweb_Util_String::formatString("Transaction with id '!id' successful updated.", array('!id' => $transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_INFO);
             } catch (Exception $e) {
                 $this->getHandler()->log($e->getMessage(), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR);
                 // Reschedule the transaction of the update.
                 // 					The API should handle all Exceptions.
                 // 					We catch the unexpected ones, therefore it was a fatal error and we stop
                 // 					the pulling for this transaction, as it will most likely fail again.
                 // 					if (method_exists($transactionObject, 'setUpdateExecutionDate')) {
                 // 						$transactionObject->setUpdateExecutionDate($lastUpdateDate);
                 // 					}
             }
         }
         $this->getTransactionHandler()->persistTransactionObject($transactionObject);
     }
     $this->getTransactionHandler()->commitTransaction();
 }
Beispiel #4
0
 public static function applyOrderSchema($orderSchema, $transactionId, $maxLength)
 {
     $id = (string) $transactionId;
     if (!empty($orderSchema)) {
         $totalLength = strlen($id) + strlen($orderSchema);
         // In case the {id} is present, we have to substract 4 chars,
         // because they will be replaced later.
         if (stristr($orderSchema, '{id}')) {
             $totalLength = $totalLength - 4;
         }
         if ($totalLength > $maxLength) {
             $lengthToReduce = $totalLength - $maxLength;
             $orderSchema = Customweb_Util_String::substrUtf8($orderSchema, min($lengthToReduce, strlen($orderSchema)), strlen($orderSchema));
         }
         if (strstr($orderSchema, '{id}')) {
             $id = str_replace('{id}', $id, $orderSchema);
         } else {
             if (strstr($orderSchema, '{ID}')) {
                 $id = str_replace('{ID}', $id, $orderSchema);
             } else {
                 $id = $orderSchema . $id;
             }
         }
     }
     return Customweb_Util_String::substrUtf8($id, 0, $maxLength);
 }