romansh/omnipay-creem

Creem driver for Omnipay payment processing library

Maintainers

Package info

github.com/romansh/omnipay-creem

pkg:composer/romansh/omnipay-creem

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.1 2026-02-26 21:41 UTC

This package is auto-updated.

Last update: 2026-02-26 21:43:24 UTC


README

Creem.io gateway driver for the Omnipay payment processing library.

Installation

composer require romansh/omnipay-creem

Features

  • Hosted Checkout — redirect customers to Creem-hosted payment page
  • Webhook verification — HMAC SHA-256 signature validation
  • Customer Portal — generate self-service billing URLs
  • Subscription lifecycle — handle active, trialing, canceled, expired, and renewed events

Gateway Parameters

Parameter Description Default
apiKey Your Creem API key ''
testMode Enable sandbox/test mode true
webhookSecret Secret for verifying webhook signatures ''
productId Default Creem Product ID ''

Usage

Initialize the gateway

use Omnipay\Omnipay;

$gateway = Omnipay::create('Creem');
$gateway->setApiKey('your_api_key');
$gateway->setTestMode(true);

Create a checkout (purchase)

$response = $gateway->purchase([
    'productId'     => 'prod_xxxxxxxxx',   // Creem product ID
    'transactionId' => 'ORDER-12345',       // your unique order/request ID
    'returnUrl'     => 'https://your-site.com/return',
    'card' => [
        'email' => 'customer@example.com',
        'name'  => 'John Doe',
    ],
    'description' => 'Premium plan',
])->send();

if ($response->isRedirect()) {
    $response->redirect(); // send the customer to Creem checkout

    // — or get the URL to use in your own redirect / JS —
    // $checkoutUrl = $response->getRedirectUrl();
    // $checkoutId  = $response->getTransactionReference();
} else {
    echo 'Error: ' . $response->getMessage();
}

Handle a webhook (completePurchase)

completePurchase() reads the incoming HTTP request body and validates the creem-signature header automatically — no parameters are needed.

$gateway->setWebhookSecret('your_webhook_secret');

$response = $gateway->completePurchase()->send();

switch ($response->getEventType()) {
    case 'checkout.completed':
        $orderId  = $response->getTransactionId();   // your request_id
        $customer = $response->getCustomer();         // ['id' => …, 'email' => …]
        $product  = $response->getProduct();          // ['id' => …, 'name' => …]
        // mark order as paid …
        break;

    case 'subscription.active':
    case 'subscription.renewed':
        // grant / extend access
        break;

    case 'subscription.trialing':
        // grant trial access
        break;

    case 'subscription.canceled':
    case 'subscription.expired':
        // revoke access
        break;

    case 'refund.created':
        // process refund
        break;
}

http_response_code(200);
echo json_encode(['status' => 'ok']);

Customer Portal

$response = $gateway->customerPortal([
    'customerId' => 'cust_xxxxxxxxx',
])->send();

if ($response->isSuccessful()) {
    $portalUrl = $response->getPortalUrl();
    header("Location: {$portalUrl}");
}

Full examples

See examples/usage.php for a complete standalone script and a Laravel controller example.

License

MIT