PHPackages                             maestrano/maestrano-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. maestrano/maestrano-php

ActiveLibrary[API Development](/categories/api)

maestrano/maestrano-php
=======================

Maestrano PHP Library

2.0.2(9y ago)024.8k↓50%7[3 issues](https://github.com/maestrano/maestrano-php/issues)MITPHPPHP &gt;=5.3

Since Nov 10Pushed 9y ago8 watchersCompare

[ Source](https://github.com/maestrano/maestrano-php)[ Packagist](https://packagist.org/packages/maestrano/maestrano-php)[ Docs](https://maestrano.com)[ RSS](/packages/maestrano-maestrano-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (38)Used By (0)

[![Maestrano Logo](https://camo.githubusercontent.com/f5ab3e3b51934ba584f6d3d0e81eda9d1d7c243bf5ea0a150c09e0a75d8f76fa/68747470733a2f2f7261772e6769746875622e636f6d2f6d6165737472616e6f2f6d6165737472616e6f2d7068702f6d61737465722f6d6165737472616e6f2e706e67)](https://camo.githubusercontent.com/f5ab3e3b51934ba584f6d3d0e81eda9d1d7c243bf5ea0a150c09e0a75d8f76fa/68747470733a2f2f7261772e6769746875622e636f6d2f6d6165737472616e6f2f6d6165737472616e6f2d7068702f6d61737465722f6d6165737472616e6f2e706e67)

Maestrano Cloud Integration is currently in closed beta. Want to know more? Send us an email to .

---

1. [Getting Setup](#getting-setup)
2. [Getting Started](#getting-started)

- [Installation](#installation)
- [Configuration](#configuration)
- [Metadata Endpoint](#metadata-endpoint)

3. [Single Sign-On Setup](#single-sign-on-setup)

- [User Setup](#user-setup)
- [Group Setup](#group-setup)
- [Controller Setup](#controller-setup)
- [Other Controllers](#other-controllers)
- [Redirecting on logout](#redirecting-on-logout)
- [Redirecting on error](#redirecting-on-error)

4. [Account Webhooks](#account-webhooks)

- [Groups Controller](#groups-controller-service-cancellation)
- [Group Users Controller](#group-users-controller-business-member-removal)

5. [API](#api)

- [Payment API](#payment-api)
    - [Bill](#bill)
    - [Recurring Bill](#recurring-bill)
- [Membership API](#membership-api)
    - [User](#user)
    - [Group](#group)

6. [Connec!™ Data Sharing](#connec-data-sharing)

- [Making Requests](#making-requests)
- [Webhook Notifications](#webhook-notifications)

---

Getting Setup
-------------

[](#getting-setup)

Before integrating with us you will need an to create your app on the developer platform and link it to a marketplace. Maestrano Cloud Integration being still in closed beta you will need to contact us beforehand to gain production access.

We provide a Sandbox environment where you can freely launch your app to test your integration. The sandbox is great to test single sign-on and API integration (e.g: Connec! API). This Sandbox is available on the developer platform on your app technical page.

To get started just go to: . You will find the developer platform documentation here: [Documentation](https://maestrano.atlassian.net/wiki/display/DEV/Integrate+your+app+on+partner%27s+marketplaces).

A **php demo application** is also available:

Do not hesitate to shoot us an email at  if you have any question.

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

To install maestrano-php using Composer, add this dependency to your project's composer.json:

```
{
  "require": {
    "maestrano/maestrano-php": "2.0.*"
  }
}

```

Then install via:

```
composer install

```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading):

```
require_once('vendor/autoload.php');
```

### Configuration

[](#configuration)

The [developer platform](https://dev-platform.maestrano.com) is the easiest way to configure Maestrano. The only actions needed from your part is to create your application and environments on the developer platform and to create a config file or use environment variable to configure the SDK. The SDK will then contact the developer platform and retrieve the marketplaces configuration for your app environment.

A `dev-platform.json` config file is loaded using:

```
Maestrano::autoConfigure('/path/to/dev-platform.json');
```

The json file may look like this:

```
{
  # ===> Developer Platform Configuration
  # This is the host and base path that should be used by your environment to connect to the developer platform API.
  "dev-platform": {
    "host": "https://developer.maestrano.com",
    "api_path": "/api/config/v1/"
  },
  # => Environment credentials
  # These are your environment credentials, you can get them by connecting on the developer platform, then go on your app, they will be display under the technical view on each environment.
  "environment": {
    "api_key": "",
    "api_secret": ""
  }
}
```

You can also use environment variables to configure your app environment:

```
export MNO_DEVPL_HOST=
export MNO_DEVPL_API_PATH=
export MNO_DEVPL_ENV_KEY=
export MNO_DEVPL_ENV_SECRET=

```

To use configure the Developer Platform using environment variables, omit the file argument:

```
Maestrano::autoConfigure();
```

Single Sign-On Setup
--------------------

[](#single-sign-on-setup)

It will require you to write a controller for the init phase and consume phase of the single sign-on handshake. You will receive 3 informations when logging in a user: the user, his group and the marketplace he's coming from.

You might wonder why we need a 'group' on top of a user. Well, Maestrano works with businesses and as such expects your service to be able to manage groups of users. A group represents 1) a billing entity 2) a collaboration group. During the first single sign-on handshake both a user and a group should be created. Additional users logging in via the same group should then be added to this existing group (see controller setup below).

For more information, please consult [Multi-Marketplace Ingration](https://maestrano.atlassian.net/wiki/display/DEV/Multi-Marketplace+Integration).

### User Setup

[](#user-setup)

Let's assume that your user model is called 'User'. The best way to get started with SSO is to define a class method on this model called 'findOrCreateForMaestrano' accepting a Maestrano.Sso.User and aiming at either finding an existing maestrano user in your database or creating a new one. Your user model should also have a 'Provider' property and a 'Uid' property used to identify the source of the user - Maestrano, LinkedIn, AngelList etc..

### Group Setup

[](#group-setup)

The group setup is similar to the user one. The mapping is a little easier though. Your model should also have the 'Provider' property and a 'Uid' properties. Also your group model could have a AddMember method and also a hasMember method (see controller below)

### Controller Setup

[](#controller-setup)

You will need two controller action init and consume. The init action will initiate the single sign-on request and redirect the user to Maestrano. The consume action will receive the single sign-on response, process it and match/create the user and the group.

The init action is all handled via Maestrano methods and should look like this:

```
