1. Go to this page and download the library: Download geniuspay/laravel-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/ */
// app/Listeners/HandlePaymentCompleted.php
namespace App\Listeners;
use GeniusPay\Laravel\Events\PaymentCompleted;
class HandlePaymentCompleted
{
public function handle(PaymentCompleted $event): void
{
$reference = $event->getReference();
$orderId = $event->getMetadata('order_id');
// Mettre à jour votre commande
$order = Order::find($orderId);
$order->markAsPaid($reference);
}
}
use GeniusPay\Laravel\Traits\HasGeniusPayPayments;
class Order extends Model
{
use HasGeniusPayPayments;
}
// Utilisation
$order = Order::find(1);
// Créer un paiement lié à la commande
$payment = $order->createGeniusPayPayment([
'amount' => $order->total,
'description' => "Commande #{$order->id}",
]);
// Récupérer les paiements
$order->geniusPayTransactions;
$order->completedPayments()->get();
$order->totalPaid();
if (GeniusPay::testConnection()) {
echo "Connexion OK";
}
use GeniusPay\Laravel\Exceptions\ApiException;
use GeniusPay\Laravel\Exceptions\AuthenticationException;
use GeniusPay\Laravel\Exceptions\ValidationException;
try {
$payment = GeniusPay::createPayment($data);
} catch (AuthenticationException $e) {
// Clés API invalides
} catch (ValidationException $e) {
// Données invalides
$errors = $e->getErrors();
} catch (ApiException $e) {
// Autre erreur API
}
bash
php artisan geniuspay:install
bash
# Publier la configuration
php artisan vendor:publish --tag=geniuspay-config
# Publier les migrations
php artisan vendor:publish --tag=geniuspay-migrations
# Exécuter les migrations
php artisan migrate
bash
# Installer le package
php artisan geniuspay:install
# Générer un secret webhook
php artisan geniuspay:webhook-secret
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.