Installation
composer require devmatchable/whop-php-sdk
Add the SDK to your config/services.php:
'whop' => [
'secret_key' => env('WHOP_SECRET_KEY'),
'api_url' => env('WHOP_API_URL', 'https://api.whop.com'),
],
First Use Case: Create a Customer
use Whop\Whop;
$whop = new Whop(config('services.whop.secret_key'));
$customer = $whop->customers()->create([
'email' => 'user@example.com',
'name' => 'John Doe',
]);
Where to Look First
vendor/devmatchable/whop-php-sdk/src/Whop/ for available methods.tests/ in the SDK for usage patterns.Customer Management
customers()->create() or customers()->update().customers()->get($id) or list via customers()->all().customer.created via Whop dashboard.Subscription Handling
$subscription = $whop->subscriptions()->create([
'customer_id' => $customer->id,
'plan_id' => 'monthly_plan_123',
]);
$whop->subscriptions()->cancel($subscription->id);
$whop->subscriptions()->resume($subscription->id);
Payment Processing
$charge = $whop->charges()->create([
'customer_id' => $customer->id,
'amount' => 1000, // cents
'currency' => 'USD',
]);
$whop->charges()->refund($charge->id);
Webhook Handling
public function handle($request, Closure $next) {
$whop = new Whop(config('services.whop.secret_key'));
if (!$whop->verifyWebhook($request->getContent(), $request->header('whop-signature'))) {
abort(403);
}
return $next($request);
}
Route::post('/whop-webhook', [WhopWebhookController::class, 'handle']);
Integration with Laravel Ecosystem
event(new SubscriptionCreated($subscription));
SubscriptionCreated::dispatch($subscription)->onQueue('whop');
API Key Security
WHOP_SECRET_KEY in your code. Always use .env.Idempotency
POST requests (e.g., X-Idempotency-Key). Use them for retries:
$whop->withOptions(['idempotency_key' => 'unique_key_123'])->customers()->create(...);
Rate Limiting
$customers = Cache::remember('whop_customers', 60, function() {
return $whop->customers()->all();
});
Webhook Delays
$attempts = 0;
while ($attempts < 3) {
try {
$whop->verifyWebhook(...);
break;
} catch (Exception $e) {
sleep(2 ** $attempts);
$attempts++;
}
}
Currency/Amount Handling
$amountInDollars = 9.99;
$amountInCents = $amountInDollars * 100; // 999
Enable SDK Logging
Add to config/services.php:
'whop' => [
'debug' => env('WHOP_DEBUG', false),
],
Logs will appear in Laravel’s log channel.
Test with Sandbox Use Whop’s sandbox mode for testing:
$wh
How can I help you explore Laravel packages today?