cleeng/cleeng-php-sdk
The Cleeng PHP SDK provides a convenient client for integrating Cleeng's subscription monetization platform into PHP applications, with API access for customers, subscriptions, offers, transactions, entitlements, and related billing workflows.
Install the package with Composer and publish its configuration:
composer require vendor/package
php artisan vendor:publish --tag="package-config"
Add the required credentials to .env (for example PACKAGE_API_KEY and PACKAGE_API_URL), then clear cached config with php artisan config:clear if you are working locally. The first places to look are config/package.php, the package service provider, and the main client class (usually under src/Client.php or src/Actions/). That is where the 3.7.0 registerCustomer method will be exposed.
The most immediate use case is customer onboarding: after a user registers, create the corresponding customer in the external system and persist the returned identifier.
use Vendor\Package\Facades\Package;
$customer = Package::registerCustomer([
'name' => $user->name,
'email' => $user->email,
]);
$user->update(['package_customer_id' => $customer->id]);
Check the exact method signature in the source before relying on it. Some releases accept a model or a DTO directly:
Package::registerCustomer($user);
Because 3.7.0 is an additive minor release, existing integrations should continue to work; the new method is the main reason to upgrade.
Onboarding listener or job. Trigger customer registration from a Registered event listener, but dispatch a queued job rather than calling the API inside the request. This keeps registration fast and gives you retries.
class RegisterExternalCustomer implements ShouldQueue
{
public function handle(): void
{
$customer = Package::registerCustomer([
'name' => $this->user->name,
'email' => $this->user->email,
]);
$this->user->update(['package_customer_id' => $customer->id]);
}
}
Persist the external ID. Store the returned customer ID on your users table (or a dedicated customers table). You will need it for later calls such as subscriptions, invoices, or updates. Add a nullable package_customer_id column and an index.
Use idempotency where possible. If the external API supports idempotency keys, pass one derived from your user ID or email. If not, guard the job with ShouldBeUnique and check for an existing package_customer_id before calling registerCustomer.
Map data explicitly. Avoid passing the entire Eloquent model unless the package documents that behaviour. Build a small array or DTO with only the fields the API expects. This makes tests clearer and prevents accidental PII leakage.
Test with HTTP fakes. The package usually sits on top of Laravel’s HTTP client. Use Http::fake() and assert the outgoing payload:
Http::fake([
'api.example.com/customers' => Http::response(['id' => 'cus_123'], 201),
]);
Package::registerCustomer(['name' => 'Ada', 'email' => '[email protected]']);
Http::assertSent(fn ($request) => $request['email'] === '[email protected]');
Reconcile with webhooks. If the external service emits customer-created webhooks, use them to backfill or verify the local package_customer_id. This is especially useful for bulk imports or retries.
Bulk operations. For imports, chunk users and dispatch jobs. Respect the API’s rate limits and avoid calling registerCustomer in a tight loop from a single process.
registerCustomer is a generic name. If your application already has a method with that name on a model or service, alias the facade or inject the client explicitly.PACKAGE_API_URL and key values per environment. A common failure is registering test customers in production because .env was copied without changes.php artisan config:clear locally and redeploy with php artisan config:cache in production.429, use exponential backoff rather than immediate retries.registerCustomer.macroable client before forking the package.Http::recorded() in tests. For production issues, log the request ID returned by the API rather than the full response body.package_customer_id before rolling it out to all onboarding flows.How can I help you explore Laravel packages today?