/** * Create transaction and return result * * @param object $paymentObj * * @since 1.0.0 * @return array */ public function doCheckout($paymentObj, $orderObj = null) { $obj = new StdClass(); $obj->MerchantID = $this->getMerchantID(); $obj->Timestamp = $this->getTimeStamp(); $obj->Amount = $paymentObj->getAmount(); $obj->Country = $paymentObj->getCountry(); $obj->Currency = $paymentObj->getCurrency(); $obj->Description = $paymentObj->getDescription(); $obj->EndUserIP = $this->getIP(); $obj->Issuer = $paymentObj->getPaymentMethodIssuer(); $obj->Language = $paymentObj->getLanguage(); $obj->OrderID = $paymentObj->getOrderID(); $obj->PaymentMethod = $paymentObj->getPaymentMethod(); $obj->Reference = $paymentObj->getReference(); $obj->URLCompleted = ''; $obj->URLError = ''; if ($this->isExtendedCheckout($obj->PaymentMethod)) { $obj->XML = $orderObj->getXML(); } $obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode()); if ($this->isExtendedCheckout($obj->PaymentMethod)) { $result = $this->client->CheckoutExtended(array('request' => $obj)); } else { $result = $this->client->Checkout(array('request' => $obj)); } return (array) $result; }
/** * Sets grand total order price to pdf. * * @param int &$iStartPos text start position */ protected function _setGrandTotalPriceInfo(&$iStartPos) { $this->font($this->getFont(), 'B', 10); // total order sum $sTotalOrderSum = $this->_oData->getFormattedTotalOrderSum() . ' ' . $this->_oData->getCurrency()->name; $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLSUM')); $this->text(195 - $this->_oPdf->getStringWidth($sTotalOrderSum), $iStartPos, $sTotalOrderSum); $iStartPos += 2; if ($this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value) { $iStartPos += 2; } }
/** * Update solr index for ad * * @param object $ad ad object * * @throws */ public function updateSolrIndex($ad) { try { $ping = $this->masterClient->createPing(); } catch (Solarium\Exception $e) { throw \Exception('Ping query failed'); } if (!$this->update) { $this->update = $this->masterClient->createUpdate(); } $contentArr = array(); $doc = $this->update->createDocument(); $doc->id = $ad->getId(); $doc->vertical_i = $ad->getVertical()->getId(); $doc->user_i = $ad->getUser()->getId(); $doc->cat1_i = $ad->getCategory1()->getId(); if ($ad->getCategory2()) { $doc->cat2_i = $ad->getCategory2()->getId(); } if ($ad->getCategory3()) { $doc->cat3_i = $ad->getCategory3()->getId(); } $doc->status_s = $ad->getStatus(); $doc->price_d = $ad->getPrice(); $doc->currency_i = $ad->getCurrency()->getId(); $title = preg_replace('/[\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F]/', '', $ad->getTitle()); $doc->title_s = $title; $contentArr[] = $title; $contentArr[] = $ad->getDescription(); $doc->seller_type_s = $ad->getUser()->isPrivateAdvertiser() ? 'PrivateAdvertiser' : 'BusinessAdvertiser'; $userTypes = array(); if ($ad->getUser()->getRoles()) { foreach ($ad->getUser()->getRoles() as $role) { $userTypes[] = $role ? $role->getId() : 0; } } if (count($userTypes)) { $doc->userType_is = array_unique($userTypes); } $doc->createdAt_dt = $ad->getCreatedAt(); $doc->createdAt_i = $ad->getCreatedAt()->getTimestamp(); $doc->updatedAt_dt = $ad->getUpdatedAt(); $doc->updatedAt_i = $ad->getUpdatedAt()->getTimestamp(); $doc->content = $contentArr; return $doc; }
/** * Sets grand total order price to pdf * * @param int &$iStartPos text start position * * @return none */ protected function _setGrandTotalPriceInfo(&$iStartPos) { $oLang = oxLang::getInstance(); // total netto price (A. very unprecise, impossible to count because of many factors) $this->font($this->getFont(), 'B', 10); if ($this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value) { // collecting total net price $sTotalNetSum = $oLang->formatCurrency($this->_oData->getOrderNetSum(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name; $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLSUM_NET')); $this->text(195 - $this->_oPdf->getStringWidth($sTotalNetSum), $iStartPos, $sTotalNetSum); $iStartPos += 4; } // total order sum $sTotalOrderSum = $oLang->formatCurrency($this->_oData->oxorder__oxtotalordersum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name; $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLSUM')); $this->text(195 - $this->_oPdf->getStringWidth($sTotalOrderSum), $iStartPos, $sTotalOrderSum); $iStartPos += 2; }
/** * Listens out for user commands in magical dice chat * * @param object $message Last message in chat * @param bool $pm Determines if user has PMed message or not * * @return void */ public function receiveMessage($message, $pm = false) { // definitons // user object $user = array('userId' => $message['userId'], 'user' => $message['user'], 'isMod' => $message['isMod']); // will store sent status $sent = false; $block = false; // check permission if ($user['isMod'] == $this->_isMod || $user['userId'] == $this->_userId) { // check if message is a command if (substr($message['msg'], 0, 3) == '!m ' || substr($message['msg'], 0, 1) == '!') { // if user is in the blacklist if (in_array($user['user'], $this->_blackList)) { // pm user letting them know they are blacklisted $this->internalSendMessage('You have been blacklisted', true, $user); // exit out $block = true; } else { if ($user['userId'] != $this->_userId && isset($this->_waitingList[$user['user']]) && time() - $this->_waitingList[$user['user']] < 30) { // pm user letting them know they have to wait $this->internalSendMessage('Please wait 30 seconds before trying another command', true, $user); // exit out $block = true; } } // block user if blocked if ($block) { return false; } // store message $offset = substr($message['msg'], 0, 3) == '!m ' ? 3 : 1; $msg = explode(' ', substr($message['msg'], $offset)); // PM command $prv = $this->isPrivCommand($msg[0]); // check invalid if ($prv !== -1) { // magic check if ($prv == $pm) { // get method $mrefl = $this->_reflection->getMethod('command_' . $msg[0]); // call method $mrefl->setAccessible(true); $mrefl->invokeArgs($this, array($user, $msg)); // log command usage Logger::notice('Username ' . $user['user'] . ' (' . $user['userId'] . ') performed ' . $msg[0] . ' command'); // set sent indicator to true $sent = true; } else { if (!$prv == $pm) { // send notification $this->_eventEmitter->sendMessage('This command needs to be ' . ($pm === false ? 'private messaged' : 'globally messaged'), true, $user); // set sent indicator to true $sent = true; } } } // if message has not been sent if (!$sent) { // check if command is a currency if ($this->_priceMarket->isCurrency($msg[0])) { // get currency price $price = $this->_priceMarket->getCurrency($msg[0]); // broadcasting price to chat if ($this->_limits['logOnly']) { // log message Logger::notice($price); } else { // chat message $this->_eventEmitter->sendMessage($price); } // log usage Logger::notice('Username ' . $user['user'] . ' (' . $user['userId'] . ') performed ' . $msg[0] . ' command'); // set sent indicator to true $sent = true; } // if message has not been sent if (!$sent && $offset == 3) { // output help command $this->command_help($user, $msg); // log action to console Logger::notice('Username ' . $user['user'] . ' (' . $user['userId'] . ') typed a non-existent command'); } } } // if message is sent if ($sent) { // add user to waiting list $this->_waitingList[$user['user']] = $message['time']; } } // store username $this->_userTable->store($message); // scan pm queue $this->scan_msg($user); }
/** * Creates Payment object with PayPal response data. * * @param object $oResponse * * @return oePayPalOrderPayment */ protected function _createPayment($oResponse) { $oPayment = oxNew('oePayPalOrderPayment'); $oPayment->setDate($this->getDate()); $oPayment->setTransactionId($oResponse->getTransactionId()); $oPayment->setCorrelationId($oResponse->getCorrelationId()); $oPayment->setAction('capture'); $oPayment->setStatus($oResponse->getPaymentStatus()); $oPayment->setAmount($oResponse->getCapturedAmount()); $oPayment->setCurrency($oResponse->getCurrency()); return $oPayment; }
/** * Returns true if the argument contains the same amount and the same currency. * * @param object $obj * * @return bool True if $obj is equal to this instance */ public function equals($obj) { if (!$obj instanceof Money) { return false; } if ($this->getCurrency() != $obj->getCurrency()) { return false; } return $this->getAmount() == $obj->getAmount(); }