barstec/laravel-paypal-payment-ipn
Composer 安装命令:
composer require barstec/laravel-paypal-payment-ipn
包简介
Package for easily integrating paypal payments via html buttons with Laravel and IPN verification.
README 文档
README
This package facilitates seamless integration of PayPal payments via pay now buttons and IPN verification within Laravel. It's specifically designed for sellers without a PayPal business account, eliminating the need for access to the live API version.
Support
If this package is helpful for you, you can support my work on Ko-fi.
Installation
- Install composer package using command:
composer require barstec/laravel-paypal-payment-ipn
- Publish configuration files to your project
php artisan vendor:publish --provider="Barstec\Paypal\PaypalServiceProvider"
- Run migrations
php artisan migrate
Setup
Firstly you need to move environmental variables from .env.example to .env:
PAYPAL_MODE=dev PAYPAL_EMAIL=
If you are in testing mode, set PAYPAL_MODE to dev. When in production, switch it to prod.
PAYPAL_EMAIL is the email address of the PayPal account where payments will be sent.
In the configuration file, you can define return routes, default values, the database table name, and the columns to be collected. After modifying columns, rerun the migration process.
Ensure that you specify the same notification route as in the PayPal IPN settings. This URL is used to verify transactions and is set by default to /api/paypal/notification.
Important! You should set your PayPal IPN settings to use encoding UTF-8. Otherwise, there is no guarantee that certain characters will be recognized correctly. You can set it up here: https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-language-encoding
Usage/Examples
To initiate a transaction, create a Payload object in your controller and assign values. Then, create a Payment object, pass the Payload, and call redirect(). This action will start the transaction and redirect the user to the Paypal payment page. By default Payload object is configured to handle single-item payment without delivery or additional costs. You can modify it using predefined methods or by adding any fields you want using setParams.
<?php namespace App\Http\Controllers; use Barstec\Paypal\Payload; use Barstec\Paypal\Payment; class PaypalController extends Controller { public function paypalTest(){ $payload = new Payload(); $payload->setBusinessEmail("youremail@example.com"); $payload->setItemName("Testowe"); $payload->setAmount(1); $payment = new Payment($payload); return $payment->redirect(); } }
Upon transaction creation, the PaypalTransactionCreated event is triggered. You can use it to retrieve the payload and transaction ID to associate the transaction with a specific user. To achieve this, create a listener and register it in your EventServiceProvider.
protected $listen = [ PaypalTransactionCreated::class => [ ExampleListener::class ] ];
By default, all transaction status changes are handled by the package. The PaypalPaymentCompleted event is triggered after receiving a Completed signal from Paypal. Otherwise, for status changes, the PaypalPaymentStatusChanged event is triggered.
Author
License
This package is distributed under the MIT license
barstec/laravel-paypal-payment-ipn 适用场景与选型建议
barstec/laravel-paypal-payment-ipn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「package」 「api」 「payments」 「paypal」 「ipn」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 barstec/laravel-paypal-payment-ipn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 barstec/laravel-paypal-payment-ipn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 barstec/laravel-paypal-payment-ipn 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
A PSR-7 compatible library for making CRUD API endpoints
Simple ASCII output of array data
Package for view storage in laravel
User Approval Laravel Package
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-25