PHP code example of youkeofficial / laravel-chapchap

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

    

youkeofficial / laravel-chapchap example snippets


use Youkeofficial\ChapChap\Facades\ChapChap;

// Créer un paiement
$result = ChapChap::requestPayment(
    amount: 10000,
    orderId: 'ORDER-123',
    description: 'Paiement commande #123'
);

// Rediriger l'utilisateur
return redirect($result['payment_url']);

use Youkeofficial\ChapChap\Services\ChapChapService;

class PaymentController extends Controller
{
    public function __construct(private ChapChapService $chapchap) {}

    public function create(): RedirectResponse
    {
        $result = $this->chapchap->requestPayment(
            amount: 10000,
            orderId: 'ORDER-123',
            description: 'Paiement commande #123'
        );

        return redirect($result['payment_url']);
    }
}

$data = ChapChap::requestVerification($operationId);

// Normaliser le statut vers : 'created' | 'processing' | 'success' | 'cancel' | 'error'
$status = ChapChap::normalizeChapChapStatus($data['status']['code']);
bash
php artisan vendor:publish --tag=chapchap-config