sejator / waba-sdk
Laravel SDK for WhatsApp Cloud API (WABA)
v1.0.2
2026-03-18 07:24 UTC
Requires
- php: >=8.2
- illuminate/support: ^12.0
This package is auto-updated.
Last update: 2026-03-18 07:25:02 UTC
README
Laravel-native SDK untuk WhatsApp Cloud API (WABA).
SDK ini dirancang untuk kebutuhan production & SaaS (Omnichannel / BSP) dengan fitur lengkap:
- WhatsApp Cloud API (Messaging, Media, Template)
- Embedded Signup (OAuth & Embedded Flow)
- System User & BSP Management
- Credit Line (Billing)
- Webhook Verification & Parsing
- Multi-tenant ready
- Retry, timeout & logging (production-grade)
Requirements
- PHP >= 8.2
- Laravel 12.x
- Meta (Facebook) Developer Account
Installation
Local Development (Path Repository)
- Tambahkan repository path di composer.json
{
"repositories": [
{
"type": "path",
"url": "../waba-sdk"
}
],
"require": {
"sejator/waba-sdk": "*"
}
}
composer update sejator/waba-sdk
- Install package
composer require sejator/waba-sdk:*
Service Provider & Facade
Auto-discovery aktif secara default.
Facade:
use Waba;
Alias:
Sejator\WabaSdk\Facades\Waba
Configuration
Publish Config
php artisan vendor:publish \
--provider="Sejator\WabaSdk\WabaServiceProvider" \
--tag=waba-config
File config:
config/waba.php
Environment Variables (.env)
# Meta App META_APP_ID= META_APP_SECRET= # Graph API META_GRAPH_URL=https://graph.facebook.com META_GRAPH_VERSION=v24.0 # OAuth / Embedded Signup META_OAUTH_BASE_URL=https://www.facebook.com META_OAUTH_VERSION=v24.0 META_OAUTH_REDIRECT_URI=https://your-domain.com/waba/callback # Webhook META_WEBHOOK_VERIFY_TOKEN= # Default Token (optional) WABA_TOKEN= # HTTP Config WABA_HTTP_TIMEOUT=10 WABA_HTTP_RETRY=3
Basic Usage
Set Access Token (Multi-tenant)
$waba = Waba::withAccessToken($token);
Messaging API
- Send Text
Waba::withAccessToken($token) ->messages($phoneNumberId) ->text('628xxxx', 'Hello world');
- Send Image
->image($to, $url, $caption);
- Send Template
->template($to, 'hello_world', 'id', $components);
- Mark as Read
->markAsRead($messageId);
Media API
- Upload
Waba::withAccessToken($token) ->media() ->upload(storage_path('app/image.jpg'), 'image/jpeg');
Template API
Waba::withAccessToken($token) ->templates($wabaId) ->list();
Billing (Credit Line)
Waba::withAccessToken($token) ->credit() ->listCreditLines($businessId);
Embedded Signup
- Generate URL
$url = Waba::embeddedSignup() ->clientId() ->redirectUri(route('waba.callback')) ->state(csrf_token()) ->build();
- Exchange Code
$data = Waba::exchangeEmbeddedCode($code);
BSP / Admin Flow
- Create System User
$userId = Waba::admin() ->createSystemUser($businessId);
- Assign WABA
Waba::admin()->assignWabaAsset($userId, $wabaId);
- Generate Token
$token = Waba::admin()->generateToken($userId);
Embedded User Flow
Waba::withAccessToken($token) ->embedded() ->subscribeAppToWaba($wabaId);
Webhook
- Verify Signature
Waba::verifyWebhookSignature( $request->getContent(), config('waba.meta.app_secret'), $request->header('X-Hub-Signature-256') );
- Parse Payload
$payload = Waba::parseWebhook($request->getContent()); $type = $payload->type(); // message | status | template
Error Handling
try { // call SDK } catch (\Sejator\WabaSdk\Exceptions\WabaException $e) { report($e); }