1. Go to this page and download the library: Download sevaske/payfort-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sevaske / payfort-api example snippets
use Sevaske\PayfortApi\Credential;
use Sevaske\PayfortApi\Merchant;
use Sevaske\PayfortApi\Http\Responses\CheckStatusResponse;
// Setup credentials
$credential = new Credential(
'merchantIdentifier',
'accessCode',
'shaRequestPhrase',
'shaResponsePhrase',
);
// Use any PSR-18 compatible HTTP client
$httpClient = new \GuzzleHttp\Client(); // or any other PSR-18 client
// Create merchant instance
$merchant = new Merchant('sandbox', $httpClient, $credential);
// Simple status check
$response = $merchant->api()->checkStatus('12345'); // CheckStatusResponse
$merchant->api()->checkStatus(); // Check the status of a transaction
$merchant->api()->recurring(); // Purchase
$merchant->api()->voidAuthorization(); // Void an authorization
$merchant->api()->refund(); // Process a refund
$merchant->api()->createToken(); // Create a new payment token
$merchant->api()->updateToken(); // Update an existing payment token
$response = $merchant->api()->checkStatus('12345', callback: function (
CheckStatusResponse $response,
array $request
) {
$request; // Raw request data
$response->jsonSerialize(); // Parsed response as array
$response->authorizedAmount(); // ?string
$response->capturedAmount(); // ?string
$response->refundedAmount(); // ?string
return $response;
});