tresorg / cakephp-paypalbuttons
CakePHP 对 PaypalButtons 的 webservice 实现
0.0.4
2019-02-06 13:08 UTC
Requires
- guzzlehttp/guzzle: ^6.2
- muffin/webservice: ^1.0
Requires (Dev)
- cakephp/cakephp: ^3.3
- cakephp/cakephp-codesniffer: ^2.1
- phpunit/phpunit: ^5.5
This package is not auto-updated.
Last update: 2024-09-21 14:07:53 UTC
README
安装
使用 composer 安装插件
$ composer require tresorg/cakephp-paypalbuttons
不建议手动安装,但您可以检查 composer.json 文件以了解包要求。
在您的 config/app.php
文件中的 Datasources 中添加以下配置。
'Datasources' => [
...
'paypal_buttons' => [
'className' => 'Muffin\Webservice\Connection',
'service' => 'Tresorg/PaypalButtons.PaypalButtons',
'endpoint' => 'https://api-3t.paypal.com/nvp',
'credentials' => [
'USER' => 'paypal.username',
'PWD' => 'pass***word',
'SIGNATURE' => 'your-signature-here-012345678900123456789001234567890',
'VERSION' => 94,
],
// these options can be overridden upon button creation, per button
'defaults' => [
'notify_url' => 'http://exmpl.com/ipn.php', // IPN calls get called here
'return' => 'http://exmpl.com/thanks.php', // Successful Sales Page
'cancel_return'=> 'http://exmpl.com/tryagain.php', // Unsuccessful Sale URL
],
],
],
使用方法
如果您从不是 CakePHP 控制器或 Shell 的对象中加载此插件,请在您的类中使用 ModelAwareTrait
以获取方法: modelFactory
& loadModel
。
// use the Muffin Webservice
$this->modelFactory('Endpoint', ['Muffin\Webservice\Model\EndpointRegistry', 'get']);
// load your remote Webservice:
$paypalButtonsRemoteWebservice = $this->loadModel('PaypalButtons.PaypalButtons', 'Endpoint');
// sends the data to paypal
subscription = $this->PaypalButtonsRemote->save( new Entity([
'item_number' => 'yourInventoryNumber',
'item_name' => 'MyCoolProductName',
'price' => 9.99,
'subscription_type' => 'M', //monthly subscription
'subscription_recurring' => '1', //recurring subscription
]));
// receive the paypal button ID add it to your form, etc
$buttonId = $buttonCreated->id;
贡献
此插件与所有货币、订阅、试用期配合良好。尚未实现运输。
欢迎贡献、分支和 PR。
🍺