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: 3 additions & 4 deletions DIEGIMAS.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Diegimas

1. Ikelkite viska i pagrindine csCart direktorija.
2. Ivikdykite SQL uzklausa Jusu csCart duomenu bazeje:
REPLACE INTO cscart_payment_processors (processor_id, processor, processor_script,processor_template, admin_template, callback, type)
values ('1111', 'Paysera','paysera.php', 'paysera.tpl','paysera.tpl', 'N', 'P');
2. Ivikdykite SQL uzklausas esancias /var/databse/backup/db_changes_paysera.sql faile Jusu csCart duomenu bazeje.

3. Administravime eikite i Administration -> Payment methods -> Add payment. Naudokite siuos nustatymus: General tab -> Name = "Paysera - payment gateway", Processor -> "Paysera".
4. Paspauskite konfiguruoti ir iveskite visus duomenis.

Kontaktai

Kilus klausimams prasome kreiptis i pagalba@mokejimai.lt
Kilus klausimams prasome kreiptis i pagalba@paysera.lt
21 changes: 4 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
plugin-cscart
=============

Paysera.com payment gateway plugin for csCart 2.x-3

Requirements
------------

- csCart 2.x - 3.x

Installation
------------

1. Download this repository as zip and extract "payments,skins,stores" folders into csCart main directory.
2. Insert this SQL statement in your cscart database:
REPLACE INTO cscart_payment_processors (processor_id, processor, processor_script,processor_template, admin_template, callback, type)
values ('1111', 'Paysera','paysera.php', 'paysera.tpl','paysera.tpl', 'N', 'P');
1. Download the repository files ant put them in your default cscart directory.
2. Insert SQL statements from/var/databse/backup/db_changes_paysera.sql into your cscart database:

3. In administrator menu go to Administration -> Payment methods -> Add payment. Use these settings General tab -> Name = "Paysera - payment gateway", Processor -> "Paysera".
4. Press configure and fill all the necessary information and save.

Contacts
--------

If any problems occur please feel free to seek help via support@paysera.com
If any problems occur please feel free to seek help via support@paysera.com
7 changes: 3 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Installation

1. Download the repository files ant put them in your default cscart directory.
2. Insert this SQL statement in your cscart database:
REPLACE INTO cscart_payment_processors (processor_id, processor, processor_script,processor_template, admin_template, callback, type)
values ('1111', 'Paysera','paysera.php', 'paysera.tpl','paysera.tpl', 'N', 'P');
2. Insert SQL statements from/var/databse/backup/db_changes_paysera.sql into your cscart database:

3. In administrator menu go to Administration -> Payment methods -> Add payment. Use these settings General tab -> Name = "Paysera - payment gateway", Processor -> "Paysera".
4. Press configure and fill all the necessary information and save.

Contacts

If any problems occur please feel free to seek help via support@paysera.com
If any problems occur please feel free to seek help via support@paysera.com
75 changes: 43 additions & 32 deletions payments/paysera.php → app/payments/paysera.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

use Tygh\Http;
use Tygh\Registry;

require_once(dirname(__FILE__) . '/vendor/webtopay/libwebtopay/WebToPay.php');

if (!defined('AREA')) {
die('Access denied');
}

if (!defined('BOOTSTRAP')) { die('Access denied'); }

//print_r($_GET); echo $mode;

if (defined('PAYMENT_NOTIFICATION')) {
function fn_payment_end($order_id, $pp_response, $force_notification = array()) {
Expand All @@ -22,28 +26,30 @@ function fn_payment_end($order_id, $pp_response, $force_notification = array())
}
fn_change_order_status($order_id, $pp_response['order_status'], '', $force_notification);
}

