PHP code example of opennebel / laravel-yabetoopay
1. Go to this page and download the library: Download opennebel/laravel-yabetoopay 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/ */
opennebel / laravel-yabetoopay example snippets
use Yabetoopay\Laravel\Facades\Yabetoo;
use Yabetoopay\Laravel\YabetooException;
try {
$response = Yabetoo::createPaymentIntent(
amount: 1000, // En centimes ou selon les spécifications de la devise
currency: 'XAF',
description: 'Achat de crédits SMS',
metadata: ['payment_id' => 42],
paymentId: 42 // Optionnel : identifiant local pour le traçage des logs
);
$intentId = $response['id'];
$clientSecret = $response['clientSecret'];
// Enregistrez ces informations sur votre paiement local
} catch (YabetooException $e) {
// Gérer l'erreur
$errorMessage = $e->getMessage();
$errorData = $e->response; // Contenu brut de la réponse d'erreur de l'API
}
use Yabetoopay\Laravel\Facades\Yabetoo;
$response = Yabetoo::getPaymentIntent($intentId);
if ($response['status'] === 'succeeded') {
// Le paiement est réussi !
}