承接 yared/laravel-smart-stripe 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yared/laravel-smart-stripe

Composer 安装命令:

composer require yared/laravel-smart-stripe

包简介

Secure Stripe Payments for Laravel with Fraud Detection, Automatic Webhooks, Smart Checkout, and Payment Logging

README 文档

README

One-time Stripe payments for Laravel — flexible for hotel bookings, ecommerce, donations, and more.

Latest Version License

One-line payments:

StripePay::charge(1000)->from($user)->pay();

or redirect to Stripe Checkout:

return StripePay::checkout()
    ->product('Hotel Room')
    ->price(1999)
    ->success('/success')
    ->cancel('/cancel')
    ->redirect();

Features

  • One-time payments only — No subscriptions; ideal for bookings, orders, donations
  • One-line charge — Fluent API for direct charges
  • Smart Checkout — Single item or multi-item cart (ecommerce)
  • Webhookspayment_succeeded, payment_failed, refund_created
  • Fraud detection — IP limits, rapid attempts, suspicious countries
  • Smart metadata — Auto-attach user_id, IP, browser, country, app name
  • Payable handlers — Auto-update models (e.g. Booking, Order) when paid
  • Payment logging — Audit trail for every Stripe interaction
  • Queue support — Background processing
  • Test simulator — Simulate success/failure/refund locally

Installation

composer require yared/laravel-smart-stripe

Publish config and migrations:

php artisan vendor:publish --tag=stripe-smart-config
php artisan vendor:publish --tag=stripe-smart-migrations
php artisan migrate

Add to .env:

STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_CURRENCY=usd

Usage

Direct charge

use Yared\SmartStripe\Facades\StripePay;

StripePay::charge(2000)
    ->currency('usd')
    ->customer($user)
    ->description('Order #2001')
    ->metadata(['order_id' => 2001])
    ->pay();

With fraud detection

StripePay::charge(1000)
    ->from($user)
    ->detectFraud()
    ->pay();

Stripe Checkout (single item)

return StripePay::checkout()
    ->product('Premium Plan')
    ->price(1999)
    ->success('/success')
    ->cancel('/cancel')
    ->redirect();

Multi-item checkout (ecommerce cart)

return StripePay::checkout()
    ->items([
        ['name' => 'Room A', 'price' => 15000, 'quantity' => 2, 'description' => '2 nights'],
        ['name' => 'Breakfast', 'price' => 999, 'quantity' => 1],
    ])
    ->metadata(['booking_id' => $booking->id])
    ->success('/hotel/success')
    ->cancel('/hotel/cancel')
    ->redirect();

Hotel booking example

StripePay::checkout()
    ->product("Room {$room->name} - {$checkIn} to {$checkOut}")
    ->price($totalCents)
    ->metadata(['booking_id' => $booking->id])
    ->success(route('hotel.success'))
    ->cancel(route('hotel.cancel'))
    ->redirect();

Refund

StripePay::refund($paymentIntentId);
StripePay::refund($paymentIntentId, 500); // Partial refund

Queue payment

StripePay::charge(2000)
    ->customer($user)
    ->queue();

Auto-update payment status (Payable handlers)

In config/stripe-smart.php:

'payable_handlers' => [
    'booking_id' => [
        'model' => \App\Models\Booking::class,
        'method' => 'markAsPaid',
    ],
    'order_id' => [
        'model' => \App\Models\Order::class,
        'method' => 'markAsPaid',
    ],
],

Include the metadata key when creating checkout:

StripePay::checkout()
    ->product('Hotel Booking')
    ->price(1999)
    ->metadata(['booking_id' => $booking->id])
    ->success('/success')
    ->redirect();

Success page helper

$session = StripePay::retrieveCheckoutSession($request->query('session_id'));
$metadata = StripePayment::getSessionMetadata($session);
$bookingId = $metadata['booking_id'] ?? null;

Webhook listeners

In AppServiceProvider::boot():

use Yared\SmartStripe\Facades\StripeWebhook;

StripeWebhook::listen('payment_succeeded', function ($event) {
    $orderId = $event->data->object->metadata['order_id'] ?? null;
    if ($orderId) {
        Order::find($orderId)?->markPaid();
    }
});

StripeWebhook::listen('payment_failed', fn ($event) => /* ... */);
StripeWebhook::listen('refund_created', fn ($event) => /* ... */);

Supported events: payment_succeeded, payment_failed, refund_created.

Test simulator

STRIPE_SIMULATOR_ENABLED=true
StripePay::simulateSuccess();
StripePay::simulateFailure(); // Throws exception
StripePay::simulateRefund();

Billable user trait

Add to your User model:

use Yared\SmartStripe\Traits\BillableUser;

class User extends Authenticatable
{
    use BillableUser;
}

Add stripe_id to users (migration included):

$user->createAsStripeCustomer();
$user->asStripeCustomer();

Security

  • Webhook signature verification
  • CSRF excluded for webhook route only
  • Fraud detection (configurable)
  • Rate limiting on webhook endpoint
  • Payment logging for audit trail

Configuration

See config/stripe-smart.php:

  • fraud_detection — Limits per IP/user, suspicious countries
  • metadata — Auto-attach user_id, IP, browser, etc.
  • logging — Payment audit logs
  • simulator — Test mode for local development

License

MIT

yared/laravel-smart-stripe 适用场景与选型建议

yared/laravel-smart-stripe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「checkout」 「payments」 「stripe」 「laravel」 「webhooks」 「fraud-detection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yared/laravel-smart-stripe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yared/laravel-smart-stripe 我们能提供哪些服务?
定制开发 / 二次开发

基于 yared/laravel-smart-stripe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-12