Skip to content
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
Binary file modified en/Payeer (WHMCS 6.2).doc
Binary file not shown.
Binary file modified en/Payeer (WHMCS 6.2).pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Payment module Payeer
To install a plugin download all files.
Then follow the provided instructions.

Support of version CMS WHMCS 6.2, WHMCS 7.7
Support WHMCS CMS version 6.2
103 changes: 55 additions & 48 deletions en/modules/gateways/callback/payeer.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
<?php

require_once __DIR__ . '/../../../init.php';
if (file_exists('../../../init.php'))
{
include_once('../../../init.php');
}
else
{
include_once('../../../dbconnect.php');
include_once('../../../includes/functions.php');
}

$whmcs->load_function('gateway');
$whmcs->load_function('invoice');

$gatewayModuleName = basename(__FILE__, '.php');
$gatewayParams = getGatewayVariables($gatewayModuleName);

if (!$gatewayParams['type']) {
die('Module Not Activated');
}
$gatewaymodule = 'payeer';
$GATEWAY = getGatewayVariables($gatewaymodule);

if (isset($_POST['m_operation_id']) && isset($_POST['m_sign'])) {
if (isset($_POST['m_operation_id']) && isset($_POST['m_sign']))
{
$err = false;
$message = '';

// запись логов

$log_text = "--------------------------------------------------------\n".
"operation id " . $_POST["m_operation_id"] . "\n".
"operation ps " . $_POST["m_operation_ps"] . "\n".
"operation date " . $_POST["m_operation_date"] . "\n".
"operation pay date " . $_POST["m_operation_pay_date"] . "\n".
"shop " . $_POST["m_shop"] . "\n".
"order id " . $_POST['m_orderid'] . "\n".
"amount " . $_POST["m_amount"] . "\n".
"currency " . $_POST["m_curr"] . "\n".
"description " . base64_decode($_POST["m_desc"]) . "\n".
"status " . $_POST["m_status"] . "\n".
"sign " . $_POST["m_sign"] . "\n\n";
$log_text =
"--------------------------------------------------------\n".
"operation id " . $_POST["m_operation_id"] . "\n".
"operation ps " . $_POST["m_operation_ps"] . "\n".
"operation date " . $_POST["m_operation_date"] . "\n".
"operation pay date " . $_POST["m_operation_pay_date"] . "\n".
"shop " . $_POST["m_shop"] . "\n".
"order id " . $_POST['m_orderid'] . "\n".
"amount " . $_POST["m_amount"] . "\n".
"currency " . $_POST["m_curr"] . "\n".
"description " . base64_decode($_POST["m_desc"]) . "\n".
"status " . $_POST["m_status"] . "\n".
"sign " . $_POST["m_sign"] . "\n\n";

$log_file = $gatewayParams['payeer_logfile'];
$log_file = $GATEWAY['payeer_logfile'];

if (!empty($log_file)) {
if (!empty($log_file))
{
file_put_contents($_SERVER['DOCUMENT_ROOT'] . $log_file, $log_text, FILE_APPEND);
}

checkCbInvoiceID($_POST['m_orderid'], $gatewayParams['name']);

// проверка цифровой подписи и ip

$sign_hash = strtoupper(hash('sha256', implode(":", array(
Expand All @@ -53,14 +57,14 @@
$_POST['m_curr'],
$_POST['m_desc'],
$_POST['m_status'],
$gatewayParams['payeer_secret_key']
$GATEWAY['payeer_secret_key']
))));

$valid_ip = true;
$sIP = str_replace(' ', '', $gatewayParams['payeer_ipfilter']);
$sIP = str_replace(' ', '', $GATEWAY['payeer_ipfilter']);

if (!empty($sIP)) {
if (!empty($sIP))
{
$arrIP = explode('.', $_SERVER['REMOTE_ADDR']);
if (!preg_match('/(^|,)(' . $arrIP[0] . '|\*{1})(\.)' .
'(' . $arrIP[1] . '|\*{1})(\.)' .
Expand All @@ -71,51 +75,54 @@
}
}

if (!$valid_ip) {
if (!$valid_ip)
{
$message .= " - IP address of the server is not trusted\n" .
" trusted IP: " . $sIP . "\n" .
" IP of the current server: " . $_SERVER['REMOTE_ADDR'] . "\n";
$err = true;
}

if ($_POST["m_sign"] != $sign_hash) {
if ($_POST["m_sign"] != $sign_hash)
{
$message .= " - do not match the digital signature\n";
$err = true;
}

if (!$err) {

switch ($_POST['m_status']) {

if (!$err)
{

switch ($_POST['m_status'])
{
case 'success':
echo $_POST['m_orderid'] . '|success';
checkCbTransID($_POST["m_operation_id"]);
addInvoicePayment($_POST['m_orderid'], $_POST["m_operation_id"], $_POST["m_amount"], '', $gatewaymodule);
logTransaction($gatewayParams['name'], $_POST, 'Successful');
addInvoicePayment($_POST['m_orderid'], $_POST["m_operation_id"], $payed, '', $gatewaymodule);
logTransaction($GATEWAY['name'], $_POST, 'Successful');
break;

default:
$message .= " - the payment status is not success\n";
logTransaction($gatewayParams["name"], $_POST, "Unsuccessful");
logTransaction($GATEWAY["name"], $event, "Unsuccessful");
$err = true;
break;
}
}

if ($err) {
$to = $gatewayParams['payeer_email_error'];
if ($err)
{
$to = $GATEWAY['payeer_email_error'];

if (!empty($to)) {
if (!empty($to))
{
$message = "Failed to make the payment through Payeer for the following reasons:\n\n" . $message . "\n" . $log_text;
$headers = "From: no-reply@" . $_SERVER['HTTP_HOST'] . "\r\n" .
"Content-type: text/plain; charset=utf-8 \r\n";
mail($to, 'Payment error', $message, $headers);
}

echo $_POST['m_orderid'] . '|error';
exit($_POST['m_orderid'] . '|error');
}
else
{
exit($_POST['m_orderid'] . '|success');
}
}
74 changes: 33 additions & 41 deletions en/modules/gateways/payeer.php
Original file line number Diff line number Diff line change
@@ -1,60 +1,49 @@
<?php

if (!defined('WHMCS')) {
die('This file cannot be accessed directly');
}

function payeer_config() {

function payeer_config()
{
$configarray = array(
'FriendlyName' => array(
'Type' => 'System',
'Value' => 'Payeer'
),
'payeer_url' => array(
'FriendlyName' => 'Merchant URL',
'FriendlyName' => "merchant's URL (by default, https://payeer.com/merchant/)",
'Type' => 'text',
'Size' => '100',
'Default' => 'https://payeer.com/merchant/',
'Description' => 'The URL for the payment'
'Default' => 'https://payeer.com/merchant/'
),
'payeer_shop' => array(
'FriendlyName' => 'ID store',
'Type' => 'text',
'Size' => '50',
'Description' => 'The store identifier registered in Payeer'
'FriendlyName' => 'ID of the store',
'Type' => 'text',
'Size' => '50'
),
'payeer_secret_key' => array(
'FriendlyName' => 'Secret key',
'Type' => 'text',
'Size' => '100',
'Description' => 'The secret key of merchant'
'FriendlyName' => 'Secret key',
'Type' => 'text',
'Size' => '100'
),
'payeer_logfile' => array(
'FriendlyName' => 'Path to the log file for payments (for example, /payeer_orders.log)',
'Type' => 'text',
'Size' => '100',
'Description' => 'If path is not specified, the log is not written'
'FriendlyName' => 'Path to file for logging of payments (for example, /payeer_orders.log)',
'Type' => 'text',
'Size' => '100'
),
'payeer_ipfilter' => array(
'FriendlyName' => 'IP - filter',
'Type' => 'text',
'Size' => '100',
'Description' => 'The list of trusted ip addresses, you can specify the mask'
'FriendlyName' => 'IP filter handler',
'Type' => 'text',
'Size' => '100'
),
'payeer_email_error' => array(
'FriendlyName' => 'Email for errors',
'Type' => 'text',
'Size' => '100',
'Description' => 'Email to send payment errors'
'FriendlyName' => 'Email for payment errors',
'Type' => 'text',
'Size' => '100'
)
);

return $configarray;
}

function payeer_link($params) {
function payeer_link($params)
{
global $_LANG;

$m_url = $params['payeer_url'];
Expand All @@ -76,15 +65,18 @@ function payeer_link($params) {
);
$sign = strtoupper(hash('sha256', implode(':', $arHash)));

$code = '<form id = "form_payment_payeer" method="GET" action="' . $m_url . '">
<input type="hidden" name="m_shop" value="' . $m_shop . '">
<input type="hidden" name="m_orderid" value="' . $m_orderid . '">
<input type="hidden" name="m_amount" value="' . $m_amount . '">
<input type="hidden" name="m_curr" value="' . $m_curr . '">
<input type="hidden" name="m_desc" value="' . $m_desc . '">
<input type="hidden" name="m_sign" value="' . $sign . '">
<input type="hidden" name="lang" value="' . $m_lang . '">
<input type="submit" name="m_process" value="' . $_LANG['invoicespaynow'] . '" /></form>';
$code = '
<form id = "form_payment_payeer" method="GET" action="' . $m_url . '">
<input type="hidden" name="m_shop" value="' . $m_shop . '">
<input type="hidden" name="m_orderid" value="' . $m_orderid . '">
<input type="hidden" name="m_amount" value="' . $m_amount . '">
<input type="hidden" name="m_curr" value="' . $m_curr . '">
<input type="hidden" name="m_desc" value="' . $m_desc . '">
<input type="hidden" name="m_sign" value="' . $sign . '">
<input type="hidden" name="lang" value="' . $m_lang . '">
<input type="submit" name="m_process" value="' . $_LANG['invoicespaynow'] . '" />
</form>
';

return $code;
}
Binary file removed en/modules/gateways/payeer/logo.png
Binary file not shown.
23 changes: 0 additions & 23 deletions en/modules/gateways/payeer/whmcs.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

if (isset($_GET['m_orderid'])) {
if (isset($_GET['m_orderid']))
{
$order_id = preg_replace('/[^a-zA-Z0-9_-]/', '', substr($_GET['m_orderid'], 0, 32));
header('Location: ' . $_SERVER['HOST'] . '/viewinvoice.php?id=' . $order_id . '&paymentfailed=true');
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

if (isset($_GET['m_orderid'])) {
if (isset($_GET['m_orderid']))
{
$order_id = preg_replace('/[^a-zA-Z0-9_-]/', '', substr($_GET['m_orderid'], 0, 32));
header('Location: ' . $_SERVER['HOST'] . '/viewinvoice.php?id=' . $order_id . '&paymentsuccess=true');
}
Binary file modified ru/Payeer (WHMCS 6.2).doc
Binary file not shown.
Binary file modified ru/Payeer (WHMCS 6.2).pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion ru/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ WHMCS
Для установки модуля скачайте все файлы.
Далее следуйте прилагаемой инструкции

Поддержка версии CMS WHMCS 6.2, WHMCS 7.7
Поддержка версии CMS WHMCS 6.2
Loading