Download the PHP package smlv/sdk without Composer
On this page you can find all versions of the php package smlv/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package sdk
Short Description SMLV Platform SDK - Easy integration of SMLV payment system into any SaaS. Includes a CDN-ready JS widget (no iframe) with JWT auth.
License MIT
Informations about the package sdk
SMLV SDK
PHP SDK for integrating SMLV billing into your SaaS application.
v2.2 — The widget now renders directly into your page DOM (no iframe). Account creation and management are handled fully inside the widget — no extra server-side code required from SaaS developers.
Features
- Zero account management — widget auto-resolves or creates the user account on first load
- No iframe — widget renders as native DOM elements, fully styleable
- Secure JWT — short-lived signed tokens (900 s), never exposed in URLs
- Full CRUD widget — Deposit / Balance / Transactions / Account management tabs
- Headless API — use
SmlvClientdirectly for server-side automation - Framework agnostic — plain PHP, Laravel, Yii2, Symfony
Requirements
- PHP 7.4+
firebase/php-jwt^6.0 || ^7.0
Installation
Quick Start
1. Initialize the client
Keep credentials in a config file that is excluded from version control (e.g.
main-local.phpin Yii2,services.phpin Laravel). Never commit real keys to git.
3. Embed a widget
That is literally all you need to show a full billing UI to your user:
The widget will:
- Load the SMLV JS bundle from CDN
- Resolve the user's SMLV account (or show a creation form on first visit)
- Render the deposit UI directly in your page
No database column, no createAccount() call, no extra routes required.
Widget Types
| Type | Best for | Account required? |
|---|---|---|
deposit |
Standalone deposit page | Auto-resolves |
balance |
Balance panel / sidebar | Auto-resolves |
mini |
Top navbar inline bar | No (direct fetch) |
transactions |
Transaction history page | Auto-resolves |
management |
Account settings page | Auto-resolves |
account |
Subscriber detail page | No (handles both) |
All methods return a self-contained HTML snippet:
Options
Common options
| Key | Type | Default | Description |
|---|---|---|---|
theme |
string |
'light' |
'light' or 'dark' |
language |
string |
'en' |
UI language code |
Deposit options
| Key | Type | Description |
|---|---|---|
currencies |
string[] |
Allowed currencies to show |
default_currency |
string |
Pre-selected currency |
Balance options
| Key | Type | Description |
|---|---|---|
show_sync |
bool |
Show Sync button (default true) |
JS callbacks (inline <script> pattern)
Headless API (SmlvClient)
Use SmlvClient directly for server-side operations — background sync, webhooks, reporting, etc.
Webhook Handling
Webhook events
| Event | Payload fields |
|---|---|
account.created |
account_reference, status |
account.closed |
account_reference |
balance.updated |
account_reference, old_balance, new_balance |
transaction.pending |
transaction_id, amount, type |
transaction.completed |
transaction_id, amount, type, balance |
transaction.failed |
transaction_id, error |
Framework Integration
Laravel
Yii2
main-local.phpis generated fromenvironments/and is listed in.gitignoreby default in the Yii2 advanced template — safe for secrets.
Embed a widget in a view:
Drop-in Yii2 widget class (SmlvBalanceWidget):
For even simpler embedding use the bundled Yii2 Widget class — no generator calls needed:
| Property | Type | Default | Description |
|---|---|---|---|
subscriberId |
string |
'' |
Subscriber ID in your system |
email |
string |
'' |
Subscriber e-mail |
widgetType |
string |
'mini' |
'mini' | 'balance' | 'account' |
compact |
bool |
false |
Adds smlv-widget-compact CSS class |
theme |
string |
'light' |
'light' or 'dark' |
language |
string |
auto | BCP-47 tag; defaults to Yii::$app->language |
prefill |
array |
[] |
first_name, last_name, account_type |
widgetOptions |
array |
[] |
Extra options forwarded to the generator |
The mini type automatically generates a deposit redirect URL via generateDepositUrl() — no extra config needed.
Generate a deposit redirect URL (server-side):
Generating Snippets Separately
Auto-charge Behavior (Yii2)
SmlvChargeBehavior deducts a deposit automatically every time a model is saved (EVENT_AFTER_INSERT). All data is provided via callables — no interface implementation required in your model.
Option A — Raw behavior (simple cases)
Option B — Wrapper trait (recommended for SaaS, eGram pattern)
For production SaaS apps, the recommended approach is to put all charge logic into a reusable wrapper trait in your own codebase.
This is exactly the pattern used in eGram via common\traits\smlv\SmlvChargeableTrait.
The trait provides:
smlvBehaviorConfig()— returns readySmlvChargeBehaviorconfig to register inbehaviors()getChargeEmail()— resolves subscriber email (main client contact → abonent admin user fallback)getChargeAmount()— converts EUR price from pricelist to SMLV; returnsnullif the subscriber has no SMLV account (opt-in guard: no account = fall back to bank billing)getChargeDescription()/getChargeMetadata()— human label + EUR/rate/SMLV metadata for reporting- abstract
getSmlvActionType()— the only method your model must implement
In your trait:
In each model:
How the opt-in guard works:
| Subscriber state | resolveAccountByEmail() |
Result |
|---|---|---|
| Has SMLV account | returns account ref | Charged in SMLV tokens |
| No SMLV account | returns null |
Skipped → bank invoice issued |
smlv component absent |
— | Skipped (CLI, test, dev) |
| API error | throws (caught) | Skipped, warning logged |
Errors are logged to Yii::error(..., 'smlv') and never break the original AR save — the charge is best-effort.
Tip: All four
SmlvChargeBehaviorproperties (amount,description,metadata) accept either acallableor a scalar value. Use callables when you need$thiscontext.
Security
- All API requests are signed with HMAC-SHA256 (
X-API-Key,X-Signature,X-Timestamp) - Widget JWTs: HS256, TTL 900 s, one-time
jticlaim enforced by the server - Tokens are injected into an inline
<script>block — never in a URL or query string - Webhook signatures verified before payload processing
- TLS 1.2+ required
Testing
Support
- Documentation: https://docs.smlvcoin.com
- API Reference: https://api.smlvcoin.com/docs
- Issues: https://github.com/smlv/sdk/issues
- Email: [email protected]
License
MIT — see LICENSE
All versions of sdk with dependencies
ext-json Version *
ext-curl Version *
firebase/php-jwt Version ^6.0 || ^7.0