pwparsons / paygate
此包已被弃用,不再维护。未建议替代包。
一个用于集成PayGate的PayWeb3 API的Laravel包。
2.2.0
2020-10-29 15:54 UTC
Requires
- php: ^7.4
- ext-bcmath: *
- guzzlehttp/guzzle: ^6.3|^7.0.1
- illuminate/support: ^7.15|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^9.0
- psalm/plugin-laravel: ^1.2
- vimeo/psalm: ^3.11
README
此存储库将不再更新。存储库将以只读模式保留。
此包提供了一个简单的方法将PayGate的PayWeb3 API与Laravel集成。
官方文档可在此处找到。
兼容性图表
包版本 | Laravel | PHP |
---|---|---|
2.0.0 | 7.15+ | 7.4+ |
1.3.2 | 5.6 – 6.x | 7.1+ |
安装
您可以通过composer使用以下命令安装此包
composer require pwparsons/paygate
该包将自动注册自身。
要发布配置文件到config/paygate.php
运行
php artisan vendor:publish --tag=paygate.config
使用
安装此包并填写配置文件中的值后,使用此包将变得非常简单。以下所有示例都使用了外观。
创建交易
// Initiate transaction $http = PayGate::initiate() ->withReference('pgtest_123456789') ->withAmount(32.99) ->withEmail('email@example.com') ->withCurrency('USD') // Optional: defaults to ZAR ->withCountry('USA') // Optional: defaults to ZAF ->withLocale('en-us') // Optional: defaults to 'en' ->withReturnUrl('https://website.com/return_url') ->withNotifyUrl('https://website.com/notify_url') // Optional ->create(); if ($http->fails()) { dump($http->getErrorCode()); dump($http->getErrorMessage()); dump($http->all()); } // Redirect to PayGate's payment page return PayGate::redirect();
可以找到初始化响应示例的文档中。
查询交易
$http = PayGate::query() ->withPayRequestId('YOUR_PAY_REQUEST_ID_HERE') ->withReference('pgtest_123456789') ->create(); if ($http->fails()) { dump($http->getErrorCode()); dump($http->getErrorMessage()); dump($http->all()); } dd($http->all());
可以在文档中找到查询响应的示例。
提示
Paygate将向RETURN_URL和NOTIFY_URL发送请求。将这些URI排除在CSRF验证之外,请将它们添加到VerifyCsrfToken中间件中。例如:
class VerifyCsrfToken extends Middleware { protected $except = [ 'return_url', 'notify_url', ]; }
有用的方法
with
魔法方法允许您在调用该对象时提供“with”之后的字符串。这和魔法获取器的工作方式完全相同,除了它设置字段值并返回对象,这样您就可以链接设置器,例如
$object->withReference('pgtest_123456789') ->withAmount(32.99) ->withEmail('email@example.com') ->withReturnUrl('https://my.return.url/page');
将产生以下结果
{ "REFERENCE": "pgtest_123456789", "AMOUNT": "3299", "EMAIL": "email@example.com", "RETURN_URL": "https://my.return.url/page" }
get
魔法方法允许您调用“get”之后的任何字符串,并将返回该值,例如
{ "PAYGATE_ID": "10011072130", "PAY_REQUEST_ID": "23B785AE-C96C-32AF-4879-D2C9363DB6E8", "REFERENCE": "pgtest_123456789" }
从对象中获取数据
echo $object->getPaygateId(); // 10011072130 echo $object->getPayRequestId(); // 23B785AE-C96C-32AF-4879-D2C9363DB6E8 echo $object->getReference(); // pgtest_123456789
变更日志
有关最近更改的更多信息,请参阅变更日志。
贡献
请参阅contributing.md以获取详细信息及待办事项列表。
安全
如果您发现任何安全问题,请通过电子邮件peterw.parsons@gmail.com联系,而不是使用问题跟踪器。
致谢
许可
MIT 许可证(MIT)。请参阅许可文件以获取更多信息。