コード例 #1
0
 public function hookAdminOrder($params)
 {
     $error = 0;
     $order = new Order((int) $params['id_order']);
     if (!Validate::isLoadedObject($order)) {
         die(Tools::displayError());
     }
     if ($order->module != $this->name) {
         return false;
     }
     $disposition = PSCDisposition::getByCartId((int) $order->id_cart);
     if (!$disposition) {
         // No disposition = Order paid
         return false;
     }
     // check disposition state
     $res = PSCPrepaidServicesAPI::getSerialNumbers($this->getAPIConfiguration($disposition['currency']), Configuration::get($this->prefix . 'MERCHANT_ID_' . $disposition['currency']), $disposition['mtid'], $disposition['currency']);
     $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
     // if the disposition is not "active"
     if ($res[5] != PSCPrepaidServicesAPI::DISPOSITION_DISPOSED && $res[5] != PSCPrepaidServicesAPI::DISPOSITION_DEBITED) {
         $this->context->smarty->assign(array('disposition_state' => $res[5], 'payment_name' => $order->payment));
         return $this->display($this->module_dir . '/' . $this->name, 'disposition-error.tpl');
     }
     if (Tools::isSubmit('acceptPayment')) {
         $amount = Tools::getValue('ps_amount');
         if (isset($amount) && !empty($amount) && $amount <= $res[3] && $amount > 0) {
             if (!$this->_acceptPayment($order, $disposition, $currency->getSign('right'), $amount)) {
                 $error = 1;
             }
         } else {
             $error = 2;
         }
         $query_string = $error ? self::changeQueryStringParameter($_SERVER['QUERY_STRING'], 'pp_error', (int) $error) : self::removeQueryStringParameter($_SERVER['QUERY_STRING'], 'pp_error');
         Tools::redirectAdmin(Tools::safeOutput($_SERVER['PHP_SELF']) . '?' . $query_string);
     } else {
         if (Tools::isSubmit('releasePayment')) {
             if (!$this->_releasePayment($order, $disposition)) {
                 $error = 1;
             }
             $query_string = $error ? self::changeQueryStringParameter($_SERVER['QUERY_STRING'], 'pp_error', (int) $error) : $_SERVER['QUERY_STRING'];
             Tools::redirectAdmin(Tools::safeOutput($_SERVER['PHP_SELF']) . '?' . $query_string);
         }
     }
     $error_msg = '';
     if (Tools::getIsset('pp_error')) {
         $error_msg = $this->_getErrorMsgFromErrorCode(Tools::getValue('pp_error'));
     }
     $this->context->smarty->assign(array('action' => Tools::safeOutput($_SERVER['PHP_SELF']) . '?' . $_SERVER['QUERY_STRING'], 'payment_name' => $order->payment, 'error' => $error_msg, 'currency' => $currency->getSign('right'), 'amount' => $res[3]));
     return $this->display($this->module_dir . '/' . $this->name, $this->name . '-accept-payment.tpl');
 }
コード例 #2
0
ファイル: payment.php プロジェクト: greench/prestashop
include dirname(__FILE__) . '/paysafecard.php';
$module = new PaysafeCard();
if (!$cart->id or $cart->id_customer == 0 or $cart->id_address_delivery == 0 or $cart->id_address_invoice == 0 or !$module->active) {
    Tools::redirect('order.php?step=3');
}
$currency = new Currency($cart->id_currency);
if (!$module->isCurrencyActive($currency->iso_code)) {
    Tools::redirect('order.php?step=3');
}
$amount = number_format((double) $cart->getOrderTotal(true, Cart::BOTH), 2, '.', '');
if (Tools::getValue('hash') != md5(Configuration::get($module->prefix . 'SALT') + $amount + $currency->iso_code)) {
    die(Tools::displayError());
}
$result = $module->getDispositionState((int) $cart->id);
$state = Configuration::get('PS_OS_ERROR');
$disposition = PSCDisposition::getByCartId((int) $cart->id);
$message = 'Transaction ID #' . $disposition['mtid'] . ': ' . $disposition['amount'] . $disposition['currency'] . '<br />' . date('Y-m-d') . ' ';
if ($result[0] == 0) {
    list($rc, $errorcode, $error_message, $amount, $used_currency, $state) = $result;
    if ($state == PSCPrepaidServicesAPI::DISPOSITION_DISPOSED || $state == PSCPrepaidServicesAPI::DISPOSITION_DEBITED) {
        $state = Configuration::get('PS_OS_PAYMENT');
        $message .= $module->getL('disposition_created');
    } else {
        $message .= $module->getL('disposition_invalid') . ' ' . $state;
    }
} else {
    $message .= 'payment_error' . ' ' . $result[2];
}
if ($state != Configuration::get('PS_OS_ERROR')) {
    $state = (int) Configuration::get($module->prefix . 'ORDER_STATE_ID');
    if (Configuration::get($module->prefix . 'IMMEDIAT_PAYMENT')) {