Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/terminal42/swissbilling-api
An API client for SwissBilling written in PHP.
https://github.com/terminal42/swissbilling-api
Last synced: 23 days ago
JSON representation
An API client for SwissBilling written in PHP.
- Host: GitHub
- URL: https://github.com/terminal42/swissbilling-api
- Owner: terminal42
- License: mit
- Created: 2020-02-06T16:00:50.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-05T10:22:55.000Z (11 months ago)
- Last Synced: 2024-09-14T13:11:43.159Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwissBilling API Client
An API client for [SwissBilling](https://www.swissbilling.ch) written in PHP.
**ATTENTION:** This repo is still in early development and subject to changes!
## Installing
```
composer require terminal42/swissbilling-api
```## Usage
### Basics
Use the `Client` object to interact with the API. All API types have DocBlock properties, so a smart IDE (like PhpStorm)
will give you autocomplete support on the properties.```php
use Terminal42\SwissbillingApi\Client;
use Terminal42\SwissbillingApi\Api\ApiFactory;
use Terminal42\SwissbillingApi\Type\Debtor;
use Terminal42\SwissbillingApi\Type\Merchant;
use Terminal42\SwissbillingApi\Type\InvoiceItem;
use Terminal42\SwissbillingApi\Type\Transaction;
use Terminal42\SwissbillingApi\Type\TransactionStatus;$client = new Client(new ApiFactory());
$merchant = new Merchant('user', 'password', 'success_url', 'cancel_url', 'error_url');
$transaction = new Transaction();
// fill in the required transaction properties
// $transaction->amount = 100;$debtor = new Debtor();
// fill in the required debtor properties
// $transaction->firstname = 'John';
// $transaction->lastname = 'Doe';$items = [
new InvoiceItem(),
];/** @var TransactionStatus $status */
$status = $client->request($transaction, $debtor, $items, $merchant);var_dump($status->hasError());
```### Multiple calls / Dependency Injection
You can pass the merchant information to the Client instead of passing it on every method call,
e.g. if using this in a Symfony bundle with dependency injection.```php
$merchant = new Merchant('user', 'password', 'success_url', 'cancel_url', 'error_url');
$client = new Client(new ApiFactory(), $merchant);// No need to pass the merchant anymore
$status = $client->request($transaction, $debtor, $items);```
## Software Best Practice
This repository is following [SemVer](https://semver.org). If you rely on a stable API,
make sure to install a version tag.## License
Licensed under the [MIT license](https://github.com/terminal42/swissbilling-api/blob/master/LICENSE).