Exemplo n.º 1
0
<?php

session_start();
require_once '../../bootstrap.php';
require '../../services/UserService.php';
require '../../services/ItemService.php';
require '../../services/RequestService.php';
UserService::withRole(UserService::$CONTRIBUTOR, function () {
    $_PUT = RequestService::processPutParams();
    if (array_key_exists("id", $_GET)) {
        $ingredientId = $_GET["id"];
        $ingredient = ingredientTypeQuery::create()->findPk($ingredientId);
    }
    if (isset($ingredient)) {
        $ingredient->setName($_PUT["name"]);
        ItemService::saveWithValidation($ingredient, 204);
    } else {
        http_response_code(404);
    }
});
Exemplo n.º 2
0
 /**
  * Call PAYMENT_CHANGE with the subtype credit
  * and add a credit item to the order
  */
 public static function creditAction()
 {
     $orderId = Globals::getPostEntry('order_number');
     $order = new order($orderId);
     $payment = Loader::getRatepayPayment($order->info['payment_method']);
     $transactionId = Db::getRatepayOrderDataEntry($orderId, 'transaction_id');
     $transactionShortId = Db::getRatepayOrderDataEntry($orderId, 'transaction_short_id');
     $data = array('HeadInfo' => RequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId, 'credit'), 'BasketInfo' => RequestMapper::getBasketInfoModel($order, $orderId, Globals::getPost()), 'CustomerInfo' => RequestMapper::getCustomerInfoModel($order, $orderId), 'PaymentInfo' => RequestMapper::getPaymentInfoModel($order, $orderId));
     $requestService = new RequestService($payment->sandbox, $data);
     $result = $requestService->callPaymentChange();
     Db::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse());
     if (!array_key_exists('error', $result)) {
         Session::setRpSessionEntry('message_css_class', 'messageStackSuccess');
         Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_SUCCESS);
         Db::setRpCreditItem(Globals::getPost());
         Db::setRpHistoryEntry($orderId, Data::getCreditItem(Globals::getPost()), 'PAYMENT_CHANGE', 'credit');
         Db::addCreditToShop($orderId, Globals::getPost());
         Db::updateShopOrderTotals($orderId);
     } else {
         Session::setRpSessionEntry('message_css_class', 'messageStackError');
         Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_ERROR);
     }
     tep_redirect(tep_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL'));
 }
 /**
  * Call PAYMENT_CONFIRM request
  * 
  * @global order $order
  * @param string $transactionId
  * @param string $transactionShortId
  * @param int $orderId
  * @return array
  */
 protected function _paymentConfirm($transactionId, $transactionShortId, $orderId)
 {
     global $order;
     $data = array('HeadInfo' => RequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId));
     $requestService = new RequestService($this->sandbox, $data);
     $result = $requestService->callPaymentConfirm();
     Db::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse());
     return $result;
 }