1. Go to this page and download the library: Download hypertech/paysuite-php-sdk 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/ */
hypertech / paysuite-php-sdk example snippets
use Hypertech\Paysuite\Client;
use Hypertech\Paysuite\Exception\ValidationException;
use Hypertech\Paysuite\Exception\PaysuiteException;
$token = "your-access-token";
$client = new Client($token);
try {
$response = $client->createPayment([
'amount' => '100.50',
'reference' => 'INV123',
'description' => 'Invoice payment',
'return_url' => 'https://yoursite.com/return',
'callback_url' => 'https://yoursite.com/callback'
]);
if ($response->isSuccessfully()) {
// Get the checkout URL to redirect the customer
$checkoutUrl = $response->getCheckoutUrl();
// Get the payment ID for later reference
$paymentId = $response->getData()['id'];
// Redirect customer to payment page
header("Location: " . $checkoutUrl);
exit;
}
} catch (ValidationException $e) {
// Handle validation errors
echo "Validation error: " . $e->getMessage();
} catch (PaysuiteException $e) {
// Handle API errors
echo "API error: " . $e->getMessage();
}
try {
$response = $client->getPayment($paymentId);
if ($response->isSuccessfully()) {
$status = $response->getData()['status'];
// Check if transaction data is available
if (isset($response->getData()['transaction'])) {
$transaction = $response->getData()['transaction'];
$transactionId = $transaction['transaction_id'];
$paidAt = $transaction['paid_at'];
}
}
} catch (ValidationException $e) {
echo "Validation error: " . $e->getMessage();
} catch (PaysuiteException $e) {
echo "API error: " . $e->getMessage();
}
// Check if the request was successful
$isSuccess = $response->isSuccessfully();
// Get the full response content
$content = $response->getContent();
// Get just the data portion of the response
$data = $response->getData();
// Get specific fields with helper methods
$reference = $response->getReference();
$amount = $response->getAmount();
$checkoutUrl = $response->getCheckoutUrl();
// Get error message if request failed
$errorMessage = $response->getMessage();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.