lasserafn / php-dinero
PHP 的 Dinero REST 封装器
1.0.3
2020-11-23 12:38 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- satooshi/php-coveralls: ^1.0
README
这是一个 PHP 封装器,用于 Dinero。从 lasserafn/laravel-dinero 分支而来。
安装
- 需要使用 composer
composer require lasserafn/php-dinero
要求
- PHP +5.6
入门指南
-
获取您的客户端 ID 和密钥
-
登录 Dinero 后,找到组织 ID(左下角)
-
在 Dinero 内部创建 API 密钥
-
如下使用封装器:
$dinero = new \LasseRafn\Dinero\Dinero( $clientId, $clientSecret ); $dinero->auth( $apiKey, $orgId ); // this WILL send a request to the auth API. $contacts = $dinero->contacts()->perPage(10)->page(2)->get(); // Do something with the contacts.
$invoices = $dinero->invoices()->all();
$products = $dinero->products()->deletedOnly()->all();
如果您不希望每次设置新的 Dinero 实例时都进行身份验证,也可以使用旧的身份验证令牌。
$dinero = new \LasseRafn\Dinero\Dinero( $clientId, $clientSecret ); $dinero->setAuth($token, $orgId); // this will NOT send a request to the auth API. $products = $dinero->products()->deletedOnly()->all();
用法
创建联系人
// Create Instance $dinero = new \LasseRafn\Dinero\Dinero( $clientId, $clientSecret ); // Auth to a Dinero account $dinero->auth( $apiKey, $orgId ); // Create the contact $contact = $dinero->contacts()->create([ 'IsPerson' => true, 'Name' => 'Test', 'CountryKey' => 'DK' ]); // if the request succeeded, $contact will be a \LasseRafn\Dinero\Models\Contact object.