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
5 changes: 0 additions & 5 deletions examples/CardNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public function init()

private function getTpayNotification()
{
// If you want to disable server IP validation, run this command (not recommended):
$this->disableValidationServerIP();
// If you use proxy communication and want to check for Tpay server IP at HTTP_X_FORWARDED_FOR, fun this command:
$this->enableForwardedIPValidation();
// Check Tpay server IP and validate parameters
$notification = $this->handleNotification();
// Get order details from your DB
$shopOrderData = $this->getOrderDetailsFromDatabase($notification['order_id']);
Expand Down
15 changes: 0 additions & 15 deletions src/Dictionaries/NotificationsIP.php

This file was deleted.

5 changes: 1 addition & 4 deletions src/Notifications/BasicNotificationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BasicNotificationHandler extends BasicPaymentOptions
{
/**
* Check cURL request from tpay server after payment.
* This method check server ip, required fields and md5 checksum sent by payment server.
* This method check required fields and md5 checksum sent by payment server.
* Display information to prevent sending repeated notifications.
*
* @param string $response Print response to Tpay server (enum: 'TRUE', 'FALSE').
Expand All @@ -32,9 +32,6 @@ public function checkPayment($response = 'TRUE')
$res['tr_crc']
);
Util::logLine('Check MD5: '.(int) $checkMD5);
if (true === $this->validateServerIP && false === $this->isTpayServer()) {
throw new TException('Request is not from secure server');
}
if (false === $checkMD5) {
throw new TException('MD5 checksum is invalid');
}
Expand Down
34 changes: 0 additions & 34 deletions src/Notifications/BlikAliasNotificationHandler.php

This file was deleted.

5 changes: 1 addition & 4 deletions src/Notifications/CardNotificationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CardNotificationHandler extends PaymentCard
{
/**
* Check cURL request from tpay server after payment.
* This method check server ip, required fields and md5 checksum sent by payment server.
* This method check required fields and md5 checksum sent by payment server.
* Display information to prevent sending repeated notifications.
*
* @throws TException
Expand All @@ -32,9 +32,6 @@ public function handleNotification()
} else {
throw new TException('Unknown notification type');
}
if (true === $this->validateServerIP && false === $this->isTpayServer()) {
throw new TException('Request is not from secure server');
}

echo json_encode([CardDictionary::RESULT => '1']);

Expand Down
63 changes: 1 addition & 62 deletions src/Utilities/ObjectsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Tpay\OriginApi\Utilities;

use Tpay\OriginApi\Curl\Curl;
use Tpay\OriginApi\Dictionaries\NotificationsIP;
use Tpay\OriginApi\Validators\FieldsConfigValidator;

class ObjectsHelper
Expand Down Expand Up @@ -73,17 +72,11 @@ class ObjectsHelper
*/
protected $cardHashAlg = 'sha1';

protected $secureIP = NotificationsIP::SECURE_IPS;
protected $validateServerIP = true;
protected $validateForwardedIP = false;
protected $transactionApi;
protected $cardsApi;
protected $basicClient;
protected $validator;
protected $curl;

/**
* @param string $url
*
* @param array $params
*
* @return array
Expand All @@ -98,58 +91,4 @@ public function requests($url, $params)
->doRequest()
->getResult();
}

/**
* Disabling validation of payment notification server IP
* Validation of tpay server ip is very important.
* Use this method only in test mode and be sure to enable validation in production.
*/
public function disableValidationServerIP()
{
$this->validateServerIP = false;

return $this;
}

/** Enabling validation of payment notification server IP */
public function enableValidationServerIP()
{
$this->validateServerIP = true;

return $this;
}

/**
* CloudFlare protected servers will be validated like all others
* It is default behavior
*/
public function disableForwardedIPValidation()
{
$this->validateForwardedIP = false;

return $this;
}

/** Enabling validation for CloudFlare protected servers */
public function enableForwardedIPValidation()
{
$this->validateForwardedIP = true;

return $this;
}

/**
* Check if request is called from secure tpay server
*
* @return bool
*/
public function isTpayServer()
{
return (new ServerValidator(
$this->validateServerIP,
$this->validateForwardedIP,
$this->secureIP
)
)->isValid();
}
}
76 changes: 0 additions & 76 deletions src/Utilities/ServerValidator.php

This file was deleted.

3 changes: 0 additions & 3 deletions src/legacy_classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CurlOptions extends \Tpay\OriginApi\Curl\CurlOptions {}

namespace tpayLibs\src\_class_tpay\Notifications {
class BasicNotificationHandler extends \Tpay\OriginApi\Notifications\BasicNotificationHandler {}
class BlikAliasNotificationHandler extends \Tpay\OriginApi\Notifications\BlikAliasNotificationHandler {}
class CardNotificationHandler extends \Tpay\OriginApi\Notifications\CardNotificationHandler {}
}

Expand All @@ -42,7 +41,6 @@ class BasicReports extends \Tpay\OriginApi\Reports\BasicReports {}
namespace tpayLibs\src\_class_tpay\Utilities {
class Lang extends \Tpay\OriginApi\Utilities\Lang {}
class ObjectsHelper extends \Tpay\OriginApi\Utilities\ObjectsHelper {}
class ServerValidator extends \Tpay\OriginApi\Utilities\ServerValidator {}
class TException extends \Tpay\OriginApi\Utilities\TException {}
class Util extends \Tpay\OriginApi\Utilities\Util {}
}
Expand Down Expand Up @@ -95,7 +93,6 @@ class CardDictionary extends \Tpay\OriginApi\Dictionaries\CardDictionary {}
class FieldsConfigDictionary extends \Tpay\OriginApi\Dictionaries\FieldsConfigDictionary {}
class FieldValueFilters extends \Tpay\OriginApi\Dictionaries\FieldValueFilters {}
class HttpCodesDictionary extends \Tpay\OriginApi\Dictionaries\HttpCodesDictionary {}
class NotificationsIP extends \Tpay\OriginApi\Dictionaries\NotificationsIP {}
class PaymentTypesDictionary extends \Tpay\OriginApi\Dictionaries\PaymentTypesDictionary {}
}

