Esempio n. 1
0
if (!($ps = Tools::getValue('ps')) || $ps != 1) {
    Payplug::redirectForVersion('index.php?controller=order&step=1');
}
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$payplug->active) {
    Payplug::redirectForVersion('index.php?controller=order&step=1');
}
/**
 * Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
 */
if (!Payplug::moduleIsActive()) {
    die($payplug->l('This payment method is not available.', 'validation'));
}
$customer = new Customer((int) $cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
    Payplug::redirectForVersion('index.php?controller=order&step=1');
}
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
PayplugLock::check($cart->id);
$order_id = Order::getOrderByCartId($cart->id);
if (!$order_id) {
    PayplugLock::addLock($cart->id);
    /** Get the right order status following module configuration (Sandbox or not) */
    $order_state = Payplug::getOsConfiguration('waiting');
    $payplug->validateOrder($cart->id, $order_state, $total, $payplug->displayName, false, array(), (int) $currency->id, false, $customer->secure_key);
    PayplugLock::deleteLock($cart->id);
    $order_id = $payplug->currentOrder;
}
/** Change variable name, because $link is already instanciated */
$link_redirect = $order_confirmation_url . 'id_cart=' . $cart->id . '&id_module=' . $payplug->id . '&id_order=' . $order_id . '&key=' . $customer->secure_key;
Payplug::redirectForVersion($link_redirect);
Esempio n. 2
0
}
/**
 *  Check amount
 */
$amount = $context->cart->getOrderTotal(true, Cart::BOTH) * 100;
if ($amount < Configuration::get('PAYPLUG_MODULE_MIN_AMOUNT') * 100 || $amount > Configuration::get('PAYPLUG_MODULE_MAX_AMOUNT') * 100) {
    return false;
}
/**
 *  Parameters for payment url
 */
$url_payment = Configuration::get('PAYPLUG_MODULE_URL');
if (Tools::getShopProtocol() == 'https://') {
    $baseurl = _PS_BASE_URL_SSL_;
} else {
    $baseurl = _PS_BASE_URL_;
}
$base_return_url = $baseurl . __PS_BASE_URI__ . 'modules/payplug/controllers/front/validation.php';
if (version_compare(_PS_VERSION_, '1.5', '<')) {
    $customer = new Customer($context->cookie->id_customer);
} else {
    $customer = $context->customer;
}
$params = array('amount' => $amount, 'custom_data' => $context->cart->id, 'origin' => 'Prestashop ' . _PS_VERSION_ . ' module ' . $payplug->version, 'currency' => $result_currency['iso_code'], 'ipn_url' => $baseurl . __PS_BASE_URI__ . 'modules/payplug/ipn.php', 'cancel_url' => $base_return_url . '?ps=2&cartid=' . $context->cart->id, 'return_url' => $base_return_url . '?ps=1&cartid=' . $context->cart->id, 'email' => $customer->email, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'order' => $context->cart->id, 'customer' => $customer->id);
$url_params = http_build_query($params);
$privatekey = Configuration::get('PAYPLUG_MODULE_KEY');
openssl_sign($url_params, $signature, $privatekey, $signature_alg = OPENSSL_ALGO_SHA1);
$url_param_base_encode = base64_encode($url_params);
$signature = base64_encode($signature);
Payplug::redirectForVersion($url_payment . '?data=' . urlencode($url_param_base_encode) . '&sign=' . urlencode($signature));