wenson/paypal
Composer 安装命令:
composer require wenson/paypal
包简介
Laravel plugin For Processing Payments Through Paypal Express Checkout. Can Be Used Independently With Other Applications.
README 文档
README
Introduction
This package is build on srmklive/paypal package with Partner api support
This plugin supports the new paypal rest api.
PayPal API Credentials
This package uses the new paypal rest api. Refer to this link on how to create API credentials:
https://developer.paypal.com/docs/api/overview/
Installation
- Use following command to install:
If you intend to use ExpressCheckout, please to the following README. v2.0 & v3.0 uses the new rest api.
composer require wenson/paypal
- Run the following command to publish configuration:
php artisan vendor:publish --provider "Srmklive\PayPal\Providers\PayPalServiceProvider"
Configuration
- After installation, you will need to add your paypal settings. Following is the code you will find in config/paypal.php, which you should update accordingly.
return [ 'mode' => env('PAYPAL_MODE', 'sandbox'), // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used. 'sandbox' => [ 'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID', ''), 'client_secret' => env('PAYPAL_SANDBOX_CLIENT_SECRET', ''), 'app_id' => 'APP-80W284485P519543T', ], 'live' => [ 'client_id' => env('PAYPAL_LIVE_CLIENT_ID', ''), 'client_secret' => env('PAYPAL_LIVE_CLIENT_SECRET', ''), 'app_id' => '', ], 'payment_action' => env('PAYPAL_PAYMENT_ACTION', 'Sale'), // Can only be 'Sale', 'Authorization' or 'Order' 'currency' => env('PAYPAL_CURRENCY', 'USD'), 'notify_url' => env('PAYPAL_NOTIFY_URL', ''), // Change this accordingly for your application. 'locale' => env('PAYPAL_LOCALE', 'en_US'), // force gateway language i.e. it_IT, es_ES, en_US ... (for express checkout only) 'validate_ssl' => env('PAYPAL_VALIDATE_SSL', true), // Validate SSL when creating api client. ];
- Add this to
.env.exampleand.env
#PayPal Setting & API Credentials - sandbox
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SANDBOX_CLIENT_SECRET=
#PayPal Setting & API Credentials - live
PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_CLIENT_SECRET=
Usage
Following are some ways through which you can access the paypal provider:
// Import the class namespaces first, before using it directly use Srmklive\PayPal\Services\PayPal as PayPalClient; $provider = new PayPalClient; // Through facade. No need to import namespaces $provider = PayPal::setProvider();
Override PayPal API Configuration
You can override PayPal API configuration by calling setApiCredentials method:
$provider->setApiCredentials($config);
Get Access Token
After setting the PayPal API configuration by calling setApiCredentials method. You need to get access token before performing any API calls
if (Cache::get('token')) { $provider->setAccessToken(Cache::get('token')); } else { $response = $provider->getAccessToken(); Cache::set('token', $response); }
Set Currency
By default the currency used is USD. If you wish to change it, you may call setCurrency method to set a different currency before calling any respective API methods:
$provider->setCurrency('EUR');
Initiating an order for Checkout
Use the createOrder method to initiate an order
$provider->createOrder([ "intent"=> "CAPTURE", "purchase_units"=> [ 0 => [ "amount"=> [ "currency_code"=> "USD", "value"=? "100.00" ] ] ] ]);
The response from this will include an order ID which you will need to retail, and a links collection so you can direct the user to Paypal to complete the order with their payment details
When the user returns to the notifcation url you can capture the order payment with
$provider->capturePaymentOrder($order_id); //order id from the createOrder step
Partner
$provider = new Paypal(); // behalf of merchant $provider->actingAs($merchantId); // partner referrals $provider->partnerReferrals($trackingId);
Support
This version supports Laravel 6 or greater.
- In case of any issues, kindly create one on the Issues section.
- If you would like to contribute:
- Fork this repository.
- Implement your features.
- Generate pull request.
wenson/paypal 适用场景与选型建议
wenson/paypal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「rest」 「web service」 「paypal」 「laravel paypal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wenson/paypal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wenson/paypal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wenson/paypal 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Model of a web-based resource
A PSR-7 compatible library for making CRUD API endpoints
Retrieve a WebResourceInterface instance over HTTP
Api bundle
http客户端
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-16