Download the PHP package keeal/keeal-php without Composer
On this page you can find all versions of the php package keeal/keeal-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download keeal/keeal-php
More information about keeal/keeal-php
Files in keeal/keeal-php
Package keeal-php
Short Description Keeal PHP SDK — hosted checkout REST API client
License MIT
Informations about the package keeal-php
Keeal PHP SDK
Official PHP client for Keeal hosted checkout: create sessions with your secret API key, redirect buyers to the returned URL, and verify webhooks.
Repository: github.com/KeealPay/keeal-php · Package: keeal/keeal-php
Overview
Keeal hosted checkout is a redirect-based payment flow:
- Create a session on your server with your secret API key (
keeal_sk_…). - Redirect the customer to the session
urlreturned by the API. - Fulfill your order when you receive a signed
checkout.session.completedwebhook.
Your server never handles card data. Payment UI, PayPal, and cancellation are handled on Keeal's hosted page.
Installation
Requires PHP 8.1+ with the json extension.
Configuration
Set these environment variables on your server:
| Variable | Description |
|---|---|
KEEAL_API_KEY |
Secret API key (keeal_sk_…) from the Keeal dashboard |
KEEAL_BASE_URL |
API base URL including /api, e.g. https://api.keeal.com/api |
KEEAL_WEBHOOK_SECRET |
Webhook signing secret (whsec_…) from Settings → API Keys → Webhook |
Use separate keys, base URLs, and webhook secrets for staging and production.
When constructing KeealCheckout, pass apiKey and baseUrl explicitly (from getenv() or your framework's config).
Quick start
API reference
KeealCheckout
Server-side client. Requires your secret API key.
| Method | Signature | Description | Status |
|---|---|---|---|
__construct |
__construct(array $options) |
apiKey required. baseUrl required (defaults to https://api.keeal.com/api when omitted). Optional: defaultHeaders, http. |
Hosted |
createSession |
createSession(array $params, array $options = []) → array{id, url} |
Create a checkout session. Sends Idempotency-Key (auto-generated if omitted). |
Hosted |
createSessionUrl |
createSessionUrl(array $params, array $options = []) → string |
Convenience wrapper; returns the hosted checkout url. |
Hosted |
listMerchantSessions |
listMerchantSessions(?array $options = null) → array |
List your checkout sessions. Options: limit, page. |
Hosted |
retrieveMerchantSession |
retrieveMerchantSession(string $sessionId) → array |
Get one session by cs_… id, including payments[]. |
Hosted |
retrieveSession |
retrieveSession(string $sessionId) → array |
Public session lookup (no API key sent). | Hosted |
createPayment |
createPayment(string $sessionId, array $params, array $options = []) → array |
Legacy custom /pay flow. |
Deprecated |
cancelSession |
cancelSession(string $sessionId) → void |
Legacy session cancel. | Deprecated |
abandonSession |
abandonSession(string $sessionId) → void |
Legacy session abandon. | Deprecated |
paypalCreateOrder |
paypalCreateOrder(string $sessionId, array $params) → array |
Legacy PayPal create-order. | Deprecated |
paypalCapture |
paypalCapture(string $sessionId, array $params) → array |
Legacy PayPal capture. | Deprecated |
KeealCheckoutPublic
Unauthenticated client for legacy custom checkout UIs. Not recommended for new integrations.
| Method | Signature | Description | Status |
|---|---|---|---|
__construct |
__construct(array $options) |
baseUrl required. Optional: defaultHeaders, http. |
Deprecated |
retrieveSession |
retrieveSession(string $sessionId) → array |
Public session lookup. | Deprecated |
createPayment |
createPayment(string $sessionId, array $params, array $options = []) → array |
Legacy /pay from a custom UI. |
Deprecated |
cancelSession |
cancelSession(string $sessionId) → void |
Legacy cancel. | Deprecated |
abandonSession |
abandonSession(string $sessionId) → void |
Legacy abandon. | Deprecated |
paypalCreateOrder |
paypalCreateOrder(string $sessionId, array $params) → array |
Legacy PayPal. | Deprecated |
paypalCapture |
paypalCapture(string $sessionId, array $params) → array |
Legacy PayPal. | Deprecated |
WebhookVerifier
| Method / constant | Signature | Description |
|---|---|---|
SIGNATURE_HEADER |
— | X-Keeal-Signature |
EVENT_HEADER |
— | X-Keeal-Event |
verify |
verify(string $rawBody, string $signatureHeader, string $whsec, int $toleranceSeconds = 300) → bool |
Verify signature on the raw request body. |
constructEvent |
constructEvent(string $rawBody, string $signatureHeader, string $whsec, int $toleranceSeconds = 300) → array |
Verify signature and decode the JSON envelope. Throws KeealCheckoutException on failure. |
Webhook verification
Configure your webhook URL in the Keeal dashboard. Verify signatures on the raw request body — do not re-encode JSON.
Signature format: t=<unix_seconds>,v1=<hex_hmac> where HMAC-SHA256 is computed over <t>.<rawBody> using your whsec_… secret.
Subscription checkout
Hosted subscription checkout follows the same pattern as Stripe Checkout for subscriptions:
- Create a product and price in the Keeal dashboard and copy the price id (
price_…). - Create a session with
mode => 'subscription'and the catalog price id. - Redirect to the session
url. - Handle
checkout.session.completedand subscription webhooks.
Subscription lifecycle events (subscription.created, subscription.activated, etc.) are delivered to the same webhook URL and verified with the same signing secret as checkout events.
Legacy & deprecated APIs
These classes and methods remain for backward compatibility but are not offered to new merchants:
| Symbol | Use instead |
|---|---|
KeealCheckoutPublic |
KeealCheckout::createSession() + redirect to url |
KeealCheckout::createPayment() |
Redirect to session url |
KeealCheckoutPublic::createPayment() |
Redirect to session url |
cancelSession / abandonSession |
Handled on Keeal's hosted pay page |
paypalCreateOrder / paypalCapture |
Handled on Keeal's hosted pay page |
Laravel
Using Laravel? See keeal/laravel-checkout for a ServiceProvider, Facade, config publishing, and webhook middleware.
Development
End-to-end tests (optional)
License
MIT — see LICENSE.
All versions of keeal-php with dependencies
ext-json Version *