dodopayments-ismail-taibi/laravel-dodopayments
Composer 安装命令:
composer require dodopayments-ismail-taibi/laravel-dodopayments
包简介
Official Laravel integration for DodoPayments - Accept payments with ease by ismail taibi
README 文档
README
Official Laravel package for DodoPayments - Accept payments with ease in your Laravel applications.
Features
- 🚀 Easy Integration - Get started in minutes
- 💳 Checkout Sessions - Secure hosted checkout pages
- 🔗 Payment Links - Static and dynamic payment URLs
- 🔔 Webhook Support - Real-time payment notifications
- 🎨 Beautiful UI - Pre-built, customizable checkout views
- 🔐 Secure - Built-in webhook signature verification
- 📦 Laravel Standard - Follows Laravel best practices
- 🎯 Event-Driven - Laravel events for all webhooks
Requirements
- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- A DodoPayments account (Sign up here)
Installation
Install the package via Composer:
composer require dodopayments-ismail-taibi/laravel-dodopayments
Publish Configuration
Publish the config file:
php artisan vendor:publish --tag=dodopayments-config
Publish Views (Optional)
If you want to customize the checkout views:
php artisan vendor:publish --tag=dodopayments-views
Configuration
Add your DodoPayments credentials to your .env file:
DODO_PAYMENTS_API_KEY=your_api_key_here DODO_PAYMENTS_PUBLISHABLE_KEY=your_publishable_key_here DODO_PAYMENTS_WEBHOOK_SECRET=your_webhook_secret_here DODO_PAYMENTS_ENVIRONMENT=test_mode # Optional: Customize URLs DODO_PAYMENTS_SUCCESS_URL=/payment/success DODO_PAYMENTS_CANCEL_URL=/payment/cancel # Optional: Product ID for quick testing DODO_PRODUCT_ID=prod_your_product_id
Getting Your Credentials
- API Key: Dashboard → Developer → API
- Webhook Secret: Dashboard → Developer → Webhooks
- Product ID: Dashboard → Products → Select Product
Quick Start
1. Basic Checkout
The package automatically registers routes. Visit:
http://your-app.test/payment/checkout
2. Create Checkout Programmatically
use DodoPayments\Laravel\Facades\DodoPayments; $session = DodoPayments::createCheckoutSession( productCart: [ [ 'product_id' => 'prod_abc123', 'quantity' => 1, ] ], options: [ 'customer' => [ 'email' => '[email protected]', 'name' => 'John Doe', ], 'return_url' => url('/payment/success'), 'metadata' => [ 'order_id' => 'order_123', ], ] ); return redirect()->away($session['checkout_url']);
3. Handle Webhooks
The package fires Laravel events for all webhooks. Listen to them in your EventServiceProvider:
use DodoPayments\Laravel\Events\WebhookReceived; protected $listen = [ WebhookReceived::class => [ \App\Listeners\HandlePaymentSuccess::class, ], ];
Create a listener:
namespace App\Listeners; use DodoPayments\Laravel\Events\WebhookReceived; use Illuminate\Support\Facades\Log; class HandlePaymentSuccess { public function handle(WebhookReceived $event): void { if ($event->type === 'payment.succeeded') { $data = $event->data['data'] ?? []; Log::info('Payment successful', [ 'payment_id' => $data['payment_id'] ?? null, 'amount' => $data['amount'] ?? null, ]); // Your business logic here // Update order status, send emails, etc. } } }
Usage
Create Checkout Session
use DodoPayments\Laravel\Facades\DodoPayments; // Simple checkout $session = DodoPayments::createCheckoutSession([ ['product_id' => 'prod_abc123', 'quantity' => 1] ]); // With customer details $session = DodoPayments::createCheckoutSession( productCart: [ ['product_id' => 'prod_abc123', 'quantity' => 2], ['product_id' => 'prod_xyz789', 'quantity' => 1], ], options: [ 'customer' => [ 'email' => '[email protected]', 'name' => 'Jane Smith', ], 'billing_address' => [ 'street' => '123 Main St', 'city' => 'San Francisco', 'state' => 'CA', 'country' => 'US', 'zipcode' => '94103', ], 'metadata' => [ 'user_id' => auth()->id(), 'order_id' => 'order_456', ], 'return_url' => url('/orders/success'), ] ); redirect()->away($session['checkout_url']);
Create Payment Link
// Static payment link $link = DodoPayments::buildStaticPaymentLink( productId: 'prod_abc123', params: [ 'quantity' => 1, 'email' => '[email protected]', 'redirect_url' => url('/success'), ] ); // Dynamic payment link $payment = DodoPayments::createPaymentLink( productId: 'prod_abc123', options: [ 'billing' => [ 'city' => 'New York', 'country' => 'US', 'state' => 'NY', 'street' => '456 Broadway', 'zipcode' => 10013, ], 'customer' => [ 'email' => '[email protected]', 'name' => 'Bob Wilson', ], ] ); return $payment['payment_link'];
Retrieve Payment
$payment = DodoPayments::getPayment('pay_123abc'); echo $payment['status']; // succeeded, failed, pending, etc. echo $payment['amount']; echo $payment['customer']['email'];
List Payments
$payments = DodoPayments::listPayments([ 'limit' => 10, 'page' => 1, ]); foreach ($payments['data'] as $payment) { echo $payment['payment_id']; }
Webhook Events
The package automatically verifies webhook signatures and fires the WebhookReceived event.
Available Event Types
payment.succeeded- Payment completed successfullypayment.failed- Payment failedpayment.refunded- Payment was refundedsubscription.created- New subscription createdsubscription.updated- Subscription details updatedsubscription.cancelled- Subscription cancelledsubscription.renewed- Subscription renewed
Webhook Configuration
- In your DodoPayments dashboard, go to Developer → Webhooks
- Add webhook URL:
https://your-domain.com/webhook/dodopayments - Copy the webhook secret
- Add to
.env:DODO_PAYMENTS_WEBHOOK_SECRET=your_secret
Example Webhook Listener
namespace App\Listeners; use DodoPayments\Laravel\Events\WebhookReceived; use App\Models\Order; use Illuminate\Support\Facades\Mail; class HandlePaymentSuccess { public function handle(WebhookReceived $event): void { match($event->type) { 'payment.succeeded' => $this->handlePaymentSuccess($event->data), 'payment.refunded' => $this->handleRefund($event->data), 'subscription.created' => $this->handleSubscriptionCreated($event->data), default => null, }; } private function handlePaymentSuccess(array $data): void { $paymentData = $data['data'] ?? []; $orderId = $paymentData['metadata']['order_id'] ?? null; if ($orderId) { Order::where('id', $orderId)->update([ 'status' => 'paid', 'payment_id' => $paymentData['payment_id'], 'paid_at' => now(), ]); // Send confirmation email Mail::to($paymentData['customer']['email']) ->send(new OrderConfirmation($orderId)); } } }
Routes
The package automatically registers these routes:
| Method | URI | Name | Description |
|---|---|---|---|
| GET | /payment/checkout |
dodopayments.checkout |
Checkout page |
| POST | /payment/checkout |
dodopayments.create-checkout |
Create checkout session |
| GET | /payment/success |
dodopayments.success |
Success page |
| GET | /payment/cancel |
dodopayments.cancel |
Cancel page |
| POST | /payment/create-link |
dodopayments.create-link |
Create payment link |
| POST | /webhook/dodopayments |
dodopayments.webhook |
Webhook endpoint |
Disable Auto Routes
If you want to register routes manually, disable them in config:
// config/dodopayments.php 'routes' => [ 'enabled' => false, ],
Customization
Custom Views
Publish and customize the views:
php artisan vendor:publish --tag=dodopayments-views
Views will be available in resources/views/vendor/dodopayments/:
checkout.blade.php- Checkout pagesuccess.blade.php- Success pagecancel.blade.php- Cancel page
Custom Route Prefix
// config/dodopayments.php 'routes' => [ 'prefix' => 'payments', // Changes /payment/* to /payments/* ],
Testing
The package uses the test mode API by default when DODO_PAYMENTS_ENVIRONMENT=test_mode.
Test Locally
php artisan serve
# Visit: http://localhost:8000/payment/checkout
Test Webhooks with ngrok
ngrok http 8000 # Use the ngrok URL in your DodoPayments webhook settings # Example: https://abc123.ngrok.io/webhook/dodopayments
API Reference
Facade Methods
// Create checkout session DodoPayments::createCheckoutSession(array $productCart, array $options = []): array // Create payment link DodoPayments::createPaymentLink(string $productId, array $options = []): array // Get payment details DodoPayments::getPayment(string $paymentId): array // List payments DodoPayments::listPayments(array $filters = []): array // Build static payment link DodoPayments::buildStaticPaymentLink(string $productId, array $params = []): string // Verify webhook signature DodoPayments::verifyWebhookSignature(string $payload, array $headers): bool // Get API URL DodoPayments::getApiUrl(): string // Get environment DodoPayments::getEnvironment(): string
Security
- Webhook signatures are automatically verified
- API keys should be stored in
.envfile - Never commit API keys to version control
- Use HTTPS in production
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Support
- 📧 Email: [email protected]
- 📚 Documentation: https://docs.dodopayments.com
- 🐛 Issues: GitHub Issues
License
The MIT License (MIT). Please see License File for more information.
Made with ❤️ by DodoPayments
dodopayments-ismail-taibi/laravel-dodopayments 适用场景与选型建议
dodopayments-ismail-taibi/laravel-dodopayments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「checkout」 「subscription」 「laravel」 「billing」 「dodopayments」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dodopayments-ismail-taibi/laravel-dodopayments 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dodopayments-ismail-taibi/laravel-dodopayments 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dodopayments-ismail-taibi/laravel-dodopayments 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
MaxAl Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Adds a 'checkout' to a SilverStripe site which links to an Estimate and adds the ability to setup and pay
Rinvex Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Rinvex Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Rinvex Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-06