PHPackages                             einenlum/creem-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. einenlum/creem-php-sdk

ActiveLibrary[API Development](/categories/api)

einenlum/creem-php-sdk
======================

PHP SDK for the Creem merchant of records API

0.1.0(5mo ago)01MITPHPPHP ^8.1

Since Jan 10Pushed 5mo agoCompare

[ Source](https://github.com/einenlum/creem-php-sdk)[ Packagist](https://packagist.org/packages/einenlum/creem-php-sdk)[ RSS](/packages/einenlum-creem-php-sdk/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Creem PHP SDK
=============

[](#creem-php-sdk)

A PHP SDK for the [Creem](https://creem.io) merchant of records API. This library provides a clean, type-safe interface for interacting with all Creem API endpoints and handling webhooks.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- A PSR-18 HTTP client (e.g., Guzzle)
- A PSR-17 HTTP factory (e.g., Nyholm PSR-7 or Guzzle PSR-7)

Installation
------------

[](#installation)

```
composer require einenlum/creem-php-sdk
```

If you don't have an HTTP client installed, you can install Guzzle:

```
composer require guzzlehttp/guzzle
```

Quick Start
-----------

[](#quick-start)

```
use Einenlum\CreemPhpSdk\Creem;

// Create a client (auto-discovers PSR-18/17 implementations)
$creem = Creem::create(
    apiKey: 'creem_xxxxx',
    testMode: true // Use test API environment
);

// Get a product
$product = $creem->products->get('prod_xxxxx');
echo $product->name;

// Create a checkout session
$checkout = $creem->checkouts->create(
    productId: 'prod_xxxxx',
    successUrl: 'https://example.com/success'
);
echo $checkout->checkoutUrl;
```

Configuration
-------------

[](#configuration)

### Basic Configuration

[](#basic-configuration)

```
use Einenlum\CreemPhpSdk\Creem;

$creem = Creem::create(
    apiKey: 'creem_xxxxx',
    webhookSecret: 'whsec_xxxxx', // Optional, for webhook handling
    testMode: false               // false = production, true = test environment
);
```

### Custom HTTP Client

[](#custom-http-client)

If you need to customize the HTTP client (e.g., for timeouts or proxies):

```
use Einenlum\CreemPhpSdk\Creem;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$httpClient = new Client([
    'timeout' => 30,
    'proxy' => 'http://proxy.example.com:8080'
]);
$factory = new HttpFactory();

$creem = Creem::create(
    apiKey: 'creem_xxxxx',
    httpClient: $httpClient,
    requestFactory: $factory,
    streamFactory: $factory
);
```

API Resources
-------------

[](#api-resources)

### Products

[](#products)

```
// Get a product by ID
$product = $creem->products->get('prod_xxxxx');

// Create a product
$product = $creem->products->create([
    'name' => 'My Product',
    'price' => 1999, // Price in cents
    'currency' => 'USD'
]);

// Search products with pagination
$result = $creem->products->search(limit: 10, page: 1);
foreach ($result->items as $product) {
    echo $product->name;
}
```

### Checkouts

[](#checkouts)

```
// Create a checkout session
$checkout = $creem->checkouts->create(
    productId: 'prod_xxxxx',
    successUrl: 'https://example.com/success',
    customer: [
        'email' => 'customer@example.com',
        'name' => 'John Doe'
    ],
    metadata: [
        'order_id' => '12345'
    ]
);

// Redirect user to checkout
header('Location: ' . $checkout->checkoutUrl);

// Get checkout details
$checkout = $creem->checkouts->get('ch_xxxxx');
```

### Customers

[](#customers)

```
// Get a customer by ID or email
$customer = $creem->customers->get(customerId: 'cus_xxxxx');
$customer = $creem->customers->get(email: 'customer@example.com');

// List customers
$result = $creem->customers->list(limit: 20, page: 1);

// Create a billing portal session
$portal = $creem->customers->createBillingPortal('cus_xxxxx');
echo $portal->url;
```

### Subscriptions

[](#subscriptions)

```
// Get subscription details
$subscription = $creem->subscriptions->get('sub_xxxxx');
echo $subscription->status->value; // 'active', 'canceled', etc.

// Update subscription units
$subscription = $creem->subscriptions->updateUnits('sub_xxxxx', units: 5);

// Upgrade to a different product
$subscription = $creem->subscriptions->upgrade('sub_xxxxx', newProductId: 'prod_yyyyy');

// Cancel subscription
$subscription = $creem->subscriptions->cancel('sub_xxxxx');
```

### Discounts

[](#discounts)

```
// Create a discount
$discount = $creem->discounts->create([
    'code' => 'SUMMER20',
    'type' => 'percentage',
    'amount' => 20,
    'duration' => 'forever'
]);

// Get discount by ID or code
$discount = $creem->discounts->get(discountId: 'disc_xxxxx');
$discount = $creem->discounts->get(code: 'SUMMER20');

// Delete a discount
$creem->discounts->delete('disc_xxxxx');
```

### Licenses

[](#licenses)

```
// Activate a license
$license = $creem->licenses->activate(
    key: 'XXXX-XXXX-XXXX-XXXX',
    instanceName: 'My Computer'
);
echo $license->instanceId;

// Validate a license
$license = $creem->licenses->validate(
    key: 'XXXX-XXXX-XXXX-XXXX',
    instanceId: 'inst_xxxxx'
);

// Deactivate a license
$license = $creem->licenses->deactivate(
    key: 'XXXX-XXXX-XXXX-XXXX',
    instanceId: 'inst_xxxxx'
);
```

### Transactions

[](#transactions)

```
// Search transactions
$result = $creem->transactions->search(
    customerId: 'cus_xxxxx',
    limit: 50,
    page: 1
);

// Search by subscription
$result = $creem->transactions->search(
    subscriptionId: 'sub_xxxxx'
);
```

Webhook Handling
----------------

[](#webhook-handling)

The SDK provides a `WebhookHandler` class for processing incoming webhooks with signature verification.

### Basic Webhook Setup

[](#basic-webhook-setup)

```
use Einenlum\CreemPhpSdk\Webhook\WebhookHandler;
use Einenlum\CreemPhpSdk\Exception\WebhookException;

$handler = new WebhookHandler('whsec_xxxxx');

// Register event handlers
$handler
    ->onCheckoutCompleted(function ($event) {
        $checkout = $event->object;
        // Grant access to the customer
    })
    ->onSubscriptionActive(function ($event) {
        $subscription = $event->object;
        // Activate subscription
    })
    ->onSubscriptionCanceled(function ($event) {
        $subscription = $event->object;
        // Handle cancellation
    });

// Process webhook in your endpoint
try {
    $payload = file_get_contents('php://input');
    $signature = $_SERVER['HTTP_CREEM_SIGNATURE'] ?? '';

    $event = $handler->handle($payload, $signature);

    http_response_code(200);
    echo json_encode(['received' => true]);
} catch (WebhookException $e) {
    http_response_code(400);
    echo json_encode(['error' => $e->getMessage()]);
}
```

### Available Webhook Events

[](#available-webhook-events)

EventHandler MethodDescription`checkout.completed``onCheckoutCompleted()`Checkout was completed`subscription.active``onSubscriptionActive()`Subscription is now active`subscription.paid``onSubscriptionPaid()`Subscription payment received`subscription.canceled``onSubscriptionCanceled()`Subscription was canceled`subscription.expired``onSubscriptionExpired()`Subscription has expired`subscription.trialing``onSubscriptionTrialing()`Subscription is in trial`subscription.paused``onSubscriptionPaused()`Subscription was paused`subscription.update``onSubscriptionUpdate()`Subscription was updated`refund.created``onRefundCreated()`Refund was created`dispute.created``onDisputeCreated()`Dispute was created### Generic Event Handler

[](#generic-event-handler)

```
use Einenlum\CreemPhpSdk\Enum\WebhookEvent;

$handler->on(WebhookEvent::CheckoutCompleted, function ($event) {
    // Handle event
});
```

Error Handling
--------------

[](#error-handling)

The SDK throws specific exceptions for different error types:

```
use Einenlum\CreemPhpSdk\Exception\AuthenticationException;
use Einenlum\CreemPhpSdk\Exception\ValidationException;
use Einenlum\CreemPhpSdk\Exception\NotFoundException;
use Einenlum\CreemPhpSdk\Exception\RateLimitException;
use Einenlum\CreemPhpSdk\Exception\ApiException;
use Einenlum\CreemPhpSdk\Exception\CreemException;

try {
    $product = $creem->products->get('prod_xxxxx');
} catch (AuthenticationException $e) {
    // Invalid API key (401/403)
} catch (ValidationException $e) {
    // Invalid request data (400)
} catch (NotFoundException $e) {
    // Resource not found (404)
} catch (RateLimitException $e) {
    // Too many requests (429)
} catch (ApiException $e) {
    // Server error (500+)
} catch (CreemException $e) {
    // Other errors
}
```

All exceptions include response details:

```
try {
    $product = $creem->products->get('invalid_id');
} catch (CreemException $e) {
    echo $e->getMessage();
    print_r($e->getResponseBody());
    print_r($e->getResponseHeaders());
}
```

Enums
-----

[](#enums)

The SDK uses PHP enums for type-safe values:

```
use Einenlum\CreemPhpSdk\Enum\SubscriptionStatus;
use Einenlum\CreemPhpSdk\Enum\LicenseStatus;
use Einenlum\CreemPhpSdk\Enum\DiscountType;
use Einenlum\CreemPhpSdk\Enum\DiscountDuration;

// Check subscription status
if ($subscription->status === SubscriptionStatus::Active) {
    // Subscription is active
}

// All enum values
SubscriptionStatus::Active;
SubscriptionStatus::Canceled;
SubscriptionStatus::Expired;
SubscriptionStatus::Trialing;
SubscriptionStatus::Paused;
```

Testing
-------

[](#testing)

For testing your integration, use the test mode:

```
$creem = Creem::create(
    apiKey: 'creem_test_xxxxx',
    testMode: true
);
```

This will route all API calls to `https://test-api.creem.io`.

License
-------

[](#license)

MIT License

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance70

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

176d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5675200?v=4)[Yann Rabiller](/maintainers/Einenlum)[@einenlum](https://github.com/einenlum)

---

Top Contributors

[![einenlum](https://avatars.githubusercontent.com/u/5675200?v=4)](https://github.com/einenlum "einenlum (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/einenlum-creem-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/einenlum-creem-php-sdk/health.svg)](https://phpackages.com/packages/einenlum-creem-php-sdk)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60216.0M85](/packages/mollie-mollie-api-php)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M50](/packages/getbrevo-brevo-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
