romansh/omnipay-creem
最新稳定版本:v1.0.1
Composer 安装命令:
composer require romansh/omnipay-creem
包简介
Creem driver for Omnipay payment processing library
README 文档
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
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-26