maatify / pay-tabs
maatify.dev PayTabs, known by our team
1.1.0004
2024-12-02 00:09 UTC
Requires
- php: >=8.0.0
- ext-curl: *
- ext-json: *
- maatify/logger: ^1.1
README
PayTabs
maatify.dev logger, known by our team
Installation
composer require maatify/pay-tabs
Usage
- Get Payment Link Example :
use App\Assist\AppFunctions; use Maatify\PayTabs\PayTabsRedirectUrl; class PayTabsCartPayUrl extends PayTabsRedirectUrl { public function __construct() { $this->url = 'https://secure-egypt.paytabs.com/payment/request'; $this->profile_id = 142849; $this->server_secret_key = __YOUR_SERVER_KEY__; $this->client_secret_key = __YOUR_CLIENT_KEY__; $this->currency = 'EGP'; $this->url_callback = __CALLBACK_URL__; $this->url_return = __RETURN_URL__; } }
try { return PayTabsCartPayUrl::obj()->getRedirectUrl($name, $email, $amount, $cart_id, $description, $language); } catch (PayTabsException $exception){ Logger::RecordLog($exception, 'paytabs_getRedirectUrl_exception'); // Handle specific error codes programmatically switch ($exception->getErrorCode()) { case 1004: // Connection Error break; case 1003: // Curl response Error break; } }
- Validate Payment response/return Example :
use App\Assist\AppFunctions; use Maatify\PayTabs\PayTabsValidations; class PayTabsAppValidation extends PayTabsValidations { public function __construct() { $this->url = 'https://secure-egypt.paytabs.com/payment/request'; $this->profile_id = 142849; $this->server_secret_key = __YOUR_SERVER_KEY__; $this->client_secret_key = __YOUR_CLIENT_KEY__; $this->currency = 'EGP'; $this->url_callback = __CALLBACK_URL__; $this->url_return = __RETURN_URL__; } }
try { $signature_fields = (new PayTabsAppValidation())->returnValidation(); // Start logic for success|Declined|Canceled return }catch (PayTabsException $exception){ Logger::RecordLog($exception, 'paytabs_return_exception'); // Handle specific error codes programmatically switch ($exception->getErrorCode()) { case 1002: // Missing Post break; case 1005: // Hash Nit Equals break; } }
try { $signature_fields = (new PayTabsAppValidation())->callbackValidation(); // Start logic for success|Declined|Canceled return }catch (PayTabsException $exception){ Logger::RecordLog($exception, 'paytabs_callback_exception'); // Handle specific error codes programmatically switch ($exception->getErrorCode()) { case 1002: // echo "Handle MissingPost logic here.\n"; break; case 1005: // echo "Handle InvalidSignature logic here.\n"; break; } }