if ($mode == 'return') {
if (fn_check_payment_script('paysera.php', $_REQUEST['orderId'])) {
$order_info = fn_get_order_info($_REQUEST['orderId'], true);
//echo $mode; die;
if ($mode == 'success') { print_r($response);
if (fn_check_payment_script('paysera.php', $_REQUEST['order_id'])) {
$order_info = fn_get_order_info($_REQUEST['order_id'], true);
if ($order_info['status'] == 'N') {
fn_change_order_status($_REQUEST['orderId'], 'O', '', false);
fn_change_order_status($_REQUEST['order_id'], 'O', '', false);
}
}
fn_order_placement_routines($_REQUEST['orderId'], false);
} elseif ($mode == 'callback') {
$order_info = fn_get_order_info($_REQUEST['orderId']);
fn_order_placement_routines('route', $_REQUEST['order_id']);
exit;
}
elseif ($mode == 'notify') {
$order_info = fn_get_order_info($_REQUEST['order_id']);
if (empty($processor_data)) {
$processor_data = fn_get_processor_data($order_info['payment_id']);
}
if (empty($order_info)) {
throw new Exception(sprintf("Missing order by specified id (order_id=%s)", $response['orderid']));
throw new Exception(sprintf("Missing order by specified id (order_id=%s)", $response['order_id']));
}

try {
try {
$response = WebToPay::checkResponse($_REQUEST, array(
'projectid' => $processor_data['params']['project_id'],
'sign_password' => $processor_data['params']['sign'],
'projectid' => $processor_data['processor_params']['project_id'],
'sign_password' => $processor_data['processor_params']['sign'],

));

Expand All @@ -69,43 +75,48 @@ function fn_payment_end($order_id, $pp_response, $force_notification = array())
} catch (Exception $e) {
exit(sprintf("ERROR: %s", $e->getMessage()));
}
} elseif ($mode == 'cancel') {
fn_payment_end($_REQUEST['orderId'], $response);
fn_order_placement_routines($_REQUEST['orderId']);
}
elseif ($mode == 'failed') { //echo 'ok'; die;
//fn_payment_end($_REQUEST['order_id'], $response);
fn_order_placement_routines('route', $_REQUEST['order_id']);
exit;
}
exit;
} else {

//print_r($order_info);
$pid = $order_info['payment_method']['processor_params']['project_id'];
$psign = $order_info['payment_method']['processor_params']['sign'];
$ptest = $order_info['payment_method']['processor_params']['test'];
$pcurr = $order_info['payment_method']['processor_params']['currency'];
$_order_id = ($order_info['repaid']) ? ($order_id . '_' . $order_info['repaid']) : $order_id;

$s_id = Session::get_id();
//$s_id = Session::get_id();

$order_info['b_country'] = strtolower($order_info['b_country']);

$language = strtoupper($_SESSION['settings']['cart_languageC']['value']);
$currency = strtoupper($_SESSION['settings']['secondary_currencyC']['value']);

//echo $currency;
$currencyCo = db_get_field("SELECT ?:currencies.coefficient FROM ?:currencies WHERE ?:currencies.currency_code = ?s", $currency);
$price = intval(number_format($order_info['total'] / $currencyCo, 2, '', ''));

$url = (strpos($_SERVER['SERVER_PROTOCOL'], 'HTTPS') !== false ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$url = strtr($url, array('index.php' => '/payments/paysera.php'));
$urlIndex = strtr($url, array('/payments/paysera.php' => 'index.php'));

$psData = fn_get_payment_method_data($_SESSION['cart']['payment_id']);
//$psData = fn_get_payment_method_data($_SESSION['cart']['payment_id']);

try {
$payment_info = array(
'projectid' => $psData['params']['project_id'],
'sign_password' => $psData['params']['sign'],
'projectid' => $pid,
'sign_password' => $psign,
'orderid' => $_order_id,
'lang' => ($language === 'LT') ? 'LIT' : 'ENG',
'amount' => $price,
'currency' => $currency,
'accepturl' => "{$urlIndex}?dispatch=payment_notification.return&payment=paysera&orderId={$_order_id}",
'cancelurl' => "{$urlIndex}?dispatch=payment_notification.cancel&payment=paysera&orderId={$_order_id}",
'callbackurl' => "{$urlIndex}?dispatch=payment_notification.callback&payment=paysera&orderId={$_order_id}",
'accepturl' => fn_url("payment_notification.success?payment=paysera&order_id=$order_id", AREA, 'current'),
'cancelurl' => fn_url("payment_notification.failed?payment=paysera&order_id=$order_id", AREA, 'current'),
'callbackurl' => fn_url("payment_notification.notify?payment=paysera&order_id=$order_id", AREA, 'current'),
'payment' => '',
'country' => $order_info['b_country'],
'logo' => '',
Expand All @@ -119,12 +130,12 @@ function fn_payment_end($order_id, $pp_response, $force_notification = array())
'p_zip' => $order_info['b_zipcode'],
'p_countrycode' => $order_info['b_country'],

'test' => $psData['params']['test'],
);

WebToPay::redirectToPayment($payment_info);
'test' => $ptest,
); ///print_r($payment_info); //die;
WebToPay::redirectToPayment($payment_info);

} catch (WebToPayException $e) {
exit(get_class($e) . ': ' . $e->getMessage());
}
} die;
fn_start_payment($_order_id, false, $payment_info);
}
Loading