Expand Down
3 changes: 0 additions & 3 deletions tests/LegacyNamespaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function legacyClassNamesFromArray()
'tpayLibs\\src\\Dictionaries\\ISO_codes\\CountryCodesDictionary',
'tpayLibs\\src\\Dictionaries\\ISO_codes\\CurrencyCodesDictionary',
'tpayLibs\\src\\Dictionaries\\Localization\\CardPaymentLanguagesDictionary',
'tpayLibs\\src\\Dictionaries\\NotificationsIP',
'tpayLibs\\src\\Dictionaries\\PaymentTypesDictionary',
'tpayLibs\\src\\Dictionaries\\Payments\\BasicFieldsDictionary',
'tpayLibs\\src\\Dictionaries\\Payments\\BlikFieldsDictionary',
Expand All @@ -72,7 +71,6 @@ public function legacyClassNamesFromArray()
'tpayLibs\\src\\_class_tpay\\Curl\\CurlOptions',
'tpayLibs\\src\\_class_tpay\\MassPayments',
'tpayLibs\\src\\_class_tpay\\Notifications\\BasicNotificationHandler',
'tpayLibs\\src\\_class_tpay\\Notifications\\BlikAliasNotificationHandler',
'tpayLibs\\src\\_class_tpay\\Notifications\\CardNotificationHandler',
'tpayLibs\\src\\_class_tpay\\PaymentBlik',
'tpayLibs\\src\\_class_tpay\\PaymentCard',
Expand All @@ -87,7 +85,6 @@ public function legacyClassNamesFromArray()
'tpayLibs\\src\\_class_tpay\\TransactionApi',
'tpayLibs\\src\\_class_tpay\\Utilities\\Lang',
'tpayLibs\\src\\_class_tpay\\Utilities\\ObjectsHelper',
'tpayLibs\\src\\_class_tpay\\Utilities\\ServerValidator',
'tpayLibs\\src\\_class_tpay\\Utilities\\TException',
'tpayLibs\\src\\_class_tpay\\Utilities\\Util',
'tpayLibs\\src\\_class_tpay\\Validators\\AccessConfigValidator',
Expand Down
Loading