naif / laravel-paypal
Laravel PayPal 用于与 PayPal API 通信以获取当前余额和交易
dev-master
2022-03-31 20:36 UTC
This package is not auto-updated.
Last update: 2024-09-21 20:05:34 UTC
README
为了与 PayPal API 通信以获取当前余额和交易。
安装
composer require naif/laravel-paypal
如果你的 Laravel 版本低于 5.5,您需要在 config/app.php 中添加服务提供者和别名
Naif\LaravelPayPal\LaravelPayPalServiceProvider::class,
'PayPal' => Naif\LaravelPayPal\Facades\LaravelPayPal::class,
配置
发布包的配置文件
php artisan vendor:publish --provider="Naif\LaravelPayPal\LaravelPayPalServiceProvider"
配置将发布在 [config/laravel-paypal.php]。
API 密钥
从 PayPal 网站获取您的 API 访问权限
https://www.paypal.com/businessprofile/mytools/apiaccess/firstparty/signature
Paypal > 个人资料 > 个人资料和设置 > 我的销售工具 > API 访问 > NVP/SOAP API 集成(经典)
将这些添加到您的 .env
LARAVEL_PAYPAL_USERNAME=
LARAVEL_PAYPAL_PASSWORD=
LARAVEL_PAYPAL_SIGNATURE=
使用方法
use Naif\LaravelPayPal\LaravelPayPal;
$paypal = new LaravelPayPal();
//Get Current Balance
$balance = $paypal->getBalance();
Response:
[
"balance" => array:5 [▼
"ACK" => "Success"
"L_AMT0" => "120.62"
"L_SEVERITYCODE0" => null
"L_ERRORCODE0" => null
"L_LONGMESSAGE0" => null
]
]
//Get Transactions
$transactions = $paypal->getTransactions();
You can specify the number of days and number of transactions to retreive. Default (7 days, 10 transations)
Response:
[
"transactions" => array:3 [▼
0 => array:11 [▼
"timestamp" => "2019-01-17"
"timezone" => "GMT"
"type" => "Payment"
"email" => "naif@naif.io"
"name" => "Naif Alshaye"
"transaction_id" => "3DR402287R3992703"
"status" => "Completed"
"amt" => "1.00"
"currency_code" => "USD"
"fee_amount" => "-0.34"
"net_amount" => "0.66"
]
]
]
支持
https://www.linkedin.com/in/naif
许可
MIT 许可证 (MIT)。请参阅 许可文件 获取更多信息。