PHP code example of triyatna / digiflazz-laravel-4buyer
1. Go to this page and download the library: Download triyatna/digiflazz-laravel-4buyer 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/ */
triyatna / digiflazz-laravel-4buyer example snippets
use Triyatna\Digiflazz\Digiflazz;
use Illuminate\Support\Str;
$response = Digiflazz::checkBalance();
if ($response->isSuccess()) {
return $response->get('deposit');
}
$response = Digiflazz::checkTransactionStatus(
'TRX-xxxxxxxx-xxxx',
'prepaid',
'tsel5',
'081234567890'
);
if ($response->isSuccess()) {
// status sukses
}
use App\Http\Controllers\WebhookController;
Route::post('/webhooks/digiflazz', [WebhookController::class, 'handle']);
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Triyatna\Digiflazz\Helpers\Webhook;
class WebhookController extends Controller
{
public function handle(Request $request)
{
$signature = $request->header('X-Hub-Signature');
$payload = $request->getContent();
$secret = config('digiflazz.webhook_secret');
if (!Webhook::validate($signature, $payload, $secret)) {
return response('Validasi gagal.', 403);
}
$data = $request->input('data');
Log::info("Webhook diterima untuk ref_id {$data['ref_id']} dengan status {$data['status']}");
return response('Webhook diterima.', 200);
}
}
bash
php artisan ty-digiflazz:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.