andisiahaan/digiflazz-php
Composer 安装命令:
composer require andisiahaan/digiflazz-php
包简介
Modern PHP client for Digiflazz API - Prepaid, Postpaid, PLN, and more
README 文档
README
Modern PHP client for the Digiflazz API. Supports prepaid topup, postpaid bill payment, PLN inquiry, and more.
Requirements
- PHP 8.1 or higher
- ext-json
- Guzzle 7.0+
Installation
composer require andisiahaan/digiflazz-php
Quick Start
use AndiSiahaan\Digiflazz\DigiflazzClient; // Create client with credentials $client = new DigiflazzClient('your_username', 'your_api_key'); // Check balance $balance = $client->checkBalance(); print_r($balance); // Or create from environment variables $client = DigiflazzClient::fromEnvironment();
Configuration
Using Environment Variables
Set your credentials:
# Linux/macOS export DIGIFLAZZ_USERNAME='your_username' export DIGIFLAZZ_APIKEY='your_api_key' # PowerShell $env:DIGIFLAZZ_USERNAME='your_username' $env:DIGIFLAZZ_APIKEY='your_api_key'
Then:
$client = DigiflazzClient::fromEnvironment();
Using Configuration Object
use AndiSiahaan\Digiflazz\Config\Configuration; $config = new Configuration( username: 'your_username', apiKey: 'your_api_key', timeout: 30.0, verifySsl: true, ); $client = new DigiflazzClient($config);
Usage
Check Balance
$balance = $client->checkBalance(); // or $balance = $client->balance()->check();
Price List
// Prepaid products $prepaid = $client->priceListPrepaid(); // Postpaid products $postpaid = $client->priceListPasca(); // With filters $filtered = $client->priceList()->prepaid([ 'category' => 'Pulsa', 'brand' => 'TELKOMSEL', ]); // Get all at once $all = $client->priceList()->all();
Prepaid Transaction (Topup)
// Using array $result = $client->topup([ 'buyer_sku_code' => 'xld10', 'customer_no' => '087800001230', 'ref_id' => 'unique-ref-123', 'testing' => true, // Use sandbox ]); // Using typed method $result = $client->transaction()->topup( skuCode: 'xld10', customerNo: '087800001230', refId: 'unique-ref-123', testing: true, ); // Generate unique ref_id use AndiSiahaan\Digiflazz\Services\TransactionService; $refId = TransactionService::generateRefId('TRX');
Postpaid Bill (Pascabayar)
// Step 1: Inquiry (check bill) $inquiry = $client->inqPasca([ 'buyer_sku_code' => 'pln', 'customer_no' => '530000000001', 'ref_id' => 'ref-001', 'testing' => true, ]); // Step 2: Pay the bill if ($inquiry['data']['status'] === 'Sukses') { $payment = $client->payPasca([ 'buyer_sku_code' => 'pln', 'customer_no' => '530000000001', 'ref_id' => 'ref-001', 'testing' => true, ]); } // Check status $status = $client->statusPasca([...]);
PLN Inquiry
// Quick inquiry $pln = $client->inquiryPln('530000000001'); // Check if valid $isValid = $client->pln()->isValidCustomer('530000000001');
Deposit Request
$deposit = $client->requestDeposit([ 'amount' => 1000000, 'Bank' => 'BCA', 'owner_name' => 'John Doe', ]); // Or using typed method $deposit = $client->deposit()->withdraw(1000000, 'BCA', 'John Doe');
Error Handling
The library throws specific exceptions for different error types:
use AndiSiahaan\Digiflazz\Exceptions\DigiflazzException; use AndiSiahaan\Digiflazz\Exceptions\ApiException; use AndiSiahaan\Digiflazz\Exceptions\HttpException; use AndiSiahaan\Digiflazz\Exceptions\ValidationException; try { $result = $client->topup([...]); } catch (ValidationException $e) { // Missing or invalid parameters echo "Validation error: " . $e->getMessage(); print_r($e->getErrors()); } catch (ApiException $e) { // API returned an error echo "API error: " . $e->getMessage(); echo "Error code: " . $e->getErrorCode(); if ($e->isInsufficientBalance()) { echo "Please top up your balance"; } if ($e->isRetryable()) { // Safe to retry } } catch (HttpException $e) { // Network or HTTP error echo "HTTP error: " . $e->getMessage(); echo "Status code: " . $e->getStatusCode(); } catch (DigiflazzException $e) { // Base exception (catch all library exceptions) echo "Error: " . $e->getMessage(); }
Service Classes
Direct access to service classes for more control:
$balanceService = $client->balance(); $transactionService = $client->transaction(); $priceListService = $client->priceList(); $depositService = $client->deposit(); $plnService = $client->pln();
Development
Install Dependencies
composer install
Run Tests
# All tests composer test # With coverage composer test:coverage
Static Analysis
composer analyse
Code Style
# Check code style composer cs-check # Fix code style composer cs-fix
Architecture
src/
├── Config/
│ └── Configuration.php # Immutable configuration
├── Contracts/
│ ├── ClientInterface.php # Client contract
│ ├── HttpClientInterface.php # HTTP abstraction
│ └── ServiceInterface.php # Service contract
├── Exceptions/
│ ├── DigiflazzException.php # Base exception
│ ├── ApiException.php # API errors
│ ├── AuthenticationException.php
│ ├── HttpException.php # HTTP errors
│ └── ValidationException.php # Validation errors
├── Http/
│ └── GuzzleHttpClient.php # Guzzle adapter
├── Services/
│ ├── Concerns/
│ │ └── ValidatesParameters.php
│ ├── AbstractService.php # Base service
│ ├── BalanceService.php
│ ├── DepositService.php
│ ├── PlnService.php
│ ├── PriceListService.php
│ └── TransactionService.php
├── Support/
│ └── Signature.php # Signature generator
└── DigiflazzClient.php # Main client
Notes
- IP Whitelist: Digiflazz requires your server IP to be whitelisted. Contact Digiflazz support.
- Testing Mode: Use
testing: truefor sandbox transactions. - Credentials: Never commit credentials. Use environment variables or
.envfile.
License
MIT - see LICENSE file.
andisiahaan/digiflazz-php 适用场景与选型建议
andisiahaan/digiflazz-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「API-Client」 「PLN」 「Topup」 「digiflazz」 「ppob」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 andisiahaan/digiflazz-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 andisiahaan/digiflazz-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 andisiahaan/digiflazz-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Delivers current exchange rates for EUR provided by the ECB as PHP objects.
Skolkovo API Client
A high-performance PHP framework featuring automatic autoloading, smart routing, and auto-generated CRUDs, seamlessly integrated with NLP capabilities and Large Language Model (LLM) orchestration.
A client library for the OpenPLZ API project
chargebee-php-sdk integration for WordPress
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-24