PHP code example of zampou / cinetpay

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

    

zampou / cinetpay example snippets


'providers' => [
    /*
    * Package Service Providers...
    */
    Zampou\CinetPay\Providers\CinetPayProvider::class,
],

return [
    'CINETPAY_API_KEY' => env('CINETPAY_API_KEY'),
    'CINETPAY_SITE_ID' =>  env('CINETPAY_SITE_ID')
];

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array<int, string>
     */
    protected $except = [
        '/cinetpay-ipn'
    ];

use Zampou\CinetPay\Facades\CinetPay;

$transactionLink = CinetPay::generatePaymentLink([
    'amount' => '100',
    'currency' => 'XOF',
    'customer_name' => 'John',
    'customer_surname' => 'Doe',
    'transaction_id' => '123456789',
    'description' => 'Bon gbozon bien chaud de qualité',
]);

dd($transactionLink);

    use App\Listeners\CinetPayIpnListener;
    use Zampou\CinetPay\Events\CinetPayIPN;
    // ...

    /**
     * The event to listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        CinetPayIPN::class => [
            CinetPayIpnListener::class
        ]
    ];



namespace App\Listeners;

class CinetPayIpnListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        // Vous faite votre traitement ici
        // Structure des données dans la variable `payment_data`
        // [
        //     'code',
        //     'message',
        //     'amount',
        //     'metadata',
        //     'currency',
        //     'operator_id',
        //     'description',
        //     'payment_date',
        //     'payment_method'
        //     'api_response_id',
        // ]

        dd($event->payment_data);
    }
}
text
php artisan make:listener CinetPayIPNListener