Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudstek/mollie-php-api
Simple to use, modern and well-tested PHP API client for Mollie.
https://github.com/cloudstek/mollie-php-api
api-client mollie payment-gateway payment-service payments php
Last synced: about 2 months ago
JSON representation
Simple to use, modern and well-tested PHP API client for Mollie.
- Host: GitHub
- URL: https://github.com/cloudstek/mollie-php-api
- Owner: Cloudstek
- License: bsd-2-clause
- Created: 2016-08-08T17:27:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-22T23:07:35.000Z (about 8 years ago)
- Last Synced: 2024-09-06T19:16:14.509Z (4 months ago)
- Topics: api-client, mollie, payment-gateway, payment-service, payments, php
- Language: PHP
- Homepage:
- Size: 190 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Mollie PHP API client
[![Travis](https://img.shields.io/travis/Cloudstek/mollie-php-api.svg)](https://travis-ci.org/Cloudstek/mollie-php-api) [![Code Climate](https://img.shields.io/codeclimate/github/Cloudstek/mollie-php-api.svg)](https://codeclimate.com/github/Cloudstek/mollie-php-api) [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/Cloudstek/mollie-php-api.svg)](https://codeclimate.com/github/Cloudstek/mollie-php-api/coverage) [![Code Climate](https://img.shields.io/codeclimate/issues/github/Cloudstek/mollie-php-api.svg)](https://codeclimate.com/github/Cloudstek/mollie-php-api/issues) [![Downloads](https://img.shields.io/packagist/dt/cloudstek/mollie-php-api.svg)](https://packagist.org/packages/cloudstek/mollie-php-api) [![Latest Version](https://img.shields.io/packagist/v/cloudstek/mollie-php-api.svg)](https://packagist.org/packages/cloudstek/mollie-php-api)
Simple to use, modern and well-tested PHP API client for [Mollie](https://www.mollie.com/nl/docs/overview).
## Requirements
* PHP 5.3 or newer
* PHP cURL extension (with SSL)
* PHP xdebug extension (optional, for unit tests)
* [Composer](https://getcomposer.org)
* Active website profile at Mollie.com (see: [Mollie Documentation](https://www.mollie.com/en/docs/authentication))## Features
Currently all API functions that don't require oauth authentication are supported. This means you can use this API client for everything except managing organizations, profiles, permissions and settlements.
* Payments
* Payment methods
* Issuers
* Refunds
* Recurring payments
* Customers
* Mandates
* Subscriptions## Installation
The Mollie PHP API client is available as composer package. Installation is as simple as requiring the package for your project.
```sh
composer require cloudstek/mollie-php-api
```You can also manually add the package to your projects composer.json requirements:
```json
{
"require": {
"cloudstek/mollie-php-api": "^2.0.1"
}
}
```Next, require the composer autoloader in your project:
```php
setApiKey('test_yourapikeyhere');// Now you're ready to use the Mollie API, please read on for more examples.
```### Creating a new customer
```php
customer()->create('John Doe', '[email protected]');// Alternatively you can also specify a locale and/or metadata.
// In the following example we'll create the same customer with some metadata
$customer = $mollie->customer()->create(
'John Doe',
'[email protected]',
array(
'user_id' => 11,
'group' => 'regular_customers'
)
);// Now save the customer ID to your database for future reference. Pseudo code:
$db->save($customer->id);
```### Payments
#### Regular payment
```php
payment()->create(
10.00,
'Expensive cup of coffee',
'https://example.org/order/101'
);// Redirect user to payment page
$payment->gotoPaymentPage();
```#### Customer payment
According to the Mollie API documentation, Linking customers to payments enables a number of [Mollie Checkout](https://www.mollie.com/nl/checkout) features, including:
- Payment preferences for your customers.
- Enabling your customers to charge a previously used debit or credit card with a single click.
- Improved payment insights in your dashboard.
- Recurring payments.```php
customer('cst_test')->payment()->create(
10.00,
'Expensive cup of coffee',
'https://example.org/order/101'
);// Redirect user to payment page
$payment->gotoPaymentPage();
exit; // Do redirect immediately
```
### Recurring payments#### Getting a recurring payment mandate
```php
customer('cst_test')->get();// Make sure the customer has no valid mandates
if(!$customer->mandate()->hasValid()) {
// Create mandate by issueing the first recurring payment.
// This is usually a small amount like a few cents as it's only used to confirm
// the payment details.
$customer->mandate()->createFirstRecurring(
0.01,
'Recurring payment mandate confirmation',
'https://example.org/account'
);
}
```#### Create a recurring payment
```php
customer('cst_test')->get();// Check if customer has a valid mandate for recurring payments
if($customer->mandate()->hasValid()) {
$customer->payment()->createRecurring(10.00, 'Expensive cup of coffee');
}
else {
// Customer has no valid mandates, you should get one first.
}
```## Changelog
See CHANGELOG.md for a complete list of changes.
## Contributing
Feel free to make contributions to the code by submitting pull requests and opening issues to express your ideas and feature requests.
If you contribute code, make sure it is covered by unit tests and passes existing tests to prevent regressions.