Skip to content
This repository was archived by the owner on Apr 9, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions DIEGIMAS.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Diegimas

1. Padarykite atsargine failu kopija[nebutina].
2. Nukopijuokite viska i magento direktorija.
3. Isjunkite visus cache.
4. System -> Configuration -> Payments -> Paysera.com (irasykite Jusu Mokejimai.lt duomenis).
2. Nukopijuokite visus archyvo failus i jusu svetaines app/code direktorija (jeigu code direktorijos nera - sukurkite).
3. app/etc/config.php faile, pridekite tokia eilute: 'Paysera_Paysera' => 1, (eilute reikia prideti pries ");" ir ")," zenklus).
4. Isjunkite visus cache.
5. Admin meniu: Stores -> Configuration -> Sales -> Payment Methods -> Paysera (irasykite Jusu Mokejimai.lt duomenis).

Kontaktai

Expand Down
68 changes: 68 additions & 0 deletions Paysera/Paysera/Controller/Index/Callback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
namespace Paysera\Paysera\Controller\Index;

use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;

class Callback extends \Magento\Framework\App\Action\Action
{
protected $pageFactory;

public function __construct(
Context $context,
PageFactory $pageFactory,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
)
{
$this->pageFactory = $pageFactory;
$this->scopeConfig = $scopeConfig;
return parent::__construct($context);
}

public function execute()
{
require_once('WebToPay.php');

$paysera_config = $this->scopeConfig->getValue('payment/paysera', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

$callback = \WebToPay::checkResponse($_GET, $paysera_config);

if($callback['status'] == 1){
$env = (include './app/etc/env.php');
$db = $env['db']['connection']['default'];

$con = mysqli_connect($db['host'], $db['username'], $db['password'], $db['dbname']);
if (!$con) {
die("Database connection failed: " . mysqli_connect_error());
}

$i = 0;

if (mysqli_query($con, "UPDATE sales_order SET state='pending' WHERE entity_id=".$callback['orderid'])) {
$i++;
} else {
echo "Error updating record: " . mysqli_error($con);
}

if (mysqli_query($con, "UPDATE sales_order SET status='pending' WHERE entity_id=".$callback['orderid'])) {
$i++;
} else {
echo "Error updating record: " . mysqli_error($con);
}

if (mysqli_query($con, "UPDATE sales_order_grid SET status='pending' WHERE entity_id=".$callback['orderid'])) {
$i++;
} else {
echo "Error updating record: " . mysqli_error($con);
}

if($i == 3){
echo 'OK';
}else{
echo 'NOT OK';
}
}else{
echo 'NOT OK';
}
}
}
62 changes: 62 additions & 0 deletions Paysera/Paysera/Controller/Index/Index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
namespace Paysera\Paysera\Controller\Index;

use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;

class Index extends \Magento\Framework\App\Action\Action
{
protected $pageFactory;

public function __construct(
Context $context,
PageFactory $pageFactory,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager
)
{
$this->pageFactory = $pageFactory;
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
return parent::__construct($context);
}

public function execute()
{
$env = (include './app/etc/env.php');
$db = $env['db']['connection']['default'];

$con = mysqli_connect($db['host'], $db['username'], $db['password'], $db['dbname']);
if (!$con) {
die("Database connection failed: " . mysqli_connect_error());
}

$id = mysqli_query($con, "SELECT MAX(entity_id) AS MAX_ID FROM sales_order");
$id = mysqli_fetch_assoc($id);
$id = $id['MAX_ID'];

$order = mysqli_query($con, 'SELECT * FROM sales_order WHERE entity_id='.$id);
$order = mysqli_fetch_assoc($order);

require_once('WebToPay.php');

$paysera_config = $this->scopeConfig->getValue('payment/paysera', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

$request = \WebToPay::buildRequest(array(
'projectid' => $paysera_config['projectid'],
'amount' => $order['grand_total']*100,
'orderid' => $order['entity_id'],
'callbackurl' => $this->storeManager->getStore()->getBaseUrl().'paysera/index/callback',
'currency' => $order['order_currency_code'],
'country' => 'LT',
'p_email' => $order['customer_email'],
'sign_password' => $paysera_config['sign_password'],
'accepturl' => $this->storeManager->getStore()->getBaseUrl().'checkout/onepage/success',
'cancelurl' => $this->storeManager->getStore()->getBaseUrl(),
'test' => $paysera_config['test'],
));

echo json_encode(array("url" => \WebToPay::PAYSERA_PAY_URL.'?data='.$request['data'].'&sign='.$request['sign']));

}
}
Loading