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;
 }
Пример #2
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);
 }