PHP code example of simonet85 / laravel-moneyfusion

1. Go to this page and download the library: Download simonet85/laravel-moneyfusion 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/ */

    

simonet85 / laravel-moneyfusion example snippets


use VotreVendor\LaravelMoneyFusion\Facades\MoneyFusion;

// Créer un paiement
$result = MoneyFusion::createPayment([
    'total_price' => 5000,
    'articles' => [
        [
            'name' => 'Produit A',
            'price' => 5000,
            'quantity' => 1
        ]
    ],
    'nom_client' => 'Jean Dupont',
    'numero_send' => '0707070707',
    'user_id' => auth()->id(),
]);

// Rediriger vers la page de paiement
return redirect($result['url']);

$status = MoneyFusion::checkPaymentStatus($token);

if ($status['data']['statut'] === 'paid') {
    // Paiement réussi
}

$payment = MoneyFusion::getPaymentByToken($token);

if ($payment->isPaid()) {
    // Traiter la commande
}

use VotreVendor\LaravelMoneyFusion\MoneyFusionService;

class CheckoutController extends Controller
{
    public function __construct(
        protected MoneyFusionService $moneyFusion
    ) {}

    public function process(Request $request)
    {
        try {
            $result = $this->moneyFusion->createPayment([
                'total_price' => $request->total,
                'articles' => $request->articles,
                'nom_client' => $request->nom_client,
            ]);

            return redirect($result['url']);

        } catch (\Exception $e) {
            return back()->with('error', $e->getMessage());
        }
    }
}

MoneyFusionPayment {
    id
    token_pay          // Token unique du paiement
    user_id            // ID de l'utilisateur (optionnel)
    order_id           // ID de la commande (optionnel)
    numero_send        // Numéro de téléphone
    nom_client         // Nom du client
    montant            // Montant en FCFA
    frais              // Frais de transaction
    numero_transaction // Numéro de transaction
    statut             // pending, paid, failed, cancelled
    moyen              // Moyen de paiement utilisé
    payment_url        // URL de paiement
    personal_info      // Données personnalisées (JSON)
    articles           // Liste des articles (JSON)
    raw_response       // Réponse brute de l'API (JSON)
    paid_at            // Date de paiement
    created_at
    updated_at
}

$payment = MoneyFusionPayment::find(1);

// Vérifier le statut
$payment->isPaid();      // bool
$payment->isPending();   // bool
$payment->isFailed();    // bool

// Marquer comme payé
$payment->markAsPaid([
    'numeroTransaction' => 'TRX123',
    'moyen' => 'orange_money',
    'frais' => 250,
]);

// Relations
$payment->user;    // Utilisateur
$payment->order;   // Commande (si configuré)

// Scopes
MoneyFusionPayment::paid()->get();      // Tous les paiements payés
MoneyFusionPayment::pending()->get();   // En attente
MoneyFusionPayment::today()->get();     // Paiements du jour
bash
php artisan vendor:publish --tag=moneyfusion-config
bash
php artisan migrate
bash
php artisan vendor:publish --tag=moneyfusion-views
bash
php artisan moneyfusion:test-payment --amount=5000 --client="Jean Test"
bash
php artisan moneyfusion:check-payment {token}