Events & Hooks
The Envato Integration module fires three events that other modules can listen to.
EnvatoPurchaseVerified
Fired immediately after the Envato API confirms a purchase code is valid — before the mapping is resolved or the license is issued.
php
use Modules\EnvatoIntegration\Events\EnvatoPurchaseVerified;
$this->app['events']->listen(EnvatoPurchaseVerified::class, function ($event) {
$saleData = $event->saleData;
// ['purchase_code', 'item_id', 'item_name', 'buyer', 'supported_until',
// 'amount', 'currency', 'purchased_at', 'license']
});EnvatoItemMappingResolving
Fired when the claim service is about to look up an EnvatoItemMapping row. A listener may set $event->mapping to override the default database lookup — for example to apply custom rules based on the Envato license type.
php
use Modules\EnvatoIntegration\Events\EnvatoItemMappingResolving;
use Modules\EnvatoIntegration\Models\EnvatoItemMapping;
$this->app['events']->listen(EnvatoItemMappingResolving::class, function ($event) {
if ($event->envatoItemId === '99999999') {
$event->mapping = EnvatoItemMapping::find(42);
}
});TIP
If no listener sets $event->mapping, the module falls back to the standard DB lookup. If no mapping is found an ItemNotMappedException is thrown and the claim is rejected with a user-facing error.
EnvatoLicenseClaimed
Fired after the Order and License have been created and the EnvatoClaim row persisted.
php
use Modules\EnvatoIntegration\Events\EnvatoLicenseClaimed;
$this->app['events']->listen(EnvatoLicenseClaimed::class, function ($event) {
$claim = $event->claim; // EnvatoClaim model
$license = $claim->license; // License model
$order = $claim->order; // Order model
$user = $claim->user; // User model
// Send a custom email, grant a Plan entitlement, etc.
});