mooore / ecurring-api-php
PHP的eCurring API客户端库。
0.5.0
2020-10-23 07:05 UTC
Requires
- php: >=7.2
- ext-json: *
- composer/ca-bundle: ^1.1
- guzzlehttp/guzzle: ^6.3|^7.0.1
Requires (Dev)
- fzaninotto/faker: ^1.8
- phpro/grumphp: ^0.19.0
- phpstan/phpstan: ^0.12.0
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-08-29 05:07:17 UTC
README
这是一个非官方库,提供了对eCurring API的PHP绑定。
此库受Mollie API for PHP客户端的启发。
需求
为了使用此库,您需要
- 有效的eCurring账户和API密钥。
- PHP >= 7.2
安装
composer require mooore/ecurring-api-php
入门
初始化eCurring客户端
use Mooore\eCurring\eCurringHttpClient; $client = new eCurringHttpClient(); $client->setApiKey('your_api_key');
创建客户
$customer = $client->customers->create([ 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'example@domain.com' ]);
从客户处创建订阅
$customer = $client->customers->get(200); $subscription = $customer->createSubscription(1);
从订阅计划创建订阅
$subscriptionPlan = $client->subscriptionPlans->get(1); $subscription = $subscriptionPlan->createSubscription(200);
获取所有订阅
$customers = $client->customers->page(); do { foreach ($customers as $customer) { if ($subscription->isActive()) { // do something } } } while ($customers = $customers->next());