Skip to content

mooore-digital/ecurring-api-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eCurring API client library for PHP

This is an unofficial library which provides PHP bindings for the eCurring API.

eCurring Home | eCurring API Documentation

This library is inspired by Mollie API client for PHP.

Requirements

In order to use this library, you need:

  • An active eCurring account and API key.
  • PHP >= 7.2

Installation

composer require mooore/ecurring-api-php

Getting started

Initializing the eCurring client

use Mooore\eCurring\eCurringHttpClient;

$client = new eCurringHttpClient();
$client->setApiKey('your_api_key');

Creating a customer

$customer = $client->customers->create([
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => '[email protected]'
]);

Creating a subscription from customer

$customer = $client->customers->get(200);
$subscription = $customer->createSubscription(1);

Creating a subscription from subscription plan

$subscriptionPlan = $client->subscriptionPlans->get(1);
$subscription = $subscriptionPlan->createSubscription(200);

Get all subscriptions

$customers = $client->customers->page();
do {
    foreach ($customers as $customer) {
        if ($subscription->isActive()) {
            // do something
        }
    }
} while ($customers = $customers->next());

Roadmap