1. Go to this page and download the library: Download einenlum/creem-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
einenlum / creem-php-sdk example snippets
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;
use Einenlum\CreemPhpSdk\Creem;
$creem = Creem::create(
apiKey: 'creem_xxxxx',
webhookSecret: 'whsec_xxxxx', // Optional, for webhook handling
testMode: false // false = production, true = test environment
);
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
);
// 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;
}
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;