https://github.com/rebilly/rebilly-php
SDK for PHP
https://github.com/rebilly/rebilly-php
payment-gateway subscriptions transactions
Last synced: 11 months ago
JSON representation
SDK for PHP
- Host: GitHub
- URL: https://github.com/rebilly/rebilly-php
- Owner: Rebilly
- License: mit
- Created: 2014-01-11T16:27:59.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2025-03-07T20:35:10.000Z (11 months ago)
- Last Synced: 2025-03-28T20:11:15.135Z (11 months ago)
- Topics: payment-gateway, subscriptions, transactions
- Language: PHP
- Homepage: https://www.rebilly.com
- Size: 4.16 MB
- Stars: 18
- Watchers: 21
- Forks: 21
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Rebilly SDK for PHP
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE)
[![Total Downloads][ico-downloads]][link-downloads]
The **Rebilly SDK for PHP** makes it easy for developers to access
[Rebilly REST APIs][link-api-doc] in their PHP code.
## Requirements
* PHP 8.0+.
* CURL (verify peer requires a root certificate authority -- if you have not configured php curl to use one, and your system libs aren't linked to one, you may need to do a [manual configuration](http://stackoverflow.com/questions/17478283/paypal-access-ssl-certificate-unable-to-get-local-issuer-certificate/19149687#19149687) to use the appropriate certificate authority)
## Installation
> [!WARNING]
> This package does not follow semantic versioning, so minor version updates can cause backward compatibility breaks. Updates to the package should be tested before switching versions.
Using [Composer](http://getcomposer.org/) is the recommended way to install the Rebilly SDK for PHP.
To get started, you need run the Composer commands (assume you're in the project's root directory).
- Install the latest stable version of the SDK:
```bash
composer require rebilly/client-php
```
_You can find out more on how to install Composer, configure autoloading,
and other best-practices for defining dependencies at [getcomposer.org](http://getcomposer.org/)._
## Supported Versions
The previous version of the SDK can be outdated and won't provide all (or the correct) specifications to communicate with the REST APIs. Only the latest version is constantly supported.
| Version | Supported | Documentation |
|------------------------|--------------------------|---------------------------------------|
| [2.x][link-github-v2x] | ⚠️ (security fixes only) | ✅ [See tab PHP-SDK-2.0][link-api-doc] |
| 3.x | ✅ (current) | ✅ [See tab PHP][link-api-doc] |
## Quick Examples
Create a Rebilly Client
```php
use Rebilly\Sdk\Client;
use Rebilly\Sdk\Service;
// Instantiate Rebilly client.
$client = new Client([
'baseUrl' => Client::SANDBOX_HOST,
'organizationId' => '{organizationId}',
'apiKey' => '{secretKey}',
]);
$service = new Service(client: $client);
```
Create a Customer
```php
use Rebilly\Sdk\Exception\DataValidationException;
use Rebilly\Sdk\Model\ContactObject;
use Rebilly\Sdk\Model\Customer;
$customer = Customer::from([])
->setWebsiteId('{websiteId}')
->setPrimaryAddress(
ContactObject::from([])
->setFirstName('John')
->setLastName('Doe'),
);
try {
$customer = $service->customers()->create($form);
} catch (DataValidationException $e) {
var_dump($e->getValidationErrors());
}
```
For more see [examples directory](./examples/).
## Documentation
Read [Rebilly REST APIs documentation][link-api-doc] for more details.
## Migration from SDK v2.x to v3.x
This new major version brings several new helper classes to communicate with Rebilly REST APIs and some incompatibilities that should be tested before switching SDK versions.
- Now, a `Service` class can be explicitly instantiated to make the API calls instead of using only the `Client`, as it encapsulates the API calls.
- To simplify the migration from the previous version, the `Client` object can be used to make calls to any API directly. For example, instead of instantiating a service class, one can use:
```php
$client->customers()->create($form);
```
- The namespace changed from `Rebilly\Entities` to `Rebilly\Sdk\Model`. Now, the `src` is `Rebilly\Sdk`.
- The classes are now generated by an automated process that is triggered every time a new version of the [API definitions][link-api-defs] is released. It means more frequency on the SDK updates, keeping it synced with the REST APIs.
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg
[ico-version]: https://img.shields.io/packagist/v/rebilly/client-php.svg
[ico-downloads]: https://img.shields.io/packagist/dt/rebilly/client-php.svg
[link-api-doc]: https://www.rebilly.com/catalog/all
[link-github]: https://github.com/Rebilly/rebilly-php
[link-packagist]: https://packagist.org/packages/rebilly/client-php
[link-downloads]: https://packagist.org/packages/rebilly/client-php
[link-github-v2x]: https://github.com/Rebilly/rebilly-php/tree/v2.x
[link-api-defs]: https://github.com/Rebilly/api-definitions