定制 brightcweb/paypal 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

brightcweb/paypal

Composer 安装命令:

composer require brightcweb/paypal

包简介

A professional PayPal integration package for Laravel applications, suitable for any Laravel application, such as NGO'S, e-commerces and more

README 文档

README

Brightcweb/Paypal is a Laravel package that simplifies PayPal integration for your e-commerce system or donation platform. With this package, you can handle payments efficiently while maintaining the flexibility to customize routes, views, and authentication requirements.

Features

  • Seamless PayPal checkout integration.
  • Customizable success and cancellation routes.
  • Records all payment transactions in the Brightcwebpayment table.
  • Optionally enforce user authentication before checkout.
  • Pre-built, modifiable views for success and cancellation pages.

Installation

Install the package via Composer:

composer require brightcweb/paypal

Publish the package configuration assets:

php artisan vendor:publish --tag=brightpaypalconfig

Run the migrations to create the Brightcwebpayment table:

php artisan migrate

Add the following entries to your .env file:

PAYPAL_CLIENT_ID=your-paypal-client-id
PAYPAL_CLIENT_SECRET=your-paypal-client-secret

Clear and cache the configuration:

php artisan config:clear
php artisan cache:clear
php artisan config:cache

Usage

Controller Setup

  • In your controller, import the PayPal class and inject it into the constructor:
use Brightcweb\Paypal\Myclass\BrightCWebPaypalClass;

class YourController extends Controller
{
    protected $BrightCwebPaypalClass;

    public function __construct(BrightCWebPaypalClass $BrightCWebPaypalClass)
    {
        $this->BrightCwebPaypalClass = $BrightCWebPaypalClass;
    }
}

Checkout Endpoint

Create a route and controller method for initiating the checkout process. Example:

public function checkout(Request $req)
{
    $amount = $req->amount; // Get order or donation amount
    $paymentData = $this->BrightCwebPaypalClass->createPaypalOrder($amount);

    return redirect($paymentData['links'][1]['href']);
}

Define the route in web.php:

Route::get('/checkout', [YourController::class, 'checkout'])->name('checkout');

Success and Cancel Routes

Add routes for handling successful and canceled payments:

public function successpaypal(Request $request)
{
    $orderId = $request->query('token');
    $payerId = $request->query('PayerID');

    $paymentDetails = $this->BrightCwebPaypalClass->handlePaymentSuccess($orderId, $payerId);

    if ($paymentDetails) {
        // Optionally send notifications or update tables
        return view('vendor.brightcwebpaypal.sucesspaypal', $paymentDetails);
    }

    return view('vendor.brightcwebpaypal.canceled');
}

public function cancelpaypal()
{
    return view('vendor.brightcwebpaypal.canceled');
}

Define these routes in web.php:

Route::get('/successpaypal', [YourController::class, 'successpaypal'])->name('successpaypal');
Route::get('/cancelpaypal', [YourController::class, 'cancelpaypal'])->name('cancelpaypal');

Add these routes in your .env file:

PAYPAL_SUCCESS_ROUTE="success payment route name"
PAYPAL_CANCELLED_ROUTE="cancelled payment route name"

Views Customization

The package includes default views for success and cancellation located in vendor/brightcwebpaypal. Feel free to modify or rename them according to your needs.

Authentication

This package allows you to decide whether users should be authenticated before proceeding with checkout or not. You can customize your middleware as needed.

Key Features

Payment Recording

Every successful payment is recorded in the Brightcwebpayment table for easy tracking.

Optional Authentication

You have full control over whether users need to be authenticated before initiating a checkout or not. This package works perfectly without authentication, which is useful in scenarios where registration is not required for checkout.

Clearing and Caching Configuration

Whenever you make changes to your .env file or configuration, remember to run the following commands:

php artisan config:clear
php artisan cache:clear
php artisan config:cache

Notes

  • Ensure that your PayPal credentials in the .env file are correct.
  • Ensure that PAYPAL_SUCCESS_ROUTE and PAYPAL_CANCELLED_ROUTE are correctly set in your .env file.
  • Always test your integration in PayPal's sandbox environment before going live.
  • Use php artisan optimize:clear if you encounter any cache-related issues.

Support

For support, please send us an email at: chikanwazuo@gmail.com

License

This package is open-sourced software licensed under the MIT license.

Contributing

We welcome contributions to enhance this package. Please contact us at chikanwazuo@gmail.com for any inquiries or contributions.

Conclusion

The Brightcweb PayPal Package is an excellent tool for integrating a payment gateway into your Laravel application, suitable for any project requiring PayPal payment integration.

brightcweb/paypal 适用场景与选型建议

brightcweb/paypal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 brightcweb/paypal 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-26