定制 sudiptpa/paypal-ipn 二次开发

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

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

sudiptpa/paypal-ipn

Composer 安装命令:

composer require sudiptpa/paypal-ipn

包简介

Modernized, framework-agnostic PayPal IPN verification package for legacy IPN workflows.

README 文档

README

Framework-agnostic, modernized PayPal IPN verification package for legacy Instant Payment Notification workflows.

CI Packagist Version Packagist Downloads PHP Version License

Sponsor

If this package has been useful to you, GitHub Sponsors is a simple way to support ongoing maintenance, improvements, and future releases.

Why This Package

PayPal IPN is legacy, but thousands of projects still depend on it. This package now gives you a modern fluent API for new work while still preserving the familiar listener flow that existing integrations already use.

If you are integrating today, prefer the modern Ipn entry point. Keep the legacy handler flow when you want minimal application changes during upgrades.

Highlights

  • preferred modern fluent usage with Sujip\PayPal\Notification\Ipn
  • stable legacy-style usage with ArrayHandler and StreamHandler
  • zero hard runtime dependencies beyond PHP
  • no hard Guzzle dependency
  • no hard Symfony dependency
  • built-in lightweight event dispatcher
  • built-in cURL transport when ext-curl is available
  • optional Guzzle transport support
  • custom transport and custom dispatcher support
  • PHP 8.2 to <8.6

Installation

composer require sudiptpa/paypal-ipn

Optional Guzzle usage:

composer require guzzlehttp/guzzle

Documentation

Looking For A Modern Unified PayPal Package?

If you are starting a new integration or want one modern package for both legacy IPN and PayPal Webhooks, use sudiptpa/paypal-notifications.

Use this package when:

  • you want a focused IPN-only package
  • you need to modernize an existing IPN integration with minimal behavioral change

Use paypal-notifications when:

  • you want support for both PayPal IPN and Webhooks
  • you are building a newer integration around the modern PayPal notification model
  • you want one package to handle legacy and newer notification flows together

Recommended Usage

For new integrations and most upgrades, prefer the modern fluent API:

use Sujip\PayPal\Notification\Ipn;

$result = Ipn::fromArray($_POST)
    ->sandbox()
    ->verify();

You can still attach listeners, custom transports, and dispatchers as needed.

Quick Start

Modern Fluent Usage

use Sujip\PayPal\Notification\Events\Failure;
use Sujip\PayPal\Notification\Events\Invalid;
use Sujip\PayPal\Notification\Events\Verified;
use Sujip\PayPal\Notification\Ipn;

$result = Ipn::fromArray($_POST)
    ->sandbox()
    ->onVerified(function (Verified $event): void {
        $payload = $event->getPayload();

        // Process the verified PayPal IPN here.
    })
    ->onInvalid(function (Invalid $event): void {
        $payload = $event->getPayload();

        // Log the invalid payload here.
    })
    ->onError(function (Failure $event): void {
        $error = $event->error();

        // Log transport or verification errors here.
    })
    ->verify();

Legacy Listener Usage

use Sujip\PayPal\Notification\Events\Failure;
use Sujip\PayPal\Notification\Events\Invalid;
use Sujip\PayPal\Notification\Events\Verified;
use Sujip\PayPal\Notification\Handler\ArrayHandler;

$manager = (new ArrayHandler($_POST))
    ->sandbox()
    ->handle();

$manager->onVerified(function (Verified $event): void {
    $payload = $event->getPayload();

    // Process the verified PayPal IPN here.
});

$manager->onInvalid(function (Invalid $event): void {
    $payload = $event->getPayload();

    // Log the invalid payload here.
});

$manager->onError(function (Failure $event): void {
    $error = $event->error();

    // Log transport or verification errors here.
});

$manager->fire();

Public API Stability

The package is intentionally conservative about the legacy integration shape. These areas should be treated as public API for consumers:

  • Sujip\PayPal\Notification\Ipn
  • Sujip\PayPal\Notification\Handler\ArrayHandler
  • Sujip\PayPal\Notification\Handler\StreamHandler
  • Sujip\PayPal\Notification\Manager
  • verification events
  • Sujip\PayPal\Notification\Contracts\Service
  • listener methods and event names

Internal implementation classes may evolve over time, especially where compatibility wrappers exist to preserve user-facing behavior.

Transport Resolution

The package resolves verification transports in this order:

  1. a custom service passed via ->using()
  2. a transport or Guzzle client passed via ->withTransport() or ->withClient()
  3. the built-in cURL transport when ext-curl is available
  4. the optional Guzzle transport when Guzzle is installed

If none of those are available, the verification cycle fails with a clear transport exception.

Backward Compatibility

The legacy listener-driven flow is intentionally preserved, but it is now the compatibility path rather than the recommended starting point:

$manager = (new ArrayHandler($payload))->sandbox()->handle();
$manager->onVerified(fn ($event) => null);
$manager->onInvalid(fn ($event) => null);
$manager->onError(fn ($event) => null);
$manager->fire();

There is also a modern fluent entry point with the same verification engine underneath:

Ipn::fromArray($payload)
    ->sandbox()
    ->onVerified(fn ($event) => null)
    ->verify();

That means users can upgrade the package internals without needing a functionality rewrite in their applications, while newer integrations can adopt a cleaner API.

Extendability

Custom transport

Implement Sujip\PayPal\Notification\Contracts\Service and pass it to ->using().

Optional Guzzle transport

Install Guzzle in your application and pass a client into ->withClient().

External event dispatcher

Pass any compatible dispatcher object into ->withDispatcher() as long as it provides addListener() and dispatch() methods.

Support

  • use the GitHub issue tracker for bugs and regressions
  • report security issues privately using SECURITY.md
  • use PayPal sandbox IPN verification in your own app before deploying changes

Development

composer lint
composer stan
composer rector:check
composer test
composer test:coverage

Testing Strategy

The test suite covers:

  • endpoint switching between live and sandbox
  • payload parsing and serialization
  • verified, invalid, and failure event dispatching
  • custom service injection
  • local dispatcher behavior and external dispatcher interoperability
  • legacy and modern public usage styles
  • request transport validation behavior

License

MIT

sudiptpa/paypal-ipn 适用场景与选型建议

sudiptpa/paypal-ipn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.52k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2016 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-31