/** * Confirm payment based on Dotpay URLC */ public function displayAjax() { $sellerApiCallback = new DotpaySellerApi($this->config->getDotpaySellerApiUrl()); if ($_SERVER['REMOTE_ADDR'] == $this->config->getOfficeIp() && $_SERVER['REQUEST_METHOD'] == 'GET') { die("--- Dotpay PrestaShop ---" . "<br>" . "Active: " . (int) $this->config->isDotpayEnabled() . "<br><br>" . "--- System Info ---" . "<br>" . "PrestaShop Version: " . _PS_VERSION_ . "<br>" . "Module Version: " . $this->module->version . "<br>" . "PHP Version: " . PHP_VERSION . "<br>" . "SSL: " . (int) Configuration::get('PS_SSL_ENABLED') . "<br>" . "SSL EVERYWHERE: " . (int) Configuration::get('PS_SSL_ENABLED_EVERYWHERE') . "<br><br>" . "--- Dotpay PLN ---" . "<br>" . "ID: " . $this->config->getDotpayId() . "<br>" . "ID Correct: " . (int) $this->api->checkSellerId($this->config->getDotpayId()) . "<br>" . "API Version: " . $this->config->getDotpayApiVersion() . "<br>" . "Test Mode: " . (int) $this->config->isDotpayTestMode() . "<br>" . "Widget: " . (int) $this->config->isDotpayWidgetMode() . "<br>" . "Payment Renew: " . (int) $this->config->isDotpayRenewEn() . "<br>" . "Refund: " . (int) $this->config->isDotpayRefundEn() . "<br>" . "Register Order: " . (int) $this->config->isDotpayDispInstruction() . "<br>" . "Disabled Currencies: " . $this->config->getDotpayWidgetDisCurr() . "<br><br>" . "--- Separate Channels ---" . "<br>" . "Credit Card: " . (int) $this->config->isDotpayCreditCard() . "<br>" . "MasterPass: "******"<br>" . "Blik: " . (int) $this->config->isDotpayBlik() . "<br>" . "One Click: " . (int) $this->config->isDotpayOneClick() . "<br><br>" . "--- Dotpay PV ---" . "<br>" . "PV Mode: " . (int) $this->config->isDotpayPV() . "<br>" . "PV ID: " . $this->config->getDotpayPvId() . "<br>" . "PV Currencies: " . $this->config->getDotpayPvCurrencies() . "<br><br>" . "--- Dotpay API ---" . "<br>" . "Login: "******"<br>" . "Password Correct: " . var_export($sellerApiCallback->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion()), true) . "<br><br>" . "--- Dotpay Fee ---" . "<br>" . "Fee Enabled: " . (int) $this->config->getDotpayExCh() . "<br>" . "Fee Flat: " . $this->config->getDotpayExAmount() . "<br>" . "Fee Percentage: " . $this->config->getDotpayExPercentage() . "<br><br>" . "--- Dotpay Discount ---" . "<br>" . "Discount Enabled: " . (int) $this->config->getDotpayDiscount() . "<br>" . "Discount Flat: " . $this->config->getDotpayDiscAmount() . "<br>" . "Discount Percentage: " . $this->config->getDotpayDiscPercentage()); } if (!($_SERVER['REMOTE_ADDR'] == $this->config->getDotpayIp() || $this->config->isDotpayTestMode() && ($_SERVER['REMOTE_ADDR'] == $this->config->getOfficeIp() || $_SERVER['REMOTE_ADDR'] == self::LOCAL_IP))) { die("PrestaShop - ERROR (REMOTE ADDRESS: " . $_SERVER['REMOTE_ADDR'] . ")"); } if ($_SERVER['REQUEST_METHOD'] != 'POST') { die("PrestaShop - ERROR (METHOD <> POST)"); } if (!$this->api->checkConfirm()) { die("PrestaShop - ERROR SIGNATURE - CHECK PIN"); } $api = $this->api; if ($api->getOperationType() == $api::paymentOperation) { $this->makePayment(); } else { if ($api->getOperationType() == $api::refundOperation) { $this->makeRefund(); } else { die('PrestaShop - ERROR STATUS'); } } }
/** * Preparing hidden form with payment data before sending it to Dotpay */ public function initContent() { parent::initContent(); $this->display_column_left = false; $this->display_header = false; $this->display_footer = false; $cartId = 0; if (Tools::getValue('order_id') == false) { $cartId = $this->context->cart->id; $exAmount = $this->api->getExtrachargeAmount(true); if ($exAmount > 0 && !$this->isExVPinCart()) { $productId = $this->config->getDotpayExchVPid(); if ($productId != 0) { $product = new Product($productId, true); $product->price = $exAmount; $product->save(); $product->flushPriceCache(); $this->context->cart->updateQty(1, $product->id); $this->context->cart->update(); $this->context->cart->getPackageList(true); } } $discAmount = $this->api->getDiscountAmount(); if ($discAmount > 0) { $discount = new CartRule($this->config->getDotpayDiscountId()); $discount->reduction_amount = $this->api->getDiscountAmount(); $discount->reduction_currency = $this->context->cart->id_currency; $discount->reduction_tax = 1; $discount->update(); $this->context->cart->addCartRule($discount->id); $this->context->cart->update(); $this->context->cart->getPackageList(true); } $result = $this->module->validateOrder($this->context->cart->id, (int) $this->config->getDotpayNewStatusId(), $this->getDotAmount(), $this->module->displayName, NULL, array(), NULL, false, $this->customer->secure_key); } else { $this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id')); $this->initPersonalData(); $cartId = $this->context->cart->id; } $this->api->onPrepareAction(Tools::getValue('dotpay_type'), array('order' => Order::getOrderByCartId($cartId), 'customer' => $this->context->customer->id)); $sa = new DotpaySellerApi($this->config->getDotpaySellerApiUrl()); if ($this->config->isDotpayDispInstruction() && $this->config->isApiConfigOk() && $this->api->isChannelInGroup(Tools::getValue('channel'), array(DotpayApi::cashGroup, DotpayApi::transfersGroup)) && $sa->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion())) { $this->context->cookie->dotpay_channel = Tools::getValue('channel'); Tools::redirect($this->context->link->getModuleLink($this->module->name, 'confirm', array('order_id' => Order::getOrderByCartId($cartId)))); die; } $this->context->smarty->assign(array('hiddenForm' => $this->api->getHiddenForm())); $cookie = new Cookie('lastOrder'); $cookie->orderId = Order::getOrderByCartId($cartId); $cookie->write(); $this->setTemplate("preparing.tpl"); }
/** * Returns HTML for module settings * @return string */ public function getContent() { $this->saveConfiguration(); $sellerApi = new DotpaySellerApi($this->config->getDotpaySellerApiUrl()); $version = DotpayGithubApi::getLatestVersion(); $this->context->smarty->assign(array('regMessEn' => $this->config->isDotpayTestMode() || !$this->config->isAccountConfigOk(), 'targetForUrlc' => $this->context->link->getModuleLink('dotpay', 'callback', array('ajax' => '1'), $this->isSSLEnabled()), 'moduleMainDir' => $this->_path, 'testMode' => $this->config->isDotpayTestMode(), 'oldVersion' => !version_compare(_PS_VERSION_, "1.6.0.1", ">="), 'badPhpVersion' => !version_compare(PHP_VERSION, "5.4", ">="), 'confOK' => $this->config->isAccountConfigOk() && $this->config->isDotpayEnabled(), 'moduleVersion' => $this->version, 'apiVersion' => $this->config->getDotpayApiVersion(), 'phpVersion' => PHP_VERSION, 'minorPhpVersion' => '5.4', 'badNewIdMessage' => $this->l('Incorrect ID (required 6 digits)'), 'badOldIdMessage' => $this->l('Incorrect ID (5 digits maximum)'), 'badNewPinMessage' => $this->l('Incorrect PIN (minimum 16 and maximum 32 alphanumeric characters)'), 'badOldPinMessage' => $this->l('Incorrect PIN (0 or 16 alphanumeric characters)'), 'valueLowerThanZero' => $this->l('The value must be greater than zero.'), 'testSellerId' => $this->api->checkSellerId($this->config->getDotpayId()), 'testApiAccount' => $sellerApi->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion()), 'urlWithNewVersion' => $version['url'], 'obsoletePlugin' => version_compare($version['version'], $this->version, '>'), 'canNotCheckPlugin' => $version['version'] === NULL)); $template = $this->context->smarty->fetch($this->local_path . 'views/templates/admin/configure.tpl'); return $template . $this->renderForm(); }